summaryrefslogtreecommitdiffstats
path: root/src/include/catalog/duplicate_oids
blob: 9e5e9a15be0a8cc02b170a7f8f63b671fc288a3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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-2020, 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;