From: Mark Wong Date: Thu, 29 Jan 2026 15:47:50 -0800 Subject: [PATCH v3 1/7] Track retired system procedures in pg_retired.dat System procedures may be removed from time to time. Keep track of previously used OIDs to prevent potential conflicts from reusing OIDs after an upgrade. --- src/include/catalog/pg_retired.dat | 20 ++++++++++++++++++++ src/include/catalog/renumber_oids.pl | 9 +++++++++ src/include/catalog/unused_oids | 7 +++++++ 3 files changed, 36 insertions(+) create mode 100644 src/include/catalog/pg_retired.dat diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat new file mode 100644 index 00000000000..413b68ad1cd --- /dev/null +++ b/src/include/catalog/pg_retired.dat @@ -0,0 +1,20 @@ +#---------------------------------------------------------------------- +# +# pg_retired.dat +# Entries that have been removed from pg_proc.dat with OIDs that are +# are not to be reused. +# +# Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group +# Portions Copyright (c) 1994, Regents of the University of California +# +# src/include/catalog/pg_retired.dat +# +#---------------------------------------------------------------------- + +[ + +# What's primarily important here is knowing which OIDs are not to be reused. +# At the same time, it may be good to be reminded what procedure was associated +# with it. + +] diff --git a/src/include/catalog/renumber_oids.pl b/src/include/catalog/renumber_oids.pl index f6e25d0f1e1..7489be02a50 100755 --- a/src/include/catalog/renumber_oids.pl +++ b/src/include/catalog/renumber_oids.pl @@ -68,6 +68,15 @@ my $oids = Catalog::FindAllOidsFromHeaders(@header_files); my %oidhash; @oidhash{@$oids} = undef; +# Also include OIDs listed in pg_retired.dat to prevent new OIDs to be mapped +# to OIDs that have been retired. +my $retired_data = Catalog::ParseData('pg_retired.dat', undef, 0); +foreach my $row (@$retired_data) +{ + $oidhash{ $row->{oid} } = undef + if ref $row eq 'HASH' && defined $row->{oid}; +} + # Select new OIDs for existing OIDs in the mapped range. # We do this first so that we preserve the ordering of the mapped OIDs # (for reproducibility's sake), and so that if we fail due to running out diff --git a/src/include/catalog/unused_oids b/src/include/catalog/unused_oids index 147fba5e209..aeb485d9b5e 100755 --- a/src/include/catalog/unused_oids +++ b/src/include/catalog/unused_oids @@ -32,6 +32,13 @@ my @input_files = glob("pg_*.h"); my $oids = Catalog::FindAllOidsFromHeaders(@input_files); +# Also exclude OIDs listed in pg_retired.dat +my $retired_data = Catalog::ParseData('pg_retired.dat', undef, 0); +foreach my $row (@$retired_data) +{ + push @{$oids}, $row->{oid} if ref $row eq 'HASH' && defined $row->{oid}; +} + # Also push FirstGenbkiObjectId to serve as a terminator for the last gap. my $FirstGenbkiObjectId = Catalog::FindDefinedSymbol('access/transam.h', '..', 'FirstGenbkiObjectId'); -- 2.43.0 --zd8Z8rlPOcTi77n/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0002-Handle-pg_get_ruledef-default-args-in-system_func.patch"