head	1.9;
access;
symbols
	REL7_4_29:1.7
	REL8_0_25:1.8
	REL7_4_28:1.7
	REL8_0_24:1.8
	REL7_4_27:1.7
	REL8_0_23:1.8
	REL7_4_26:1.7
	REL8_0_22:1.8
	REL7_4_25:1.7
	REL8_0_21:1.8
	REL7_4_24:1.7
	REL8_0_20:1.8
	REL7_4_23:1.7
	REL8_0_19:1.8
	REL7_4_22:1.7
	REL8_0_18:1.8
	REL7_4_21:1.7
	REL8_0_17:1.8
	REL7_4_20:1.7
	REL8_0_16:1.8
	REL7_3_21:1.6
	REL7_4_19:1.7
	REL8_0_15:1.8
	REL7_3_20:1.6
	REL7_4_18:1.7
	REL8_0_14:1.8
	REL7_3_19:1.6
	REL7_4_17:1.7
	REL8_0_13:1.8
	REL8_0_12:1.8
	REL7_3_18:1.6
	REL7_4_16:1.7
	REL8_0_11:1.8
	REL8_0_10:1.8
	REL7_4_15:1.7
	REL7_3_17:1.6
	REL8_0_9:1.8
	REL7_4_14:1.7
	REL7_3_16:1.6
	REL7_3_15:1.6
	REL7_4_13:1.7
	REL8_0_8:1.8
	REL7_3_14:1.6
	REL7_4_12:1.7
	REL8_0_7:1.8
	REL7_3_13:1.6
	REL7_4_11:1.7
	REL8_0_6:1.8
	REL7_3_12:1.6
	REL7_4_10:1.7
	REL8_0_5:1.8
	REL7_3_11:1.6
	REL7_4_9:1.7
	REL8_0_4:1.8
	REL7_2_8:1.4
	REL7_3_10:1.6
	REL7_4_8:1.7
	REL8_0_3:1.8
	REL8_0_2:1.8
	REL7_2_7:1.4
	REL7_3_9:1.6
	REL7_4_7:1.7
	REL8_0_1:1.8
	REL8_0_STABLE:1.8.0.4
	REL8_0_0:1.8.0.2
	REL8_0_0RC5:1.8
	REL8_0_0RC4:1.8
	REL8_0_0RC3:1.8
	REL8_0_0RC2:1.8
	REL8_0_0RC1:1.8
	REL8_0_0BETA5:1.8
	REL8_0_0BETA4:1.8
	REL7_4_6:1.7
	REL7_3_8:1.6
	REL7_2_6:1.4
	REL8_0_0BETA3:1.8
	REL8_0_0BETA2:1.8
	REL7_2_5:1.4
	REL7_4_5:1.7
	REL7_3_7:1.6
	REL7_4_4:1.7
	REL8_0_0BETA1:1.8
	REL7_4_3:1.7
	REL7_4_2:1.7
	REL7_3_6:1.6
	REL7_4_1:1.7
	REL7_3_5:1.6
	REL7_4:1.7
	REL7_4_RC2:1.7
	REL7_4_STABLE:1.7.0.2
	REL7_4_RC1:1.7
	REL7_4_BETA5:1.7
	REL7_4_BETA4:1.6
	REL7_4_BETA3:1.6
	REL7_4_BETA2:1.6
	WIN32_DEV:1.6.0.4
	REL7_4_BETA1:1.6
	REL7_3_4:1.6
	REL7_3_2:1.6
	REL7_2_4:1.4
	REL7_3_STABLE:1.6.0.2
	REL7_2_3:1.4
	REL7_2_STABLE:1.4.0.2
	REL7_2:1.4
	REL7_2_RC2:1.4
	REL7_2_RC1:1.4
	REL7_2_BETA5:1.4
	REL7_2_BETA4:1.4
	REL7_2_BETA3:1.4
	REL7_2_BETA2:1.4
	REL7_2_BETA1:1.4
	REL7_1_2:1.2
	REL7_1_STABLE:1.2.0.2
	REL7_1_BETA:1.1
	REL7_1_BETA3:1.1
	REL7_1_BETA2:1.1
	REL7_1:1.2;
locks; strict;
comment	@# @;


1.9
date	2005.06.23.02.33.27;	author tgl;	state dead;
branches;
next	1.8;

