MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Alex Ivanov Date:October 28 2005 1:16pm
Subject:bk commit into 4.1 tree (aivanov:1.2451) BUG#10511
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of alexi. When alexi does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2451 05/10/28 17:16:22 aivanov@stripped +1 -0
  Fix BUG#10511: Wrong padding of UCS2 CHAR columns in
   ON UPDATE CASCADE

  innobase/row/row0ins.c
    1.55 05/10/28 17:15:52 aivanov@stripped +38 -8
    Patch from Marko is applied

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	aivanov
# Host:	mysql.creware.com
# Root:	/home/alexi/dev/mysql-4.1-10511

--- 1.54/innobase/row/row0ins.c	2005-04-18 13:17:09 +04:00
+++ 1.55/innobase/row/row0ins.c	2005-10-28 17:15:52 +04:00
@@ -522,20 +522,50 @@
 				    && ufield->new_val.len
 				       < dtype_get_fixed_size(type)) {
 
+                                        ulint cset;
+
 				        ufield->new_val.data =
 						mem_heap_alloc(heap,
 						  dtype_get_fixed_size(type));
 					ufield->new_val.len = 
 						dtype_get_fixed_size(type);
-					ut_a(dtype_get_pad_char(type)
-					     != ULINT_UNDEFINED);
 
-					memset(ufield->new_val.data,
-					       (byte)dtype_get_pad_char(type),
-					       dtype_get_fixed_size(type));
-					ut_memcpy(ufield->new_val.data,
-						parent_ufield->new_val.data,
-						parent_ufield->new_val.len);
+                                        /* 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 is based on
+                                        mbminlen. */
+                                        cset = dtype_get_charset_coll(
+                                          dtype_get_prtype(type));
+
+                                        if (cset == 35/*ucs2_general_ci*/
+                                            || cset == 90/*ucs2_bin*/
+                                            || (cset >= 128/*ucs2_unicode_ci*/
+                                          && cset <= 144
+                                          /*ucs2_persian_ci*/)) {
+                                          /* space=0x0020 */
+                                          ulint i;
+                                          for (i = 0;
+                                               i < ufield->new_val.len;
+                                               i += 2) {
+                                            mach_write_to_2(((byte*)
+                                              ufield->new_val.data)
+                                              + i, 0x0020);
+                                          }
+                                        } else {
+                                          ut_a(dtype_get_pad_char(type)
+                                              != ULINT_UNDEFINED);
+
+                                          memset(ufield->new_val.data,
+                                              (byte)dtype_get_pad_char(
+                                                type),
+                                              ufield->new_val.len);
+                                        }
+
+                                        memcpy(ufield->new_val.data,
+                                          parent_ufield->new_val.data,
+                                          parent_ufield->new_val.len);
 				}
 
 				ufield->extern_storage = FALSE;
Thread
bk commit into 4.1 tree (aivanov:1.2451) BUG#10511Alex Ivanov28 Oct