Properly access a buffer's LSN using existing access macros instead of abusing
[PostgreSQL.git] / src / include / catalog / unused_oids
blob0a1a64d85898d5ad20babf85928703bf7033c9dd
1 #!/bin/sh
3 # unused_oids
5 # $PostgreSQL$
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.
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.
16 # run this script in src/include/catalog.
20 AWK="awk"
22 # Get FirstBootstrapObjectId from access/transam.h
23 FIRSTOBJECTID=`grep '#define[ ]*FirstBootstrapObjectId' ../access/transam.h | $AWK '{ print $3 }'`
24 export FIRSTOBJECTID
26 # this part (down to the uniq step) should match the duplicate_oids script
27 # note: we exclude BKI_BOOTSTRAP relations since they are expected to have
28 # matching DATA lines in pg_class.h
30 cat pg_*.h toasting.h indexing.h | \
31 egrep -v -e '^CATALOG\(.*BKI_BOOTSTRAP' | \
32 sed -n -e 's/^DATA(insert *OID *= *\([0-9][0-9]*\).*$/\1/p' \
33 -e 's/^CATALOG([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
34 -e 's/^DECLARE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
35 -e 's/^DECLARE_UNIQUE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
36 -e 's/^DECLARE_TOAST([^,]*, *\([0-9][0-9]*\), *\([0-9][0-9]*\).*$/\1,\2/p' | \
37 tr ',' '\n' | \
38 sort -n | \
39 uniq | \
40 $AWK '
41 BEGIN {
42 last = 0;
44 /^[0-9]/ {
45 if ($1 > last + 1) {
46 if ($1 > last + 2) {
47 print last + 1, "-", $1 - 1;
48 } else {
49 print last + 1;
52 last = $1;
54 END {
55 print last + 1, "-", ENVIRON["FIRSTOBJECTID"]-1;