0002-Remove-requirement-to-call-unused_oids-from-its-dire.patch
text/x-patch
Filename: 0002-Remove-requirement-to-call-unused_oids-from-its-dire.patch
Type: text/x-patch
Part: 1
Patch
Format: format-patch
Series: patch 0002
Subject: Remove requirement to call unused_oids from its directory
| File | + | − |
|---|---|---|
| src/include/catalog/unused_oids | 28 | 14 |
From 337d1eee0473dd5742993161256692bed25097fa Mon Sep 17 00:00:00 2001
From: John Naylor <jcnaylor@gmail.com>
Date: Thu, 26 Apr 2018 17:50:28 +0700
Subject: [PATCH 2/2] Remove requirement to call unused_oids from its directory
No doc change, since that fact wasn't mentioned before.
Also do an editing pass over the boilerplate comments.
---
src/include/catalog/unused_oids | 42 +++++++++++++++++++++++++++--------------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/src/include/catalog/unused_oids b/src/include/catalog/unused_oids
index 333b547..120f744 100755
--- a/src/include/catalog/unused_oids
+++ b/src/include/catalog/unused_oids
@@ -1,33 +1,47 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
+#----------------------------------------------------------------------
#
# 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. It also reports any duplicate OIDs found.
#
-# src/include/catalog/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.
#
-# finds blocks of manually-assignable oids that have not already been
-# claimed by post_hackers. primarily useful for finding available
-# oids for new internal functions. the numbers printed are inclusive
-# ranges of unused oids.
+# Note: You must pass the location of the Catalog.pm module to the
+# Perl interpreter:
+# perl -I /path/to/Catalog.pm /path/to/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
#
-# run this script in src/include/catalog.
+# src/include/catalog/unused_oids
#
-use lib '../../backend/catalog/';
+#----------------------------------------------------------------------
+
use Catalog;
+use File::Basename qw(dirname);
+my $catdir = dirname(__FILE__);
use strict;
use warnings;
-my @input_files = (glob("pg_*.h"), qw(indexing.h toasting.h));
+
+opendir(my $cd, $catdir)
+ or die "Can't opendir $catdir $!";
+my @filenames = grep { /(pg_\w+|toasting|indexing)\.h$/ } readdir($cd);
+closedir $cd;
# Extract an array of all the OIDs assigned in the specified catalog headers
# and their associated data files (if any).
my @oids;
-foreach my $header (@input_files)
+foreach my $filename (@filenames)
{
+ my $header = "$catdir/$filename";
+
$header =~ /(.+)\.h$/
or die "Input files need to be header files.\n";
my $datfile = "$1.dat";
@@ -69,7 +83,7 @@ foreach my $header (@input_files)
# Also push FirstBootstrapObjectId to serve as a terminator for the last gap.
my $FirstBootstrapObjectId =
- Catalog::FindDefinedSymbol('access/transam.h', [".."],
+ Catalog::FindDefinedSymbol('access/transam.h', ["$catdir/.."],
'FirstBootstrapObjectId');
push @oids, $FirstBootstrapObjectId;
--
2.7.4