diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result
index 5b0c2ffd7a26818ef88704c8c7b9225c472912c1..aac0a52e166b3388f11283739bb6389d0294d1f3 100644
--- a/mysql-test/r/index_merge.result
+++ b/mysql-test/r/index_merge.result
@@ -304,9 +304,9 @@ key1	key2	key3	key4	key5	key6	key7	key8	key9	keyA	keyB	keyC
 5	5	5	5	5	5	5	1019	5	5	5	5
 6	6	6	6	6	6	6	1018	6	6	6	6
 7	7	7	7	7	7	7	1017	7	7	7	7
-1016	1016	1016	1016	1016	1016	1016	8	1016	1016	1016	1016
 9	9	9	9	9	9	9	1015	9	9	9	9
 10	10	10	10	10	10	10	1014	10	10	10	10
 11	11	11	11	11	11	11	1013	11	11	11	11
 12	12	12	12	12	12	12	1012	12	12	12	12
+1016	1016	1016	1016	1016	1016	1016	8	1016	1016	1016	1016
 drop table t0, t1, t2, t3, t4;
diff --git a/mysql-test/r/index_merge_innodb.result b/mysql-test/r/index_merge_innodb.result
index ef6ffa82da7aaaa4ba43195cb3eda0a118502f3e..dc1fdd977234109b6fbbc71bb56831e74f59b2d8 100644
--- a/mysql-test/r/index_merge_innodb.result
+++ b/mysql-test/r/index_merge_innodb.result
@@ -24,8 +24,8 @@ key1	key2
 0	200
 1	199
 2	198
-4	196
 3	197
+4	196
 alter table t1 add str1 char (255) not null, 
 add zeroval int not null default 0,
 add str2 char (255) not null,
@@ -37,19 +37,19 @@ id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index_merge	i1,i2	i1,i2	4,4	NULL	8	Using where
 select * from t1 where key1 < 5 or key2 > 197;
 key1	key2	str1	zeroval	str2	str3
-0	200	aaa	0	bbb	200-0_a
-1	199	aaa	0	bbb	199-0_A
-2	198	aaa	0	bbb	198-1_a
-3	197	aaa	0	bbb	197-1_A
 4	196	aaa	0	bbb	196-2_a
+3	197	aaa	0	bbb	197-1_A
+2	198	aaa	0	bbb	198-1_a
+1	199	aaa	0	bbb	199-0_A
+0	200	aaa	0	bbb	200-0_a
 explain select * from t1 where key1 < 3 or key2 > 195;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	index_merge	i1,i2	i1,i2	4,4	NULL	8	Using where
 select * from t1 where key1 < 3 or key2 > 195;
 key1	key2	str1	zeroval	str2	str3
-0	200	aaa	0	bbb	200-0_a
-1	199	aaa	0	bbb	199-0_A
-2	198	aaa	0	bbb	198-1_a
 4	196	aaa	0	bbb	196-2_a
 3	197	aaa	0	bbb	197-1_A
+2	198	aaa	0	bbb	198-1_a
+1	199	aaa	0	bbb	199-0_A
+0	200	aaa	0	bbb	200-0_a
 drop table t1;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 91b3fa6616960da1b0eac9fdf786c72a567d07aa..5f282695494af225926e5c29373ecabc4aea62a3 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1169,9 +1169,9 @@ end:
   DBUG_EXECUTE("info",
     {
       if (quick_imerge)
-        print_quick_sel_imerge(quick_imerge, needed_reg);
+        print_quick_sel_imerge(quick_imerge, &needed_reg);
       else
-        print_quick_sel_range((QUICK_RANGE_SELECT*)quick, needed_reg);
+        print_quick_sel_range((QUICK_RANGE_SELECT*)quick, &needed_reg);
     }
   );
 
@@ -1720,7 +1720,6 @@ tree_and(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
     uint flag=0;
     if (*key1 || *key2)
     {
-      trees_have_key = true;
       if (*key1 && !(*key1)->simple_key())
 	flag|=CLONE_KEY1_MAYBE;
       if (*key2 && !(*key2)->simple_key())
diff --git a/sql/opt_range.h b/sql/opt_range.h
index e312dd39bada68ab98370720ac891b170edbdee8..9e3921048182dd0ab3fe0db8de43bd17256e2acf 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -88,7 +88,7 @@ public:
   QUICK_SELECT_I();
   virtual ~QUICK_SELECT_I(){};
   virtual int  init() = 0;
-  virtual void reset(void) = 0;
+  virtual int  reset(void) = 0;
   virtual int  get_next() = 0;   /* get next record to retrieve */
   virtual bool reverse_sorted() = 0;
   virtual bool unique_key_range() { return false; }
@@ -140,7 +140,7 @@ public:
                      MEM_ROOT *parent_alloc=NULL);
   ~QUICK_RANGE_SELECT();
   
-  void reset(void) { next=0; it.rewind(); }
+  int reset(void) { next=0; it.rewind(); return 0; }
   int init();
   int get_next();
   bool reverse_sorted() { return 0; }