diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index 56f7a69..24fbc61 100644
*** a/doc/src/sgml/datatype.sgml
--- b/doc/src/sgml/datatype.sgml
*************** SET xmloption TO { DOCUMENT | CONTENT };
*** 4117,4122 ****
--- 4117,4126 ----
+ regschema
+
+
+
regconfig
*************** SET xmloption TO { DOCUMENT | CONTENT };
*** 4146,4152 ****
an object identifier. There are also several alias types for
oid>: regproc>, regprocedure>,
regoper>, regoperator>, regclass>,
! regtype>, regconfig>, and regdictionary>.
shows an overview.
--- 4150,4157 ----
an object identifier. There are also several alias types for
oid>: regproc>, regprocedure>,
regoper>, regoperator>, regclass>,
! regtype>, regschema>, regconfig>,
! and regdictionary>.
shows an overview.
*************** SELECT * FROM pg_attribute
*** 4256,4261 ****
--- 4261,4273 ----
+ regschema>
+ pg_namespace>
+ schema name
+ public>
+
+
+
regconfig>
pg_ts_config>
text search configuration
*************** SELECT * FROM pg_attribute
*** 4273,4284 ****
! All of the OID alias types accept schema-qualified names, and will
! display schema-qualified names on output if the object would not
! be found in the current search path without being qualified.
! The regproc> and regoper> alias types will only
! accept input names that are unique (not overloaded), so they are
! of limited use; for most uses regprocedure> or
regoperator> are more appropriate. For regoperator>,
unary operators are identified by writing NONE> for the unused
operand.
--- 4285,4297 ----
! All of the OID alias types (except regschema>) accept
! schema-qualified names, and will display schema-qualified names on
! output if the object would not be found in the current search path
! without being qualified. The regproc>
! and regoper> alias types will only accept input names that
! are unique (not overloaded), so they are of limited use; for most
! uses regprocedure> or
regoperator> are more appropriate. For regoperator>,
unary operators are identified by writing NONE> for the unused
operand.
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 7214d94..cf2538f 100644
*** a/src/backend/utils/adt/regproc.c
--- b/src/backend/utils/adt/regproc.c
***************
*** 27,32 ****
--- 27,33 ----
#include "catalog/namespace.h"
#include "catalog/pg_class.h"
#include "catalog/pg_operator.h"
+ #include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
*************** regtypesend(PG_FUNCTION_ARGS)
*** 1071,1076 ****
--- 1072,1185 ----
/*
+ * regschemain - converts "nspname" to pg_namespace OID
+ *
+ * We also accept a numeric OID, for symmetry with the output routine.
+ *
+ * '-' signifies unknown (OID 0). In all other cases, the input must
+ * match an existing pg_namespace entry.
+ *
+ * This function is not needed in bootstrap mode, so we don't worry about
+ * making it work then.
+ */
+ Datum
+ regschemain(PG_FUNCTION_ARGS)
+ {
+ char *nsp_name_or_oid = PG_GETARG_CSTRING(0);
+ Oid result;
+ List *names;
+
+ /* '-' ? */
+ if (strcmp(nsp_name_or_oid, "-") == 0)
+ PG_RETURN_OID(InvalidOid);
+
+ /* Numeric OID? */
+ if (nsp_name_or_oid[0] >= '0' &&
+ nsp_name_or_oid[0] <= '9' &&
+ strspn(nsp_name_or_oid, "0123456789") == strlen(nsp_name_or_oid))
+ {
+ result = DatumGetObjectId(DirectFunctionCall1(oidin,
+ CStringGetDatum(nsp_name_or_oid)));
+ PG_RETURN_OID(result);
+ }
+
+ /*
+ * Normal case: lookup the namespace name.
+ */
+
+ names = stringToQualifiedNameList(nsp_name_or_oid);
+ nsp_name_or_oid = strVal(linitial(names));
+
+ result = LookupNamespaceNoError(nsp_name_or_oid);
+ if (result == InvalidOid)
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("schema \"%s\" does not exist", nsp_name_or_oid)));
+
+ PG_RETURN_OID(result);
+ }
+
+ /*
+ * regschemaout - converts pg_namespace OID to "nspname"
+ */
+ Datum
+ regschemaout(PG_FUNCTION_ARGS)
+ {
+ Oid nspid = PG_GETARG_OID(0);
+ char *result;
+ HeapTuple nsptup;
+
+ if (nspid == InvalidOid)
+ {
+ result = pstrdup("-");
+ PG_RETURN_CSTRING(result);
+ }
+
+ nsptup = SearchSysCache(NAMESPACEOID,
+ ObjectIdGetDatum(nspid),
+ 0, 0, 0);
+
+ if (HeapTupleIsValid(nsptup))
+ {
+ Form_pg_namespace nspform = (Form_pg_namespace) GETSTRUCT(nsptup);
+ char *nspname = NameStr(nspform->nspname);
+
+ result = pstrdup(quote_identifier(nspname));
+
+ ReleaseSysCache(nsptup);
+ }
+ else
+ {
+ /* If OID doesn't match any pg_namespace row, return it numerically */
+ result = (char *) palloc(NAMEDATALEN);
+ snprintf(result, NAMEDATALEN, "%u", nspid);
+ }
+
+ PG_RETURN_CSTRING(result);
+ }
+
+ /*
+ * regschemarecv - converts external binary format to regschema
+ */
+ Datum
+ regschemarecv(PG_FUNCTION_ARGS)
+ {
+ /* Exactly the same as oidrecv, so share code */
+ return oidrecv(fcinfo);
+ }
+
+ /*
+ * regschemasend - converts regschema to binary format
+ */
+ Datum
+ regschemasend(PG_FUNCTION_ARGS)
+ {
+ /* Exactly the same as oidsend, so share code */
+ return oidsend(fcinfo);
+ }
+
+
+ /*
* regconfigin - converts "tsconfigname" to tsconfig OID
*
* We also accept a numeric OID, for symmetry with the output routine.
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index cfa14d6..72ee594 100644
*** a/src/include/catalog/pg_cast.h
--- b/src/include/catalog/pg_cast.h
*************** DATA(insert ( 3769 20 1288 a f ));
*** 206,211 ****
--- 206,220 ----
DATA(insert ( 3769 23 0 a b ));
DATA(insert ( 25 2205 1079 i f ));
DATA(insert ( 1043 2205 1079 i f ));
+ DATA(insert ( 26 2212 0 i b ));
+ DATA(insert ( 2212 26 0 i b ));
+ DATA(insert ( 20 2212 1287 i f ));
+ DATA(insert ( 21 2212 313 i f ));
+ DATA(insert ( 23 2212 0 i b ));
+ DATA(insert ( 2212 20 1288 a f ));
+ DATA(insert ( 2212 23 0 a b ));
+ //DATA(insert ( 25 2212 1079 i f ));
+ //DATA(insert ( 1043 2212 1079 i f ));
/*
* String category
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index b93987b..43965da 100644
*** a/src/include/catalog/pg_proc.h
--- b/src/include/catalog/pg_proc.h
*************** DATA(insert OID = 2221 ( regtypeout PG
*** 3579,3584 ****
--- 3579,3589 ----
DESCR("I/O");
DATA(insert OID = 1079 ( regclass PGNSP PGUID 12 1 0 0 f f f t f s 1 0 2205 "25" _null_ _null_ _null_ _null_ text_regclass _null_ _null_ _null_ ));
DESCR("convert text to regclass");
+ DATA(insert OID = 3030 ( regschemain PGNSP PGUID 12 1 0 0 f f f t f s 1 0 2212 "2275" _null_ _null_ _null_ _null_ regschemain _null_ _null_ _null_ ));
+ DATA(insert OID = 3031 ( regschemaout PGNSP PGUID 12 1 0 0 f f f t f s 1 0 2275 "2212" _null_ _null_ _null_ _null_ regschemaout _null_ _null_ _null_ ));
+ DATA(insert OID = 3033 ( regschemarecv PGNSP PGUID 12 1 0 0 f f f t f i 1 0 2212 "2281" _null_ _null_ _null_ _null_ regschemarecv _null_ _null_ _null_ ));
+ DATA(insert OID = 3034 ( regschemasend PGNSP PGUID 12 1 0 0 f f f t f i 1 0 17 "2212" _null_ _null_ _null_ _null_ regschemasend _null_ _null_ _null_ ));
+
DATA(insert OID = 2246 ( fmgr_internal_validator PGNSP PGUID 12 1 0 0 f f f t f s 1 0 2278 "26" _null_ _null_ _null_ _null_ fmgr_internal_validator _null_ _null_ _null_ ));
DESCR("(internal)");
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index c22aacc..6eb9ac0 100644
*** a/src/include/catalog/pg_type.h
--- b/src/include/catalog/pg_type.h
*************** DATA(insert OID = 2210 ( _regclass PG
*** 549,554 ****
--- 549,561 ----
DATA(insert OID = 2211 ( _regtype PGNSP PGUID -1 f b A f t \054 0 2206 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ ));
#define REGTYPEARRAYOID 2211
+ DATA(insert OID = 2212 ( regschema PGNSP PGUID 4 t b N f t \054 0 0 2213 regschemain regschemaout regschemarecv regschemasend - - - i p f 0 -1 0 _null_ _null_ ));
+ DESCR("registered schema");
+ #define REGSCHEMAOID 2212
+
+ DATA(insert OID = 2213 ( _regschema PGNSP PGUID -1 f b A f t \054 0 2212 0 array_in array_out array_recv array_send - - - i x f 0 -1 0 _null_ _null_ ));
+ #define REGSCHEMAARRAYOID 2213
+
/* uuid */
DATA(insert OID = 2950 ( uuid PGNSP PGUID 16 f b U f t \054 0 0 2951 uuid_in uuid_out uuid_recv uuid_send - - - c p f 0 -1 0 _null_ _null_ ));
DESCR("UUID datatype");
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index 91411a4..9c5f637 100644
*** a/src/include/utils/builtins.h
--- b/src/include/utils/builtins.h
*************** extern Datum regclassin(PG_FUNCTION_ARGS
*** 547,552 ****
--- 547,556 ----
extern Datum regclassout(PG_FUNCTION_ARGS);
extern Datum regclassrecv(PG_FUNCTION_ARGS);
extern Datum regclasssend(PG_FUNCTION_ARGS);
+ extern Datum regschemain(PG_FUNCTION_ARGS);
+ extern Datum regschemaout(PG_FUNCTION_ARGS);
+ extern Datum regschemarecv(PG_FUNCTION_ARGS);
+ extern Datum regschemasend(PG_FUNCTION_ARGS);
extern Datum regtypein(PG_FUNCTION_ARGS);
extern Datum regtypeout(PG_FUNCTION_ARGS);
extern Datum regtyperecv(PG_FUNCTION_ARGS);