[Commits] Rev 2876: BUG#665669: Result differences on query re-execution in file:///home/psergey/dev2/5.3/

Sergey Petrunya psergey at askmonty.org
Wed Jan 12 14:00:13 EET 2011


At file:///home/psergey/dev2/5.3/

------------------------------------------------------------
revno: 2876
revision-id: psergey at askmonty.org-20110112120010-w4wygo4cz7bs73og
parent: igor at askmonty.org-20110105230330-2nzlm8641wcrwzio
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.3
timestamp: Wed 2011-01-12 15:00:10 +0300
message:
  BUG#665669: Result differences on query re-execution
  - Cause: handler::in_range_check_pushed_down was not reset when a 
    command would call handler->idx_cond_push() without later calling
    handler->index_end().
  - Fix: reset the variable in handler->reset(), too (like we do with other
    Index Condition Pushdown members).
=== modified file 'mysql-test/r/innodb_mrr.result'
--- a/mysql-test/r/innodb_mrr.result	2010-12-08 21:47:33 +0000
+++ b/mysql-test/r/innodb_mrr.result	2011-01-12 12:00:10 +0000
@@ -660,3 +660,24 @@
 drop table t1,t2;
 set join_cache_level=@my_save_join_cache_level;
 set join_buffer_size=@my_save_join_buffer_size;
+#
+# BUG#665669: Result differences on query re-execution
+#
+create table t1 (pk int primary key, b int, c int default 0, index idx(b)) engine=innodb;
+insert into t1(pk,b) values (3, 30), (2, 20), (9, 90), (7, 70), (4, 40), (5, 50), (10, 100), (12, 120);
+set @my_save_optimizer_use_mrr=@@optimizer_use_mrr;
+set optimizer_use_mrr='disable';
+explain select * from t1 where b > 1000;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	range	idx	idx	5	NULL	1	Using index condition
+# The following two must produce indentical results:
+select * from t1 where pk < 2 or pk between 3 and 4;
+pk	b	c
+3	30	0
+4	40	0
+select * from t1 where pk < 2 or pk between 3 and 4;
+pk	b	c
+3	30	0
+4	40	0
+drop table t1;
+set optimizer_use_mrr = @my_save_optimizer_use_mrr;

=== modified file 'mysql-test/t/innodb_mrr.test'
--- a/mysql-test/t/innodb_mrr.test	2010-12-08 21:47:33 +0000
+++ b/mysql-test/t/innodb_mrr.test	2011-01-12 12:00:10 +0000
@@ -364,3 +364,18 @@
 set join_cache_level=@my_save_join_cache_level;
 set join_buffer_size=@my_save_join_buffer_size;
 
+
+--echo #
+--echo # BUG#665669: Result differences on query re-execution
+--echo #
+create table t1 (pk int primary key, b int, c int default 0, index idx(b)) engine=innodb;
+insert into t1(pk,b) values (3, 30), (2, 20), (9, 90), (7, 70), (4, 40), (5, 50), (10, 100), (12, 120);
+set @my_save_optimizer_use_mrr=@@optimizer_use_mrr;
+set optimizer_use_mrr='disable';
+explain select * from t1 where b > 1000;
+--echo # The following two must produce indentical results:
+select * from t1 where pk < 2 or pk between 3 and 4;
+select * from t1 where pk < 2 or pk between 3 and 4;   
+drop table t1;
+set optimizer_use_mrr = @my_save_optimizer_use_mrr;
+

=== modified file 'storage/maria/ha_maria.cc'
--- a/storage/maria/ha_maria.cc	2010-12-13 10:42:40 +0000
+++ b/storage/maria/ha_maria.cc	2011-01-12 12:00:10 +0000
@@ -2456,6 +2456,7 @@
 {
   pushed_idx_cond= NULL;
   pushed_idx_cond_keyno= MAX_KEY;
+  in_range_check_pushed_down= FALSE;
   ma_set_index_cond_func(file, NULL, 0);
   ds_mrr.dsmrr_close();
   if (file->trn)

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2010-12-13 10:42:40 +0000
+++ b/storage/myisam/ha_myisam.cc	2011-01-12 12:00:10 +0000
@@ -1929,6 +1929,7 @@
 {
   pushed_idx_cond= NULL;
   pushed_idx_cond_keyno= MAX_KEY;
+  in_range_check_pushed_down= FALSE;
   mi_set_index_cond_func(file, NULL, 0);
   ds_mrr.dsmrr_close();
   return mi_reset(file);

=== modified file 'storage/xtradb/handler/ha_innodb.cc'
--- a/storage/xtradb/handler/ha_innodb.cc	2010-12-13 10:42:40 +0000
+++ b/storage/xtradb/handler/ha_innodb.cc	2011-01-12 12:00:10 +0000
@@ -8865,6 +8865,7 @@
                         pushed_idx_cond= FALSE;
                         pushed_idx_cond_keyno= MAX_KEY;
                         prebuilt->idx_cond_func= NULL;
+                        in_range_check_pushed_down= FALSE;
 			break;
 		case HA_EXTRA_NO_KEYREAD:
 			prebuilt->read_just_key = 0;
@@ -8915,6 +8916,7 @@
 	/* Reset index condition pushdown state */
 	pushed_idx_cond_keyno= MAX_KEY;
 	pushed_idx_cond= NULL;
+        in_range_check_pushed_down= FALSE;
 	ds_mrr.dsmrr_close();
 	prebuilt->idx_cond_func= NULL;
 



More information about the commits mailing list