Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / test / regress / sql / sanity_check.sql
blobb0d800bc797755aa677f0f36d003c86603fb689f
1 VACUUM;
3 --
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) as well as temp tables
7 -- of other backends (to avoid timing-dependent behavior).
8 --
9 SELECT relname, relhasindex
10    FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
11    WHERE relkind = 'r' AND (nspname ~ '^pg_temp_') IS NOT TRUE
12    ORDER BY relname;
15 -- another sanity check: every system catalog that has OIDs should have
16 -- a unique index on OID.  This ensures that the OIDs will be unique,
17 -- even after the OID counter wraps around.
18 -- We exclude non-system tables from the check by looking at nspname.
20 SELECT relname, nspname
21 FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
22 WHERE relhasoids
23     AND ((nspname ~ '^pg_') IS NOT FALSE)
24     AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
25                     AND indkey[0] = -2 AND indnatts = 1 AND indisunique);