MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:igor Date:June 26 2007 5:44am
Subject:bk commit into 5.0 tree (igor:1.2502) BUG#29087
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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-06-25 22:44:22-07:00, igor@stripped +3 -0
  Fixed bug #29087. This bug manifested itself for queries that performed
  a lookup into a BINARY index by a key ended with spaces. It caused
  an assertion abort for a debug version and wrong results for non-debug
  versions.
  
  The problem occurred because the function _mi_pack_key stripped off 
  the trailing spaces from binary search keys while the function _mi_make_key
  did not do it when keys were inserted into the index.
  
  Now the function _mi_pack_key does not remove the trailing spaces from
  search keys if they are of the binary type.

  myisam/mi_key.c@stripped, 2007-06-25 22:44:19-07:00, igor@stripped +6 -6
    Fixed bug #29087. This bug manifested itself for queries that performed
    a lookup into a BINARY index by a key ended with spaces. It caused
    an assertion abort for a debug version and wrong results for non-debug
    versions.
    
    The problem occurred because the function _mi_pack_key stripped off 
    the trailing spaces from binary search keys while the function _mi_make_key
    did not do it when keys were inserted into the index.
    
    Now the function _mi_pack_key does not remove the trailing spaces from
    search keys if they are of the binary type.

  mysql-test/r/binary.result@stripped, 2007-06-25 22:44:19-07:00, igor@stripped +38 -0
    Added a test case for bug #29087.

  mysql-test/t/binary.test@stripped, 2007-06-25 22:44:19-07:00, igor@stripped +38 -0
    Added a test case for bug #29087.

# 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:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/dev-opt/mysql-5.0-opt-bug29087

--- 1.55/myisam/mi_key.c	2007-06-25 22:44:27 -07:00
+++ 1.56/myisam/mi_key.c	2007-06-25 22:44:27 -07:00
@@ -252,15 +252,15 @@
     if (keyseg->flag & HA_SPACE_PACK)
     {
       uchar *end=pos+length;
-      if (type != HA_KEYTYPE_NUM)
-      {
-	while (end > pos && end[-1] == ' ')
-	  end--;
-      }
-      else
+      if (type == HA_KEYTYPE_NUM)
       {
 	while (pos < end && pos[0] == ' ')
 	  pos++;
+      }
+      else if (type != HA_KEYTYPE_BINARY)
+      {
+	while (end > pos && end[-1] == ' ')
+	  end--;
       }
       k_length-=length;
       length=(uint) (end-pos);

--- 1.22/mysql-test/r/binary.result	2007-06-25 22:44:27 -07:00
+++ 1.23/mysql-test/r/binary.result	2007-06-25 22:44:27 -07:00
@@ -160,3 +160,41 @@
 62000000000000000000
 62200000000000000000
 drop table t1;
+CREATE TABLE t1 (
+a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 
+index idx(a)
+);
+INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575');
+INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
+INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707');
+SELECT hex(a) FROM t1 order by a;
+hex(a)
+1F9480179366F2BF567E1C4B964C1EF029080707
+1F9480179366F2BF567E1C4B964C1EF029082020
+1F9480179366F2BF567E1C4B964C1EF029087575
+EXPLAIN SELECT hex(a) FROM t1 order by a;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	idx	20	NULL	3	Using index
+SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
+hex(a)
+1F9480179366F2BF567E1C4B964C1EF029082020
+EXPLAIN
+SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ref	idx	idx	20	const	1	Using where; Using index
+SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908');
+hex(a)
+DROP TABLE t1;
+CREATE TABLE t1 (
+id numeric(20) NOT NULL,
+lang varchar(8) NOT NULL,
+msg varchar(32) NOT NULL,
+PRIMARY KEY (id,lang)
+);
+INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz');
+INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx');
+INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy');
+SELECT * FROM t1 WHERE id=32;
+id	lang	msg
+32	en	yyyyyyy
+DROP TABLE t1;

--- 1.17/mysql-test/t/binary.test	2007-06-25 22:44:27 -07:00
+++ 1.18/mysql-test/t/binary.test	2007-06-25 22:44:27 -07:00
@@ -101,3 +101,41 @@
 insert into t1 values ('b'),('b ');
 select hex(col1) from t1;
 drop table t1;
+
+#
+# Bug #29087: assertion abort for a search in a BINARY non-nullable index 
+#             by a key with trailing spaces 
+#
+
+CREATE TABLE t1 (
+  a binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 
+  index idx(a)
+);
+INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029087575');
+INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
+INSERT INTO t1 SET a=unhex('1F9480179366F2BF567E1C4B964C1EF029080707');
+
+SELECT hex(a) FROM t1 order by a;
+EXPLAIN SELECT hex(a) FROM t1 order by a;
+
+SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
+EXPLAIN
+SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF029082020');
+
+SELECT hex(a) from t1 WHERE a=unhex('1F9480179366F2BF567E1C4B964C1EF02908');
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (
+  id numeric(20) NOT NULL,
+  lang varchar(8) NOT NULL,
+  msg varchar(32) NOT NULL,
+  PRIMARY KEY (id,lang)
+);
+INSERT INTO t1 VALUES (33, 'en', 'zzzzzzz');
+INSERT INTO t1 VALUES (31, 'en', 'xxxxxxx');
+INSERT INTO t1 VALUES (32, 'en', 'yyyyyyy');
+SELECT * FROM t1 WHERE id=32;
+
+DROP TABLE t1;
+
Thread
bk commit into 5.0 tree (igor:1.2502) BUG#29087igor26 Jun
  • Re: bk commit into 5.0 tree (igor:1.2502) BUG#29087Sergei Golubchik27 Jun