3 -- Sanity check: every system catalog that has OIDs should have
4 -- a unique index on OID. This ensures that the OIDs will be unique,
5 -- even after the OID counter wraps around.
6 -- We exclude non-system tables from the check by looking at nspname.
8 SELECT relname, nspname
9 FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace JOIN pg_attribute a ON (attrelid = c.oid AND attname = 'oid')
10 WHERE relkind = 'r' and c.oid < 16384
11 AND ((nspname ~ '^pg_') IS NOT FALSE)
12 AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
13 AND indkey[0] = a.attnum AND indnatts = 1
14 AND indisunique AND indimmediate);
19 -- check that relations without storage don't have relfilenode
20 SELECT relname, relkind
22 WHERE relkind IN ('v', 'c', 'f', 'p', 'I')