#!/bin/sh

set -eu

# apparently this is missing in the main Makefile
make -C sql/txid

for version in $(pg_buildext supported-versions); do
	if ! pg_virtualenv -v $version \
		make installcheck \
		PG_CONFIG=/usr/lib/postgresql/$version/bin/pg_config USE_PGXS=1; then
		for f in $(find . -name regression.diffs); do
			if [ -s $f ]; then
				echo "**** $f ****"
				cat $f
			fi
		done
		if [ "$version" = "8.4" ]; then
			# CREATE OR REPLACE LANGUAGE "plpythonu"
			echo "**** expected failure on 8.4"
			continue
		fi
		exit 1
	fi
done
