1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Add new make_oidjoin_check utility and template1_check.sql. Fix some

pg_operator problems.
This commit is contained in:
Bruce Momjian
1998-09-14 01:14:49 +00:00
parent f1bcb171e8
commit 3700981108
6 changed files with 223 additions and 7 deletions

View File

@ -2,7 +2,7 @@
# Makefile, requires pgsql/contrib/pginterface
#
#
PGINTERFACE = pginterface.o halt.o # these have to be in your library search path
PGINTERFACE = ../pginterface/pginterface.o ../pginterface/halt.o # these have to be in your library search path
TARGET = findoidjoins
CFLAGS = -g -Wall -I. -I../../src/interfaces/libpq -I/usr/local/pgsql/include
LDFLAGS = -L/usr/local/pgsql/lib -lpq

View File

@ -35,6 +35,7 @@ Join pg_am.ambuild => pg_proc.oid
Join pg_amop.amopid => pg_am.oid
Join pg_amop.amopclaid => pg_opclass.oid
Join pg_amop.amopopr => pg_operator.oid
Join pg_amop.amopopr => pg_proc.oid
Join pg_amop.amopselect => pg_proc.oid
Join pg_amop.amopnpages => pg_proc.oid
Join pg_amproc.amid => pg_am.oid
@ -51,7 +52,6 @@ Join pg_description.objoid => pg_proc.oid
Join pg_description.objoid => pg_type.oid
Join pg_index.indexrelid => pg_class.oid
Join pg_index.indrelid => pg_class.oid
Join pg_index.indproc => pg_proc.oid
Join pg_opclass.opcdeftype => pg_type.oid
Join pg_operator.oprleft => pg_type.oid
Join pg_operator.oprright => pg_type.oid

View File

@ -35,6 +35,7 @@ main(int argc, char **argv)
FROM pg_class c, pg_attribute a, pg_type t \
WHERE a.attnum > 0 AND \
relkind = 'r' AND \
relhasrules = 'f' AND \
(typname = 'oid' OR \
typname = 'regproc') AND \
a.attrelid = c.oid AND \
@ -49,6 +50,7 @@ main(int argc, char **argv)
SELECT relname \
FROM pg_class c \
WHERE relkind = 'r' AND \
relhasrules = 'f' AND \
relname != 'pg_user' \
ORDER BY 1; \
");

View File

@ -0,0 +1,35 @@
:
# You first run findoidjoins on the template1 database, and send that
# output into this file to generate a list of SQL statements.
trap "rm -f /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
cat "$@" >/tmp/$$
cat /tmp/$$ | cut -d' ' -f2 | sort | uniq -d >/tmp/$$a
cat /tmp/$$ | while read LINE
do
set -- $LINE
grep "$2" /tmp/$$a >/dev/null 2>&1 || echo $LINE
done >/tmp/$$b
cat /tmp/$$b |
awk -F'[ \.]' '\
BEGIN \
{
printf "\
--\n\
-- This is created by pgsql/contrib/findoidjoins/make_oidjoin_check\n\
--\n";
}
{
printf "\
SELECT oid, %s.%s \n\
FROM %s \n\
WHERE %s%s.%s%s NOT IN (SELECT oid FROM %s) AND \n\
%s%s.%s%s != 0;\n", $2, $3, $2,
($5 == "pg_proc") ? "RegprocToOid(" : "",
$2, $3,
($5 == "pg_proc") ? ")" : "",
$5,
($5 == "pg_proc") ? "RegprocToOid(" : "",
$2, $3,
($5 == "pg_proc") ? ")" : "";
}'