As detailed in the email to pgsql-hackers, this patch alters the second
argument of the type input functions so that for base types it passes
the oid, just as for composite types. For all cases where the oid is
currently non-zero (composite and array types) it remains unchanged.

This basically came about because currently there is no easy way for an
input function to determine what type it's supposed to return.

Have a nice day,
Martijn van Oosterhout   <>
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
Index: doc/src/sgml/ref/create_type.sgml
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v
retrieving revision 1.57
diff -u -r1.57 create_type.sgml
--- doc/src/sgml/ref/create_type.sgml   14 Jul 2005 06:17:36 -0000      1.57
+++ doc/src/sgml/ref/create_type.sgml   12 Aug 2005 12:52:17 -0000
@@ -102,9 +102,8 @@
    declared as taking one argument of type <type>cstring</type>,
    or as taking three arguments of types
    <type>cstring</type>, <type>oid</type>, <type>integer</type>.
-   The first argument is the input text as a C string, the second
-   argument is the element type's OID in case this is an array type
-   (or the type's own OID for a composite type),
+   The first argument is the input text as a C string, the second argument is 
+   the OID of the type, except for arrays where it is the element type's OID
    and the third is the <literal>typmod</> of the destination column, if known
    (-1 will be passed if not).
    The input function must return a value of the data type itself.
Index: src/backend/utils/cache/lsyscache.c
RCS file: /projects/cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v
retrieving revision 1.116
diff -u -r1.116 lsyscache.c
--- src/backend/utils/cache/lsyscache.c 29 Aug 2004 05:06:50 -0000      1.116
+++ src/backend/utils/cache/lsyscache.c 12 Aug 2005 12:52:17 -0000
@@ -1220,12 +1220,14 @@
         * Composite types get their own OID as parameter; array types get
-        * their typelem as parameter; everybody else gets zero.
+        * their typelem as parameter; everybody else gets their own oid.
        if (typeStruct->typtype == 'c')
                return HeapTupleGetOid(typeTuple);
-       else
+       else if( typeStruct->typelem != 0 )
                return typeStruct->typelem;
+       else
+               return HeapTupleGetOid(typeTuple);

Attachment: pgpc9cVXui3QG.pgp
Description: PGP signature

Reply via email to