diff -ur postgresql-7.4.5.orig/contrib/findoidjoins/make_oidjoins_check postgresql-7.4.5/contrib/findoidjoins/make_oidjoins_check --- postgresql-7.4.5.orig/contrib/findoidjoins/make_oidjoins_check 2002-09-05 21:57:32.000000000 +0200 +++ postgresql-7.4.5/contrib/findoidjoins/make_oidjoins_check 2004-09-20 11:51:39.000000000 +0200 @@ -10,27 +10,35 @@ # Caution: you may need to use GNU awk. AWK=${AWK:-awk} -trap "rm -f /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15 +TMP= +TMPA= +TMPB= +trap 'rm -f -- "$TMP" "$TMPA" "$TMPB"' EXIT +trap 'trap - EXIT; rm -f -- "$TMP" "$TMPA" "$TMPB"; exit 1' HUP INT QUIT TERM + +TMP=`mktemp -t oidjoins.XXXXXX` || exit 1 +TMPA=`mktemp -t oidjoins.a.XXXXXX` || exit 1 +TMPB=`mktemp -t oidjoins.b.XXXXXX` || exit 1 # Read input -cat "$@" >/tmp/$$ +cat "$@" > $TMP # Look for fields with multiple references. -cat /tmp/$$ | cut -d' ' -f2 | sort | uniq -d >/tmp/$$a -if [ -s /tmp/$$a ] ; then +cat $TMP | cut -d' ' -f2 | sort | uniq -d > $TMPA +if [ -s $TMPA ] ; then echo "Ignoring these fields that link to multiple tables:" 1>&2 - cat /tmp/$$a 1>&2 + cat $TMPA 1>&2 fi # Get the non-multiply-referenced fields. -cat /tmp/$$ | while read LINE +cat $TMP | while read LINE do set -- $LINE - grep "^$2\$" /tmp/$$a >/dev/null 2>&1 || echo $LINE -done >/tmp/$$b + grep "^$2\$" $TMPA >/dev/null 2>&1 || echo $LINE +done > $TMPB # Generate the output. -cat /tmp/$$b | +cat $TMPB | $AWK -F'[ \.]' '\ BEGIN \ {