Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3dc543b

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 parent083b86e commit3dc543b

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+
nextif/^CATALOG\(.*BKI_BOOTSTRAP/;
16+
nextunless
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+
foreachmy$oid (sort {$a<=>$b}keys%oidcounts)
30+
{
31+
nextunless$oidcounts{$oid} > 1;
32+
$found = 1;
33+
print"$oid\n";
34+
}
35+
36+
exit$found;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp