scratch31.sql
application/sql
Filename: scratch31.sql
Type: application/sql
Part: 0
screate type compostype as (x int, y varchar);
create or replace function compos() returns compostype as $$
begin
return (1, 'hello');
end;
$$ language plpgsql;
create or replace function compos1() returns compostype as $$
begin
return (1, 'hello'::varchar);
end;
$$ language plpgsql;
create or replace function f2() returns setof int as $$
begin
return query select 1 union all select 2;
end;
$$ language plpgsql;
create or replace function f3() returns setof int as $$
begin
return query select 1 union select 2;
end;
$$ language plpgsql;
create or replace function f4(in i int, out j int) returns setof int as $$
begin
j := i+1;
return next;
j := i+2;
return next;
return;
end$$ language plpgsql;
create or replace function returnsrecord(int) returns record language plpgsql as
$$
begin
return row($1,$1+1);
end $$;
create or replace function my_f3(a integer)
returns table(xxyy int) language plpgsql as
$function$
begin
return query select a;
end;
$function$;
copy(SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8)) to stdout (format json);
copy(select * from my_f3(1)) to stdout (format json);
copy(select my_f3(1)) to stdout (format json);
copy(select * from f2()) to stdout (format json);
copy(select * from f3()) to stdout (format json);
copy(select * from f4(11)) to stdout (format json);
copy(select compos1()) to stdout (format json);
copy(select * from compos1()) to stdout (format json);
copy(select * from returnsrecord(42) as r(xxx1 int, z1 int)) to stdout (format json);