diff options
| author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2022-07-30 16:56:18 +0530 |
|---|---|---|
| committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2022-08-11 13:47:25 +0530 |
| commit | 11d6de7032ab7fb221315ee5680504f34d1ba3ed (patch) | |
| tree | afd7888c3d6b33998631a43b9e40cc7712f780fb /mysql-test/main | |
| parent | bfdc4ff22ecf626eb46479e1a0dc1049d61a8d78 (diff) | |
| download | mariadb-git-11d6de7032ab7fb221315ee5680504f34d1ba3ed.tar.gz | |
MDEV-29212: json_overlaps() does not check nested key-value pair correctly
Analysis: JSON_OVERLAPS() does not check nested key-value pair completely.
If there is nested object, then it only scans and validates if two json values
overlap until one of the value (which is of type object) is exhausted.
This does not really check if the two values of keys are exacly the same, instead
it only checks if key-value pair of one is present in key-value pair of the
other
Fix: Normalize the values (which are of type object) and compare
using string compare. This will validate if two values
are exactly the same.
Diffstat (limited to 'mysql-test/main')
| -rw-r--r-- | mysql-test/main/func_json.result | 11 | ||||
| -rw-r--r-- | mysql-test/main/func_json.test | 9 |
2 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index ffdda37684e..4eb741e280b 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -2284,5 +2284,16 @@ SELECT * FROM JSON_TABLE('{"foo":["bar","qux"]}','$**.*[0]' COLUMNS(col1 CHAR(8) col1 bar # +# MDEV-29212: json_overlaps() does not check nested key-value pair correctly +# +SET @json1 = '{"kk":{"k1":"v1","k2":"v2"}}'; +SET @json2 = '{"kk":{"k1":"v1","k2":"v2","k3":"v3"}}'; +SELECT JSON_OVERLAPS(@json2, @json1); +JSON_OVERLAPS(@json2, @json1) +0 +SELECT JSON_OVERLAPS(@json1, @json2); +JSON_OVERLAPS(@json1, @json2) +0 +# # End of 10.9 Test # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 91d5002acc8..3c0c72b6758 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1534,5 +1534,14 @@ SELECT JSON_EXISTS(@json, '$[2][2][1 to 4]'); SELECT * FROM JSON_TABLE('{"foo":["bar","qux"]}','$**.*[0]' COLUMNS(col1 CHAR(8) PATH '$[0]')) AS jt; --echo # +--echo # MDEV-29212: json_overlaps() does not check nested key-value pair correctly +--echo # + +SET @json1 = '{"kk":{"k1":"v1","k2":"v2"}}'; +SET @json2 = '{"kk":{"k1":"v1","k2":"v2","k3":"v3"}}'; +SELECT JSON_OVERLAPS(@json2, @json1); +SELECT JSON_OVERLAPS(@json1, @json2); + +--echo # --echo # End of 10.9 Test --echo # |
