From: Bruce Momjian Date: Wed, 24 Apr 2002 02:12:53 +0000 (+0000) Subject: Here's a patch to add unknownin/unknownout support. I also poked around X-Git-Tag: REL7_3~1631 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d2fdf6e6d0aa397eee8b5946ba705917e5bf695;p=postgresql Here's a patch to add unknownin/unknownout support. I also poked around looking for places that assume UNKNOWN == TEXT. One of those was the "SET" type in pg_type.h, which was using textin/textout. This one I took care of in this patch. The other suspicious place was in string_to_dataum (which is defined in both selfuncs.c and indxpath.c). I wasn't too sure about those, so I left them be. Joe Conway --- diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 2007e78910..e7ac4b30b5 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.83 2002/04/15 07:54:37 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.84 2002/04/24 02:12:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -228,6 +228,46 @@ textout(PG_FUNCTION_ARGS) } +/* + * unknownin - converts "..." to internal representation + */ +Datum +unknownin(PG_FUNCTION_ARGS) +{ + char *inputStr = PG_GETARG_CSTRING(0); + unknown *result; + int len; + + len = strlen(inputStr) + VARHDRSZ; + + result = (unknown *) palloc(len); + VARATT_SIZEP(result) = len; + + memcpy(VARDATA(result), inputStr, len - VARHDRSZ); + + PG_RETURN_UNKNOWN_P(result); +} + + +/* + * unknownout - converts internal representation to "..." + */ +Datum +unknownout(PG_FUNCTION_ARGS) +{ + unknown *t = PG_GETARG_UNKNOWN_P(0); + int len; + char *result; + + len = VARSIZE(t) - VARHDRSZ; + result = (char *) palloc(len + 1); + memcpy(result, VARDATA(t), len); + result[len] = '\0'; + + PG_RETURN_CSTRING(result); +} + + /* ========== PUBLIC ROUTINES ========== */ /* diff --git a/src/include/c.h b/src/include/c.h index f01d204746..40abf99aec 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.117 2002/04/23 15:45:30 tgl Exp $ + * $Id: c.h,v 1.118 2002/04/24 02:12:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -404,6 +404,7 @@ struct varlena */ typedef struct varlena bytea; typedef struct varlena text; +typedef struct varlena unknown; typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */ typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */ diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 00a00bf1b0..a6d32210a0 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.122 2002/04/21 19:48:22 thomas Exp $ + * $Id: catversion.h,v 1.123 2002/04/24 02:12:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200204211 +#define CATALOG_VERSION_NO 200204231 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 3cdf0a488e..e858bb663a 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.229 2002/04/21 19:48:23 thomas Exp $ + * $Id: pg_proc.h,v 1.230 2002/04/24 02:12:53 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -237,6 +237,11 @@ DESCR("join selectivity of < and related operators on scalar datatypes"); DATA(insert OID = 108 ( scalargtjoinsel PGNSP PGUID 12 f t f t f s 3 701 "0 26 0" 100 0 0 100 scalargtjoinsel - _null_ )); DESCR("join selectivity of > and related operators on scalar datatypes"); +DATA(insert OID = 109 ( unknownin PGNSP PGUID 12 f t t i 1 f 705 "0" 100 0 0 100 unknownin - _null_ )); +DESCR("(internal)"); +DATA(insert OID = 110 ( unknownout PGNSP PGUID 12 f t t i 1 f 23 "0" 100 0 0 100 unknownout - _null_ )); +DESCR("(internal)"); + DATA(insert OID = 112 ( text PGNSP PGUID 12 f t t t f i 1 25 "23" 100 0 0 100 int4_text - _null_ )); DESCR("convert int4 to text"); DATA(insert OID = 113 ( text PGNSP PGUID 12 f t t t f i 1 25 "21" 100 0 0 100 int2_text - _null_ )); diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 5359ba7338..f6d0de6f1c 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.120 2002/04/21 00:26:43 tgl Exp $ + * $Id: pg_type.h,v 1.121 2002/04/24 02:12:53 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -302,7 +302,7 @@ DATA(insert OID = 30 ( oidvector PGNSP PGUID INDEX_MAX_KEYS*4 -1 f b t \054 0 DESCR("array of INDEX_MAX_KEYS oids, used in system tables"); #define OIDVECTOROID 30 -DATA(insert OID = 32 ( SET PGNSP PGUID -1 -1 f b t \054 0 0 textin textout textin textout i p f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 32 ( SET PGNSP PGUID -1 -1 f b t \054 0 0 unknownin unknownout unknownin unknownout i p f 0 -1 0 _null_ _null_ )); DESCR("set of tuples"); DATA(insert OID = 71 ( pg_type PGNSP PGUID 4 4 t c t \054 1247 0 int4in int4out int4in int4out i p f 0 -1 0 _null_ _null_ )); @@ -366,7 +366,7 @@ DESCR("relative, limited-range time interval (Unix delta time)"); DATA(insert OID = 704 ( tinterval PGNSP PGUID 12 47 f b t \054 0 0 tintervalin tintervalout tintervalin tintervalout i p f 0 -1 0 _null_ _null_ )); DESCR("(abstime,abstime), time interval"); #define TINTERVALOID 704 -DATA(insert OID = 705 ( unknown PGNSP PGUID -1 -1 f b t \054 0 0 textin textout textin textout i p f 0 -1 0 _null_ _null_ )); +DATA(insert OID = 705 ( unknown PGNSP PGUID -1 -1 f b t \054 0 0 unknownin unknownout unknownin unknownout i p f 0 -1 0 _null_ _null_ )); DESCR(""); #define UNKNOWNOID 705 diff --git a/src/include/fmgr.h b/src/include/fmgr.h index 017f73fb75..6280ff294a 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fmgr.h,v 1.19 2002/03/05 05:33:22 momjian Exp $ + * $Id: fmgr.h,v 1.20 2002/04/24 02:12:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -185,6 +185,7 @@ extern struct varlena *pg_detoast_datum_slice(struct varlena * datum, /* DatumGetFoo macros for varlena types will typically look like this: */ #define DatumGetByteaP(X) ((bytea *) PG_DETOAST_DATUM(X)) #define DatumGetTextP(X) ((text *) PG_DETOAST_DATUM(X)) +#define DatumGetUnknownP(X) ((unknown *) PG_DETOAST_DATUM(X)) #define DatumGetBpCharP(X) ((BpChar *) PG_DETOAST_DATUM(X)) #define DatumGetVarCharP(X) ((VarChar *) PG_DETOAST_DATUM(X)) /* And we also offer variants that return an OK-to-write copy */ @@ -200,6 +201,7 @@ extern struct varlena *pg_detoast_datum_slice(struct varlena * datum, /* GETARG macros for varlena types will typically look like this: */ #define PG_GETARG_BYTEA_P(n) DatumGetByteaP(PG_GETARG_DATUM(n)) #define PG_GETARG_TEXT_P(n) DatumGetTextP(PG_GETARG_DATUM(n)) +#define PG_GETARG_UNKNOWN_P(n) DatumGetUnknownP(PG_GETARG_DATUM(n)) #define PG_GETARG_BPCHAR_P(n) DatumGetBpCharP(PG_GETARG_DATUM(n)) #define PG_GETARG_VARCHAR_P(n) DatumGetVarCharP(PG_GETARG_DATUM(n)) /* And we also offer variants that return an OK-to-write copy */ @@ -239,6 +241,7 @@ extern struct varlena *pg_detoast_datum_slice(struct varlena * datum, /* RETURN macros for other pass-by-ref types will typically look like this: */ #define PG_RETURN_BYTEA_P(x) PG_RETURN_POINTER(x) #define PG_RETURN_TEXT_P(x) PG_RETURN_POINTER(x) +#define PG_RETURN_UNKNOWN_P(x) PG_RETURN_POINTER(x) #define PG_RETURN_BPCHAR_P(x) PG_RETURN_POINTER(x) #define PG_RETURN_VARCHAR_P(x) PG_RETURN_POINTER(x) diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index caa2c57102..59b1c9d359 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.177 2002/04/18 20:01:11 tgl Exp $ + * $Id: builtins.h,v 1.178 2002/04/24 02:12:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -414,6 +414,9 @@ extern List *textToQualifiedNameList(text *textval, const char *caller); extern bool SplitIdentifierString(char *rawstring, char separator, List **namelist); +extern Datum unknownin(PG_FUNCTION_ARGS); +extern Datum unknownout(PG_FUNCTION_ARGS); + extern Datum byteain(PG_FUNCTION_ARGS); extern Datum byteaout(PG_FUNCTION_ARGS); extern Datum byteaoctetlen(PG_FUNCTION_ARGS);