1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-33942 View cuts off the end of string with the utf8 character set in INSERT function

Item_func_insert::fix_length_and_dec() incorrectly calculated max_length
when its collation.collation evaluated to my_charset_bin.

Fixing the code to calculate max_length in terms of octets rather
than in terms of characters when collation.collation is my_charset_bin.
This commit is contained in:
Alexander Barkov
2024-11-05 11:16:10 +04:00
parent c2bf1d4781
commit eb41c1171e
3 changed files with 27 additions and 2 deletions

View File

@@ -5344,5 +5344,16 @@ left('hello', 4294967295)
hello hello
drop view v1; drop view v1;
# #
# MDEV-33942 View cuts off the end of string with the utf8 character set in INSERT function
#
SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20));
HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20))
D120D18E
CREATE VIEW v1 AS SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20));
SELECT * FROM v1;
HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20))
D120D18E
DROP VIEW v1;
#
# End of 10.6 tests # End of 10.6 tests
# #

View File

@@ -2393,6 +2393,16 @@ create view v1 as select left('hello', 4294967295);
select * from v1; select * from v1;
drop view v1; drop view v1;
--echo #
--echo # MDEV-33942 View cuts off the end of string with the utf8 character set in INSERT function
--echo #
SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20));
CREATE VIEW v1 AS SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20));
SELECT * FROM v1;
DROP VIEW v1;
--echo # --echo #
--echo # End of 10.6 tests --echo # End of 10.6 tests
--echo # --echo #

View File

@@ -1562,8 +1562,12 @@ bool Item_func_insert::fix_length_and_dec()
// Handle character set for args[0] and args[3]. // Handle character set for args[0] and args[3].
if (agg_arg_charsets_for_string_result(collation, args, 2, 3)) if (agg_arg_charsets_for_string_result(collation, args, 2, 3))
return TRUE; return TRUE;
char_length= ((ulonglong) args[0]->max_char_length() + if (collation.collation == &my_charset_bin)
(ulonglong) args[3]->max_char_length()); char_length= (ulonglong) args[0]->max_length +
(ulonglong) args[3]->max_length;
else
char_length= ((ulonglong) args[0]->max_char_length() +
(ulonglong) args[3]->max_char_length());
fix_char_length_ulonglong(char_length); fix_char_length_ulonglong(char_length);
return FALSE; return FALSE;
} }