select (fn()).* executes function multiple times

From: Andrey <parihaaraka(at)gmail(dot)com>
To: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: select (fn()).* executes function multiple times
Date: 2018-11-16 14:49:35
Message-ID: CAOYf6edujEOGB-9fGG_V9PGQ5O9yoyWmTnE9RyBYTGw+Dq3SpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 -----------------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2018-11-16 14:57:22 Re: select (fn()).* executes function multiple times
Previous Message Michael Paquier 2018-11-16 13:31:03 Re: ALTER INDEX ... ALTER COLUMN not present in dump