summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-04-24 02:12:53 +0000
committerBruce Momjian <bruce@momjian.us>2002-04-24 02:12:53 +0000
commit5d2fdf6e6d0aa397eee8b5946ba705917e5bf695 (patch)
tree72535777186fc1c8a1234ec35c9540e963b1703a
parentbe9728acf1395ee45d82aa1e922570a82f9d040f (diff)
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
-rw-r--r--src/backend/utils/adt/varlena.c42
-rw-r--r--src/include/c.h3
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/pg_proc.h7
-rw-r--r--src/include/catalog/pg_type.h6
-rw-r--r--src/include/fmgr.h5
-rw-r--r--src/include/utils/builtins.h5
7 files changed, 62 insertions, 10 deletions
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 2007e78910f..e7ac4b30b59 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 f01d2047463..40abf99aecf 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 00a00bf1b03..a6d32210a09 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 3cdf0a488e9..e858bb663a7 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 5359ba73383..f6d0de6f1cf 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 017f73fb757..6280ff294a7 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 caa2c571029..59b1c9d3592 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);