pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix erroneous hash calculations in gin_extract_jsonb_path().
3+ messages / 1 participants
[nested] [flat]

* pgsql: Fix erroneous hash calculations in gin_extract_jsonb_path().
@ 2015-11-05 23:16 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2015-11-05 23:16 UTC (permalink / raw)
  To: pgsql-committers

Fix erroneous hash calculations in gin_extract_jsonb_path().

The jsonb_path_ops code calculated hash values inconsistently in some cases
involving nested arrays and objects.  This would result in queries possibly
not finding entries that they should find, when using a jsonb_path_ops GIN
index for the search.  The problem cases involve JSONB values that contain
both scalars and sub-objects at the same nesting level, for example an
array containing both scalars and sub-arrays.  To fix, reset the current
stack->hash after processing each value or sub-object, not before; and
don't try to be cute about the outermost level's initial hash.

Correcting this means that existing jsonb_path_ops indexes may now be
inconsistent with the new hash calculation code.  The symptom is the same
--- searches not finding entries they should find --- but the specific
rows affected are likely to be different.  Users will need to REINDEX
jsonb_path_ops indexes to make sure that all searches work as expected.

Per bug #13756 from Daniel Cheng.  Back-patch to 9.4 where the faulty
logic was introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b23af458755ed90ae9164857e59d034bad75a672

Modified Files
--------------
src/backend/utils/adt/jsonb_gin.c   |   51 +++++++++++++----------------------
src/test/regress/expected/jsonb.out |   50 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/jsonb.sql      |   20 ++++++++++++++
3 files changed, 88 insertions(+), 33 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix erroneous hash calculations in gin_extract_jsonb_path().
@ 2015-11-05 23:16 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2015-11-05 23:16 UTC (permalink / raw)
  To: pgsql-committers

Fix erroneous hash calculations in gin_extract_jsonb_path().

The jsonb_path_ops code calculated hash values inconsistently in some cases
involving nested arrays and objects.  This would result in queries possibly
not finding entries that they should find, when using a jsonb_path_ops GIN
index for the search.  The problem cases involve JSONB values that contain
both scalars and sub-objects at the same nesting level, for example an
array containing both scalars and sub-arrays.  To fix, reset the current
stack->hash after processing each value or sub-object, not before; and
don't try to be cute about the outermost level's initial hash.

Correcting this means that existing jsonb_path_ops indexes may now be
inconsistent with the new hash calculation code.  The symptom is the same
--- searches not finding entries they should find --- but the specific
rows affected are likely to be different.  Users will need to REINDEX
jsonb_path_ops indexes to make sure that all searches work as expected.

Per bug #13756 from Daniel Cheng.  Back-patch to 9.4 where the faulty
logic was introduced.

Branch
------
REL9_5_STABLE

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

Modified Files
--------------
src/backend/utils/adt/jsonb_gin.c   |   51 +++++++++++++----------------------
src/test/regress/expected/jsonb.out |   50 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/jsonb.sql      |   20 ++++++++++++++
3 files changed, 88 insertions(+), 33 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* pgsql: Fix erroneous hash calculations in gin_extract_jsonb_path().
@ 2015-11-05 23:16 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2015-11-05 23:16 UTC (permalink / raw)
  To: pgsql-committers

Fix erroneous hash calculations in gin_extract_jsonb_path().

The jsonb_path_ops code calculated hash values inconsistently in some cases
involving nested arrays and objects.  This would result in queries possibly
not finding entries that they should find, when using a jsonb_path_ops GIN
index for the search.  The problem cases involve JSONB values that contain
both scalars and sub-objects at the same nesting level, for example an
array containing both scalars and sub-arrays.  To fix, reset the current
stack->hash after processing each value or sub-object, not before; and
don't try to be cute about the outermost level's initial hash.

Correcting this means that existing jsonb_path_ops indexes may now be
inconsistent with the new hash calculation code.  The symptom is the same
--- searches not finding entries they should find --- but the specific
rows affected are likely to be different.  Users will need to REINDEX
jsonb_path_ops indexes to make sure that all searches work as expected.

Per bug #13756 from Daniel Cheng.  Back-patch to 9.4 where the faulty
logic was introduced.

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/788e35ac0bc00489e2b86a930d8c1264100fb94b

Modified Files
--------------
src/backend/utils/adt/jsonb_gin.c   |   51 +++++++++++++----------------------
src/test/regress/expected/jsonb.out |   50 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/jsonb.sql      |   20 ++++++++++++++
3 files changed, 88 insertions(+), 33 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-11-05 23:16 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-11-05 23:16 pgsql: Fix erroneous hash calculations in gin_extract_jsonb_path(). Tom Lane <tgl@sss.pgh.pa.us>
2015-11-05 23:16 pgsql: Fix erroneous hash calculations in gin_extract_jsonb_path(). Tom Lane <tgl@sss.pgh.pa.us>
2015-11-05 23:16 pgsql: Fix erroneous hash calculations in gin_extract_jsonb_path(). Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox