begin;

create table test (fk_item integer);

create function test()
	returns boolean
	language 'plpgsql'
	as '
declare
	cmd text;
begin
	cmd := ''select 1 from test where fk_item=1324314'';
	raise notice ''running: %'', cmd;

	execute cmd;
	raise notice ''found (execute 1): %'', found;

	execute cmd;
	raise notice ''found (execute 2): %'', found;

	perform cmd;
	raise notice ''found (perform): %'', found;

	execute cmd;
	raise notice ''found (execute 3): %'', found;

	return true;
end;
';

\set ECHO queries
select * from test;
select test();

rollback;