1.8
date	2004.08.04.20.33.37;	author tgl;	state Exp;
branches;
next	1.7;

1.7
date	2003.10.19.22.15.32;	author tgl;	state Exp;
branches;
next	1.6;

1.6
date	2002.09.05.19.57.32;	author tgl;	state Exp;
branches;
next	1.5;

1.5
date	2002.04.25.02.56.55;	author tgl;	state Exp;
branches;
next	1.4;

1.4
date	2001.08.21.16.35.57;	author tgl;	state Exp;
branches;
next	1.3;

1.3
date	2001.08.10.18.57.32;	author tgl;	state Exp;
branches;
next	1.2;

1.2
date	2001.02.10.03.57.42;	author tgl;	state Exp;
branches;
next	1.1;

1.1
date	2000.06.19.14.01.24;	author momjian;	state Exp;
branches;
next	;


desc
@@


1.9
log
@Move findoidjoins out of contrib and into src/tools, which is a more
logical place for it since it is of no use to users.  Per recent
discussions on cleaning up contrib.
@
text
@
   			      findoidjoins

This program scans a database and prints oid fields (also reg* fields)
and the tables they join to.  We don't really recommend running it on
anything but an empty database, such as template1; else it's likely to
be very slow.

Run on an empty database, it returns the system join relationships (shown
below for 8.0).  Note that unexpected matches may indicate bogus entries
in system tables --- don't accept a peculiar match without question.
In particular, a field shown as joining to more than one target table is
probably messed up.  In 8.0, the *only* fields that should join to more
than one target are pg_description.objoid, pg_depend.objid, and
pg_depend.refobjid.  (Running make_oidjoins_check is an easy way to spot
fields joining to more than one table, BTW.)

