summaryrefslogtreecommitdiff
path: root/innobase/include/row0mysql.ic
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/include/row0mysql.ic')
-rw-r--r--innobase/include/row0mysql.ic31
1 files changed, 26 insertions, 5 deletions
diff --git a/innobase/include/row0mysql.ic b/innobase/include/row0mysql.ic
index 4ecd66e06ec..fc922b52d0a 100644
--- a/innobase/include/row0mysql.ic
+++ b/innobase/include/row0mysql.ic
@@ -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);
}