pgsql: Remove "invalid concatenation of jsonb objects" error case.

Started by Tom Laneover 5 years ago1 messagescomitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Remove "invalid concatenation of jsonb objects" error case.

The jsonb || jsonb operator arbitrarily rejected certain combinations
of scalar and non-scalar inputs, while being willing to concatenate
other combinations. This was of course quite undocumented. Rather
than trying to document it, let's just remove the restriction,
creating a uniform rule that unless we are handling an object-to-object
concatenation, non-array inputs are converted to one-element arrays,
resulting in an array-to-array concatenation. (This does not change
the behavior for any case that didn't throw an error before.)

Per complaint from Joel Jacobson. Back-patch to all supported branches.

Discussion: /messages/by-id/163099.1608312033@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ff5d5611c01f60525c30b2c3ebc16d05edb7956d

Modified Files
--------------
doc/src/sgml/func.sgml | 22 +++++++++++-
src/backend/utils/adt/jsonfuncs.c | 71 ++++++++++++++++++-------------------
src/test/regress/expected/jsonb.out | 36 +++++++++++++++++--
src/test/regress/sql/jsonb.sql | 5 +++
4 files changed, 94 insertions(+), 40 deletions(-)