List:Commits« Previous MessageNext Message »
From:holyfoot Date:March 25 2007 4:25pm
Subject:bk commit into 5.1 tree (holyfoot:1.2501) BUG#27123
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of hf. When hf 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@stripped, 2007-03-25 19:25:51+05:00, holyfoot@stripped +3 -0
  Bug #27123 partition + on duplicate key update + varchar = Can't find record in
<table> 
     key_restore function didn't work as it was described in
     the description in the case of VARCHAR or BLOB fields, it
     stored the restored key in field->ptr instead of to_record.
     That produced wrong key so searching failed.

  mysql-test/r/partition.result@stripped, 2007-03-25 19:25:49+05:00, holyfoot@stripped +8 -0
    result fixed

  mysql-test/t/partition.test@stripped, 2007-03-25 19:25:49+05:00, holyfoot@stripped +10 -0
    testcase

  sql/key.cc@stripped, 2007-03-25 19:25:49+05:00, holyfoot@stripped +13 -6
    set key_part->field->ptr to the proper place in 'to_record',
    so the restored key will be placed in to_record as key_restore()
    is supposed to do

# 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:	holyfoot
# Host:	hfmain.(none)
# Root:	/home/hf/work/27123/my51-27123

--- 1.49/sql/key.cc	2007-03-25 19:25:58 +05:00
+++ 1.50/sql/key.cc	2007-03-25 19:25:58 +05:00
@@ -222,22 +222,29 @@ void key_restore(byte *to_record, byte *
     if (key_part->key_part_flag & HA_BLOB_PART)
     {
       uint blob_length= uint2korr(from_key);
+      Field_blob *field= (Field_blob *) (key_part->field);
+      char *field_ptr_orig= field->ptr;
+
+      field->move_field_offset(to_record - field->table->record[0]);
       from_key+= HA_KEY_BLOB_LENGTH;
       key_length-= HA_KEY_BLOB_LENGTH;
-      ((Field_blob*) key_part->field)->set_ptr((ulong) blob_length,
-					       (char*) from_key);
+      field->set_ptr((ulong) blob_length, (char*) from_key);
       length= key_part->length;
+      field->ptr= field_ptr_orig;
     }
     else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
     {
+      Field *field= key_part->field;
+      char *field_ptr_orig= field->ptr;
       my_bitmap_map *old_map;
+      field->move_field_offset(to_record - field->table->record[0]);
       key_length-= HA_KEY_BLOB_LENGTH;
       length= min(key_length, key_part->length);
-      old_map= dbug_tmp_use_all_columns(key_part->field->table,
-                                        key_part->field->table->write_set);
-      key_part->field->set_key_image((char *) from_key, length);
-      dbug_tmp_restore_column_map(key_part->field->table->write_set, old_map);
+      old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set);
+      field->set_key_image((char *) from_key, length);
+      dbug_tmp_restore_column_map(field->table->write_set, old_map);
       from_key+= HA_KEY_BLOB_LENGTH;
+      field->ptr= field_ptr_orig;
     }
     else
     {

--- 1.58/mysql-test/r/partition.result	2007-03-25 19:25:58 +05:00
+++ 1.59/mysql-test/r/partition.result	2007-03-25 19:25:58 +05:00
@@ -1219,4 +1219,12 @@ SELECT t2.id FROM t2 WHERE t2.id IN (SEL
 id
 22589
 drop table t1, t2;
+create table t1 (c1 varchar(255),c2 tinyint,primary key(c1))
+partition by key (c1) partitions 10 ;
+insert into t1 values ('aaa','1') on duplicate key update c2 = c2 + 1;
+insert into t1 values ('aaa','1') on duplicate key update c2 = c2 + 1;
+select * from t1;
+c1	c2
+aaa	2
+drop table t1;
 End of 5.1 tests

--- 1.52/mysql-test/t/partition.test	2007-03-25 19:25:58 +05:00
+++ 1.53/mysql-test/t/partition.test	2007-03-25 19:25:58 +05:00
@@ -1463,4 +1463,14 @@ SELECT t2.id FROM t2 WHERE t2.id IN (SEL
 
 drop table t1, t2;
 
+#
+# Bug #27123 partition + on duplicate key update + varchar = Can't find record in
<table> 
+#
+create table t1 (c1 varchar(255),c2 tinyint,primary key(c1))
+   partition by key (c1) partitions 10 ;
+insert into t1 values ('aaa','1') on duplicate key update c2 = c2 + 1;
+insert into t1 values ('aaa','1') on duplicate key update c2 = c2 + 1;
+select * from t1;
+drop table t1;
+
 --echo End of 5.1 tests
Thread
bk commit into 5.1 tree (holyfoot:1.2501) BUG#27123holyfoot25 Mar