Add some checks on "char"-type columns to type_sanity and opr_sanity.

I noticed that the sanity checks in the regression tests omitted to
check a couple of "poor man's enum" columns that you'd reasonably
expect them to check.

There are other "char"-type columns in system catalogs that are not
covered by either type_sanity or opr_sanity, e.g. pg_rewrite.ev_type.
However, those catalogs are not populated with any manually-created
data during bootstrap, so it seems less necessary to check them
this way.
This commit is contained in:
Tom Lane 2016-01-09 17:20:58 -05:00
parent 26d538dc93
commit 3ef16c46fb
4 changed files with 12 additions and 4 deletions

View File

@ -57,7 +57,9 @@ WHERE p1.prolang = 0 OR p1.prorettype = 0 OR
array_upper(p1.proargtypes, 1) != p1.pronargs-1 OR
0::oid = ANY (p1.proargtypes) OR
procost <= 0 OR
CASE WHEN proretset THEN prorows <= 0 ELSE prorows != 0 END;
CASE WHEN proretset THEN prorows <= 0 ELSE prorows != 0 END OR
provolatile NOT IN ('i', 's', 'v') OR
proparallel NOT IN ('s', 'r', 'u');
oid | proname
-----+---------
(0 rows)

View File

@ -465,7 +465,9 @@ ORDER BY 1;
-- Look for illegal values in pg_class fields
SELECT p1.oid, p1.relname
FROM pg_class as p1
WHERE p1.relkind NOT IN ('r', 'i', 's', 'S', 'c', 't', 'v', 'f');
WHERE relkind NOT IN ('r', 'i', 's', 'S', 'c', 't', 'v', 'f') OR
relpersistence NOT IN ('p', 'u', 't') OR
relreplident NOT IN ('d', 'n', 'f', 'i');
oid | relname
-----+---------
(0 rows)

View File

@ -64,7 +64,9 @@ WHERE p1.prolang = 0 OR p1.prorettype = 0 OR
array_upper(p1.proargtypes, 1) != p1.pronargs-1 OR
0::oid = ANY (p1.proargtypes) OR
procost <= 0 OR
CASE WHEN proretset THEN prorows <= 0 ELSE prorows != 0 END;
CASE WHEN proretset THEN prorows <= 0 ELSE prorows != 0 END OR
provolatile NOT IN ('i', 's', 'v') OR
proparallel NOT IN ('s', 'r', 'u');
-- prosrc should never be null or empty
SELECT p1.oid, p1.proname

View File

@ -339,7 +339,9 @@ ORDER BY 1;
SELECT p1.oid, p1.relname
FROM pg_class as p1
WHERE p1.relkind NOT IN ('r', 'i', 's', 'S', 'c', 't', 'v', 'f');
WHERE relkind NOT IN ('r', 'i', 's', 'S', 'c', 't', 'v', 'f') OR
relpersistence NOT IN ('p', 'u', 't') OR
relreplident NOT IN ('d', 'n', 'f', 'i');
-- Indexes should have an access method, others not.