]> granicus.if.org Git - postgresql/blob - src/include/catalog/unused_oids
Create a separate oid range for oids assigned by genbki.pl.
[postgresql] / src / include / catalog / unused_oids
1 #!/usr/bin/perl
2 #----------------------------------------------------------------------
3 #
4 # unused_oids
5 #    Finds blocks of manually-assignable OIDs that have not already been
6 #    claimed by previous hackers.  The main use is for finding available
7 #    OIDs for new internal functions.  The numbers printed are inclusive
8 #    ranges of unused OIDs.
9 #
10 #    Before using a large empty block, make sure you aren't about
11 #    to take over what was intended as expansion space for something
12 #    else.
13 #
14 # Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
15 # Portions Copyright (c) 1994, Regents of the University of California
16 #
17 # src/include/catalog/unused_oids
18 #
19 #----------------------------------------------------------------------
20
21 use strict;
22 use warnings;
23
24 # Must run in src/include/catalog
25 use FindBin;
26 chdir $FindBin::RealBin or die "could not cd to $FindBin::RealBin: $!\n";
27
28 use lib "$FindBin::RealBin/../../backend/catalog/";
29 use Catalog;
30
31 my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
32
33 my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
34
35 # Also push FirstGenbkiObjectId to serve as a terminator for the last gap.
36 my $FirstGenbkiObjectId =
37   Catalog::FindDefinedSymbol('access/transam.h', '..',
38         'FirstGenbkiObjectId');
39 push @{$oids}, $FirstGenbkiObjectId;
40
41 my $prev_oid = 0;
42 foreach my $oid (sort { $a <=> $b } @{$oids})
43 {
44         if ($oid > $prev_oid + 1)
45         {
46                 if ($oid > $prev_oid + 2)
47                 {
48                         printf "%d - %d\n", $prev_oid + 1, $oid - 1;
49                 }
50                 else
51                 {
52                         printf "%d\n", $prev_oid + 1;
53                 }
54         }
55         $prev_oid = $oid;
56 }