From c89c514ed32cc63b005078adced10750e26565c2 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sun, 4 Dec 2016 23:57:26 +0400 Subject: [PATCH] MDEV-11445 JSON_MERGE requires at least two arguments in MySQL, but not in MariaDB. Create_func_json_merge::create_native fixed. --- mysql-test/r/func_json.result | 2 ++ mysql-test/t/func_json.test | 2 ++ sql/item_create.cc | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index fd31a39934f..064be1cca25 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -197,6 +197,8 @@ t1 CREATE TABLE `t1` ( `json_quote('foo')` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +select json_merge('string'); +ERROR 42000: Incorrect parameter count in the call to native function 'json_merge' select json_merge('string', 123); json_merge('string', 123) ["string", 123] diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index 229adc67e09..864c5bf9d09 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -83,6 +83,8 @@ select * from t1; show create table t1; drop table t1; +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select json_merge('string'); select json_merge('string', 123); select json_type('{"k1":123, "k2":345}'); diff --git a/sql/item_create.cc b/sql/item_create.cc index fb8aaf3d8f3..ac906b93c78 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -5192,7 +5192,7 @@ Create_func_json_merge::create_native(THD *thd, LEX_STRING name, int arg_count; if (item_list == NULL || - (arg_count= item_list->elements) == 0) + (arg_count= item_list->elements) < 2) // json, json { my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str); func= NULL;