Skip to content

Commit c89c514

Browse files
author
Alexey Botchkov
committed
MDEV-11445 JSON_MERGE requires at least two arguments in MySQL, but not in MariaDB.
Create_func_json_merge::create_native fixed.
1 parent 12897a5 commit c89c514

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

mysql-test/r/func_json.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ t1 CREATE TABLE `t1` (
197197
`json_quote('foo')` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL
198198
) ENGINE=MyISAM DEFAULT CHARSET=latin1
199199
drop table t1;
200+
select json_merge('string');
201+
ERROR 42000: Incorrect parameter count in the call to native function 'json_merge'
200202
select json_merge('string', 123);
201203
json_merge('string', 123)
202204
["string", 123]

mysql-test/t/func_json.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ select * from t1;
8383
show create table t1;
8484
drop table t1;
8585

86+
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
87+
select json_merge('string');
8688
select json_merge('string', 123);
8789

8890
select json_type('{"k1":123, "k2":345}');

sql/item_create.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5192,7 +5192,7 @@ Create_func_json_merge::create_native(THD *thd, LEX_STRING name,
51925192
int arg_count;
51935193

51945194
if (item_list == NULL ||
5195-
(arg_count= item_list->elements) == 0)
5195+
(arg_count= item_list->elements) < 2) // json, json
51965196
{
51975197
my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
51985198
func= NULL;

0 commit comments

Comments
 (0)