/*
 * Dirty test system self-check
 *
 * Insert an address, it should exist during the main test. Also create a
 * function and a table which are used to synchronise execution.
 */
BEGIN;
	INSERT INTO users.addresses ( address )
		VALUES ( 'prepare@example.org' );

	CREATE TABLE _barriers( _barrier BIGINT );

	CREATE FUNCTION _synchronise_tests( _lock BIGINT )
		RETURNS VOID
	AS $$
	BEGIN
		WHILE pg_try_advisory_lock( _lock )
		LOOP
			PERFORM pg_advisory_unlock( _lock );
		END LOOP;
	END;
	$$ LANGUAGE PLPGSQL;
COMMIT;
