From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: pfunk@mail.ru
Subject: BUG #18443: jsonb_agg issue. Again.
Date: Fri, 19 Apr 2024 14:09:26 +0000
Message-ID: <18443-bd015c763e3196ca@postgresql.org> (raw)
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#a926c8cabd0cefb1f7ba50a3...
Could it be related?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, pfunk@mail.ru
Subject: Re: BUG #18443: jsonb_agg issue. Again.
In-Reply-To: <18443-bd015c763e3196ca@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox