Re: BUG #13680: PostgreSQL backend process crashes on jsonb_object_agg() in plpgsql recursive function

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: b(dot)yordanov2(at)gmail(dot)com
Cc: PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13680: PostgreSQL backend process crashes on jsonb_object_agg() in plpgsql recursive function
Date: 2015-10-15 05:41:57
Message-ID: CAB7nPqS4ha2+d7oyTetqEMy8uLaG=n+uwK=XCPPdc+xZSSDtfA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Oct 15, 2015 at 10:44 AM, Michael Paquier wrote:
> I am looking into it in more details, for now I have added an open item for 9.5.
> Regards,

This simple query reproduces the crash as well:
=# select json_object_agg(1, NULL::json);
json_object_agg
-----------------
{ "1" : null }
(1 row)
=# select jsonb_object_agg(1, NULL::jsonb);
server closed the connection unexpectedly

It happens that jsonb_object_agg_transfn is not able to manage
correctly NULL values in the context of a JSONB value, and it seems to
me that this is caused by an oversight in datum_to_jsonb regarding the
handling of NULL values.

Attached is a patch with some regression tests for master and
REL9_5_STABLE where the bug has been introduced.
Thoughts?
--
Michael

Attachment Content-Type Size
20151015_jsonb_agg_null.patch text/x-diff 2.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message boyko yordanov 2015-10-15 10:07:53 Re: BUG #13680: PostgreSQL backend process crashes on jsonb_object_agg() in plpgsql recursive function
Previous Message Michael Paquier 2015-10-15 05:40:21 Re: BUG #13682: error while connecting to database