diff --git a/contrib/findoidjoins/Makefile b/contrib/findoidjoins/Makefile index e55b33a0ea..bf98412ecf 100644 --- a/contrib/findoidjoins/Makefile +++ b/contrib/findoidjoins/Makefile @@ -2,7 +2,7 @@ # Makefile, requires pgsql/contrib/pginterface # # -PGINTERFACE = pginterface.o halt.o # these have to be in your library search path +PGINTERFACE = ../pginterface/pginterface.o ../pginterface/halt.o # these have to be in your library search path TARGET = findoidjoins CFLAGS = -g -Wall -I. -I../../src/interfaces/libpq -I/usr/local/pgsql/include LDFLAGS = -L/usr/local/pgsql/lib -lpq diff --git a/contrib/findoidjoins/README b/contrib/findoidjoins/README index 54ef3ccbb4..9170832bde 100644 --- a/contrib/findoidjoins/README +++ b/contrib/findoidjoins/README @@ -35,6 +35,7 @@ Join pg_am.ambuild => pg_proc.oid Join pg_amop.amopid => pg_am.oid Join pg_amop.amopclaid => pg_opclass.oid Join pg_amop.amopopr => pg_operator.oid +Join pg_amop.amopopr => pg_proc.oid Join pg_amop.amopselect => pg_proc.oid Join pg_amop.amopnpages => pg_proc.oid Join pg_amproc.amid => pg_am.oid @@ -51,7 +52,6 @@ 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_opclass.opcdeftype => pg_type.oid Join pg_operator.oprleft => pg_type.oid Join pg_operator.oprright => pg_type.oid diff --git a/contrib/findoidjoins/findoidjoins.c b/contrib/findoidjoins/findoidjoins.c index b1178b5834..6c0e2e19d1 100644 --- a/contrib/findoidjoins/findoidjoins.c +++ b/contrib/findoidjoins/findoidjoins.c @@ -35,6 +35,7 @@ main(int argc, char **argv) FROM pg_class c, pg_attribute a, pg_type t \ WHERE a.attnum > 0 AND \ relkind = 'r' AND \ + relhasrules = 'f' AND \ (typname = 'oid' OR \ typname = 'regproc') AND \ a.attrelid = c.oid AND \ @@ -49,6 +50,7 @@ main(int argc, char **argv) SELECT relname \ FROM pg_class c \ WHERE relkind = 'r' AND \ + relhasrules = 'f' AND \ relname != 'pg_user' \ ORDER BY 1; \ "); diff --git a/contrib/findoidjoins/make_oidjoins_check b/contrib/findoidjoins/make_oidjoins_check new file mode 100755 index 0000000000..a17052f730 --- /dev/null +++ b/contrib/findoidjoins/make_oidjoins_check @@ -0,0 +1,35 @@ +: +# You first run findoidjoins on the template1 database, and send that +# output into this file to generate a list of SQL statements. +trap "rm -f /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15 + +cat "$@" >/tmp/$$ +cat /tmp/$$ | cut -d' ' -f2 | sort | uniq -d >/tmp/$$a +cat /tmp/$$ | while read LINE +do + set -- $LINE + grep "$2" /tmp/$$a >/dev/null 2>&1 || echo $LINE +done >/tmp/$$b +cat /tmp/$$b | +awk -F'[ \.]' '\ + BEGIN \ + { + printf "\ +--\n\ +-- This is created by pgsql/contrib/findoidjoins/make_oidjoin_check\n\ +--\n"; + } + { + printf "\ +SELECT oid, %s.%s \n\ +FROM %s \n\ +WHERE %s%s.%s%s NOT IN (SELECT oid FROM %s) AND \n\ + %s%s.%s%s != 0;\n", $2, $3, $2, + ($5 == "pg_proc") ? "RegprocToOid(" : "", + $2, $3, + ($5 == "pg_proc") ? ")" : "", + $5, + ($5 == "pg_proc") ? "RegprocToOid(" : "", + $2, $3, + ($5 == "pg_proc") ? ")" : ""; + }' diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index 2b711fe9a0..4b22362418 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_operator.h,v 1.37 1998/09/13 14:29:06 thomas Exp $ + * $Id: pg_operator.h,v 1.38 1998/09/14 01:14:48 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -200,8 +200,8 @@ DATA(insert OID = 525 ( ">=" PGUID 0 b t f 23 23 16 523 97 0 0 int4ge DATA(insert OID = 526 ( "*" PGUID 0 b t f 21 21 21 526 0 0 0 int2mul intltsel intltjoinsel )); DATA(insert OID = 527 ( "/" PGUID 0 b t f 21 21 21 0 0 0 0 int2div intltsel intltjoinsel )); DATA(insert OID = 528 ( "/" PGUID 0 b t f 23 23 23 0 0 0 0 int4div intltsel intltjoinsel )); -DATA(insert OID = 529 ( "%" PGUID 0 b t f 21 21 21 6 0 0 0 int2mod intltsel intltjoinsel )); -DATA(insert OID = 530 ( "%" PGUID 0 b t f 23 23 23 6 0 0 0 int4mod intltsel intltjoinsel )); +DATA(insert OID = 529 ( "%" PGUID 0 b t f 21 21 21 0 0 0 0 int2mod intltsel intltjoinsel )); +DATA(insert OID = 530 ( "%" PGUID 0 b t f 23 23 23 0 0 0 0 int4mod intltsel intltjoinsel )); DATA(insert OID = 531 ( "<>" PGUID 0 b t f 25 25 16 531 98 0 0 textne neqsel neqjoinsel )); DATA(insert OID = 532 ( "=" PGUID 0 b t t 21 23 16 533 538 95 97 int24eq eqsel eqjoinsel )); DATA(insert OID = 533 ( "=" PGUID 0 b t t 23 21 16 532 539 97 95 int42eq eqsel eqjoinsel )); @@ -219,8 +219,8 @@ DATA(insert OID = 544 ( "*" PGUID 0 b t f 21 23 23 545 0 0 0 int24mul DATA(insert OID = 545 ( "*" PGUID 0 b t f 23 21 23 544 0 0 0 int42mul intltsel intltjoinsel )); DATA(insert OID = 546 ( "/" PGUID 0 b t f 21 23 23 0 0 0 0 int24div intltsel intltjoinsel )); DATA(insert OID = 547 ( "/" PGUID 0 b t f 23 21 23 0 0 0 0 int42div intltsel intltjoinsel )); -DATA(insert OID = 548 ( "%" PGUID 0 b t f 21 23 23 6 0 0 0 int24mod intltsel intltjoinsel )); -DATA(insert OID = 549 ( "%" PGUID 0 b t f 23 21 23 6 0 0 0 int42mod intltsel intltjoinsel )); +DATA(insert OID = 548 ( "%" PGUID 0 b t f 21 23 23 0 0 0 0 int24mod intltsel intltjoinsel )); +DATA(insert OID = 549 ( "%" PGUID 0 b t f 23 21 23 0 0 0 0 int42mod intltsel intltjoinsel )); DATA(insert OID = 550 ( "+" PGUID 0 b t f 21 21 21 550 0 0 0 int2pl intltsel intltjoinsel )); DATA(insert OID = 551 ( "+" PGUID 0 b t f 23 23 23 551 0 0 0 int4pl intltsel intltjoinsel )); DATA(insert OID = 552 ( "+" PGUID 0 b t f 21 23 23 553 0 0 0 int24pl intltsel intltjoinsel )); diff --git a/src/include/catalog/template1_check.sql b/src/include/catalog/template1_check.sql new file mode 100644 index 0000000000..382bb2cbdb --- /dev/null +++ b/src/include/catalog/template1_check.sql @@ -0,0 +1,179 @@ +-- +-- This is created by pgsql/contrib/findoidjoins/make_oidjoin_check +-- +SELECT oid, pg_aggregate.aggtransfn1 +FROM pg_aggregate +WHERE RegprocToOid(pg_aggregate.aggtransfn1) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_aggregate.aggtransfn1) != 0; +SELECT oid, pg_aggregate.aggtransfn2 +FROM pg_aggregate +WHERE RegprocToOid(pg_aggregate.aggtransfn2) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_aggregate.aggtransfn2) != 0; +SELECT oid, pg_aggregate.aggfinalfn +FROM pg_aggregate +WHERE RegprocToOid(pg_aggregate.aggfinalfn) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_aggregate.aggfinalfn) != 0; +SELECT oid, pg_aggregate.aggtranstype2 +FROM pg_aggregate +WHERE pg_aggregate.aggtranstype2 NOT IN (SELECT oid FROM pg_type) AND + pg_aggregate.aggtranstype2 != 0; +SELECT oid, pg_am.amgettuple +FROM pg_am +WHERE RegprocToOid(pg_am.amgettuple) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.amgettuple) != 0; +SELECT oid, pg_am.aminsert +FROM pg_am +WHERE RegprocToOid(pg_am.aminsert) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.aminsert) != 0; +SELECT oid, pg_am.amdelete +FROM pg_am +WHERE RegprocToOid(pg_am.amdelete) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.amdelete) != 0; +SELECT oid, pg_am.ambeginscan +FROM pg_am +WHERE RegprocToOid(pg_am.ambeginscan) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.ambeginscan) != 0; +SELECT oid, pg_am.amrescan +FROM pg_am +WHERE RegprocToOid(pg_am.amrescan) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.amrescan) != 0; +SELECT oid, pg_am.amendscan +FROM pg_am +WHERE RegprocToOid(pg_am.amendscan) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.amendscan) != 0; +SELECT oid, pg_am.ammarkpos +FROM pg_am +WHERE RegprocToOid(pg_am.ammarkpos) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.ammarkpos) != 0; +SELECT oid, pg_am.amrestrpos +FROM pg_am +WHERE RegprocToOid(pg_am.amrestrpos) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.amrestrpos) != 0; +SELECT oid, pg_am.ambuild +FROM pg_am +WHERE RegprocToOid(pg_am.ambuild) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_am.ambuild) != 0; +SELECT oid, pg_amop.amopid +FROM pg_amop +WHERE pg_amop.amopid NOT IN (SELECT oid FROM pg_am) AND + pg_amop.amopid != 0; +SELECT oid, pg_amop.amopclaid +FROM pg_amop +WHERE pg_amop.amopclaid NOT IN (SELECT oid FROM pg_opclass) AND + pg_amop.amopclaid != 0; +SELECT oid, pg_amop.amopselect +FROM pg_amop +WHERE RegprocToOid(pg_amop.amopselect) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_amop.amopselect) != 0; +SELECT oid, pg_amop.amopnpages +FROM pg_amop +WHERE RegprocToOid(pg_amop.amopnpages) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_amop.amopnpages) != 0; +SELECT oid, pg_amproc.amid +FROM pg_amproc +WHERE pg_amproc.amid NOT IN (SELECT oid FROM pg_am) AND + pg_amproc.amid != 0; +SELECT oid, pg_attribute.attrelid +FROM pg_attribute +WHERE pg_attribute.attrelid NOT IN (SELECT oid FROM pg_class) AND + pg_attribute.attrelid != 0; +SELECT oid, pg_attribute.atttypid +FROM pg_attribute +WHERE pg_attribute.atttypid NOT IN (SELECT oid FROM pg_type) AND + pg_attribute.atttypid != 0; +SELECT oid, pg_class.reltype +FROM pg_class +WHERE pg_class.reltype NOT IN (SELECT oid FROM pg_type) AND + pg_class.reltype != 0; +SELECT oid, pg_class.relam +FROM pg_class +WHERE pg_class.relam NOT IN (SELECT oid FROM pg_am) AND + pg_class.relam != 0; +SELECT oid, pg_index.indexrelid +FROM pg_index +WHERE pg_index.indexrelid NOT IN (SELECT oid FROM pg_class) AND + pg_index.indexrelid != 0; +SELECT oid, pg_index.indrelid +FROM pg_index +WHERE pg_index.indrelid NOT IN (SELECT oid FROM pg_class) AND + pg_index.indrelid != 0; +SELECT oid, pg_opclass.opcdeftype +FROM pg_opclass +WHERE pg_opclass.opcdeftype NOT IN (SELECT oid FROM pg_type) AND + pg_opclass.opcdeftype != 0; +SELECT oid, pg_operator.oprleft +FROM pg_operator +WHERE pg_operator.oprleft NOT IN (SELECT oid FROM pg_type) AND + pg_operator.oprleft != 0; +SELECT oid, pg_operator.oprright +FROM pg_operator +WHERE pg_operator.oprright NOT IN (SELECT oid FROM pg_type) AND + pg_operator.oprright != 0; +SELECT oid, pg_operator.oprresult +FROM pg_operator +WHERE pg_operator.oprresult NOT IN (SELECT oid FROM pg_type) AND + pg_operator.oprresult != 0; +SELECT oid, pg_operator.oprcom +FROM pg_operator +WHERE pg_operator.oprcom NOT IN (SELECT oid FROM pg_operator) AND + pg_operator.oprcom != 0; +SELECT oid, pg_operator.oprnegate +FROM pg_operator +WHERE pg_operator.oprnegate NOT IN (SELECT oid FROM pg_operator) AND + pg_operator.oprnegate != 0; +SELECT oid, pg_operator.oprlsortop +FROM pg_operator +WHERE pg_operator.oprlsortop NOT IN (SELECT oid FROM pg_operator) AND + pg_operator.oprlsortop != 0; +SELECT oid, pg_operator.oprrsortop +FROM pg_operator +WHERE pg_operator.oprrsortop NOT IN (SELECT oid FROM pg_operator) AND + pg_operator.oprrsortop != 0; +SELECT oid, pg_operator.oprcode +FROM pg_operator +WHERE RegprocToOid(pg_operator.oprcode) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_operator.oprcode) != 0; +SELECT oid, pg_operator.oprrest +FROM pg_operator +WHERE RegprocToOid(pg_operator.oprrest) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_operator.oprrest) != 0; +SELECT oid, pg_operator.oprjoin +FROM pg_operator +WHERE RegprocToOid(pg_operator.oprjoin) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_operator.oprjoin) != 0; +SELECT oid, pg_parg.partype +FROM pg_parg +WHERE pg_parg.partype NOT IN (SELECT oid FROM pg_type) AND + pg_parg.partype != 0; +SELECT oid, pg_proc.prolang +FROM pg_proc +WHERE pg_proc.prolang NOT IN (SELECT oid FROM pg_language) AND + pg_proc.prolang != 0; +SELECT oid, pg_proc.prorettype +FROM pg_proc +WHERE pg_proc.prorettype NOT IN (SELECT oid FROM pg_type) AND + pg_proc.prorettype != 0; +SELECT oid, pg_rewrite.ev_class +FROM pg_rewrite +WHERE pg_rewrite.ev_class NOT IN (SELECT oid FROM pg_class) AND + pg_rewrite.ev_class != 0; +SELECT oid, pg_type.typrelid +FROM pg_type +WHERE pg_type.typrelid NOT IN (SELECT oid FROM pg_class) AND + pg_type.typrelid != 0; +SELECT oid, pg_type.typinput +FROM pg_type +WHERE RegprocToOid(pg_type.typinput) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_type.typinput) != 0; +SELECT oid, pg_type.typoutput +FROM pg_type +WHERE RegprocToOid(pg_type.typoutput) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_type.typoutput) != 0; +SELECT oid, pg_type.typreceive +FROM pg_type +WHERE RegprocToOid(pg_type.typreceive) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_type.typreceive) != 0; +SELECT oid, pg_type.typsend +FROM pg_type +WHERE RegprocToOid(pg_type.typsend) NOT IN (SELECT oid FROM pg_proc) AND + RegprocToOid(pg_type.typsend) != 0;