diff --git a/check-compatibility.sh b/check-compatibility.sh index f6930e7..966850c 100755 --- a/check-compatibility.sh +++ b/check-compatibility.sh @@ -48,7 +48,26 @@ CREATE EXTENSION crankshaft; \dx EOF -# TODO save public functions and signatures +# Save public function signatures +psql $DBNAME <<'EOF' +CREATE TABLE release_function_signatures AS + SELECT + p.proname as name, + pg_catalog.pg_get_function_result(p.oid) as result_type, + pg_catalog.pg_get_function_arguments(p.oid) as arguments, + CASE + WHEN p.proisagg THEN 'agg' + WHEN p.proiswindow THEN 'window' + WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger' + ELSE 'normal' + END as type + FROM pg_catalog.pg_proc p + LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace + WHERE + n.nspname = 'cdb_crankshaft' + AND p.proname LIKE 'cdb_%' + ORDER BY 1, 2, 4; +EOF # Deploy current dev branch make clean-dev || die "Could not clean dev files" @@ -57,6 +76,33 @@ sudo make install || die "Could not deploy current dev branch" # Check it can be upgraded psql $DBNAME -c "ALTER EXTENSION crankshaft update to 'dev';" || die "Cannot upgrade to dev version" +# Check against saved public function signatures +psql $DBNAME <<'EOF' +CREATE TABLE dev_function_signatures AS + SELECT + p.proname as name, + pg_catalog.pg_get_function_result(p.oid) as result_type, + pg_catalog.pg_get_function_arguments(p.oid) as arguments, + CASE + WHEN p.proisagg THEN 'agg' + WHEN p.proiswindow THEN 'window' + WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger' + ELSE 'normal' + END as type + FROM pg_catalog.pg_proc p + LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace + WHERE + n.nspname = 'cdb_crankshaft' + AND p.proname LIKE 'cdb_%' + ORDER BY 1, 2, 4; +EOF +echo "Functions in development not in latest release (ok):" +psql $DBNAME -c "SELECT * FROM dev_function_signatures EXCEPT SELECT * FROM release_function_signatures;" -# TODO check against saved public functions and signatures +echo "Functions in latest release not in development (compat issue):" +psql $DBNAME -c "SELECT * FROM release_function_signatures EXCEPT SELECT * FROM dev_function_signatures;" + +# Fail if there's a signature mismatch / missing functions +psql $DBNAME -c "SELECT * FROM release_function_signatures EXCEPT SELECT * FROM dev_function_signatures;" | fgrep '(0 rows)' \ + || die "Function signatures changed"