pgsql: Fix two-argument jsonb_object when called with empty arrays

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix two-argument jsonb_object when called with empty arrays
Date: 2016-02-21 15:42:18
Message-ID: E1aXW9K-0003ge-T7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix two-argument jsonb_object when called with empty arrays

Some over-eager copy-and-pasting on my part resulted in a nonsense
result being returned in this case. I have adopted the same pattern for
handling this case as is used in the one argument form of the function,
i.e. we just skip over the code that adds values to the object.

Diagnosis and patch from Michael Paquier, although not quite his
solution.

Fixes bug #13936.

Backpatch to 9.5 where jsonb_object was introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/94c745eb189e2122a3ff86c24443b11408ea2376

Modified Files
--------------
src/backend/utils/adt/jsonb.c | 7 ++++---
src/test/regress/expected/json.out | 14 ++++++++++++++
src/test/regress/expected/jsonb.out | 14 ++++++++++++++
src/test/regress/sql/json.sql | 6 ++++++
src/test/regress/sql/jsonb.sql | 6 ++++++
5 files changed, 44 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-02-21 16:38:29 pgsql: Cosmetic improvements in new config_info code.
Previous Message Robert Haas 2016-02-21 12:03:08 pgsql: Fix incorrect decision about which lock to take.