⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make_oidjoins_check

📁 PostgreSQL 8.1.4的源码 适用于Linux下的开源数据库系统
💻
字号:
#! /bin/sh# You first run findoidjoins on the template1 database, and send that# output into this script to generate a list of SQL statements.# NOTE: any field that findoidjoins thinks joins to more than one table# will NOT be checked by the output of this script.  You should be# suspicious of multiple entries in findoidjoins' output.# Caution: you may need to use GNU awk.AWK=${AWK:-awk}TMP="${TMPDIR:-/tmp}/make_oidjoins_check.$$"trap "rm -rf $TMP" 0 1 2 3 15# Create a temporary directory with the proper permissions so no one can# intercept our temporary files and cause a security breach.OMASK="`umask`"umask 077if ! mkdir $TMPthen	echo "Can't create temporary directory $TMP." 1>&2	exit 1fiumask "$OMASK"unset OMASKINPUTFILE="$TMP/a"DUPSFILE="$TMP/b"NONDUPSFILE="$TMP/c"# Read inputcat "$@" >$INPUTFILE# Look for fields with multiple references.cat $INPUTFILE | cut -d' ' -f2 | sort | uniq -d >$DUPSFILEif [ -s $DUPSFILE ] ; then	echo "Ignoring these fields that link to multiple tables:" 1>&2	cat $DUPSFILE 1>&2fi# Get the non-multiply-referenced fields.cat $INPUTFILE | while read LINEdo	set -- $LINE	grep "^$2\$" $DUPSFILE >/dev/null 2>&1 || echo $LINEdone >$NONDUPSFILE# Generate the output.cat $NONDUPSFILE |$AWK -F'[ \.]' '\	BEGIN \	{		printf "\--\n\-- This is created by pgsql/contrib/findoidjoins/make_oidjoin_check\n\--\n";	}	{		printf "\SELECT	ctid, %s \n\FROM	%s.%s fk \n\WHERE	%s != 0 AND \n\	NOT EXISTS(SELECT 1 FROM %s.%s pk WHERE pk.oid = fk.%s);\n",	$4, $2, $3, $4,	$6, $7, $4;	}'exit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -