Thread: pgsql: Replace explicit PIN entries in pg_depend with an OID range test

Replace explicit PIN entries in pg_depend with an OID range test.

As of v14, pg_depend contains almost 7000 "pin" entries recording
the OIDs of built-in objects.  This is a fair amount of bloat for
every database, and it adds time to pg_depend lookups as well as
initdb.  We can get rid of all of those entries in favor of an OID
range check, i.e. "OIDs below FirstUnpinnedObjectId are pinned".

(template1 and the public schema are exceptions.  Those exceptions
are now wired into IsPinnedObject() instead of initdb's code for
filling pg_depend, but it's the same amount of cruft either way.)

The contents of pg_shdepend are modified likewise.

Discussion: https://postgr.es/m/3737988.1618451008@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a49d081235997c67e8aab7a523b17e8d1cb93184

Modified Files
--------------
doc/src/sgml/bki.sgml                     | 28 ++++++---
doc/src/sgml/catalogs.sgml                | 60 ++++++++-----------
src/backend/access/transam/varsup.c       | 49 ++++++++++++++--
src/backend/access/transam/xlog.c         |  2 +-
src/backend/catalog/catalog.c             | 96 +++++++++++++++++++++++++++++--
src/backend/catalog/dependency.c          | 32 ++++-------
src/backend/catalog/genbki.pl             | 10 ++--
src/backend/catalog/pg_depend.c           | 66 ++++++---------------
src/backend/catalog/pg_publication.c      |  2 +-
src/backend/catalog/pg_shdepend.c         | 92 ++++++-----------------------
src/backend/commands/tablecmds.c          | 16 ++----
src/backend/commands/tablespace.c         |  4 +-
src/backend/optimizer/plan/setrefs.c      |  6 +-
src/backend/storage/lmgr/predicate.c      |  2 +-
src/bin/initdb/initdb.c                   | 77 +------------------------
src/bin/pg_resetwal/pg_resetwal.c         |  2 +-
src/include/access/transam.h              | 16 ++++--
src/include/catalog/catalog.h             |  2 +
src/include/catalog/catversion.h          |  2 +-
src/include/catalog/dependency.h          | 18 ++----
src/include/catalog/pg_depend.h           | 11 ++--
src/include/catalog/pg_proc.dat           |  4 ++
src/include/catalog/pg_shdepend.h         | 12 ++--
src/test/regress/expected/misc_sanity.out | 57 ++----------------
src/test/regress/sql/misc_sanity.sql      | 58 ++-----------------
25 files changed, 291 insertions(+), 433 deletions(-)