--- sql/pgtap.sql.saf 2011-11-10 14:58:17.000000000 -0800 +++ sql/pgtap.sql 2011-11-10 14:59:43.000000000 -0800 @@ -12,6 +12,11 @@ RETURNS text AS 'SELECT current_setting(''server_version'')' LANGUAGE SQL IMMUTABLE; +CREATE OR REPLACE FUNCTION pg_typeof("any") +RETURNS regtype +AS '$libdir/pgtap' +LANGUAGE C STABLE; + CREATE OR REPLACE FUNCTION pg_version_num() RETURNS integer AS $$ SELECT s.a[1]::int * 10000 @@ -6244,7 +6249,7 @@ FETCH want INTO want_rec; want_found := FOUND; WHILE have_found OR want_found LOOP - IF have_rec IS DISTINCT FROM want_rec OR have_found <> want_found THEN + IF have_rec::text IS DISTINCT FROM want_rec::text OR have_found <> want_found THEN RETURN ok( false, $3 ) || E'\n' || diag( ' Results differ beginning at row ' || rownum || E':\n' || ' have: ' || CASE WHEN have_found THEN have_rec::text ELSE 'NULL' END || E'\n' || @@ -6399,7 +6404,7 @@ FETCH want INTO want_rec; want_found := FOUND; WHILE have_found OR want_found LOOP - IF have_rec IS DISTINCT FROM want_rec OR have_found <> want_found THEN + IF have_rec::text IS DISTINCT FROM want_rec::text OR have_found <> want_found THEN RETURN ok( true, $3 ); ELSE FETCH have INTO have_rec; @@ -6585,13 +6590,7 @@ $$ LANGUAGE sql; -- collect_tap( tap, tap, tap ) -CREATE OR REPLACE FUNCTION collect_tap( VARIADIC text[] ) -RETURNS TEXT AS $$ - SELECT array_to_string($1, E'\n'); -$$ LANGUAGE sql; - --- collect_tap( tap[] ) -CREATE OR REPLACE FUNCTION collect_tap( VARCHAR[] ) +CREATE OR REPLACE FUNCTION collect_tap( text[] ) RETURNS TEXT AS $$ SELECT array_to_string($1, E'\n'); $$ LANGUAGE sql; @@ -7063,7 +7062,7 @@ rec RECORD; BEGIN EXECUTE _query($1) INTO rec; - IF NOT rec IS DISTINCT FROM $2 THEN RETURN ok(true, $3); END IF; + IF NOT rec::text IS DISTINCT FROM $2::text THEN RETURN ok(true, $3); END IF; RETURN ok(false, $3 ) || E'\n' || diag( ' have: ' || CASE WHEN rec IS NULL THEN 'NULL' ELSE rec::text END || E'\n want: ' || CASE WHEN $2 IS NULL THEN 'NULL' ELSE $2::text END