Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhHNH-0007n3-AI for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Apr 2022 20:56:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nhHNF-0002kX-UZ for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Apr 2022 20:56:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhHNF-0002kL-L8 for pgsql-hackers@lists.postgresql.org; Wed, 20 Apr 2022 20:56:29 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhHND-0003lc-Ci for pgsql-hackers@postgresql.org; Wed, 20 Apr 2022 20:56:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 23KKuMPQ2996610; Wed, 20 Apr 2022 16:56:22 -0400 From: Tom Lane To: Robert Haas cc: Shruthi Gowda , Julien Rouhaud , Sadhuprasad Patro , Stephen Frost , Bruce Momjian , Andres Freund , Alvaro Herrera , Masahiko Sawada , Tom Kincaid , Amit Kapila , Thomas Munro , PostgreSQL Development , Masahiko Sawada Subject: Re: preserving db/ts/relfilenode OIDs across pg_upgrade (was Re: storing an explicit nonce) In-reply-to: References: <20220115054719.yeqoy2mdllbc7wq2@jrouhaud> <2935358.1650479692@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 20 Apr 2022 15:28:03 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2996608.1650488182.1@sss.pgh.pa.us> Date: Wed, 20 Apr 2022 16:56:22 -0400 Message-ID: <2996609.1650488182@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > On Wed, Apr 20, 2022 at 2:34 PM Tom Lane wrote: >> The attached draft patch attempts to improve this situation. >> It reserves these OIDs, and creates the associated macros, through >> the normal BKI infrastructure by adding entries in pg_database.dat. >> We have to delete those rows again during initdb, which is slightly >> ugly but surely no more so than initdb's other direct manipulations >> of pg_database. > I'm not sure I really like this approach, but if you're firmly > convinced that it's better than cleaning up the loose ends in some > other way, I'm not going to waste a lot of energy fighting about it. Having just had to bury my nose in renumber_oids.pl, I thought of a different approach we could take to expose these OIDs to Catalog.pm. That's to invent a new macro that Catalog.pm recognizes, and write something about like this in pg_database.h: DECLARE_OID_DEFINING_MACRO(Template0ObjectId, 4); DECLARE_OID_DEFINING_MACRO(PostgresObjectId, 5); That would result in (a) the OIDs becoming known to Catalog.pm as reserved, though it wouldn't have any great clue about their semantics; and (b) this getting emitted into pg_database_d.h: #define Template0ObjectId 4 #define PostgresObjectId 5 Then we'd not need the dummy entries in pg_database.dat, which does seem cleaner now that I think about it. A downside is that with no context, Catalog.pm could not provide name translation services during postgres.bki generation for such OIDs --- but at least for these entries, we don't need that. If that seems more plausible to you I'll set about preparing a patch. regards, tom lane