List:Internals« Previous MessageNext Message »
From:eugene Date:November 10 2005 9:59pm
Subject:bk commit into 5.0 tree (evgen:1.1974) BUG#13293
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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.1974 05/11/10 23:59:35 evgen@stripped +3 -0
  Fix bug#13293 Wrongly used index results in endless loop.
  
  Loose index scan using only second part of multipart index was choosen, which
  results in creating wrong keys and endless loop.
  
  get_best_group_min_max() now checks whether all keyparts from 1 to 
  max keypart used are used.

  mysql-test/t/select.test
    1.91 05/11/10 23:54:37 evgen@stripped +10 -0
    Test case for bug #13293 Wrongly used index results in endless loop.

  mysql-test/r/select.result
    1.111 05/11/10 23:52:52 evgen@stripped +10 -0
    Test case for bug #13293 Wrongly used index results in endless loop.

  sql/opt_range.cc
    1.197 05/11/10 23:51:07 evgen@stripped +9 -0
    Fix bug #13293 Wrongly used index results in endless loop.
    get_best_group_min_max() now allows loose index scan only if all keyparts from 1 to
max keypart used are used.

# 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:	evgen
# Host:	moonbone.local
# Root:	/work/13293-bug-5.0-mysql

--- 1.196/sql/opt_range.cc	2005-11-03 17:42:03 +03:00
+++ 1.197/sql/opt_range.cc	2005-11-10 23:51:07 +03:00
@@ -7188,6 +7188,7 @@
     */
     else if (join->select_distinct)
     {
+      ulonglong all_parts, cur_parts;
       select_items_it.rewind();
       cur_used_key_parts.clear_all();
       while ((item= select_items_it++))
@@ -7208,6 +7209,14 @@
         cur_used_key_parts.set_bit(key_part_nr);
         ++cur_group_key_parts;
       }
+      /* Check if all key parts from 1 to max keypart used are used. */
+      all_parts= 1;
+      cur_parts= cur_used_key_parts.to_ulonglong() >> 1;
+      while (all_parts <= cur_parts)
+        all_parts<<= 1;
+      all_parts--;
+      if (all_parts != cur_parts)
+        DBUG_RETURN(NULL);
     }
     else
       DBUG_ASSERT(FALSE);

--- 1.110/mysql-test/r/select.result	2005-11-03 13:55:07 +03:00
+++ 1.111/mysql-test/r/select.result	2005-11-10 23:52:52 +03:00
@@ -3241,3 +3241,13 @@
 Warnings:
 Warning	1292	Incorrect date value: '2005-09-3a' for column 'f2' at row 1
 drop table t1;
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	index	NULL	PRIMARY	5	NULL	4	Using index; Using temporary
+explain select distinct f1, f2 from t1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	NULL	PRIMARY	5	NULL	3	Using index for group-by; Using temporary
+drop table t1;

--- 1.90/mysql-test/t/select.test	2005-11-03 13:55:07 +03:00
+++ 1.91/mysql-test/t/select.test	2005-11-10 23:54:37 +03:00
@@ -2729,3 +2729,13 @@
 select * from t1 where f2 <= '2005-09-31';
 select * from t1 where f2 <= '2005-09-3a';
 drop table t1;
+
+#
+# Bug #13293 Wrongly used index results in endless loop.
+#
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) engine=innodb;
+insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
+alter table t1 drop primary key, add primary key (f2, f1);
+explain select distinct f1 a, f1 b from t1;
+explain select distinct f1, f2 from t1;
+drop table t1;
Thread
bk commit into 5.0 tree (evgen:1.1974) BUG#13293eugene10 Nov