The shell script make_oidjoins_check converts findoidjoins' output
into an SQL script that checks for dangling links (entries in an
OID or REG* column that don't match any row in the expected table).
Note that fields joining to more than one table are NOT processed.

The result of make_oidjoins_check should be installed as the "oidjoins"
regression test.  The oidjoins test should be updated after any
revision in the patterns of cross-links between system tables.
(Ideally we'd just regenerate the script as part of the regression
tests themselves, but that seems too slow...)

NOTE: in 8.0, make_oidjoins_check produces one bogus join check:
Join pg_catalog.pg_class.relfilenode => pg_catalog.pg_class.oid
This is an artifact and should not be added to the oidjoins regress test.
Also beware of any claim that pg_database.datlastsysoid joins to anything;
this does not actually happen in 8.0, but it did happen before and might
happen again in future, depending on what operation initdb does last.

---------------------------------------------------------------------------

Join pg_catalog.pg_aggregate.aggfnoid => pg_catalog.pg_proc.oid
Join pg_catalog.pg_aggregate.aggtransfn => pg_catalog.pg_proc.oid
Join pg_catalog.pg_aggregate.aggfinalfn => pg_catalog.pg_proc.oid
Join pg_catalog.pg_aggregate.aggtranstype => pg_catalog.pg_type.oid
Join pg_catalog.pg_am.amgettuple => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.aminsert => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.ambeginscan => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.amrescan => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.amendscan => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.ammarkpos => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.amrestrpos => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.ambuild => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.ambulkdelete => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.amvacuumcleanup => pg_catalog.pg_proc.oid
Join pg_catalog.pg_am.amcostestimate => pg_catalog.pg_proc.oid
Join pg_catalog.pg_amop.amopclaid => pg_catalog.pg_opclass.oid
Join pg_catalog.pg_amop.amopsubtype => pg_catalog.pg_type.oid
Join pg_catalog.pg_amop.amopopr => pg_catalog.pg_operator.oid
Join pg_catalog.pg_amproc.amopclaid => pg_catalog.pg_opclass.oid
Join pg_catalog.pg_amproc.amprocsubtype => pg_catalog.pg_type.oid
Join pg_catalog.pg_amproc.amproc => pg_catalog.pg_proc.oid
Join pg_catalog.pg_attribute.attrelid => pg_catalog.pg_class.oid
Join pg_catalog.pg_attribute.atttypid => pg_catalog.pg_type.oid
Join pg_catalog.pg_cast.castsource => pg_catalog.pg_type.oid
Join pg_catalog.pg_cast.casttarget => pg_catalog.pg_type.oid
Join pg_catalog.pg_cast.castfunc => pg_catalog.pg_proc.oid
Join pg_catalog.pg_class.relnamespace => pg_catalog.pg_namespace.oid
Join pg_catalog.pg_class.reltype => pg_catalog.pg_type.oid
Join pg_catalog.pg_class.relam => pg_catalog.pg_am.oid
Join pg_catalog.pg_class.reltablespace => pg_catalog.pg_tablespace.oid
Join pg_catalog.pg_class.reltoastrelid => pg_catalog.pg_class.oid
Join pg_catalog.pg_class.reltoastidxid => pg_catalog.pg_class.oid
Join pg_catalog.pg_constraint.connamespace => pg_catalog.pg_namespace.oid
Join pg_catalog.pg_constraint.contypid => pg_catalog.pg_type.oid
Join pg_catalog.pg_conversion.connamespace => pg_catalog.pg_namespace.oid
Join pg_catalog.pg_conversion.conproc => pg_catalog.pg_proc.oid
Join pg_catalog.pg_database.dattablespace => pg_catalog.pg_tablespace.oid
Join pg_catalog.pg_depend.classid => pg_catalog.pg_class.oid
Join pg_catalog.pg_depend.refclassid => pg_catalog.pg_class.oid
Join pg_catalog.pg_description.classoid => pg_catalog.pg_class.oid
Join pg_catalog.pg_index.indexrelid => pg_catalog.pg_class.oid
Join pg_catalog.pg_index.indrelid => pg_catalog.pg_class.oid
Join pg_catalog.pg_language.lanvalidator => pg_catalog.pg_proc.oid
Join pg_catalog.pg_opclass.opcamid => pg_catalog.pg_am.oid
Join pg_catalog.pg_opclass.opcnamespace => pg_catalog.pg_namespace.oid
Join pg_catalog.pg_opclass.opcintype => pg_catalog.pg_type.oid
Join pg_catalog.pg_operator.oprnamespace => pg_catalog.pg_namespace.oid
Join pg_catalog.pg_operator.oprleft => pg_catalog.pg_type.oid
Join pg_catalog.pg_operator.oprright => pg_catalog.pg_type.oid
Join pg_catalog.pg_operator.oprresult => pg_catalog.pg_type.oid
Join pg_catalog.pg_operator.oprcom => pg_catalog.pg_operator.oid
Join pg_catalog.pg_operator.oprnegate => pg_catalog.pg_operator.oid
Join pg_catalog.pg_operator.oprlsortop => pg_catalog.pg_operator.oid
Join pg_catalog.pg_operator.oprrsortop => pg_catalog.pg_operator.oid
Join pg_catalog.pg_operator.oprltcmpop => pg_catalog.pg_operator.oid
Join pg_catalog.pg_operator.oprgtcmpop => pg_catalog.pg_operator.oid
Join pg_catalog.pg_operator.oprcode => pg_catalog.pg_proc.oid
Join pg_catalog.pg_operator.oprrest => pg_catalog.pg_proc.oid
Join pg_catalog.pg_operator.oprjoin => pg_catalog.pg_proc.oid
Join pg_catalog.pg_proc.pronamespace => pg_catalog.pg_namespace.oid
Join pg_catalog.pg_proc.prolang => pg_catalog.pg_language.oid
Join pg_catalog.pg_proc.prorettype => pg_catalog.pg_type.oid
Join pg_catalog.pg_rewrite.ev_class => pg_catalog.pg_class.oid
Join pg_catalog.pg_statistic.starelid => pg_catalog.pg_class.oid
Join pg_catalog.pg_statistic.staop1 => pg_catalog.pg_operator.oid
Join pg_catalog.pg_statistic.staop2 => pg_catalog.pg_operator.oid
Join pg_catalog.pg_statistic.staop3 => pg_catalog.pg_operator.oid
Join pg_catalog.pg_trigger.tgrelid => pg_catalog.pg_class.oid
Join pg_catalog.pg_trigger.tgfoid => pg_catalog.pg_proc.oid
Join pg_catalog.pg_type.typnamespace => pg_catalog.pg_namespace.oid
Join pg_catalog.pg_type.typrelid => pg_catalog.pg_class.oid
Join pg_catalog.pg_type.typelem => pg_catalog.pg_type.oid
Join pg_catalog.pg_type.typinput => pg_catalog.pg_proc.oid
Join pg_catalog.pg_type.typoutput => pg_catalog.pg_proc.oid
Join pg_catalog.pg_type.typreceive => pg_catalog.pg_proc.oid
Join pg_catalog.pg_type.typsend => pg_catalog.pg_proc.oid
Join pg_catalog.pg_type.typbasetype => pg_catalog.pg_type.oid

---------------------------------------------------------------------------

Bruce Momjian (root@@candle.pha.pa.us)
Updated for 7.3 by Joe Conway (mail@@joeconway.com)
@


1.8
log
@Update oidjoins regression test to match current catalog structure.
@
text
@@


1.7
log
@Update README file to show 7.4 oidjoins relationships.  The regression
test was updated previously, but documentation is lagging.
@
text
@d10 1
a10 1
below for 7.4).  Note that unexpected matches may indicate bogus entries
d13 1
a13 1
probably messed up.  In 7.4, the *only* fields that should join to more
d29 1
a29 1
NOTE: in 7.4, make_oidjoins_check produces one bogus join check:
d33 1
a33 1
this does not actually happen in 7.4, but it did happen before and might
d54 1
d57 1
d67 1
d74 1
@


