Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much
Date
Msg-id CAB7nPqTsuq=rnM8PQGxNS3Gh=JQQp4RmdPxGLGXSV648X4yfhA@mail.gmail.com
Whole thread Raw
In response to Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much  (Dmitry Dolgov <9erthalion6@gmail.com>)
Responses Re: [BUGS] BUG #14849: jsonb_build_object doesn't like VARIADIC callsvery much  (Dmitry Dolgov <9erthalion6@gmail.com>)
List pgsql-bugs
On Fri, Oct 13, 2017 at 10:56 PM, Dmitry Dolgov <9erthalion6@gmail.com> wrote:
>> On 13 October 2017 at 15:48, Michael Paquier <michael.paquier@gmail.com>
>> wrote:
>>
>> it is perfectly valid to have something like json_build_array('2', NULL)
>> or
>> json_build_object('1', NULL), because there can be NULL values in JSON
>> strings. What we just need to be careful here is to check if the array
>> is NULL or not in a variadic call, and just return NULL in this case.
>
> Oh, indeed, I agree.

Okay. Attached is an updated patch fixing what you have reported. Now
things behave as I would expect the way they should:
=# select json_build_array(variadic NULL::text[]);
 json_build_array
------------------
 null
(1 row)
=# select json_build_array(variadic '{}'::text[]);
 json_build_array
------------------
 []
(1 row)
=# select json_build_object(variadic '{}'::text[]);
 json_build_object
-------------------
 {}
(1 row)
=# select json_build_object(variadic NULL::text[]);
 json_build_object
-------------------
 null
(1 row)

Thanks Dmitry for the review.
-- 
Michael

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachment

pgsql-bugs by date:

Previous
From: GDR!
Date:
Subject: Re: [BUGS] BUG #14851: Systemd kills long-running recovery
Next
From: Tom Lane
Date:
Subject: Re: [BUGS] Combination of ordered-set aggregate function terminates JDBC connection on PostgreSQL 9.6.5