From: Tom Lane Date: Sat, 10 Aug 2002 15:54:04 +0000 (+0000) Subject: Add a sanity check to make sure that all system catalogs that have OIDs X-Git-Tag: REL7_3~973 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=273ae970522ba570137edf4faa56faf2d50e2caa;p=postgresql Add a sanity check to make sure that all system catalogs that have OIDs also have a unique index on OID. --- diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out index 25e7b091c2..36837f1106 100644 --- a/src/test/regress/expected/sanity_check.out +++ b/src/test/regress/expected/sanity_check.out @@ -65,3 +65,19 @@ SELECT relname, relhasindex tenk2 | t (53 rows) +-- +-- another sanity check: every system catalog that has OIDs should have +-- a unique index on OID. This ensures that the OIDs will be unique, +-- even after the OID counter wraps around. +-- We exclude non-system tables from the check by looking at nspname. +-- +SELECT relname, nspname +FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace +WHERE relhasoids + AND ((nspname ~ '^pg_') IS NOT FALSE) + AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid + AND indkey[0] = -2 AND indkey[1] = 0 AND indisunique); + relname | nspname +---------+--------- +(0 rows) + diff --git a/src/test/regress/sql/sanity_check.sql b/src/test/regress/sql/sanity_check.sql index 696a4f425d..50b1a2659b 100644 --- a/src/test/regress/sql/sanity_check.sql +++ b/src/test/regress/sql/sanity_check.sql @@ -1,5 +1,5 @@ - VACUUM; + -- -- sanity check, if we don't have indices the test will take years to -- complete. But skip TOAST relations since they will have varying @@ -10,3 +10,15 @@ SELECT relname, relhasindex WHERE relhasindex AND relkind != 't' ORDER BY relname; +-- +-- another sanity check: every system catalog that has OIDs should have +-- a unique index on OID. This ensures that the OIDs will be unique, +-- even after the OID counter wraps around. +-- We exclude non-system tables from the check by looking at nspname. +-- +SELECT relname, nspname +FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace +WHERE relhasoids + AND ((nspname ~ '^pg_') IS NOT FALSE) + AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid + AND indkey[0] = -2 AND indkey[1] = 0 AND indisunique);