diff --git a/contrib/findoidjoins/README b/contrib/findoidjoins/README index 7cd9abe9ad..ef28c51ab8 100644 --- a/contrib/findoidjoins/README +++ b/contrib/findoidjoins/README @@ -7,60 +7,83 @@ they join to. PostgreSQL version 6.3.2 crashes with aggregates on views, so I have removed the view pg_user from the list of relations to examine. +It requires /pgsql/contrib/pginterface to be compiled first. + Run on am empty database, it returns the system join relationships: --------------------------------------------------------------------------- +Join pg_aggregate.aggbasetype => pg_proc.oid +Join pg_aggregate.aggbasetype => pg_type.oid +Join pg_aggregate.aggfinalfn => pg_proc.oid Join pg_aggregate.aggfinaltype => pg_proc.oid Join pg_aggregate.aggfinaltype => pg_type.oid Join pg_aggregate.aggowner => pg_proc.oid -Join pg_aggregate.aggbasetype => pg_proc.oid -Join pg_aggregate.aggbasetype => pg_type.oid +Join pg_aggregate.aggtransfn1 => pg_proc.oid +Join pg_aggregate.aggtransfn2 => pg_proc.oid Join pg_aggregate.aggtranstype1 => pg_proc.oid Join pg_aggregate.aggtranstype1 => pg_type.oid Join pg_aggregate.aggtranstype2 => pg_type.oid +Join pg_am.ambeginscan => pg_proc.oid +Join pg_am.ambuild => pg_proc.oid +Join pg_am.amdelete => pg_proc.oid +Join pg_am.amendscan => pg_proc.oid +Join pg_am.amgettuple => pg_proc.oid +Join pg_am.aminsert => pg_proc.oid +Join pg_am.ammarkpos => pg_proc.oid Join pg_am.amowner => pg_proc.oid -Join pg_amop.amopid => pg_am.oid -Join pg_amop.amopopr => pg_operator.oid +Join pg_am.amrescan => pg_proc.oid +Join pg_am.amrestrpos => pg_proc.oid Join pg_amop.amopclaid => pg_opclass.oid -Join pg_amproc.amproc => pg_operator.oid -Join pg_amproc.amproc => pg_proc.oid +Join pg_amop.amopid => pg_am.oid +Join pg_amop.amopnpages => pg_proc.oid +Join pg_amop.amopopr => pg_operator.oid +Join pg_amop.amopselect => pg_proc.oid +Join pg_amproc.amid => pg_am.oid Join pg_amproc.amopclaid => pg_opclass.oid Join pg_amproc.amopclaid => pg_operator.oid Join pg_amproc.amopclaid => pg_proc.oid -Join pg_amproc.amid => pg_am.oid +Join pg_amproc.amproc => pg_operator.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.relam => pg_am.oid -Join pg_class.reltype => pg_type.oid Join pg_class.relowner => pg_proc.oid +Join pg_class.reltype => pg_type.oid Join pg_description.objoid => pg_proc.oid Join pg_description.objoid => pg_type.oid Join pg_index.indexrelid => pg_class.oid -Join pg_index.indrelid => pg_class.oid Join pg_index.indproc => pg_proc.oid +Join pg_index.indrelid => pg_class.oid Join pg_opclass.opcdeftype => pg_type.oid +Join pg_operator.oprcode => pg_proc.oid Join pg_operator.oprcom => pg_operator.oid -Join pg_operator.oprrsortop => pg_operator.oid +Join pg_operator.oprjoin => pg_proc.oid +Join pg_operator.oprleft => pg_type.oid Join pg_operator.oprlsortop => pg_operator.oid Join pg_operator.oprnegate => pg_operator.oid +Join pg_operator.oprowner => pg_proc.oid +Join pg_operator.oprrest => pg_proc.oid Join pg_operator.oprresult => pg_type.oid Join pg_operator.oprright => pg_type.oid -Join pg_operator.oprleft => pg_type.oid -Join pg_operator.oprowner => pg_proc.oid -Join pg_parg.partype => pg_type.oid +Join pg_operator.oprrsortop => pg_operator.oid Join pg_parg.parproid => pg_operator.oid Join pg_parg.parproid => pg_proc.oid +Join pg_parg.partype => pg_type.oid Join pg_proc.prolang => pg_language.oid -Join pg_proc.prorettype => pg_type.oid Join pg_proc.proowner => pg_proc.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_type.typrelid => pg_class.oid -Join pg_type.typowner => pg_proc.oid Join pg_type.typelem => pg_operator.oid Join pg_type.typelem => pg_proc.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.typowner => pg_proc.oid +Join pg_type.typreceive => pg_proc.oid +Join pg_type.typrelid => pg_class.oid +Join pg_type.typsend => pg_proc.oid --------------------------------------------------------------------------- diff --git a/contrib/findoidjoins/findoidjoins.c b/contrib/findoidjoins/findoidjoins.c index ad897c3fc1..8b9144ee92 100644 --- a/contrib/findoidjoins/findoidjoins.c +++ b/contrib/findoidjoins/findoidjoins.c @@ -4,6 +4,7 @@ */ #include +#include #include "halt.h" #include #include "pginterface.h" @@ -17,6 +18,7 @@ main(int argc, char **argv) char relname[256]; char relname2[256]; char attname[256]; + char typname[256]; int count; if (argc != 2) @@ -29,14 +31,15 @@ main(int argc, char **argv) doquery("BEGIN WORK"); doquery("\ DECLARE c_attributes BINARY CURSOR FOR \ - SELECT relname, a.attname \ + SELECT typname, relname, a.attname \ FROM pg_class c, pg_attribute a, pg_type t \ WHERE a.attnum > 0 AND \ relkind = 'r' AND \ - typname = 'oid' AND \ + (typname = 'oid' OR \ + typname = 'regproc') AND \ a.attrelid = c.oid AND \ a.atttypid = t.oid \ - ORDER BY 1; \ + ORDER BY 2, 3; \ "); doquery("FETCH ALL IN c_attributes"); attres = get_result(); @@ -53,18 +56,25 @@ main(int argc, char **argv) relres = get_result(); set_result(attres); - while (fetch(relname, attname) != END_OF_TUPLES) + while (fetch(typname, relname, attname) != END_OF_TUPLES) { set_result(relres); reset_fetch(); while (fetch(relname2) != END_OF_TUPLES) { unset_result(relres); - sprintf(query,"\ - DECLARE c_matches BINARY CURSOR FOR \ - SELECT count(*) - FROM %s t1, %s t2 \ - WHERE t1.%s = t2.oid", relname, relname2, attname); + if (strcmp(typname, "oid") == 0) + sprintf(query,"\ + DECLARE c_matches BINARY CURSOR FOR \ + SELECT count(*) + FROM %s t1, %s t2 \ + WHERE t1.%s = t2.oid", relname, relname2, attname); + else + sprintf(query,"\ + DECLARE c_matches BINARY CURSOR FOR \ + SELECT count(*) + FROM %s t1, %s t2 \ + WHERE RegprocToOid(t1.%s) = t2.oid", relname, relname2, attname); doquery(query); doquery("FETCH ALL IN c_matches"); diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h index 930f3ea8dd..a088ef49e5 100644 --- a/src/include/catalog/pg_am.h +++ b/src/include/catalog/pg_am.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_am.h,v 1.5 1997/11/13 03:22:57 momjian Exp $ + * $Id: pg_am.h,v 1.6 1998/08/11 05:32:43 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -109,13 +109,4 @@ DESCR(""); DATA(insert OID = 783 ( gist PGUID "o" 100 7 gistgettuple gistinsert gistdelete - - - - gistbeginscan gistrescan gistendscan gistmarkpos gistrestrpos - - gistbuild - - )); DESCR(""); -BKI_BEGIN -#ifdef NOBTREE -BKI_END -DATA(insert OID = 404 ( nobtree PGUID "o" 5 1 nobtgettuple nobtinsert nobtdelete - - - - nobtbeginscan nobtrescan nobtendscan nobtmarkpos nobtrestrpos - - nobtbuild - - )); -DESCR(""); -BKI_BEGIN -#endif /* NOBTREE */ -BKI_END - #endif /* PG_AM_H */ diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index 54ab225faa..590753fc99 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amop.h,v 1.12 1998/04/26 04:08:52 momjian Exp $ + * $Id: pg_amop.h,v 1.13 1998/08/11 05:32:45 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -318,143 +318,6 @@ DATA(insert OID = 0 ( 403 1313 1330 3 btreesel btreenpage )); DATA(insert OID = 0 ( 403 1313 1335 4 btreesel btreenpage )); DATA(insert OID = 0 ( 403 1313 1334 5 btreesel btreenpage )); -BKI_BEGIN -#ifdef NOBTREE -BKI_END -/* - * nobtree int2_ops - */ - -DATA(insert OID = 0 ( 404 421 95 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 421 522 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 421 94 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 421 524 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 421 520 5 btreesel btreenpage )); - -/* - * nobtree float8_ops - */ - -DATA(insert OID = 0 ( 404 423 672 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 423 673 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 423 670 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 423 675 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 423 674 5 btreesel btreenpage )); - -/* - * nobtree int24_ops - */ - -DATA(insert OID = 0 ( 404 424 534 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 424 540 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 424 532 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 424 542 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 424 536 5 btreesel btreenpage )); - -/* - * nobtree int42_ops - */ - -DATA(insert OID = 0 ( 404 425 535 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 425 541 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 425 533 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 425 543 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 425 537 5 btreesel btreenpage )); - -/* - * nobtree int4_ops - */ - -DATA(insert OID = 0 ( 404 426 97 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 426 523 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 426 96 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 426 525 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 426 521 5 btreesel btreenpage )); - -/* - * nobtree oid_ops - */ - -DATA(insert OID = 0 ( 404 427 609 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 427 611 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 427 607 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 427 612 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 427 610 5 btreesel btreenpage )); - -/* - * nobtree float4_ops - */ - -DATA(insert OID = 0 ( 404 428 622 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 428 624 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 428 620 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 428 625 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 428 623 5 btreesel btreenpage )); - -/* - * nobtree char_ops - */ - -DATA(insert OID = 0 ( 404 429 631 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 429 632 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 429 92 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 429 634 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 429 633 5 btreesel btreenpage )); - -/* - * nobtree name_ops - */ - -DATA(insert OID = 0 ( 404 1181 660 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1181 661 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1181 93 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1181 663 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1181 662 5 btreesel btreenpage )); - -/* - * nobtree text_ops - */ - -DATA(insert OID = 0 ( 404 431 664 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 431 665 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 431 98 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 431 667 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 431 666 5 btreesel btreenpage )); - -/* - * nobtree abstime_ops - */ - -DATA(insert OID = 0 ( 404 432 562 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 432 564 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 432 560 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 432 565 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 432 563 5 btreesel btreenpage )); - -/* - * nobtree datetime_ops - */ - -DATA(insert OID = 0 ( 404 1312 1322 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1312 1323 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1312 1320 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1312 1325 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1312 1324 5 btreesel btreenpage )); - -/* - * nobtree timespan_ops - */ - -DATA(insert OID = 0 ( 404 1313 1332 1 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1313 1333 2 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1313 1330 3 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1313 1335 4 btreesel btreenpage )); -DATA(insert OID = 0 ( 404 1313 1334 5 btreesel btreenpage )); - -BKI_BEGIN -#endif /* NOBTREE */ -BKI_END - /* * hash table _ops */ diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index 68935afa29..3c4a192cfc 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amproc.h,v 1.7 1997/11/30 22:58:07 thomas Exp $ + * $Id: pg_amproc.h,v 1.8 1998/08/11 05:32:46 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -96,28 +96,6 @@ DATA(insert OID = 0 (403 1115 1107 1)); DATA(insert OID = 0 (403 1312 1314 1)); DATA(insert OID = 0 (403 1313 1315 1)); -BKI_BEGIN -#ifdef NOBTREE -BKI_END -DATA(insert OID = 0 (404 421 350 1)); -DATA(insert OID = 0 (404 423 355 1)); -DATA(insert OID = 0 (404 424 353 1)); -DATA(insert OID = 0 (404 425 352 1)); -DATA(insert OID = 0 (404 426 351 1)); -DATA(insert OID = 0 (404 427 356 1)); -DATA(insert OID = 0 (404 428 354 1)); -DATA(insert OID = 0 (404 429 358 1)); -DATA(insert OID = 0 (404 406 689 1)); -DATA(insert OID = 0 (404 407 690 1)); -DATA(insert OID = 0 (404 408 691 1)); -DATA(insert OID = 0 (404 1181 359 1)); -DATA(insert OID = 0 (404 430 1274 1)); -DATA(insert OID = 0 (404 431 360 1)); -DATA(insert OID = 0 (404 432 357 1)); -BKI_BEGIN -#endif /* NOBTREE */ -BKI_END - DATA(insert OID = 0 (405 421 449 1)); DATA(insert OID = 0 (405 423 452 1)); DATA(insert OID = 0 (405 426 450 1));