4
-- sanity check, if we don't have indices the test will take years to
5
-- complete. But skip TOAST relations since they will have varying
6
-- names depending on the current OID counter.
8
SELECT relname, relhasindex
10
WHERE relhasindex AND relkind != 't'
14
-- another sanity check: every system catalog that has OIDs should have
15
-- a unique index on OID. This ensures that the OIDs will be unique,
16
-- even after the OID counter wraps around.
17
-- We exclude non-system tables from the check by looking at nspname.
19
SELECT relname, nspname
20
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
22
AND ((nspname ~ '^pg_') IS NOT FALSE)
23
AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
24
AND indkey[0] = -2 AND indnatts = 1 AND indisunique);