pgsql: Adjust string comparison in jsonpath

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Adjust string comparison in jsonpath
Date: 2019-08-11 20:10:49
Message-ID: E1hwuAz-0003Sr-SZ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Adjust string comparison in jsonpath

We have implemented jsonpath string comparison using default database locale.
However, standard requires us to compare Unicode codepoints. This commit
implements that, but for performance reasons we still use per-byte comparison
for "==" operator. Thus, for consistency other comparison operators do per-byte
comparison if Unicode codepoints appear to be equal.

In some edge cases, when same Unicode codepoints have different binary
representations in database encoding, we diverge standard to achieve better
performance of "==" operator. In future to implement strict standard
conformance, we can do normalization of input JSON strings.

Original patch was written by Nikita Glukhov, rewritten by me.

Reported-by: Markus Winand
Discussion: https://postgr.es/m/8B7FA3B4-328D-43D7-95A8-37B8891B8C78%40winand.at
Author: Nikita Glukhov, Alexander Korotkov
Backpatch-through: 12

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c | 72 +++++++++++-
src/test/regress/expected/jsonb_jsonpath.out | 163 +++++++++++++++++++++++++++
src/test/regress/sql/jsonb_jsonpath.sql | 16 +++
3 files changed, 248 insertions(+), 3 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2019-08-11 21:03:50 Re: pgsql: Adjust string comparison in jsonpath
Previous Message Alexander Korotkov 2019-08-11 20:10:45 pgsql: Adjust string comparison in jsonpath