mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
InnoDB: Fixed bugs in the padding and trimming of trailing spaces
that affected the UCS2 character set. (Bug #7350) innobase/data/data0type.c: Added dtype_get_charset_coll_noninline() innobase/include/data0type.h: Added dtype_get_charset_coll_noninline() innobase/include/row0mysql.h: Added charset field to mysql_row_templ_struct. innobase/include/row0mysql.ic: row_mysql_store_col_in_innobase_format(): When removing trailing spaces, treat the UCS2 character set properly. innobase/rem/rem0cmp.c: cmp_whole_field(): Do not remove trailing 0x20 bytes, as innobase_mysql_cmp() implicitly pads the strings with trailing spaces as necessary. innobase/row/row0sel.c: row_sel_field_store_in_mysql_format(): Do not pad with 0x20 bytes. row_sel_store_mysql_rec(): Pad VARCHARs with trailing spaces (0x20, or 0x0020 in UCS2). sql/ha_innodb.cc: build_template(): Initialize templ->charset
This commit is contained in:
@ -91,12 +91,33 @@ row_mysql_store_col_in_innobase_format(
|
||||
}
|
||||
} else if (type == DATA_VARCHAR || type == DATA_VARMYSQL
|
||||
|| type == DATA_BINARY) {
|
||||
/* Remove trailing spaces. */
|
||||
|
||||
/* Handle UCS2 strings differently. As no new
|
||||
collations will be introduced in 4.1, we hardcode the
|
||||
charset-collation codes here. In 5.0, the logic will
|
||||
be based on mbminlen. */
|
||||
ulint cset = dtype_get_charset_coll(
|
||||
dtype_get_prtype(dfield_get_type(dfield)));
|
||||
ptr = row_mysql_read_var_ref(&col_len, mysql_data);
|
||||
|
||||
/* Remove trailing spaces */
|
||||
while (col_len > 0 && ptr[col_len - 1] == ' ') {
|
||||
col_len--;
|
||||
}
|
||||
if (cset == 35/*ucs2_general_ci*/
|
||||
|| cset == 90/*ucs2_bin*/
|
||||
|| (cset >= 128/*ucs2_unicode_ci*/
|
||||
&& cset <= 144/*ucs2_persian_ci*/)) {
|
||||
/* space=0x0020 */
|
||||
/* Trim "half-chars", just in case. */
|
||||
col_len &= ~1;
|
||||
|
||||
while (col_len >= 2 && ptr[col_len - 2] == 0x00
|
||||
&& ptr[col_len - 1] == 0x20) {
|
||||
col_len -= 2;
|
||||
}
|
||||
} else {
|
||||
/* space=0x20 */
|
||||
while (col_len > 0 && ptr[col_len - 1] == 0x20) {
|
||||
col_len--;
|
||||
}
|
||||
}
|
||||
} else if (type == DATA_BLOB) {
|
||||
ptr = row_mysql_read_blob_ref(&col_len, mysql_data, col_len);
|
||||
}
|
||||
|
Reference in New Issue
Block a user