Skip to content

Commit 3dc543b

Browse files
committed
Replace duplicate_oids with Perl implementation
It is more portable, more robust, and more readable. From: Andrew Dunstan <andrew@dunslane.net>
1 parent 083b86e commit 3dc543b

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

src/include/catalog/duplicate_oids

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
1-
#!/bin/sh
2-
#
3-
# duplicate_oids
4-
#
5-
# src/include/catalog/duplicate_oids
6-
#
7-
# finds manually-assigned oids that are duplicated in the system tables.
8-
#
9-
# run this script in src/include/catalog.
10-
#
1+
#!/usr/bin/perl
112

12-
# note: we exclude BKI_BOOTSTRAP relations since they are expected to have
13-
# matching DATA lines in pg_class.h and pg_type.h
3+
use strict;
4+
use warnings;
145

15-
cat pg_*.h toasting.h indexing.h | \
16-
egrep -v -e '^CATALOG\(.*BKI_BOOTSTRAP' | \
17-
sed -n -e 's/^DATA(insert *OID *= *\([0-9][0-9]*\).*$/\1/p' \
18-
-e 's/^CATALOG([^,]*, *\([0-9][0-9]*\).*BKI_ROWTYPE_OID(\([0-9][0-9]*\)).*$/\1,\2/p' \
19-
-e 's/^CATALOG([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
20-
-e 's/^DECLARE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
21-
-e 's/^DECLARE_UNIQUE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
22-
-e 's/^DECLARE_TOAST([^,]*, *\([0-9][0-9]*\), *\([0-9][0-9]*\).*$/\1,\2/p' | \
23-
tr ',' '\n' | \
24-
sort -n | \
25-
uniq -d | \
26-
grep '.'
6+
BEGIN
7+
{
8+
@ARGV = (glob("pg_*.h"), qw(indexing.h toasting.h));
9+
}
2710

28-
# nonzero exit code if lines were produced
29-
[ $? -eq 1 ]
30-
exit
11+
my %oidcounts;
12+
13+
while(<>)
14+
{
15+
next if /^CATALOG\(.*BKI_BOOTSTRAP/;
16+
next unless
17+
/^DATA\(insert *OID *= *(\d+)/ ||
18+
/^CATALOG\([^,]*, *(\d+).*BKI_ROWTYPE_OID\((\d+)\)/ ||
19+
/^CATALOG\([^,]*, *(\d+)/ ||
20+
/^DECLARE_INDEX\([^,]*, *(\d+)/ ||
21+
/^DECLARE_UNIQUE_INDEX\([^,]*, *(\d+)/ ||
22+
/^DECLARE_TOAST\([^,]*, *(\d+), *(\d+)/;
23+
$oidcounts{$1}++;
24+
$oidcounts{$2}++ if $2;
25+
}
26+
27+
my $found = 0;
28+
29+
foreach my $oid (sort {$a <=> $b} keys %oidcounts)
30+
{
31+
next unless $oidcounts{$oid} > 1;
32+
$found = 1;
33+
print "$oid\n";
34+
}
35+
36+
exit $found;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy