Skip to content

Commit 5831851

Browse files
committed
MDEV-37835 mysqli silently trims each json_arrayagg result to modulo 64KB
Item_string was always using Type_handler_varchar, even though varchar only has 2 bytes for the length and Item_string can be longer.
1 parent 78ed44b commit 5831851

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

mysql-test/main/func_str.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5628,4 +5628,10 @@ SET sql_mode=DEFAULT;
56285628
select locate(1,2,NULL);
56295629
locate(1,2,NULL)
56305630
NULL
5631+
#
5632+
# MDEV-37835 mysqli silently trims each json_arrayagg result to modulo 64KB
5633+
#
5634+
select group_concat(v) from ( select '$a' as v union all select '$b' as v) t;
5635+
group_concat(v)
5636+
a...aaaaa,b...bbbbb
56315637
# End of 10.11 tests

mysql-test/main/func_str.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,4 +2577,12 @@ SET sql_mode=DEFAULT;
25772577
--echo #
25782578
select locate(1,2,NULL);
25792579

2580+
--echo #
2581+
--echo # MDEV-37835 mysqli silently trims each json_arrayagg result to modulo 64KB
2582+
--echo #
2583+
let $a=`select repeat('a', 65540)`;
2584+
let $b=`select repeat('b', 65540)`;
2585+
replace_regex /a{65535}/a.../ /b{65535}/b.../;
2586+
evalp select group_concat(v) from ( select '$a' as v union all select '$b' as v) t;
2587+
25802588
--echo # End of 10.11 tests

sql/item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4896,7 +4896,7 @@ class Item_string :public Item_literal
48964896
}
48974897
int save_in_field(Field *field, bool no_conversions) override;
48984898
const Type_handler *type_handler() const override
4899-
{ return &type_handler_varchar; }
4899+
{ return Type_handler::string_type_handler(max_length); }
49004900
Item *clone_item(THD *thd) const override;
49014901
Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs) override
49024902
{

0 commit comments

Comments
 (0)