Fix two-argument jsonb_object when called with empty arrays
authorAndrew Dunstan
Sun, 21 Feb 2016 15:30:49 +0000 (10:30 -0500)
committerAndrew Dunstan
Sun, 21 Feb 2016 15:40:39 +0000 (10:40 -0500)
commit68d68ff8333c106962d4a936e07eba24d63a2e07
tree823804eecb2e14bc0ebd5555d898217af9c1478f
parenta397f8268a6a315b8c6579124637cddc8f79ea71
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.
src/backend/utils/adt/jsonb.c
src/test/regress/expected/json.out
src/test/regress/expected/jsonb.out
src/test/regress/sql/json.sql
src/test/regress/sql/jsonb.sql