pgsql: Fix core dump in jsonb #> operator, and add regression test case

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix core dump in jsonb #> operator, and add regression test case
Date: 2014-08-20 20:49:08
Message-ID: E1XKCoe-0000AU-E5@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix core dump in jsonb #> operator, and add regression test cases.

jsonb's #> operator segfaulted (dereferencing a null pointer) if the RHS
was a zero-length array, as reported in bug #11207 from Justin Van Winkle.
json's #> operator returns NULL in such cases, so for the moment let's
make jsonb act likewise.

Also add a bunch of regression test queries memorializing the -> and #>
operators' behavior for this and other corner cases.

There is a good argument for changing some of these behaviors, as they
are not very consistent with each other, and throwing an error isn't
necessarily a desirable behavior for operators that are likely to be
used in indexes. However, everybody can agree that a core dump is the
Wrong Thing, and we need test cases even if we decide to change their
expected output later.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9bac66020db75871463bafdb394568bf946e8991

Modified Files
--------------
src/backend/utils/adt/jsonfuncs.c | 16 ++-
src/test/regress/expected/json.out | 185 +++++++++++++++++++++++++++++----
src/test/regress/expected/json_1.out | 185 +++++++++++++++++++++++++++++----
src/test/regress/expected/jsonb.out | 170 +++++++++++++++++++++++++-----
src/test/regress/expected/jsonb_1.out | 170 +++++++++++++++++++++++++-----
src/test/regress/sql/json.sql | 49 +++++++--
src/test/regress/sql/jsonb.sql | 55 +++++++---
7 files changed, 711 insertions(+), 119 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-08-20 23:05:12 pgsql: More regression test cases for json/jsonb extraction operators.
Previous Message Bruce Momjian 2014-08-20 17:04:47 pgsql: pg_upgrade: adjust logging to use QUERY_ALLOC lengths