--- sql/pgtap.sql 2011-02-01 15:32:02.000000000 -0800 +++ sql/pgtap.sql.orig 2011-02-01 15:30:37.000000000 -0800 @@ -1993,13 +1993,13 @@ CREATE OR REPLACE FUNCTION _constraint ( NAME, NAME, CHAR, NAME[], TEXT, TEXT ) RETURNS TEXT AS $$ DECLARE - akey NAME[]; + rec record; keys TEXT[] := '{}'; have TEXT; BEGIN - FOR akey IN SELECT * FROM _keys($1, $2, $3) LOOP - IF akey = $4 THEN RETURN pass($5); END IF; - keys = keys || akey::text; + FOR rec IN SELECT * FROM _keys($1, $2, $3) AS b(a) LOOP + IF rec.a = $4 THEN RETURN pass($5); END IF; + keys = keys || rec.a::text; END LOOP; IF array_upper(keys, 0) = 1 THEN have := 'No ' || $6 || ' constriants'; @@ -2017,13 +2017,13 @@ CREATE OR REPLACE FUNCTION _constraint ( NAME, CHAR, NAME[], TEXT, TEXT ) RETURNS TEXT AS $$ DECLARE - akey NAME[]; + rec record; keys TEXT[] := '{}'; have TEXT; BEGIN - FOR akey IN SELECT * FROM _keys($1, $2) LOOP - IF akey = $3 THEN RETURN pass($4); END IF; - keys = keys || akey::text; + FOR rec IN SELECT * FROM _keys($1, $2) AS b(a) LOOP + IF rec.a = $3 THEN RETURN pass($4); END IF; + keys = keys || rec.a::text; END LOOP; IF array_upper(keys, 0) = 1 THEN have := 'No ' || $5 || ' constriants'; @@ -5677,7 +5677,7 @@ CREATE OR REPLACE FUNCTION _runem( text[], boolean ) RETURNS SETOF TEXT AS $$ DECLARE - tap text; + rec record; lbound int := array_lower($1, 1); BEGIN IF lbound IS NULL THEN RETURN; END IF; @@ -5685,8 +5685,8 @@ -- Send the name of the function to diag if warranted. IF $2 THEN RETURN NEXT diag( $1[i] || '()' ); END IF; -- Execute the tap function and return its results. - FOR tap IN EXECUTE 'SELECT * FROM ' || $1[i] || '()' LOOP - RETURN NEXT tap; + FOR rec IN EXECUTE 'SELECT * FROM ' || $1[i] || '() AS b(a)' LOOP + RETURN NEXT rec.a; END LOOP; END LOOP; RETURN; @@ -5750,14 +5750,14 @@ setup ALIAS FOR $3; teardown ALIAS FOR $4; tests ALIAS FOR $5; - tap text; + rec record; verbos boolean := _is_verbose(); -- verbose is a reserved word in 8.5. num_faild INTEGER := 0; BEGIN BEGIN -- No plan support. PERFORM * FROM no_plan(); - FOR tap IN SELECT * FROM _runem(startup, false) LOOP RETURN NEXT tap; END LOOP; + FOR rec IN SELECT * FROM _runem(startup, false) AS b(a) LOOP RETURN NEXT rec.a; END LOOP; EXCEPTION -- Catch all exceptions and simply rethrow custom exceptions. This -- will roll back everything in the above block. @@ -5772,15 +5772,15 @@ IF verbos THEN RETURN NEXT diag(tests[i] || '()'); END IF; -- Run the setup functions. - FOR tap IN SELECT * FROM _runem(setup, false) LOOP RETURN NEXT tap; END LOOP; + FOR rec IN SELECT * FROM _runem(setup, false) AS b(a) LOOP RETURN NEXT rec.a; END LOOP; -- Run the actual test function. - FOR tap IN EXECUTE 'SELECT * FROM ' || tests[i] || '()' LOOP - RETURN NEXT tap; + FOR rec IN EXECUTE 'SELECT * FROM ' || tests[i] || '() AS b(a)' LOOP + RETURN NEXT rec.a; END LOOP; -- Run the teardown functions. - FOR tap IN SELECT * FROM _runem(teardown, false) LOOP RETURN NEXT tap; END LOOP; + FOR rec IN SELECT * FROM _runem(teardown, false) AS b(a) LOOP RETURN NEXT rec.a; END LOOP; -- Remember how many failed and then roll back. num_faild := num_faild + num_failed(); @@ -5795,7 +5795,7 @@ END LOOP; -- Run the shutdown functions. - FOR tap IN SELECT * FROM _runem(shutdown, false) LOOP RETURN NEXT tap; END LOOP; + FOR rec IN SELECT * FROM _runem(shutdown, false) AS b(a) LOOP RETURN NEXT rec.a; END LOOP; -- Raise an exception to rollback any changes. RAISE EXCEPTION '__TAP_ROLLBACK__'; @@ -5806,8 +5806,8 @@ END IF; END; -- Finish up. - FOR tap IN SELECT * FROM _finish( currval('__tresults___numb_seq')::integer, 0, num_faild ) LOOP - RETURN NEXT tap; + FOR rec IN SELECT * FROM _finish( currval('__tresults___numb_seq')::integer, 0, num_faild ) AS b(a) LOOP + RETURN NEXT rec.a; END LOOP; -- Clean up and return. @@ -7038,7 +7038,7 @@ DECLARE rec RECORD; BEGIN - EXECUTE _query($1) INTO rec; + FOR rec in EXECUTE _query($1) LOOP END LOOP; IF NOT textin(record_out(rec)) IS DISTINCT FROM textin(record_out($2)) THEN RETURN ok(true, $3); END IF;