Bug reference: 18443 Logged by: Alexander Tsaregorodtsev Email address: pfunk@mail.ru PostgreSQL version: 12.18 Operating system: Official docker container Description:
Greetings! Is it expected behavior?
--simple function raising ONE notice and returning record of 2 int`s drop function if exists public.out2(jsonb); create or replace function public.out2(_in jsonb, a out int, b out int) returns record as $body$ begin raise notice '***'; end; $body$ language plpgsql;
--similar function raising notice but returning record of 3 int`s drop function if exists public.out3(); create or replace function public.out3(_in jsonb, a out int, b out int, c out int) returns record
--Problem! function out2 has invoked 2 times (two NOTICE`s and accidentally number of output parameters) select (public.out2(jsonb_agg(jsonb_build_object('col', col)))).* --, jsonb_agg(jsonb_build_object('col', col)) from tmp_view;
You wrote a table-producing function (one row but three columns). Those need [1] to be executed in the FROM clause, via an implicit or explicit LATERAL join if you have data from other relations being fed in as input arguments.
David J.
1. well, at least if you don't want to see this kind of artifact where the way to expand .* is to copy the expression preceding it.