Below is the list of changes that have just been committed into a local
5.1 repository of psergey. When psergey 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, 2006-08-21 17:03:07+04:00, sergefp@stripped +3 -0
BUG#21277: Wrong results in index_merge queries:
Remove the code that cleared "read fields set" for merged scans. That code
was based on assumption that "We're going to just read rowids", while
actually QUICK_RANGE_SELECT code would also need key part values to check
that retrieved record(s) fall within the scanned intervals.
mysql-test/r/index_merge_innodb.result@stripped, 2006-08-21 17:03:04+04:00, sergefp@stripped +40 -0
BUG#21277: Testcase
mysql-test/t/index_merge_innodb.test@stripped, 2006-08-21 17:03:04+04:00, sergefp@stripped +27 -0
BUG#21277: Testcase
sql/opt_range.cc@stripped, 2006-08-21 17:03:04+04:00, sergefp@stripped +0 -7
BUG#21277: Wrong results in index_merge queries:
Remove the code that cleared "read fields set" for merged scans. That code
was based on assumption that "We're going to just read rowids", while
actually QUICK_RANGE_SELECT code would also need key part values to check
that retrieved record(s) fall within the scanned intervals.
# 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: sergefp
# Host: pylon.mylan
# Root: /home/psergey/mysql-5.1-bug21277
--- 1.228/sql/opt_range.cc 2006-08-21 17:03:14 +04:00
+++ 1.229/sql/opt_range.cc 2006-08-21 17:03:14 +04:00
@@ -7584,16 +7584,10 @@
QUICK_RANGE_SELECT* cur_quick;
int result;
Unique *unique;
- MY_BITMAP *save_read_set, *save_write_set;
handler *file= head->file;
DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::read_keys_and_merge");
- /* We're going to just read rowids. */
- save_read_set= head->read_set;
- save_write_set= head->write_set;
file->extra(HA_EXTRA_KEYREAD);
- bitmap_clear_all(&head->tmp_set);
- head->column_bitmaps_set(&head->tmp_set, &head->tmp_set);
head->prepare_for_position();
cur_quick_it.rewind();
@@ -7658,7 +7652,6 @@
doing_pk_scan= FALSE;
/* index_merge currently doesn't support "using index" at all */
file->extra(HA_EXTRA_NO_KEYREAD);
- head->column_bitmaps_set(save_read_set, save_write_set);
/* start table scan */
init_read_record(&read_record, thd, head, (SQL_SELECT*) 0, 1, 1);
DBUG_RETURN(result);
--- 1.18/mysql-test/r/index_merge_innodb.result 2006-08-21 17:03:14 +04:00
+++ 1.19/mysql-test/r/index_merge_innodb.result 2006-08-21 17:03:14 +04:00
@@ -282,3 +282,43 @@
COUNT(*)
1
drop table t1;
+create table t1
+(
+key1 int not null,
+key2 int not null default 0,
+key3 int not null default 0
+);
+insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
+set @d=8;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+insert into t1 (key1) select key1+@d from t1;
+set @d=@d*2;
+alter table t1 add index i2(key2);
+alter table t1 add index i3(key3);
+update t1 set key2=key1,key3=key1;
+explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge i2,i3 i3,i2 4,4 NULL 11 Using sort_union(i3,i2); Using where
+select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
+key1 key2 key3
+31 31 31
+32 32 32
+33 33 33
+34 34 34
+35 35 35
+36 36 36
+37 37 37
+38 38 38
+39 39 39
+drop table t1;
--- 1.12/mysql-test/t/index_merge_innodb.test 2006-08-21 17:03:14 +04:00
+++ 1.13/mysql-test/t/index_merge_innodb.test 2006-08-21 17:03:14 +04:00
@@ -299,4 +299,31 @@
drop table t1;
+# BUG#21277: Index Merge/sort_union: wrong query results
+create table t1
+(
+ key1 int not null,
+ key2 int not null default 0,
+ key3 int not null default 0
+);
+
+insert into t1(key1) values (1),(2),(3),(4),(5),(6),(7),(8);
+
+let $1=7;
+set @d=8;
+while ($1)
+{
+ eval insert into t1 (key1) select key1+@d from t1;
+ eval set @d=@d*2;
+ dec $1;
+}
+
+alter table t1 add index i2(key2);
+alter table t1 add index i3(key3);
+update t1 set key2=key1,key3=key1;
+
+# to test the bug, the following must use "sort_union":
+explain select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
+select * from t1 where (key3 > 30 and key3<35) or (key2 >32 and key2 < 40);
+drop table t1;
| Thread |
|---|
| • bk commit into 5.1 tree (sergefp:1.2274) BUG#21277 | Sergey Petrunia | 21 Aug |