Implement types regprocedure, regoper, regoperator, regclass, regtype
authorTom Lane
Thu, 25 Apr 2002 02:56:56 +0000 (02:56 +0000)
committerTom Lane
Thu, 25 Apr 2002 02:56:56 +0000 (02:56 +0000)
per pghackers discussion.  Add some more typsanity tests, and clean
up some problems exposed thereby (broken or missing array types for
some built-in types).  Also, clean up loose ends from unknownin/out
patch.

28 files changed:
contrib/findoidjoins/README.findoidjoins
contrib/findoidjoins/findoidjoins.c
doc/src/sgml/bki.sgml
doc/src/sgml/datatype.sgml
src/backend/bootstrap/bootstrap.c
src/backend/catalog/namespace.c
src/backend/catalog/pg_operator.c
src/backend/parser/parse_coerce.c
src/backend/parser/parse_node.c
src/backend/utils/adt/regproc.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/selfuncs.c
src/backend/utils/adt/varlena.c
src/backend/utils/cache/catcache.c
src/bin/psql/describe.c
src/include/c.h
src/include/catalog/catversion.h
src/include/catalog/namespace.h
src/include/catalog/pg_namespace.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_proc.h
src/include/catalog/pg_type.h
src/include/fmgr.h
src/include/utils/builtins.h
src/test/regress/expected/opr_sanity.out
src/test/regress/expected/type_sanity.out
src/test/regress/sql/opr_sanity.sql
src/test/regress/sql/type_sanity.sql

index 557fd041586939549411b110edf0d66f633780e0..14c17e1e0ede7d320d0201dc22470ddbe8804e6e 100644 (file)
@@ -1,10 +1,10 @@
 
                      findoidjoins
 
-This program scans a database, and prints oid fields (also regproc fields)
-and the tables they join to.  CAUTION: it is ver-r-r-y slow on a large
-database, or even a not-so-large one.  We don't really recommend running
-it on anything but an empty database, such as template1.
+This program scans a database, and prints oid fields (also regproc, regclass
+and regtype fields) and the tables they join to.  CAUTION: it is ver-r-r-y
+slow on a large database, or even a not-so-large one.  We don't really
+recommend running it on anything but an empty database, such as template1.
 
 Uses pgeasy library.
 
index c559b7a36256ab31b13af8a1d9375f97927d27e7..c426b5523a356b01e488a4ca55a9e72abfa6b276 100644 (file)
@@ -39,7 +39,9 @@ main(int argc, char **argv)
        WHERE a.attnum > 0 AND \
              relkind = 'r' AND \
              (typname = 'oid' OR \
-              typname = 'regproc') AND \
+              typname = 'regproc' OR \
+              typname = 'regclass' OR \
+              typname = 'regtype') AND \
              a.attrelid = c.oid AND \
              a.atttypid = t.oid \
        ORDER BY 2, a.attnum ; \
@@ -77,7 +79,7 @@ main(int argc, char **argv)
                    DECLARE c_matches BINARY CURSOR FOR \
                    SELECT  count(*)::int4 \
                        FROM \"%s\" t1, \"%s\" t2 \
-                   WHERE RegprocToOid(t1.\"%s\") = t2.oid ",
+                   WHERE t1.\"%s\"::oid = t2.oid ",
                        relname, relname2, attname);
 
            doquery(query);
index 4ea0f5f92ba91236f687f7f2683e7bb11e2ce1b7..36503de6590a93a77bbf2d7b799fc28c1a120f94 100644 (file)
@@ -1,5 +1,5 @@
 
 
 
@@ -122,7 +122,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/bki.sgml,v 1.10 2002/03/22 19:20:02 petere
       storage.  The following types are allowed: bool,
       byteachar (1 byte),
       nameint2int2vector,
-      int4regproctext,
+      int4regprocregclass,
+      regtypetext,
       oidtidxid,
       cidoidvectorsmgr,
       _int4 (array), _aclitem (array).
index aef751cbc58e2374a80dfc3055284b10bfaa7f25..4f06cee503727f1fa07456d6ba803dfcdf5f0edf 100644 (file)
@@ -1,5 +1,5 @@
 
 
  
@@ -172,12 +172,6 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.89 2002/04/21 18:58:00 th
        exact numeric with selectable precision
       
 
-      
-       oid
-       
-       object identifier
-      
-
       
        path
        
@@ -2894,6 +2888,165 @@ SELECT SUBSTRING(b FROM 1 FOR 2) FROM test;
 
   
 
+  
+   Object Identifier Types
+
+   
+    object identifier
+    data type
+   
+
+   
+    oid
+   
+
+   
+    regproc
+   
+
+   
+    regprocedure
+   
+
+   
+    regoper
+   
+
+   
+    regoperator
+   
+
+   
+    regclass
+   
+
+   
+    regtype
+   
+
+   
+    Object identifiers (OIDs) are used internally by
+    PostgreSQL as primary keys for various system
+    tables.  Also, an OID system column is added to user-created tables
+    (unless WITHOUT OIDS is specified at table creation time).
+    Type oid represents an object identifier.  There are also
+    several aliases for oid: regproc, regprocedure,
+    regoper, regoperator, regclass,
+    and regtype.
+   
+
+   
+    The oid type is currently implemented as an unsigned four-byte
+    integer.
+    Therefore, it is not large enough to provide database-wide uniqueness
+    in large databases, or even in large individual tables.  So, using a
+    user-created table's OID column as a primary key is discouraged.
+    OIDs are best used only for references to system tables.
+   
+
+   
+    The oid type itself has few operations beyond comparison
+    (which is implemented as unsigned comparison).  It can be cast to
+    integer, however, and then manipulated using the standard integer
+    operators.  (Beware of possible signed-versus-unsigned confusion
+    if you do this.)
+   
+
+   
+    The  oid alias types have no operations of their own except
+    for specialized input and output routines.  These routines are able
+    to accept and display symbolic names for system objects, rather than
+    the raw numeric value that type oid would use.  The alias
+    types allow simplified lookup of OID values for objects: for example,
+    one may write 'mytable'::regclass to get the OID of table
+    mytable, rather than SELECT oid FROM pg_class WHERE
+    relname = 'mytable'.  (In reality, a much more complicated SELECT would
+    be needed to deal with selecting the right OID when there are multiple
+    tables named mytable in different schemas.)
+   
+
+   
+    
+     Object Identifier Types
+     
+      
+       
+   Type name
+   References
+   Description
+   Examples
+       
+      
+
+      
+
+       
+   oid
+   any
+   Numeric object identifier
+   564182
+       
+
+       
+   regproc
+   pg_proc
+   Function name
+   sum
+       
+
+       
+   regprocedure
+   pg_proc
+   Function with argument types
+   sum(int4)
+       
+
+       
+   regoper
+   pg_operator
+   Operator name
+   +
+       
+
+       
+   regoperator
+   pg_operator
+   Operator with argument types
+   *(integer,integer)  -(NONE,integer)
+       
+
+       
+   regclass
+   pg_class
+   Relation name
+   pg_type
+       
+
+       
+   regtype
+   pg_type
+   Type name
+   integer
+       
+      
+     
+    
+   
+
+   
+    All of the 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 is more appropriate.  For regoperator,
+    unary operators are identified by writing NONE for the unused
+    operand.
+   
+
+  
+