renumber_oids.pl needs some updates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
Subject: renumber_oids.pl needs some updates
Date: 2022-04-20 20:45:27
Message-ID: 2995325.1650487527@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I did a test run of renumber_oids.pl to see if there would be any
problems when the time comes (pretty soon!) to run it for v15.
Depressingly enough, I found two problems:

1. When commit dfb75e478 invented DECLARE_UNIQUE_INDEX_PKEY,
it neglected to teach renumber_oids.pl about it. I'm surprised
we did not notice this last year.

2. renumber_oids.pl failed miserably on pg_parameter_acl.h:

@@ -48,11 +48,11 @@ CATALOG(pg_parameter_acl,8924,ParameterAclRelationId) BKI_SHARED_RELATION
*/
typedef FormData_pg_parameter_acl *Form_pg_parameter_acl;

-DECLARE_TOAST(pg_parameter_acl, 8925, 8926);
+DECLARE_TOAST(pg_parameter_acl, 6244, 6245);
#define PgParameterAclToastTable 8925
#define PgParameterAclToastIndex 8926

because of course it didn't know it should update the
PgParameterAclToastTable and PgParameterAclToastIndex macro definitions.
(We have this same coding pattern elsewhere, but I guess that
renumber_oids.pl has never previously been asked to renumber a shared
catalog.)

I think the right way to fix #2 is to put the responsibility for
generating the #define's into genbki.pl, instead of this mistake-prone
approach of duplicating the OID constants in the source code.

The attached proposed patch invents a variant macro
DECLARE_TOAST_WITH_MACRO for the relatively small number of cases
where we need such OID macros. A different idea could be to require
all the catalog headers to define C macros for their toast tables
and change DECLARE_TOAST to a five-argument macro across the board.
However, that would require touching a bunch more places and inventing
a bunch more macro names, and it didn't really seem useful.

Thoughts?

regards, tom lane

Attachment Content-Type Size
generate-toast-table-oid-macros-1.patch text/x-diff 11.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-04-20 20:46:35 Re: Dump/Restore of non-default PKs
Previous Message Thomas Munro 2022-04-20 20:38:33 Re: pg14 psql broke \d datname.nspname.relname