-- -- MISC_SANITY -- Sanity checks for common errors in making system tables that don't fit -- comfortably into either opr_sanity or type_sanity. -- -- Every test failure in this file should be closely inspected. -- The description of the failing test should be read carefully before -- adjusting the expected output. In most cases, the queries should -- not find *any* matching entries. -- -- NB: run this test early, because some later tests create bogus entries.
-- **************** pg_depend ****************
-- Look for illegal values in pg_depend fields.
SELECT * FROM pg_depend as d1 WHERE refclassid = 0OR refobjid = 0OR
classid = 0OR objid = 0OR
deptype NOTIN ('a', 'e', 'i', 'n', 'x', 'P', 'S');
-- **************** pg_shdepend ****************
-- Look for illegal values in pg_shdepend fields.
SELECT * FROM pg_shdepend as d1 WHERE refclassid = 0OR refobjid = 0OR
classid = 0OR objid = 0OR
deptype NOTIN ('a', 'i', 'o', 'r', 't');
-- **************** pg_class ****************
-- Look for system tables with varlena columns but no toast table. All -- system tables with toastable columns should have toast tables, with -- the following exceptions: -- 1. pg_class and pg_attribute, due to fear of recursive dependencies as -- toast tables depend on them. -- 2. pg_largeobject and pg_largeobject_metadata. Large object catalogs -- and toast tables are mutually exclusive and large object data is handled -- as user data by pg_upgrade, which would cause failures. -- 3. pg_authid, since its toast table cannot be accessed when it would be -- needed, i.e., during authentication before we've selected a database. -- 4. pg_replication_origin, since we want to be able to access that catalog -- without setting up a snapshot. To make that safe, it needs to not have a -- toast table, since toasted data cannot be fetched without a snapshot. As of -- this writing, its only varlena column is roname, which we limit to 512 bytes -- to avoid needing out-of-line storage.
SELECT relname, attname, atttypid::regtype FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid WHERE c.oid < 16384AND
reltoastrelid = 0AND
relkind = 'r'AND
attstorage != 'p' ORDERBY1, 2;
-- system catalogs without primary keys -- -- Current exceptions: -- * pg_depend, pg_shdepend don't have a unique key SELECT relname FROM pg_class WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'r' AND pg_class.oid NOTIN (SELECT indrelid FROM pg_index WHERE indisprimary) ORDERBY1;
-- system catalog unique indexes not wrapped in a constraint -- (There should be none.) SELECT relname FROM pg_class c JOIN pg_index i ON c.oid = i.indexrelid WHERE relnamespace = 'pg_catalog'::regnamespace AND relkind = 'i' AND i.indisunique AND c.oid NOTIN (SELECT conindid FROM pg_constraint) ORDERBY1;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.