Skip to content

Commit 0e63023

Browse files
abarkovgrooverdan
authored andcommitted
Merge branch 10.2 into 10.3
2 parents a950086 + 03c3dc6 commit 0e63023

File tree

7 files changed

+129
-0
lines changed

7 files changed

+129
-0
lines changed

mysql-test/main/ctype_utf32.result

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,5 +2890,28 @@ HEX(c1)
28902890
0000006100000063
28912891
DROP TABLE t1;
28922892
#
2893+
# MDEV-23210 Assertion `(length % 4) == 0' failed in my_lengthsp_utf32 on ALTER TABLE, SELECT and INSERT
2894+
#
2895+
CREATE TABLE t1 (a CHAR(1));
2896+
SET COLLATION_CONNECTION=utf32_general_ci, CHARACTER_SET_CLIENT=binary;
2897+
ALTER TABLE t1 CHANGE a a ENUM('a','a') CHARACTER SET utf32;
2898+
ERROR HY000: Column 'a' has duplicated value 'a' in ENUM
2899+
ALTER TABLE t1 CHANGE a a ENUM('aaa') CHARACTER SET utf32;
2900+
ERROR HY000: Invalid utf32 character string: '\x00aaa'
2901+
ALTER TABLE t1 CHANGE a a ENUM('aa') CHARACTER SET utf32;
2902+
SHOW CREATE TABLE t1;
2903+
Table Create Table
2904+
t1 CREATE TABLE `t1` (
2905+
`a` enum('慡') CHARACTER SET utf32 DEFAULT NULL
2906+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2907+
ALTER TABLE t1 CHANGE a a ENUM('a','b') CHARACTER SET utf32;
2908+
SHOW CREATE TABLE t1;
2909+
Table Create Table
2910+
t1 CREATE TABLE `t1` (
2911+
`a` enum('a','b') CHARACTER SET utf32 DEFAULT NULL
2912+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
2913+
DROP TABLE t1;
2914+
SET NAMES utf8;
2915+
#
28932916
# End of 10.2 tests
28942917
#

mysql-test/main/ctype_utf32.test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,25 @@ INSERT INTO t1 (c1) VALUES (1),(2),(3);
10481048
SELECT HEX(c1) FROM t1 ORDER BY c1;
10491049
DROP TABLE t1;
10501050

1051+
1052+
--echo #
1053+
--echo # MDEV-23210 Assertion `(length % 4) == 0' failed in my_lengthsp_utf32 on ALTER TABLE, SELECT and INSERT
1054+
--echo #
1055+
1056+
CREATE TABLE t1 (a CHAR(1));
1057+
SET COLLATION_CONNECTION=utf32_general_ci, CHARACTER_SET_CLIENT=binary;
1058+
--error ER_DUPLICATED_VALUE_IN_TYPE
1059+
ALTER TABLE t1 CHANGE a a ENUM('a','a') CHARACTER SET utf32;
1060+
--error ER_INVALID_CHARACTER_STRING
1061+
ALTER TABLE t1 CHANGE a a ENUM('aaa') CHARACTER SET utf32;
1062+
ALTER TABLE t1 CHANGE a a ENUM('aa') CHARACTER SET utf32;
1063+
SHOW CREATE TABLE t1;
1064+
ALTER TABLE t1 CHANGE a a ENUM('a','b') CHARACTER SET utf32;
1065+
SHOW CREATE TABLE t1;
1066+
DROP TABLE t1;
1067+
SET NAMES utf8;
1068+
1069+
10511070
--echo #
10521071
--echo # End of 10.2 tests
10531072
--echo #

mysql-test/main/ctype_utf32_uca.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7941,5 +7941,20 @@ EXECUTE s;
79417941
DEALLOCATE PREPARE s;
79427942
SET NAMES utf8;
79437943
#
7944+
# MDEV-23210 Assertion `(length % 4) == 0' failed in my_lengthsp_utf32 on ALTER TABLE, SELECT and INSERT
7945+
#
7946+
CREATE TABLE t1 (a CHAR(1));
7947+
SET COLLATION_CONNECTION=utf32_myanmar_ci, CHARACTER_SET_CLIENT=binary;
7948+
ALTER TABLE t1 CHANGE a a ENUM('a','a') CHARACTER SET utf32;
7949+
ERROR HY000: Column 'a' has duplicated value 'a' in ENUM
7950+
ALTER TABLE t1 CHANGE a a ENUM('a','b') CHARACTER SET utf32;
7951+
SHOW CREATE TABLE t1;
7952+
Table Create Table
7953+
t1 CREATE TABLE `t1` (
7954+
`a` enum('a','b') CHARACTER SET utf32 DEFAULT NULL
7955+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
7956+
DROP TABLE t1;
7957+
SET NAMES utf8;
7958+
#
79447959
# End of 10.2 tests
79457960
#

mysql-test/main/ctype_utf32_uca.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,19 @@ EXECUTE s;
290290
DEALLOCATE PREPARE s;
291291
SET NAMES utf8;
292292

293+
--echo #
294+
--echo # MDEV-23210 Assertion `(length % 4) == 0' failed in my_lengthsp_utf32 on ALTER TABLE, SELECT and INSERT
295+
--echo #
296+
297+
CREATE TABLE t1 (a CHAR(1));
298+
SET COLLATION_CONNECTION=utf32_myanmar_ci, CHARACTER_SET_CLIENT=binary;
299+
--error ER_DUPLICATED_VALUE_IN_TYPE
300+
ALTER TABLE t1 CHANGE a a ENUM('a','a') CHARACTER SET utf32;
301+
ALTER TABLE t1 CHANGE a a ENUM('a','b') CHARACTER SET utf32;
302+
SHOW CREATE TABLE t1;
303+
DROP TABLE t1;
304+
SET NAMES utf8;
305+
293306

294307
--echo #
295308
--echo # End of 10.2 tests

mysql-test/suite/gcol/inc/gcol_supported_sql_funcs_main.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# Change Date: #
1313
# Change: #
1414
################################################################################
15+
16+
--source include/have_des.inc
17+
1518
set time_zone="+03:00";
1619
--echo #
1720
--echo # NUMERIC FUNCTIONS

sql/sql_class.cc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,58 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
23062306
}
23072307

23082308

2309+
/*
2310+
Reinterpret a binary string to a character string
2311+
2312+
@param[OUT] to The result will be written here,
2313+
either the original string as is,
2314+
or a newly alloced fixed string with
2315+
some zero bytes prepended.
2316+
@param cs The destination character set
2317+
@param str The binary string
2318+
@param length The length of the binary string
2319+
2320+
@return false on success
2321+
@return true on error
2322+
*/
2323+
2324+
bool THD::reinterpret_string_from_binary(LEX_CSTRING *to, CHARSET_INFO *cs,
2325+
const char *str, size_t length)
2326+
{
2327+
/*
2328+
When reinterpreting from binary to tricky character sets like
2329+
UCS2, UTF16, UTF32, we may need to prepend some zero bytes.
2330+
This is possible in scenarios like this:
2331+
SET COLLATION_CONNECTION=utf32_general_ci, CHARACTER_SET_CLIENT=binary;
2332+
This code is similar to String::copy_aligned().
2333+
*/
2334+
size_t incomplete= length % cs->mbminlen; // Bytes in an incomplete character
2335+
if (incomplete)
2336+
{
2337+
size_t zeros= cs->mbminlen - incomplete;
2338+
size_t aligned_length= zeros + length;
2339+
char *dst= (char*) alloc(aligned_length + 1);
2340+
if (!dst)
2341+
{
2342+
to->str= NULL; // Safety
2343+
to->length= 0;
2344+
return true;
2345+
}
2346+
bzero(dst, zeros);
2347+
memcpy(dst + zeros, str, length);
2348+
dst[aligned_length]= '\0';
2349+
to->str= dst;
2350+
to->length= aligned_length;
2351+
}
2352+
else
2353+
{
2354+
to->str= str;
2355+
to->length= length;
2356+
}
2357+
return check_string_for_wellformedness(to->str, to->length, cs);
2358+
}
2359+
2360+
23092361
/*
23102362
Convert a string between two character sets.
23112363
dstcs and srccs cannot be &my_charset_bin.

sql/sql_class.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3717,6 +3717,8 @@ class THD :public Statement,
37173717
bool convert_string(LEX_STRING *to, CHARSET_INFO *to_cs,
37183718
const char *from, size_t from_length,
37193719
CHARSET_INFO *from_cs);
3720+
bool reinterpret_string_from_binary(LEX_CSTRING *to, CHARSET_INFO *to_cs,
3721+
const char *from, size_t from_length);
37203722
bool convert_string(LEX_CSTRING *to, CHARSET_INFO *to_cs,
37213723
const char *from, size_t from_length,
37223724
CHARSET_INFO *from_cs)
@@ -3733,6 +3735,8 @@ class THD :public Statement,
37333735
{
37343736
if (!simple_copy_is_possible)
37353737
return unlikely(convert_string(to, tocs, from->str, from->length, fromcs));
3738+
if (fromcs == &my_charset_bin)
3739+
return reinterpret_string_from_binary(to, tocs, from->str, from->length);
37363740
*to= *from;
37373741
return false;
37383742
}

0 commit comments

Comments
 (0)