765
765
drop function foo1(n integer);
766
-- test use of SQL functions returning record
767
-- this is supported in some cases where the query doesn't specify
768
-- the actual record type ...
769
create function array_to_set(anyarray) returns setof record as $$
770
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
771
$$ language sql strict immutable;
772
select array_to_set(array['one', 'two']);
779
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
786
select * from array_to_set(array['one', 'two']); -- fail
787
ERROR: a column definition list is required for functions returning "record"
788
LINE 1: select * from array_to_set(array['one', 'two']);
790
create temp table foo(f1 int8, f2 int8);
791
create function testfoo() returns record as $$
792
insert into foo values (1,2) returning *;
800
select * from testfoo() as t(f1 int8,f2 int8);
806
select * from testfoo(); -- fail
807
ERROR: a column definition list is required for functions returning "record"
808
LINE 1: select * from testfoo();
810
drop function testfoo();
811
create function testfoo() returns setof record as $$
812
insert into foo values (1,2), (3,4) returning *;
821
select * from testfoo() as t(f1 int8,f2 int8);
828
select * from testfoo(); -- fail
829
ERROR: a column definition list is required for functions returning "record"
830
LINE 1: select * from testfoo();
832
drop function testfoo();