agora inbox for pgsql-bugs@postgresql.org  
help / color / mirror / Atom feed
BUG #19643: Output of jsonb_populate_recordset not consistent with documentation description
2+ messages / 2 participants
[nested] [flat]

* BUG #19643: Output of jsonb_populate_recordset not consistent with documentation description
@ 2026-08-28 12:42  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2026-08-28 12:42 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: yishundinesh@gmail.com

The following bug has been logged on the website:

Bug reference:      19643
Logged by:          Balaji Venkatesan
Email address:      yishundinesh@gmail.com
PostgreSQL version: 18.6
Operating system:   Ubuntu
Description:        

As per the documentation jsonb_populate_record  "Expands the object in
from_json to a row whose columns match the record type defined by base".
The example given the documentation is working fine, but if I replace
null::myrow with Row(('a'::text,'b'::text), the output discards
from_json(second argument completely)
First argument's value is being used instead of using it as a key

Eg:
select * from
jsonb_populate_recordset(ROW('a'::text,'b'::text),'[{"a":"test","b":"55"}]')
as (a text, b text)

Output::
a,b

Expected output:

test,55







^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #19643: Output of jsonb_populate_recordset not consistent with documentation description
@ 2026-08-28 13:28  David G. Johnston <david.g.johnston@gmail.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2026-08-28 13:28 UTC (permalink / raw)
  To: yishundinesh@gmail.com; pgsql-bugs@lists.postgresql.org

On Fri, Aug 28, 2026 at 8:57 AM PG Bug reporting form <
noreply@postgresql.org> wrote:

> The following bug has been logged on the website:
>
> Bug reference:      19643
> Logged by:          Balaji Venkatesan
> Email address:      yishundinesh@gmail.com
> PostgreSQL version: 18.6
> Operating system:   Ubuntu
> Description:
>
> As per the documentation jsonb_populate_record  "Expands the object in
> from_json to a row whose columns match the record type defined by base".
> The example given the documentation is working fine, but if I replace
> null::myrow with Row(('a'::text,'b'::text), the output discards
> from_json(second argument completely)
> First argument's value is being used instead of using it as a key
>
> Eg:
> select * from
>
> jsonb_populate_recordset(ROW('a'::text,'b'::text),'[{"a":"test","b":"55"}]')
> as (a text, b text)
>
> Output::
> a,b
>
> Expected output:
>
> test,55
>

It doesn't discard the second argument - but your record type doesn't have
either "a" or "b" columns defined so no matches are found.

Your base object has only one unnamed composite typed (two text fields)
column.  Since the object itself is not null you've specified a default
value for that column which is what you see in the output.

In short, this is working as documented.  What you intended with writing
row(...) simply isn't how the system works.

Use json_to_record or json_to_recordset if you want to specify the
structure of the output explicitly inline.  The populate variants are meant
to be used when actual types exist within the system (usually because a
corresponding table exists).

David J.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-08-28 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28 12:42 BUG #19643: Output of jsonb_populate_recordset not consistent with documentation description PG Bug reporting form <noreply@postgresql.org>
2026-08-28 13:28 ` David G. Johnston <david.g.johnston@gmail.com>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox