select (fn()).* executes function multiple times - Mailing list pgsql-bugs

From Andrey
Subject select (fn()).* executes function multiple times
Date
Msg-id CAOYf6edujEOGB-9fGG_V9PGQ5O9yoyWmTnE9RyBYTGw+Dq3SpA@mail.gmail.com
Whole thread Raw
Responses Re: select (fn()).* executes function multiple times  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: select (fn()).* executes function multiple times  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
PostgreSQL 10.5, 11.1:

create table fn_ret_test_storage (f1 int default 1, f2 int default 2, f3 int default 3);

create or replace function fn_ret_test(out f1 int, out f2 int, out f3 int)
returns record
language plpgsql
as
$$
begin
insert into fn_ret_test_storage default values
returning * into f1, f2, f3;
end
$$;

do
$$
declare
_count int;
begin
select count(*) into _count from fn_ret_test_storage;
perform (fn_ret_test()).*;
select count(*) - _count into _count from fn_ret_test_storage;
raise notice '----------------- % rows inserted -----------------', _count;
end
$$;

-- output: NOTICE:  ----------------- 3 rows inserted -----------------

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: ALTER INDEX ... ALTER COLUMN not present in dump
Next
From: "David G. Johnston"
Date:
Subject: Re: select (fn()).* executes function multiple times