revision-id: 5cfb043d2919439fccfa350edd9a3fdb4aaf229b (mariadb-10.2.18-71-g5cfb043) parent(s): f5bcf788e76c2cb5da5ddecdb6ff9b2f766b1a49 committer: Alexey Botchkov timestamp: 2018-11-09 22:55:34 +0400 message: MDEV-16174 Assertion `0' failed in Type_handler_string_result::make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) maybe_null should be always set to TRUE in Item_func_json_array_append::fix_length_and_dec() --- mysql-test/r/func_json.result | 14 ++++++++++++++ mysql-test/t/func_json.test | 13 +++++++++++++ sql/item_jsonfunc.cc | 1 + 3 files changed, 28 insertions(+) diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index c828b26..90458bc 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -810,3 +810,17 @@ SET @`json` := NULL, @`value` := NULL; SELECT JSON_MERGE('[1]', '[]'); JSON_MERGE('[1]', '[]') [1] +# +# MDEV-16174 Assertion `0' failed in Type_handler_string_result:: +# make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) +# +SET sql_mode=''; +CREATE TABLE t1 (fld varchar(16) NOT NULL); +CREATE TABLE t2 SELECT JSON_ARRAY_INSERT(fld, '$.[0]', '0') FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `JSON_ARRAY_INSERT(fld, '$.[0]', '0')` varchar(25) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1, t2; +SET sql_mode=default; diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index 1dc1641..d266641 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -468,3 +468,16 @@ SET @`json` := NULL, @`value` := NULL; --echo # SELECT JSON_MERGE('[1]', '[]'); + +--echo # +--echo # MDEV-16174 Assertion `0' failed in Type_handler_string_result:: +--echo # make_sort_key(uchar*, Item*, const SORT_FIELD_ATTR*, Sort_param*) +--echo # + +SET sql_mode=''; +CREATE TABLE t1 (fld varchar(16) NOT NULL); +CREATE TABLE t2 SELECT JSON_ARRAY_INSERT(fld, '$.[0]', '0') FROM t1; +SHOW CREATE TABLE t2; +DROP TABLE t1, t2; +SET sql_mode=default; + diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 6072605..27bc97f 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -1562,6 +1562,7 @@ bool Item_func_json_array_append::fix_length_and_dec() } fix_char_length_ulonglong(char_length); + maybe_null= 1; return FALSE; }