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', 'i', '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 and pg_attribute, due to fear of recursive dependencies as
39 -- 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 -- 3. pg_authid, since its toast table cannot be accessed when it would be
44 -- needed, i.e., during authentication before we've selected a database.
45 SELECT relname, attname, atttypid::regtype
46 FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid
47 WHERE c.oid < 16384 AND
52 relname | attname | atttypid
53 -------------------------+---------------+--------------
54 pg_attribute | attacl | aclitem[]
55 pg_attribute | attfdwoptions | text[]
56 pg_attribute | attmissingval | anyarray
57 pg_attribute | attoptions | text[]
58 pg_authid | rolpassword | text
59 pg_class | relacl | aclitem[]
60 pg_class | reloptions | text[]
61 pg_class | relpartbound | pg_node_tree
62 pg_largeobject | data | bytea
63 pg_largeobject_metadata | lomacl | aclitem[]
66 -- system catalogs without primary keys
68 -- Current exceptions:
69 -- * pg_depend, pg_shdepend don't have a unique key
72 WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'r'
73 AND pg_class.oid NOT IN (SELECT indrelid FROM pg_index WHERE indisprimary)
81 -- system catalog unique indexes not wrapped in a constraint
82 -- (There should be none.)
84 FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid
85 WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'i'
87 AND c.oid NOT IN (SELECT conindid FROM pg_constraint)