BUG #18443: jsonb_agg issue. Again.

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #18443: jsonb_agg issue. Again.
Дата
Msg-id 18443-bd015c763e3196ca@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #18443: jsonb_agg issue. Again.  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
The following bug has been logged on the website:

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
as
$body$
begin
        raise notice '***';
end;
$body$
  language plpgsql;

--view with data
drop view if exists tmp_view;
create or replace temp view tmp_view(col) as 
values
(1::bigint), (2), (3), (4);

db=> select * from tmp_view;
 col
-----
   1
   2
   3
   4
(4 rows)



--result is 1 aggregated string with jsonb array
select jsonb_agg(jsonb_build_object('col', col)) from tmp_view;

db=> select jsonb_agg(jsonb_build_object('col', col)) from tmp_view;
                    jsonb_agg
--------------------------------------------------
 [{"col": 1}, {"col": 2}, {"col": 3}, {"col": 4}]
(1 row)


--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;

db=> select (public.out2(jsonb_agg(jsonb_build_object('col', col)))).* --,
jsonb_agg(jsonb_build_object('col', col))
from tmp_view;
NOTICE:  ***
NOTICE:  ***
 a | b
---+---
   |
(1 row)


--Problem! function out3 has invoked 3 times (three NOTICE`s and
accidentally number of output parameters)
select (public.out3(jsonb_agg(jsonb_build_object('col', col)))).* --,
jsonb_agg(jsonb_build_object('col', col))
from tmp_view;
db=> select (public.out3(jsonb_agg(jsonb_build_object('col', col)))).* --,
jsonb_agg(jsonb_build_object('col', col))
from tmp_view;
NOTICE:  ***
NOTICE:  ***
NOTICE:  ***
 a | b | c
---+---+---
   |   |
(1 row)



Something similar was reported in
https://www.postgresql.org/message-id/flat/18365.1529018904%40sss.pgh.pa.us#a926c8cabd0cefb1f7ba50a387f5272a
Could it be related?


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #18442: Unnecessary Sort operator in indexScan Plan
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #18443: jsonb_agg issue. Again.