1.6
log
@findoidjoins is updated for schemas, does not use libpgeasy.
From Joe Conway.
@
text
@d10 1
a10 1
below for 7.3).  Note that unexpected matches may indicate bogus entries
d13 1
a13 1
probably messed up.  In 7.3, the *only* fields that should join to more
d29 1
a29 1
NOTE: in 7.3, make_oidjoins_check produces two bogus join checks:
d31 4
a34 2
Join pg_catalog.pg_database.datlastsysoid => pg_catalog.pg_conversion.oid
These are artifacts and should not be added to the oidjoins regress test.
d51 1
d67 2
d108 3
@


1.5
log
@Implement types regprocedure, regoper, regoperator, regclass, regtype
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.
@
text
@d4 4
a7 6
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.
d10 1
a10 1
below for 7.2).  Note that unexpected matches may indicate bogus entries
d13 4
a16 3
probably messed up.  In 7.2, the *only* field that should join to more
than one target is pg_description.objoid.  (Running make_oidjoins_check
is an easy way to spot fields joining to more than one table, BTW.)
d20 1
a20 1
OID or REGPROC column that don't match any row in the expected table).
d29 4
a32 3
NOTE: in 7.2, make_oidjoins_check produces one bogus join check, for
pg_class.relfilenode => pg_class.oid.  This is an artifact and should not
be added to the oidjoins regress test.
d36 67
a102 55
Join pg_aggregate.aggtransfn => pg_proc.oid
Join pg_aggregate.aggfinalfn => pg_proc.oid
Join pg_aggregate.aggbasetype => pg_type.oid
Join pg_aggregate.aggtranstype => pg_type.oid
Join pg_aggregate.aggfinaltype => pg_type.oid
Join pg_am.amgettuple => pg_proc.oid
Join pg_am.aminsert => pg_proc.oid
Join pg_am.ambeginscan => pg_proc.oid
Join pg_am.amrescan => pg_proc.oid
Join pg_am.amendscan => pg_proc.oid
Join pg_am.ammarkpos => pg_proc.oid
Join pg_am.amrestrpos => pg_proc.oid
Join pg_am.ambuild => pg_proc.oid
Join pg_am.ambulkdelete => pg_proc.oid
Join pg_am.amcostestimate => pg_proc.oid
Join pg_amop.amopclaid => pg_opclass.oid
Join pg_amop.amopopr => pg_operator.oid
Join pg_amproc.amopclaid => pg_opclass.oid
Join pg_amproc.amproc => pg_proc.oid
Join pg_attribute.attrelid => pg_class.oid
Join pg_attribute.atttypid => pg_type.oid
Join pg_class.reltype => pg_type.oid
Join pg_class.relam => pg_am.oid
Join pg_class.reltoastrelid => pg_class.oid
Join pg_class.reltoastidxid => pg_class.oid
Join pg_description.classoid => pg_class.oid
Join pg_index.indexrelid => pg_class.oid
Join pg_index.indrelid => pg_class.oid
Join pg_opclass.opcamid => pg_am.oid
Join pg_opclass.opcintype => pg_type.oid
Join pg_operator.oprleft => pg_type.oid
Join pg_operator.oprright => pg_type.oid
Join pg_operator.oprresult => pg_type.oid
Join pg_operator.oprcom => pg_operator.oid
Join pg_operator.oprnegate => pg_operator.oid
Join pg_operator.oprlsortop => pg_operator.oid
Join pg_operator.oprrsortop => pg_operator.oid
Join pg_operator.oprcode => pg_proc.oid
Join pg_operator.oprrest => pg_proc.oid
Join pg_operator.oprjoin => pg_proc.oid
Join pg_proc.prolang => pg_language.oid
Join pg_proc.prorettype => pg_type.oid
Join pg_rewrite.ev_class => pg_class.oid
Join pg_statistic.starelid => pg_class.oid
Join pg_statistic.staop1 => pg_operator.oid
Join pg_statistic.staop2 => pg_operator.oid
Join pg_statistic.staop3 => pg_operator.oid
Join pg_trigger.tgrelid => pg_class.oid
Join pg_trigger.tgfoid => pg_proc.oid
Join pg_type.typrelid => pg_class.oid
Join pg_type.typelem => pg_type.oid
Join pg_type.typinput => pg_proc.oid
Join pg_type.typoutput => pg_proc.oid
Join pg_type.typreceive => pg_proc.oid
Join pg_type.typsend => pg_proc.oid
d107 1
@


