mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Remove remaining hard-wired OID references in the initial catalog data.
In the v11-era commits that taught genbki.pl to resolve symbolic OID references in the initial catalog data, we didn't bother to make every last reference symbolic; some of the catalogs have so few initial rows that it didn't seem worthwhile. However, the new project policy that OIDs assigned by new patches should be automatically renumberable changes this calculus. A patch that wants to add a row in one of these catalogs would have a problem when the OID it assigns gets renumbered. Hence, do the mop-up work needed to make all OID references in initial data be symbolic, and establish an associated project policy that we'll never again write a hard-wired OID reference there. No catversion bump since the contents of postgres.bki aren't actually changed by this commit. Discussion: https://postgr.es/m/CAH2-WzmMTGMcPuph4OvsO7Ykut0AOCF_i-=eaochT0dd2BN9CQ@mail.gmail.com
This commit is contained in:
@ -160,9 +160,6 @@ my $C_COLLATION_OID =
|
||||
my $PG_CATALOG_NAMESPACE =
|
||||
Catalog::FindDefinedSymbolFromData($catalog_data{pg_namespace},
|
||||
'PG_CATALOG_NAMESPACE');
|
||||
my $PG_HEAP_AM =
|
||||
Catalog::FindDefinedSymbolFromData($catalog_data{pg_am},
|
||||
'HEAP_TABLE_AM_OID');
|
||||
|
||||
|
||||
# Build lookup tables.
|
||||
@ -174,6 +171,20 @@ foreach my $row (@{ $catalog_data{pg_am} })
|
||||
$amoids{ $row->{amname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# class (relation) OID lookup (note this only covers bootstrap catalogs!)
|
||||
my %classoids;
|
||||
foreach my $row (@{ $catalog_data{pg_class} })
|
||||
{
|
||||
$classoids{ $row->{relname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# collation OID lookup
|
||||
my %collationoids;
|
||||
foreach my $row (@{ $catalog_data{pg_collation} })
|
||||
{
|
||||
$collationoids{ $row->{collname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# language OID lookup
|
||||
my %langoids;
|
||||
foreach my $row (@{ $catalog_data{pg_language} })
|
||||
@ -243,6 +254,41 @@ foreach my $row (@{ $catalog_data{pg_proc} })
|
||||
}
|
||||
}
|
||||
|
||||
# tablespace OID lookup
|
||||
my %tablespaceoids;
|
||||
foreach my $row (@{ $catalog_data{pg_tablespace} })
|
||||
{
|
||||
$tablespaceoids{ $row->{spcname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# text search configuration OID lookup
|
||||
my %tsconfigoids;
|
||||
foreach my $row (@{ $catalog_data{pg_ts_config} })
|
||||
{
|
||||
$tsconfigoids{ $row->{cfgname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# text search dictionary OID lookup
|
||||
my %tsdictoids;
|
||||
foreach my $row (@{ $catalog_data{pg_ts_dict} })
|
||||
{
|
||||
$tsdictoids{ $row->{dictname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# text search parser OID lookup
|
||||
my %tsparseroids;
|
||||
foreach my $row (@{ $catalog_data{pg_ts_parser} })
|
||||
{
|
||||
$tsparseroids{ $row->{prsname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# text search template OID lookup
|
||||
my %tstemplateoids;
|
||||
foreach my $row (@{ $catalog_data{pg_ts_template} })
|
||||
{
|
||||
$tstemplateoids{ $row->{tmplname} } = $row->{oid};
|
||||
}
|
||||
|
||||
# type lookups
|
||||
my %typeoids;
|
||||
my %types;
|
||||
@ -287,14 +333,21 @@ close $ef;
|
||||
|
||||
# Map lookup name to the corresponding hash table.
|
||||
my %lookup_kind = (
|
||||
pg_am => \%amoids,
|
||||
pg_language => \%langoids,
|
||||
pg_opclass => \%opcoids,
|
||||
pg_operator => \%operoids,
|
||||
pg_opfamily => \%opfoids,
|
||||
pg_proc => \%procoids,
|
||||
pg_type => \%typeoids,
|
||||
encoding => \%encids);
|
||||
pg_am => \%amoids,
|
||||
pg_class => \%classoids,
|
||||
pg_collation => \%collationoids,
|
||||
pg_language => \%langoids,
|
||||
pg_opclass => \%opcoids,
|
||||
pg_operator => \%operoids,
|
||||
pg_opfamily => \%opfoids,
|
||||
pg_proc => \%procoids,
|
||||
pg_tablespace => \%tablespaceoids,
|
||||
pg_ts_config => \%tsconfigoids,
|
||||
pg_ts_dict => \%tsdictoids,
|
||||
pg_ts_parser => \%tsparseroids,
|
||||
pg_ts_template => \%tstemplateoids,
|
||||
pg_type => \%typeoids,
|
||||
encoding => \%encids);
|
||||
|
||||
|
||||
# Open temp files
|
||||
@ -467,7 +520,6 @@ EOM
|
||||
# (It's intentional that this can apply to parts of a field).
|
||||
$bki_values{$attname} =~ s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g;
|
||||
$bki_values{$attname} =~ s/\bPGNSP\b/$PG_CATALOG_NAMESPACE/g;
|
||||
$bki_values{$attname} =~ s/\bPGHEAPAM\b/$PG_HEAP_AM/g;
|
||||
|
||||
# Replace OID synonyms with OIDs per the appropriate lookup rule.
|
||||
#
|
||||
@ -730,8 +782,8 @@ sub morph_row_for_pgattr
|
||||
$row->{attndims} = $type->{typcategory} eq 'A' ? '1' : '0';
|
||||
|
||||
# collation-aware catalog columns must use C collation
|
||||
$row->{attcollation} = $type->{typcollation} != 0 ?
|
||||
$C_COLLATION_OID : 0;
|
||||
$row->{attcollation} =
|
||||
$type->{typcollation} ne '0' ? $C_COLLATION_OID : 0;
|
||||
|
||||
if (defined $attr->{forcenotnull})
|
||||
{
|
||||
|
Reference in New Issue
Block a user