BUG #19643: Output of jsonb_populate_recordset not consistent with documentation description

Started by PG Bug reporting form24 days ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

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

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: PG Bug reporting form (#1)
Re: BUG #19643: Output of jsonb_populate_recordset not consistent with documentation description

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.