List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:April 10 2007 10:40pm
Subject:bk commit into 4.1 tree (svoj:1.2630) BUG#24342
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of svoj. When svoj 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-04-11 01:40:35+05:00, svoj@stripped +5 -0
  BUG#24342 - Incorrect results with query over MERGE table
  MERGE engine may return incorrect values when several representations
  of equal keys are present in the index. For example "groß" and "gross"
  or "gross" and "gross " (trailing space), which are considered equal,
  but have different lengths.
  
  The problem was that key length was not recalculated after key lookup.
  
  Only MERGE engine is affected.

  myisam/mi_rkey.c@stripped, 2007-04-11 01:40:34+05:00, svoj@stripped +2 -1
    info->lastkey gets rewritten by mi_search. Later we recalculate found lastkey
    length. This is done to make sure that mi_rnext_same gets true, found (not
    searched) lastkey length. Searched and found key lengths may be different,
    for example in case searched key is "groß" and found is "gross" or in case
    a key has trailing spaces.
    
    Unfortunately we recalculate found lastkey length only for first
    underlying table. To recalculate found key length for non-first underlying
    table we need to know how much key segments were used to create this key.
    
    When mi_rkey is called for first underlying table of a merge table, store
    offset to last used key segment.
    
    Restore last_used_keyseg variable when mi_rkey is called for non-first
    underlying table.

  myisam/myisamdef.h@stripped, 2007-04-11 01:40:34+05:00, svoj@stripped +1 -0
    Added last_used_keyseg variable to MI_INFO. It is used by merge engine to calculate
    key length.

  myisammrg/myrg_rkey.c@stripped, 2007-04-11 01:40:34+05:00, svoj@stripped +4 -0
    Pass last used key segment returned by first table key read to other
    table key reads.

  mysql-test/r/merge.result@stripped, 2007-04-11 01:40:34+05:00, svoj@stripped +11 -0
    A test case for bug#24342.

  mysql-test/t/merge.test@stripped, 2007-04-11 01:40:34+05:00, svoj@stripped +13 -0
    A test case for bug#24342.

# 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:	svoj
# Host:	april.(none)
# Root:	/home/svoj/devel/mysql/BUG24342/mysql-4.1-engines

--- 1.23/myisam/mi_rkey.c	2007-04-11 01:40:38 +05:00
+++ 1.24/myisam/mi_rkey.c	2007-04-11 01:40:38 +05:00
@@ -50,7 +50,7 @@ int mi_rkey(MI_INFO *info, byte *buf, in
     key_buff=info->lastkey+info->s->base.max_key_length;
     pack_key_length= key_len;
     bmove(key_buff,key,key_len);
-    last_used_keyseg= 0;
+    last_used_keyseg= info->s->keyinfo[inx].seg + info->last_used_keyseg;
   }
   else
   {
@@ -62,6 +62,7 @@ int mi_rkey(MI_INFO *info, byte *buf, in
 				 key_len, &last_used_keyseg);
     /* Save packed_key_length for use by the MERGE engine. */
     info->pack_key_length= pack_key_length;
+    info->last_used_keyseg= last_used_keyseg - info->s->keyinfo[inx].seg;
     DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE, keyinfo->seg,
 				     key_buff, pack_key_length););
   }

--- 1.82/myisam/myisamdef.h	2007-04-11 01:40:38 +05:00
+++ 1.83/myisam/myisamdef.h	2007-04-11 01:40:38 +05:00
@@ -263,6 +263,7 @@ struct st_myisam_info {
   enum ha_rkey_function last_key_func;  /* CONTAIN, OVERLAP, etc */
   uint  save_lastkey_length;
   uint  pack_key_length;                /* For MYISAMMRG */
+  uint16 last_used_keyseg;              /* For MyISAMMRG */
   int	errkey;				/* Got last error on this key */
   int   lock_type;			/* How database was locked */
   int   tmp_lock_type;			/* When locked by readinfo */

--- 1.46/mysql-test/r/merge.result	2007-04-11 01:40:38 +05:00
+++ 1.47/mysql-test/r/merge.result	2007-04-11 01:40:38 +05:00
@@ -819,3 +819,14 @@ ALTER TABLE m1 ENGINE=MERGE UNION=(t1);
 SELECT * FROM m1;
 c1	c2	c3	c4	c5	c6	c7	c8	c9
 DROP TABLE t1, m1;
+CREATE TABLE t1 (a VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_german2_ci,
+b INT, INDEX(a,b));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+ALTER TABLE t3 ENGINE=MERGE UNION=(t1,t2);
+INSERT INTO t1 VALUES ('ss',1);
+INSERT INTO t2 VALUES ('ss',2),(0xDF,2);
+SELECT COUNT(*) FROM t3 WHERE a=0xDF AND b=2;
+COUNT(*)
+2
+DROP TABLE t1,t2,t3;

--- 1.43/mysql-test/t/merge.test	2007-04-11 01:40:38 +05:00
+++ 1.44/mysql-test/t/merge.test	2007-04-11 01:40:38 +05:00
@@ -454,4 +454,17 @@ ALTER TABLE m1 ENGINE=MERGE UNION=(t1);
 SELECT * FROM m1;
 DROP TABLE t1, m1;
 
+#
+# BUG#24342 - Incorrect results with query over MERGE table
+#
+CREATE TABLE t1 (a VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_german2_ci,
+                 b INT, INDEX(a,b));
+CREATE TABLE t2 LIKE t1;
+CREATE TABLE t3 LIKE t1;
+ALTER TABLE t3 ENGINE=MERGE UNION=(t1,t2);
+INSERT INTO t1 VALUES ('ss',1);
+INSERT INTO t2 VALUES ('ss',2),(0xDF,2);
+SELECT COUNT(*) FROM t3 WHERE a=0xDF AND b=2;
+DROP TABLE t1,t2,t3;
+
 # End of 4.1 tests

--- 1.17/myisammrg/myrg_rkey.c	2007-04-11 01:40:38 +05:00
+++ 1.18/myisammrg/myrg_rkey.c	2007-04-11 01:40:38 +05:00
@@ -41,12 +41,14 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,
 {
   byte *key_buff;
   uint pack_key_length;
+  uint16 last_used_keyseg;
   MYRG_TABLE *table;
   MI_INFO *mi;
   int err;
   DBUG_ENTER("myrg_rkey");
   LINT_INIT(key_buff);
   LINT_INIT(pack_key_length);
+  LINT_INIT(last_used_keyseg);
 
   if (_myrg_init_queue(info,inx,search_flag))
     DBUG_RETURN(my_errno);
@@ -61,10 +63,12 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,
       /* Get the saved packed key and packed key length. */
       key_buff=(byte*) mi->lastkey+mi->s->base.max_key_length;
       pack_key_length=mi->pack_key_length;
+      last_used_keyseg= mi->last_used_keyseg;
     }
     else
     {
       mi->once_flags|= USE_PACKED_KEYS;
+      mi->last_used_keyseg= last_used_keyseg;
       err=mi_rkey(mi,0,inx,key_buff,pack_key_length,search_flag);
     }
     info->last_used_table=table+1;
Thread
bk commit into 4.1 tree (svoj:1.2630) BUG#24342Sergey Vojtovich10 Apr