mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-11436 CREATE TABLE .. AS SELECT JSON_OBJECT truncates data.
fix_length_and_dec() didn't calculate the length of the result properly.
This commit is contained in:
@ -165,6 +165,16 @@ json_object()
|
||||
select json_object("ki", 1, "mi", "ya");
|
||||
json_object("ki", 1, "mi", "ya")
|
||||
{"ki": 1, "mi": "ya"}
|
||||
create table t1 as select json_object('id', 87, 'name', 'carrot') as f;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`f` varchar(32) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
select * from t1;
|
||||
f
|
||||
{"id": 87, "name": "carrot"}
|
||||
drop table t1;
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2");
|
||||
json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2")
|
||||
1
|
||||
|
@ -68,6 +68,10 @@ select json_remove(@j, '$.a');
|
||||
|
||||
select json_object();
|
||||
select json_object("ki", 1, "mi", "ya");
|
||||
create table t1 as select json_object('id', 87, 'name', 'carrot') as f;
|
||||
show create table t1;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2");
|
||||
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2[1]");
|
||||
|
@ -874,7 +874,7 @@ append_null:
|
||||
|
||||
void Item_func_json_array::fix_length_and_dec()
|
||||
{
|
||||
ulonglong char_length= 4;
|
||||
ulonglong char_length= 2;
|
||||
uint n_arg;
|
||||
|
||||
if (arg_count == 0)
|
||||
@ -889,7 +889,7 @@ void Item_func_json_array::fix_length_and_dec()
|
||||
return;
|
||||
|
||||
for (n_arg=0 ; n_arg < arg_count ; n_arg++)
|
||||
char_length+= args[n_arg]->max_char_length() + 2;
|
||||
char_length+= args[n_arg]->max_char_length() + 4;
|
||||
|
||||
fix_char_length_ulonglong(char_length);
|
||||
tmp_val.set_charset(collation.collation);
|
||||
|
Reference in New Issue
Block a user