Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dd4cc9d

Browse files
committed
Fix duplicate_oids and unused_oids so user needn't cd to catalog dir.
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 5602265, 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
1 parent 1900365 commit dd4cc9d

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed

src/include/catalog/duplicate_oids

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
#!/usr/bin/perl
2-
3-
use lib '../../backend/catalog/';
4-
use Catalog;
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-2018, PostgreSQL Global Development Group
13+
# Portions Copyright (c) 1994, Regents of the University of California
14+
#
15+
# src/include/catalog/duplicate_oids
16+
#
17+
#----------------------------------------------------------------------
518

619
use strict;
720
use warnings;
821

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+
929
my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
1030

1131
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);

src/include/catalog/unused_oids

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
#!/usr/bin/perl
2+
#----------------------------------------------------------------------
23
#
34
# 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.
49
#
5-
# src/include/catalog/unused_oids
6-
#
7-
# finds blocks of manually-assignable oids that have not already been
8-
# claimed by post_hackers. primarily useful for finding available
9-
# oids for new internal functions. the numbers printed are inclusive
10-
# ranges of unused oids.
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.
1113
#
12-
# before using a large empty block, make sure you aren't about
13-
# to take over what was intended as expansion space for something
14-
# else.
14+
# Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
15+
# Portions Copyright (c) 1994, Regents of the University of California
1516
#
16-
# run this script in src/include/catalog.
17+
# src/include/catalog/unused_oids
1718
#
18-
use lib '../../backend/catalog/';
19-
use Catalog;
19+
#----------------------------------------------------------------------
2020

2121
use strict;
2222
use warnings;
2323

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+
2431
my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
2532

2633
my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
@@ -45,10 +52,5 @@ foreach my $oid (sort { $a <=> $b } @{$oids})
4552
printf "%d\n", $prev_oid + 1;
4653
}
4754
}
48-
elsif ($oid == $prev_oid)
49-
{
50-
print "Duplicate oid detected: $oid\n";
51-
exit 1;
52-
}
5355
$prev_oid = $oid;
5456
}

0 commit comments

Comments
 (0)