[Commits] 76f6c1e: MDEV-12262 Assertion `!null_value' failed in virtual bool Item::send on

Alexey Botchkov holyfoot at askmonty.org
Mon Mar 20 13:20:05 EET 2017


revision-id: 76f6c1e1ed2c48594832e20035cd15fec9c35d94 (mariadb-10.2.4-75-g76f6c1e)
parent(s): a06da5c848e6feeef0b1559e84479890a76c446e
committer: Alexey Botchkov
timestamp: 2017-03-20 15:18:06 +0400
message:

MDEV-12262 Assertion `!null_value' failed in virtual bool Item::send on
JSON_REMOVE.

        null_value wasn't properly set in Item_json_func_remove::val_str.

---
 mysql-test/r/func_json.result | 11 +++++++++++
 mysql-test/t/func_json.test   | 11 +++++++++++
 sql/item_jsonfunc.cc          |  2 ++
 3 files changed, 24 insertions(+)

diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result
index 6a77648..eff8f5c 100644
--- a/mysql-test/r/func_json.result
+++ b/mysql-test/r/func_json.result
@@ -618,3 +618,14 @@ connection default;
 set @@global.max_allowed_packet = default;
 set @@global.net_buffer_length = default;
 disconnect newconn;
+create table t1(j longtext, p longtext);
+insert into t1 values
+('{"a":1,"b":2,"c":3}','$.a'),
+('{"a":1,"b":2,"c":3}','$.b'),
+('{"a":1,"b":2,"c":3}','$.c');
+select j, p, json_remove(j, p) from t1;
+j	p	json_remove(j, p)
+{"a":1,"b":2,"c":3}	$.a	{"b": 2, "c": 3}
+{"a":1,"b":2,"c":3}	$.b	{"a": 1, "c": 3}
+{"a":1,"b":2,"c":3}	$.c	{"a": 1, "b": 2}
+drop table t1;
diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test
index 74692c4..72b8681 100644
--- a/mysql-test/t/func_json.test
+++ b/mysql-test/t/func_json.test
@@ -263,3 +263,14 @@ set @@global.max_allowed_packet = default;
 set @@global.net_buffer_length = default;
 --disconnect newconn
 
+
+#
+# MDEV-12262 Assertion `!null_value' failed in virtual bool Item::send on JSON_REMOVE.
+#
+create table t1(j longtext, p longtext);
+insert into t1 values
+    ('{"a":1,"b":2,"c":3}','$.a'),
+    ('{"a":1,"b":2,"c":3}','$.b'),
+      ('{"a":1,"b":2,"c":3}','$.c');
+select j, p, json_remove(j, p) from t1;
+drop table t1;
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index f3090a4..b8471dc 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -2633,6 +2633,7 @@ String *Item_func_json_remove::val_str(String *str)
     str->length(0);
 
     if (append_simple(str, js->ptr(), rem_start - js->ptr()) ||
+        (je.state == JST_KEY && n_item > 0 && str->append(",", 1)) ||
         append_simple(str, rem_end, js->end() - rem_end))
           goto js_error; /* Out of memory. */
 
@@ -2658,6 +2659,7 @@ String *Item_func_json_remove::val_str(String *str)
   if (json_nice(&je, str, Item_func_json_format::LOOSE))
     goto js_error;
 
+  null_value= 0;
   return str;
 
 js_error:


More information about the commits mailing list