summaryrefslogtreecommitdiff
path: root/contrib/findoidjoins
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-08-10 18:57:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-08-10 18:57:42 +0000
commitbf56f0759bdfa87f143c3abd09f893a5f530fe88 (patch)
tree10555a5e46bcfdfd9799b8f0e13ab48101d766de /contrib/findoidjoins
parentd062f0f4e91f68b1f55b04691bd92d1efc83dc54 (diff)
downloadpostgresql-bf56f0759bdfa87f143c3abd09f893a5f530fe88.tar.gz
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.
Diffstat (limited to 'contrib/findoidjoins')
-rw-r--r--contrib/findoidjoins/README.findoidjoins16
-rw-r--r--contrib/findoidjoins/findoidjoins.c12
-rwxr-xr-xcontrib/findoidjoins/make_oidjoins_check4
3 files changed, 16 insertions, 16 deletions
diff --git a/contrib/findoidjoins/README.findoidjoins b/contrib/findoidjoins/README.findoidjoins
index 288c3f8e98..712fc1373e 100644
--- a/contrib/findoidjoins/README.findoidjoins
+++ b/contrib/findoidjoins/README.findoidjoins
@@ -9,10 +9,10 @@ it on anything but an empty database, such as template1.
Uses pgeasy library.
Run on an empty database, it returns the system join relationships (shown
-below for 7.1). Note that unexpected matches may indicate bogus entries
+below for 7.2). 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 7.1, the *only* field that should join to more
+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.)
@@ -27,9 +27,8 @@ 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 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
+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.
---------------------------------------------------------------------------
@@ -41,13 +40,13 @@ 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.amdelete => 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.amopid => pg_am.oid
Join pg_amop.amopclaid => pg_opclass.oid
@@ -61,6 +60,7 @@ 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.opcdeftype => pg_type.oid
@@ -78,7 +78,9 @@ 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.staop => pg_operator.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
diff --git a/contrib/findoidjoins/findoidjoins.c b/contrib/findoidjoins/findoidjoins.c
index 8aabe58672..87d794a9da 100644
--- a/contrib/findoidjoins/findoidjoins.c
+++ b/contrib/findoidjoins/findoidjoins.c
@@ -38,7 +38,6 @@ 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 \
@@ -52,8 +51,7 @@ main(int argc, char **argv)
DECLARE c_relations BINARY CURSOR FOR \
SELECT relname \
FROM pg_class c \
- WHERE relkind = 'r' AND \
- relhasrules = 'f' \
+ WHERE relkind = 'r' AND relhasoids \
ORDER BY 1; \
");
doquery("FETCH ALL IN c_relations");
@@ -71,14 +69,14 @@ main(int argc, char **argv)
sprintf(query, "\
DECLARE c_matches BINARY CURSOR FOR \
SELECT count(*) \
- FROM %s t1, %s t2 \
- WHERE t1.%s = t2.oid ", relname, relname2, attname);
+ 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);
+ 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/contrib/findoidjoins/make_oidjoins_check b/contrib/findoidjoins/make_oidjoins_check
index 63cb8c8971..72bb645251 100755
--- a/contrib/findoidjoins/make_oidjoins_check
+++ b/contrib/findoidjoins/make_oidjoins_check
@@ -1,7 +1,7 @@
#! /bin/sh
# You first run findoidjoins on the template1 database, and send that
-# output into this file to generate a list of SQL statements.
+# output into this script to generate a list of SQL statements.
# NOTE: any field that findoidjoins thinks joins to more than one table
# will NOT be checked by the output of this script. You should be
@@ -41,7 +41,7 @@ $AWK -F'[ \.]' '\
}
{
printf "\
-SELECT oid, %s.%s \n\
+SELECT ctid, %s.%s \n\
FROM %s \n\
WHERE %s.%s != 0 AND \n\
NOT EXISTS(SELECT * FROM %s AS t1 WHERE t1.oid = %s.%s);\n",