pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Rethink method for assigning OIDs to the template0 and postgres
Date: Thu, 21 Apr 2022 20:23:38 +0000
Message-ID: <E1nhdKz-000Tm6-K8@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1nhdKz-000Tm6-K8@gemulon.postgresql.org>
Permalink:  ../E1nhdKz-000Tm6-K8@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nhdKz-000Tm6-K8@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Rethink method for assigning OIDs to the template0 and postgres
  In-Reply-To: <E1nhdKz-000Tm6-K8@gemulon.postgresql.org>
  References: <E1nhdKz-000Tm6-K8@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox