| 1 |
#!/usr/bin/perl |
| 2 |
#---------------------------------------------------------------------- |
| 3 |
# |
| 4 |
# duplicate_oids |
| 5 |
# Identifies any manually-assigned OIDs that are used multiple times |
| 6 |
# in the Postgres catalog data. |
| 7 |
# |
| 8 |
# While duplicate OIDs would only cause a failure if they appear in |
| 9 |
# the same catalog, our project policy is that manually assigned OIDs |
| 10 |
# should be globally unique, to avoid confusion. |
| 11 |
# |
| 12 |
# Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group |
| 13 |
# Portions Copyright (c) 1994, Regents of the University of California |
| 14 |
# |
| 15 |
# src/include/catalog/duplicate_oids |
| 16 |
# |
| 17 |
#---------------------------------------------------------------------- |
| 18 |
|
| 19 |
use strict; |
| 20 |
use warnings FATAL => 'all'; |
| 21 |
|
| 22 |
# Must run in src/include/catalog |
| 23 |
use FindBin; |
| 24 |
chdir $FindBin::RealBin or die "could not cd to $FindBin::RealBin: $!\n"; |
| 25 |
|
| 26 |
use lib "$FindBin::RealBin/../../backend/catalog/"; |
| 27 |
use Catalog; |
| 28 |
|
| 29 |
my @input_files = glob("pg_*.h"); |
| 30 |
|
| 31 |
my $oids = Catalog::FindAllOidsFromHeaders(@input_files); |
| 32 |
|
| 33 |
my %oidcounts; |
| 34 |
|
| 35 |
foreach my $oid (@{$oids}) |
| 36 |
{ |
| 37 |
$oidcounts{$oid}++; |
| 38 |
} |
| 39 |
|
| 40 |
my $found = 0; |
| 41 |
|
| 42 |
foreach my $oid (sort { $a <=> $b } keys %oidcounts) |
| 43 |
{ |
| 44 |
next unless $oidcounts{$oid} > 1; |
| 45 |
$found = 1; |
| 46 |
print "$oid\n"; |
| 47 |
} |
| 48 |
|
| 49 |
exit $found; |