List:Internals« Previous MessageNext Message »
From:sinisa Date:March 26 2004 3:01pm
Subject:bk commit into 4.0 tree (Sinisa:1.1744)
View as plain text  
Below is the list of changes that have just been committed into a local
4.0 repository of Sinisa. When Sinisa 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.1744 04/03/26 17:01:13 Sinisa@stripped +3 -0
  order_by.result:
    result of the test case for FORCE INDEX on ORDER BY
  order_by.test:
    test case for FORCE INDEX on ORDER BY
  sql_select.cc:
    Changing behaviour that MySQL server takes FORCE INDEX clause into account when optimising ORDER BY clause

  mysql-test/r/order_by.result
    1.23 04/03/26 17:00:40 Sinisa@stripped +8 -0
    result of the test case for FORCE INDEX on ORDER BY

  mysql-test/t/order_by.test
    1.15 04/03/26 17:00:28 Sinisa@stripped +12 -1
    test case for FORCE INDEX on ORDER BY

  sql/sql_select.cc
    1.278 04/03/26 16:59:33 Sinisa@stripped +12 -2
    Changing behaviour that MySQL server takes FORCE INDEX clause into account when optimising ORDER BY clause

# 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:	Sinisa
# Host:	sinisa.nasamreza.org
# Root:	/mnt/work/mysql-4.0

--- 1.277/sql/sql_select.cc	Thu Mar 11 22:24:31 2004
+++ 1.278/sql/sql_select.cc	Fri Mar 26 16:59:33 2004
@@ -6021,7 +6021,7 @@
     /* check if we can use a key to resolve the group */
     /* Tables using JT_NEXT are handled here */
     uint nr;
-    key_map keys=usable_keys;
+    key_map keys_to_use=~0,keys=usable_keys;
 
     /*
       If not used with LIMIT, only use keys if the whole query can be
@@ -6029,7 +6029,17 @@
       retrieving all rows through an index.
     */
     if (select_limit >= table->file->records)
-      keys&= (table->used_keys | table->file->keys_to_use_for_scanning());
+      keys_to_use= (table->used_keys |table->file->keys_to_use_for_scanning());
+
+    /*
+      We are adding here also the index speified in FORCE INDEX clause, 
+      if any.
+      This is to allow users to use index in ORDER BY.
+    */
+ 
+    if (table->force_index) 
+      keys_to_use|= table->keys_in_use_for_query;
+    keys&= keys_to_use;
 
     for (nr=0; keys ; keys>>=1, nr++)
     {

--- 1.22/mysql-test/r/order_by.result	Fri Nov 28 13:36:42 2003
+++ 1.23/mysql-test/r/order_by.result	Fri Mar 26 17:00:40 2004
@@ -546,3 +546,11 @@
 SET @id=0;
 UPDATE t1 SET a=0 ORDER BY (a=@id), b;
 DROP TABLE t1;
+create table t1(id int not null auto_increment primary key, t char(12));
+explain select id,t from t1 order by id;
+table	type	possible_keys	key	key_len	ref	rows	Extra
+t1	ALL	NULL	NULL	NULL	NULL	1000	Using filesort
+explain select id,t from t1 force index (primary) order by id;
+table	type	possible_keys	key	key_len	ref	rows	Extra
+t1	index	NULL	PRIMARY	4	NULL	1000	
+drop table t1;

--- 1.14/mysql-test/t/order_by.test	Fri Nov 28 13:36:42 2003
+++ 1.15/mysql-test/t/order_by.test	Fri Mar 26 17:00:28 2004
@@ -352,4 +352,15 @@
 SET @id=0;
 UPDATE t1 SET a=0 ORDER BY (a=@id), b;
 DROP TABLE t1;
-
+create table t1(id int not null auto_increment primary key, t char(12));
+disable_query_log;
+let $1 = 1000;
+while ($1)
+ {
+  eval insert into t1(t) values ('$1'); 
+  dec $1;
+ }
+enable_query_log;
+explain select id,t from t1 order by id;
+explain select id,t from t1 force index (primary) order by id;
+drop table t1;
\ No newline at end of file
Thread
bk commit into 4.0 tree (Sinisa:1.1744)sinisa26 Mar