--- /dev/null
+#!/bin/bash
+# author Bill Erickson
+# Takes a list of PG function names as a command line param
+# and compares stock functions to KCLS versions of those same
+# functions too see which differ. Diffs for functions that
+# differ are placed into the 'diffs' directory.
+# Comparisons are done by extracting function definitions from
+# live database instances. Change PSQL commands below to suit.
+# TODO: getopts, database names via command line. more docs, etc.
+FUNCS=$1
+PSQL_STOCK="psql -x -U evergreen -d evergreen"
+PSQL_KCLS="psql -x -U evergreen -d eg_kcls_25"
+
+
+mkdir -p results
+mkdir -p diffs
+while read func; do
+ echo $func;
+ echo "\\df+ $func;" | $PSQL_STOCK | grep -v " RECORD 1 " | \
+ sed -e 's/^\s*|//g' > "results/$func-stock.txt"
+ echo "\\df+ $func;" | $PSQL_KCLS | grep -v " RECORD 1 " | \
+ sed -e 's/^\s*|//g' | sed -e 's/\\r$//g' > "results/$func-kcls.txt"
+ # KCLS schema has pesky windows carriage returns
+done < $FUNCS
+
+while read func; do
+ echo $func
+
+ diff --unified=20 -Naur "results/$func-stock.txt" \
+ "results/$func-kcls.txt" > "diffs/$func.txt"
+
+ # file size 0 means no diff; kill the file.
+ size=$(stat -c '%s' "diffs/$func.txt");
+ if [ $size == "0" ]; then
+ rm "diffs/$func.txt";
+ fi;
+
+done < $FUNCS
+
+rm -r results;
+