#!/usr/bin/perl #---------------------------------------------------------------------- # # unused_oids # Finds blocks of manually-assignable OIDs that have not already been # claimed by previous hackers. The main use is for finding available # OIDs for new internal functions. The numbers printed are inclusive # ranges of unused OIDs. # # Before using a large empty block, make sure you aren't about # to take over what was intended as expansion space for something # else. # # Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group # Portions Copyright (c) 1994, Regents of the University of California # # src/include/catalog/unused_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); # Also push FirstBootstrapObjectId to serve as a terminator for the last gap. my $FirstBootstrapObjectId = Catalog::FindDefinedSymbol('access/transam.h', '..', 'FirstBootstrapObjectId'); push @{$oids}, $FirstBootstrapObjectId; my $prev_oid = 0; foreach my $oid (sort { $a <=> $b } @{$oids}) { if ($oid > $prev_oid + 1) { if ($oid > $prev_oid + 2) { printf "%d - %d\n", $prev_oid + 1, $oid - 1; } else { printf "%d\n", $prev_oid + 1; } } $prev_oid = $oid; }