Обсуждение: pgsql: Rethink method for assigning OIDs to the template0 and postgres

Поиск
Список
Период
Сортировка

pgsql: Rethink method for assigning OIDs to the template0 and postgres

От
Tom Lane
Дата:
Rethink method for assigning OIDs to the template0 and postgres DBs.

Commit aa0105141 assigned fixed OIDs to template0 and postgres
in a very ad-hoc way.  Notably, instead of teaching Catalog.pm
about these OIDs, the unused_oids script was just hacked to
not show them as unused.  That's problematic since, for example,
duplicate_oids wouldn't report any future conflict.  Hence,
invent a macro DECLARE_OID_DEFINING_MACRO() that can be used to
define an OID that is known to Catalog.pm and will participate
in duplicate-detection as well as renumbering by renumber_oids.pl.
(We don't anticipate renumbering these particular OIDs, but we
might as well build out all the Catalog.pm infrastructure while
we're here.)

Another issue is that aa0105141 neglected to touch IsPinnedObject,
with the result that it now claimed template0 and postgres are
pinned.  The right thing to do there seems to be to teach it that
no database is pinned, since in fact DROP DATABASE doesn't check
for pinned-ness (and at least for these cases, that is an
intentional choice).  It's not clear whether this wrong answer
had any visible effect, but perhaps it could have resulted in
erroneous management of dependency entries.

In passing, rename the TemplateDbOid macro to Template1DbOid
to reduce confusion (likely we should have done that way back
when we invented template0, but we didn't), and rename the
OID macros for template0 and postgres to have a similar style.

There are no changes to postgres.bki here, so no need for a
catversion bump.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2cb1272445d2a6616991fc6ede274d9f1f62ff73

Modified Files
--------------
doc/src/sgml/bki.sgml                |  7 ++++---
src/backend/access/transam/xlog.c    |  4 ++--
src/backend/catalog/Catalog.pm       | 14 ++++++++++++++
src/backend/catalog/catalog.c        | 14 +++++++++-----
src/backend/catalog/genbki.pl        |  8 +++++++-
src/backend/utils/init/postinit.c    |  2 +-
src/bin/initdb/initdb.c              |  9 +++++----
src/bin/pg_dump/pg_dump.c            |  9 +++++----
src/include/access/transam.h         |  4 ----
src/include/catalog/genbki.h         |  8 ++++++++
src/include/catalog/pg_database.dat  |  2 +-
src/include/catalog/pg_database.h    |  9 +++++++++
src/include/catalog/renumber_oids.pl | 10 ++++++++++
src/include/catalog/unused_oids      |  9 ---------
14 files changed, 75 insertions(+), 34 deletions(-)