From 9e4798ea0d0e7562e2e3fb5157c8ee17f615d170 Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Sat, 15 Mar 1997 06:03:08 +0000 Subject: [PATCH] A couple of development scripts by Dan to detect unused and duplicate oids --- src/include/catalog/duplicate_oids | 20 +++++++++++++++ src/include/catalog/unused_oids | 41 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 src/include/catalog/duplicate_oids create mode 100755 src/include/catalog/unused_oids diff --git a/src/include/catalog/duplicate_oids b/src/include/catalog/duplicate_oids new file mode 100755 index 0000000000..caf43a8010 --- /dev/null +++ b/src/include/catalog/duplicate_oids @@ -0,0 +1,20 @@ +#!/bin/sh +# +# duplicate_oids +# +# finds oids that are duplicated in the system tables. +# + +egrep '^DATA' pg_*.h | \ + sed -e 's/^.*OID[^=]*=[^0-9]*//' -e 's/[^0-9].*$//' | \ + sort -n >/tmp/alloids.$$ +uniq /tmp/alloids.$$ >/tmp/uniqoids.$$ +diff -u /tmp/alloids.$$ /tmp/uniqoids.$$ | \ + grep -v '/tmp/' | \ + grep '^-' | \ + sed -e 's/^-//' | \ + grep -v '^0$' | \ + uniq +rm /tmp/alloids.$$ +rm /tmp/uniqoids.$$ + diff --git a/src/include/catalog/unused_oids b/src/include/catalog/unused_oids new file mode 100755 index 0000000000..a30191dfa3 --- /dev/null +++ b/src/include/catalog/unused_oids @@ -0,0 +1,41 @@ +#!/bin/sh +# unused_oids +# +# $Header: /cvsroot/pgsql/src/include/catalog/unused_oids,v 1.1 1997/03/15 06:03:08 scrappy Exp $ +# +# finds blocks of oids that have not already been claimed by +# post_hackers for internal purposes. primarily useful for +# finding valid oids for new internal function oids. the numbers +# printed are inclusive ranges of valid (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. also, before using a number, do a "grepsrc" to make sure +# that someone isn't using a literal numeric constant somewhere.. +# +# non-berkeley post_hackers should probably not try to use oids +# less than the highest one that comes with the distributed source. +# +# run this script in src/backend/catalog. +# +egrep '^DATA' pg_*.h | \ + sed -e 's/^.*OID[^=]*=[^0-9]*//' -e 's/[^0-9].*$//' | \ + sort -n | \ + uniq | \ + awk ' +BEGIN { + last = 0; +} +/^[0-9]/ { + if ($1 > last + 1) { + if ($1 > last + 2) { + print last + 1, "-", $1 - 1; + } else { + print last + 1; + } + } + last = $1; +} +END { + print last + 1, "-"; +}'