]> granicus.if.org Git - postgresql/commitdiff
Here's a patch to add unknownin/unknownout support. I also poked around
authorBruce Momjian <bruce@momjian.us>
Wed, 24 Apr 2002 02:12:53 +0000 (02:12 +0000)
committerBruce Momjian <bruce@momjian.us>
Wed, 24 Apr 2002 02:12:53 +0000 (02:12 +0000)
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

src/backend/utils/adt/varlena.c
src/include/c.h
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_type.h
src/include/fmgr.h
src/include/utils/builtins.h

index 2007e78910f3564b31193a5cbcbc14854fc1e7f9..e7ac4b30b59ee8f259da881027abf6c8edea3a4e 100644 (file)
@@ -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 ========== */
 
 /*
index f01d20474637c1f58eab96037211353c5cc20999..40abf99aecf7dfb9fc28da7531b59e4321815252 100644 (file)
@@ -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) */
 
index 00a00bf1b03ad69c1eaea6e9c08a1e028bc668d9..a6d32210a09f5d7031dbe92b452b04c80eaf746e 100644 (file)
@@ -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
index 3cdf0a488e9ce98d423b49f2db31c4a0689ea14a..e858bb663a7cbcd7630a3423ce79fa1758d47eae 100644 (file)
@@ -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_ ));
index 5359ba733839097093c60bb11621453b8848b741..f6d0de6f1cfa579f55e6cbcf8e27a2bb2511ae76 100644 (file)
@@ -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
 
index 017f73fb757aac8bfe04e1843694894ff24063e0..6280ff294a701783065b5a2055ae2de1f50003a1 100644 (file)
@@ -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)
 
index caa2c571029fc258c7aa2068786d32098c6b4faf..59b1c9d35927d37e8cccacfc9e74f725bcf3f761 100644 (file)
@@ -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);