mirror of
https://github.com/postgres/postgres.git
synced 2026-02-18 10:09:35 -05:00
Previously, you had to cd into src/include/catalog before running either
of these scripts. That's a bit tedious, so let's make the scripts do it
for you.
In passing, improve the initial comments in both scripts. Also remove
unused_oids' code to complain about duplicate oids. That was added in
yesterday's commit 5602265f7, but on second thought we shouldn't be
randomly redefining the script's behavior that way.
John Naylor and Tom Lane
Discussion: https://postgr.es/m/37D774E4-FE1F-437E-B3D2-593F314B7505@postgrespro.ru
49 lines
1.2 KiB
Perl
Executable file
49 lines
1.2 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
#----------------------------------------------------------------------
|
|
#
|
|
# duplicate_oids
|
|
# Identifies any manually-assigned OIDs that are used multiple times
|
|
# in the Postgres catalog data.
|
|
#
|
|
# While duplicate OIDs would only cause a failure if they appear in
|
|
# the same catalog, our project policy is that manually assigned OIDs
|
|
# should be globally unique, to avoid confusion.
|
|
#
|
|
# Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
|
# Portions Copyright (c) 1994, Regents of the University of California
|
|
#
|
|
# src/include/catalog/duplicate_oids
|
|
#
|
|
#----------------------------------------------------------------------
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
# Must run in src/include/catalog
|
|
use FindBin;
|
|
chdir $FindBin::RealBin or die "could not cd to $FindBin::RealBin: $!\n";
|
|
|
|
use lib "$FindBin::RealBin/../../backend/catalog/";
|
|
use Catalog;
|
|
|
|
my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
|
|
|
|
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
|
|
|
|
my %oidcounts;
|
|
|
|
foreach my $oid (@{$oids})
|
|
{
|
|
$oidcounts{$oid}++;
|
|
}
|
|
|
|
my $found = 0;
|
|
|
|
foreach my $oid (sort { $a <=> $b } keys %oidcounts)
|
|
{
|
|
next unless $oidcounts{$oid} > 1;
|
|
$found = 1;
|
|
print "$oid\n";
|
|
}
|
|
|
|
exit $found;
|