]> granicus.if.org Git - postgresql/commit
Fix normalization of numeric values in JSONB GIN indexes.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Nov 2014 16:41:06 +0000 (11:41 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 6 Nov 2014 16:41:06 +0000 (11:41 -0500)
commit4875931938b27924fe8d6f91bbdb09e2e5a29d0a
tree0e474ba7569386f3d6611decd039b7ebddf8c61d
parent5332b8cec54192c5d7b0ad67dc5668ccb917eeef
Fix normalization of numeric values in JSONB GIN indexes.

The default JSONB GIN opclass (jsonb_ops) converts numeric data values
to strings for storage in the index.  It must ensure that numeric values
that would compare equal (such as 12 and 12.00) produce identical strings,
else index searches would have behavior different from regular JSONB
comparisons.  Unfortunately the function charged with doing this was
completely wrong: it could reduce distinct numeric values to the same
string, or reduce equivalent numeric values to different strings.  The
former type of error would only lead to search inefficiency, but the
latter type of error would cause index entries that should be found by
a search to not be found.

Repairing this bug therefore means that it will be necessary for 9.4 beta
testers to reindex GIN jsonb_ops indexes, if they care about getting
correct results from index searches involving numeric data values within
the comparison JSONB object.

Per report from Thomas Fanghaenel.
src/backend/utils/adt/numeric.c