1.4
log
@Restructure pg_opclass, pg_amop, and pg_amproc per previous discussions in
pgsql-hackers.  pg_opclass now has a row for each opclass supported by each
index AM, not a row for each opclass name.  This allows pg_opclass to show
directly whether an AM supports an opclass, and furthermore makes it possible
to store additional information about an opclass that might be AM-dependent.
pg_opclass and pg_amop now store "lossy" and "haskeytype" information that we
previously expected the user to remember to provide in CREATE INDEX commands.
Lossiness is no longer an index-level property, but is associated with the
use of a particular operator in a particular index opclass.

Along the way, IndexSupportInitialize now uses the syscaches to retrieve
pg_amop and pg_amproc entries.  I find this reduces backend launch time by
about ten percent, at the cost of a couple more special cases in catcache.c's
IndexScanOK.

Initial work by Oleg Bartunov and Teodor Sigaev, further hacking by Tom Lane.

initdb forced.
@
text
@d4 4
a7 4
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.
@


1.3
log
@Make OIDs optional, per discussions in pghackers.  WITH OIDS is still the
default, but OIDS are removed from many system catalogs that don't need them.
Some interesting side effects: TOAST pointers are 20 bytes not 32 now;
pg_description has a three-column key instead of one.

Bugs fixed in passing: BINARY cursors work again; pg_class.relhaspkey
has some usefulness; pg_dump dumps comments on indexes, rules, and
triggers in a valid order.

initdb forced.
@
text
@a50 1
Join pg_amop.amopid => pg_am.oid
a52 1
Join pg_amproc.amid => pg_am.oid
d64 2
a65 1
Join pg_opclass.opcdeftype => pg_type.oid
@


1.2
log
@Update findoidjoins notes for 7.1.
@
text
@d12 1
a12 1
below for 7.1).  Note that unexpected matches may indicate bogus entries
d15 1
a15 1
probably messed up.  In 7.1, the *only* field that should join to more
d30 2
a31 3
NOTE: in 7.1, make_oidjoins_check produces two bogus join checks, one for
pg_database.datlastsysoid => pg_description.oid and one for
pg_class.relfilenode => pg_class.oid.  These are artifacts and should not
a42 1
Join pg_am.amdelete => pg_proc.oid
d49 1
d63 1
d81 3
a83 1
Join pg_statistic.staop => pg_operator.oid
@


1.1
log
@Add missing /contrib files
@
text
@d12 1
a12 1
below for 7.0).  Note that unexpected matches may indicate bogus entries
d15 1
a15 1
probably messed up.  In 7.0, the *only* field that should join to more
d30 5
d37 1
a37 2
Join pg_aggregate.aggtransfn1 => pg_proc.oid
Join pg_aggregate.aggtransfn2 => pg_proc.oid
d40 1
a40 2
Join pg_aggregate.aggtranstype1 => pg_type.oid
Join pg_aggregate.aggtranstype2 => pg_type.oid
d62 2
a63 2
Join pg_description.objoid => pg_proc.oid
Join pg_description.objoid => pg_type.oid
@
