mirror of
https://github.com/postgres/postgres.git
synced 2026-02-17 17:55:04 -05:00
of an index can now be a computed expression instead of a simple variable. Restrictions on expressions are the same as for predicates (only immutable functions, no sub-selects). This fixes problems recently introduced with inlining SQL functions, because the inlining transformation is applied to both expression trees so the planner can still match them up. Along the way, improve efficiency of handling index predicates (both predicates and index expressions are now cached by the relcache) and fix 7.3 oversight that didn't record dependencies of predicate expressions.
24 lines
859 B
SQL
24 lines
859 B
SQL
VACUUM;
|
|
|
|
--
|
|
-- sanity check, if we don't have indices the test will take years to
|
|
-- complete. But skip TOAST relations since they will have varying
|
|
-- names depending on the current OID counter.
|
|
--
|
|
SELECT relname, relhasindex
|
|
FROM pg_class
|
|
WHERE relhasindex AND relkind != 't'
|
|
ORDER BY relname;
|
|
|
|
--
|
|
-- another sanity check: every system catalog that has OIDs should have
|
|
-- a unique index on OID. This ensures that the OIDs will be unique,
|
|
-- even after the OID counter wraps around.
|
|
-- We exclude non-system tables from the check by looking at nspname.
|
|
--
|
|
SELECT relname, nspname
|
|
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
|
|
WHERE relhasoids
|
|
AND ((nspname ~ '^pg_') IS NOT FALSE)
|
|
AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
|
|
AND indkey[0] = -2 AND indnatts = 1 AND indisunique);
|