From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | pfunk(at)mail(dot)ru |
Subject: | BUG #18443: jsonb_agg issue. Again. |
Date: | 2024-04-19 14:09:26 |
Message-ID: | 18443-bd015c763e3196ca@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 18443
Logged by: Alexander Tsaregorodtsev
Email address: pfunk(at)mail(dot)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?
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2024-04-19 15:34:34 | Re: BUG #18443: jsonb_agg issue. Again. |
Previous Message | Tom Lane | 2024-04-19 14:03:43 | Re: BUG #18442: Unnecessary Sort operator in indexScan Plan |