Ticket #3 (closed defect: fixed)
Remove IMMUTABLE from `test.assert_rows()`
| Reported by: | guest | Owned by: | fumanchu |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | assertions | Keywords: | |
| Cc: |
Description
Following our email exchange, here is another bug that came up when I tried to use global:
CREATE TYPE foo AS ( id int, name text );
CREATE OR REPLACE FUNCTION public.fooies()
RETURNS SETOF foo LANGUAGE sql
AS $$ VALUES (42, 'Fred'::text), (99, 'Bob'::text); $$;
CREATE OR REPLACE FUNCTION test.test_fooies() RETURNS VOID AS $_$
BEGIN
PREPARE want AS VALUES(42, 'BET'), (99, 'Bob');
PERFORM test.assert_rows(
test.global($$ EXECUTE want $$),
test.global($$ SELECT * FROM public.fooies() $$)
);
RAISE EXCEPTION '[OK]';
END;
$_$ LANGUAGE plpgsql;
SELECT * FROM test.test_fooies();
This unexpectedly passes on 8.4beta2. The problem is that assert_rows() is marked IMMUTABLE. Of course, it's not immutable, as we're fetching data from tables (which is rather the point of globa(). The fix:
Index: epic.sql
===================================================================
--- epic.sql (revision 28)
+++ epic.sql (working copy)
@@ -723,7 +723,7 @@
RAISE EXCEPTION 'Record: % from: % not found in: %', rec, call_2, call_1;
END LOOP;
END;
-$$ LANGUAGE plpgsql IMMUTABLE;
+$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION test.assert_column(call text, expected anyarray, colname text) RETURNS VOID AS $$
—Theory
Change History
Note: See
TracTickets for help on using
tickets.
