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.
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 ; \
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);
exact numeric with selectable precision
- |
- oid
-
- object identifier
-
-
|
path
+
+
Object Identifier Types
+
+
+ data type
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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.
+
+
+
+