pgsql: Fix bogus optimization in JSONB containment tests.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix bogus optimization in JSONB containment tests.
Дата
Msg-id E1Xd1B3-0000Hm-SI@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix bogus optimization in JSONB containment tests.

When determining whether one JSONB object contains another, it's okay to
make a quick exit if the first object has fewer pairs than the second:
because we de-duplicate keys within objects, it is impossible that the
first object has all the keys the second does.  However, the code was
applying this rule to JSONB arrays as well, where it does *not* hold
because arrays can contain duplicate entries.  The test was really in
the wrong place anyway; we should do it within JsonbDeepContains, where
it can be applied to nested objects not only top-level ones.

Report and test cases by Alexander Korotkov; fix by Peter Geoghegan and
Tom Lane.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4a50de13127b7657f32f14dc17beb2e15a3a4777

Modified Files
--------------
src/backend/utils/adt/jsonb_op.c      |   10 ++++-----
src/backend/utils/adt/jsonb_util.c    |   16 +++++++++++++--
src/test/regress/expected/jsonb.out   |   36 +++++++++++++++++++++++++++++++++
src/test/regress/expected/jsonb_1.out |   36 +++++++++++++++++++++++++++++++++
src/test/regress/sql/jsonb.sql        |    7 +++++++
5 files changed, 97 insertions(+), 8 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix bogus optimization in JSONB containment tests.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Improve documentation about JSONB array containment behavior.