[Commits] f701ac6: MDEV-12324 Wrong result (phantom array value) on JSON_EXTRACT.

Alexey Botchkov holyfoot at askmonty.org
Mon Aug 7 12:47:18 EEST 2017


revision-id: f701ac65e951d373f62322147c785370fe7e4e25 (mariadb-10.2.7-43-gf701ac6)
parent(s): 4ff6ebf76af763f8e9e98b22773ac68cc2415aa1
committer: Alexey Botchkov
timestamp: 2017-08-07 13:46:45 +0400
message:

MDEV-12324 Wrong result (phantom array value) on JSON_EXTRACT.

        Fixed the path comparison.

---
 mysql-test/r/func_json.result | 6 ++++++
 mysql-test/t/func_json.test   | 6 ++++++
 strings/json_lib.c            | 2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index 997d3e4..894e460 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -642,3 +642,9 @@ SELECT JSON_KEYS(f) FROM t1 ORDER BY 1;
 JSON_KEYS(f)
 NULL
 DROP TABLE t1;
+SELECT JSON_EXTRACT( '{"foo":"bar"}', '$[*].*' );
+JSON_EXTRACT( '{"foo":"bar"}', '$[*].*' )
+NULL
+SELECT JSON_EXTRACT( '{"foo":"bar"}', '$[*]' );
+JSON_EXTRACT( '{"foo":"bar"}', '$[*]' )
+NULL
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index 0fc8e97..0ce742a 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -296,3 +296,9 @@ INSERT INTO t1 VALUES (0);
 SELECT JSON_KEYS(f) FROM t1 ORDER BY 1;
 DROP TABLE t1;
 
+#
+# MDEV-12324 Wrong result (phantom array value) on JSON_EXTRACT.
+#
+SELECT JSON_EXTRACT( '{"foo":"bar"}', '$[*].*' );
+SELECT JSON_EXTRACT( '{"foo":"bar"}', '$[*]' );
+
diff --git a/strings/json_lib.c b/strings/json_lib.c
index 0e2a17b..7167b6a 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1756,7 +1756,7 @@ int json_path_parts_compare(
           goto step_fits;
         goto step_failed;
       }
-      if (a->n_item == 0)
+      if ((a->type & JSON_PATH_WILD) == 0 && a->n_item == 0)
         goto step_fits_autowrap;
       goto step_failed;
     }


More information about the commits mailing list