|
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 |
11 | 2 |
|
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; |
14 | 5 |
|
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 | +} |
27 | 10 |
|
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