3 -- Sanity checks for common errors in making system tables that don't fit
4 -- comfortably into either opr_sanity or type_sanity.
6 -- Every test failure in this file should be closely inspected.
7 -- The description of the failing test should be read carefully before
8 -- adjusting the expected output. In most cases, the queries should
9 -- not find *any* matching entries.
11 -- NB: run this test early, because some later tests create bogus entries.
12 -- **************** pg_depend ****************
13 -- Look for illegal values in pg_depend fields.
16 WHERE refclassid = 0 OR refobjid = 0 OR
17 classid = 0 OR objid = 0 OR
18 deptype NOT IN ('a', 'e', 'i', 'n', 'x', 'P', 'S');
19 classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype
20 ---------+-------+----------+------------+----------+-------------+---------
23 -- **************** pg_shdepend ****************
24 -- Look for illegal values in pg_shdepend fields.
26 FROM pg_shdepend as d1
27 WHERE refclassid = 0 OR refobjid = 0 OR
28 classid = 0 OR objid = 0 OR
29 deptype NOT IN ('a', 'o', 'r', 't');
30 dbid | classid | objid | objsubid | refclassid | refobjid | deptype
31 ------+---------+-------+----------+------------+----------+---------
34 -- **************** pg_class ****************
35 -- Look for system tables with varlena columns but no toast table. All
36 -- system tables with toastable columns should have toast tables, with
37 -- the following exceptions:
38 -- 1. pg_class, pg_attribute, and pg_index, due to fear of recursive
39 -- dependencies as toast tables depend on them.
40 -- 2. pg_largeobject and pg_largeobject_metadata. Large object catalogs
41 -- and toast tables are mutually exclusive and large object data is handled
42 -- as user data by pg_upgrade, which would cause failures.
43 SELECT relname, attname, atttypid::regtype
44 FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid
45 WHERE c.oid < 16384 AND
50 relname | attname | atttypid
51 -------------------------+---------------+--------------
52 pg_attribute | attacl | aclitem[]
53 pg_attribute | attfdwoptions | text[]
54 pg_attribute | attmissingval | anyarray
55 pg_attribute | attoptions | text[]
56 pg_class | relacl | aclitem[]
57 pg_class | reloptions | text[]
58 pg_class | relpartbound | pg_node_tree
59 pg_index | indexprs | pg_node_tree
60 pg_index | indpred | pg_node_tree
61 pg_largeobject | data | bytea
62 pg_largeobject_metadata | lomacl | aclitem[]
65 -- system catalogs without primary keys
67 -- Current exceptions:
68 -- * pg_depend, pg_shdepend don't have a unique key
71 WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'r'
72 AND pg_class.oid NOT IN (SELECT indrelid FROM pg_index WHERE indisprimary)
80 -- system catalog unique indexes not wrapped in a constraint
81 -- (There should be none.)
83 FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid
84 WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'i'
86 AND c.oid NOT IN (SELECT conindid FROM pg_constraint)