From 5d336fbbe1dd6f5bd407e7b6571c8ddda267635f Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Tue, 30 Aug 2005 03:14:39 +0400 Subject: [PATCH] Fix for BUG#12720: In QUICK_RANGE_SELECT::reset(), reset in_range so next get_next() call doesn't continue reading the last range. --- mysql-test/r/index_merge_innodb.result | 69 ++++++++++++++++++++++++ mysql-test/t/index_merge_innodb.test | 73 ++++++++++++++++++++++++++ sql/opt_range.cc | 1 + 3 files changed, 143 insertions(+) diff --git a/mysql-test/r/index_merge_innodb.result b/mysql-test/r/index_merge_innodb.result index 662fffe1ba1..81e5fa6767d 100644 --- a/mysql-test/r/index_merge_innodb.result +++ b/mysql-test/r/index_merge_innodb.result @@ -134,3 +134,72 @@ select * from t1 where id1 = 1 and id2= '20040101'; id1 id2 1 2004-01-01 drop table t1; +drop view if exists v1; +CREATE TABLE t1 ( +`oid` int(11) unsigned NOT NULL auto_increment, +`fk_bbk_niederlassung` int(11) unsigned NOT NULL, +`fk_wochentag` int(11) unsigned NOT NULL, +`uhrzeit_von` time NOT NULL COMMENT 'HH:MM', +`uhrzeit_bis` time NOT NULL COMMENT 'HH:MM', +`geloescht` tinyint(4) NOT NULL, +`version` int(5) NOT NULL, +PRIMARY KEY (`oid`), +KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`), +KEY `fk_wochentag` (`fk_wochentag`), +KEY `ix_version` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +insert into t1 values +(1, 38, 1, '08:00:00', '13:00:00', 0, 1), +(2, 38, 2, '08:00:00', '13:00:00', 0, 1), +(3, 38, 3, '08:00:00', '13:00:00', 0, 1), +(4, 38, 4, '08:00:00', '13:00:00', 0, 1), +(5, 38, 5, '08:00:00', '13:00:00', 0, 1), +(6, 38, 5, '08:00:00', '13:00:00', 1, 2), +(7, 38, 3, '08:00:00', '13:00:00', 1, 2), +(8, 38, 1, '08:00:00', '13:00:00', 1, 2), +(9, 38, 2, '08:00:00', '13:00:00', 1, 2), +(10, 38, 4, '08:00:00', '13:00:00', 1, 2), +(11, 38, 1, '08:00:00', '13:00:00', 0, 3), +(12, 38, 2, '08:00:00', '13:00:00', 0, 3), +(13, 38, 3, '08:00:00', '13:00:00', 0, 3), +(14, 38, 4, '08:00:00', '13:00:00', 0, 3), +(15, 38, 5, '08:00:00', '13:00:00', 0, 3), +(16, 38, 4, '08:00:00', '13:00:00', 0, 4), +(17, 38, 5, '08:00:00', '13:00:00', 0, 4), +(18, 38, 1, '08:00:00', '13:00:00', 0, 4), +(19, 38, 2, '08:00:00', '13:00:00', 0, 4), +(20, 38, 3, '08:00:00', '13:00:00', 0, 4), +(21, 7, 1, '08:00:00', '13:00:00', 0, 1), +(22, 7, 2, '08:00:00', '13:00:00', 0, 1), +(23, 7, 3, '08:00:00', '13:00:00', 0, 1), +(24, 7, 4, '08:00:00', '13:00:00', 0, 1), +(25, 7, 5, '08:00:00', '13:00:00', 0, 1); +create view v1 as +select +zeit1.oid AS oid, +zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung, +zeit1.fk_wochentag AS fk_wochentag, +zeit1.uhrzeit_von AS uhrzeit_von, +zeit1.uhrzeit_bis AS uhrzeit_bis, +zeit1.geloescht AS geloescht, +zeit1.version AS version +from +t1 zeit1 +where +(zeit1.version = +(select max(zeit2.version) AS `max(version)` + from t1 zeit2 +where +((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and +(zeit1.fk_wochentag = zeit2.fk_wochentag) and +(zeit1.uhrzeit_von = zeit2.uhrzeit_von) and +(zeit1.uhrzeit_bis = zeit2.uhrzeit_bis) +) +) +) +and (zeit1.geloescht = 0); +select * from v1 where oid = 21; +oid fk_bbk_niederlassung fk_wochentag uhrzeit_von uhrzeit_bis geloescht version +21 7 1 08:00:00 13:00:00 0 1 +drop view v1; +drop table t1; diff --git a/mysql-test/t/index_merge_innodb.test b/mysql-test/t/index_merge_innodb.test index c10ce3b9688..3ed7d44981b 100644 --- a/mysql-test/t/index_merge_innodb.test +++ b/mysql-test/t/index_merge_innodb.test @@ -131,3 +131,76 @@ insert into t1 values(1,'20040101'), (2,'20040102'); select * from t1 where id1 = 1 and id2= '20040101'; drop table t1; +# Test for BUG#12720 +--disable_warnings +drop view if exists v1; +--enable_warnings +CREATE TABLE t1 ( + `oid` int(11) unsigned NOT NULL auto_increment, + `fk_bbk_niederlassung` int(11) unsigned NOT NULL, + `fk_wochentag` int(11) unsigned NOT NULL, + `uhrzeit_von` time NOT NULL COMMENT 'HH:MM', + `uhrzeit_bis` time NOT NULL COMMENT 'HH:MM', + `geloescht` tinyint(4) NOT NULL, + `version` int(5) NOT NULL, + PRIMARY KEY (`oid`), + KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`), + KEY `fk_wochentag` (`fk_wochentag`), + KEY `ix_version` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert into t1 values +(1, 38, 1, '08:00:00', '13:00:00', 0, 1), +(2, 38, 2, '08:00:00', '13:00:00', 0, 1), +(3, 38, 3, '08:00:00', '13:00:00', 0, 1), +(4, 38, 4, '08:00:00', '13:00:00', 0, 1), +(5, 38, 5, '08:00:00', '13:00:00', 0, 1), +(6, 38, 5, '08:00:00', '13:00:00', 1, 2), +(7, 38, 3, '08:00:00', '13:00:00', 1, 2), +(8, 38, 1, '08:00:00', '13:00:00', 1, 2), +(9, 38, 2, '08:00:00', '13:00:00', 1, 2), +(10, 38, 4, '08:00:00', '13:00:00', 1, 2), +(11, 38, 1, '08:00:00', '13:00:00', 0, 3), +(12, 38, 2, '08:00:00', '13:00:00', 0, 3), +(13, 38, 3, '08:00:00', '13:00:00', 0, 3), +(14, 38, 4, '08:00:00', '13:00:00', 0, 3), +(15, 38, 5, '08:00:00', '13:00:00', 0, 3), +(16, 38, 4, '08:00:00', '13:00:00', 0, 4), +(17, 38, 5, '08:00:00', '13:00:00', 0, 4), +(18, 38, 1, '08:00:00', '13:00:00', 0, 4), +(19, 38, 2, '08:00:00', '13:00:00', 0, 4), +(20, 38, 3, '08:00:00', '13:00:00', 0, 4), +(21, 7, 1, '08:00:00', '13:00:00', 0, 1), +(22, 7, 2, '08:00:00', '13:00:00', 0, 1), +(23, 7, 3, '08:00:00', '13:00:00', 0, 1), +(24, 7, 4, '08:00:00', '13:00:00', 0, 1), +(25, 7, 5, '08:00:00', '13:00:00', 0, 1); + +create view v1 as +select + zeit1.oid AS oid, + zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung, + zeit1.fk_wochentag AS fk_wochentag, + zeit1.uhrzeit_von AS uhrzeit_von, + zeit1.uhrzeit_bis AS uhrzeit_bis, + zeit1.geloescht AS geloescht, + zeit1.version AS version +from + t1 zeit1 +where +(zeit1.version = + (select max(zeit2.version) AS `max(version)` + from t1 zeit2 + where + ((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and + (zeit1.fk_wochentag = zeit2.fk_wochentag) and + (zeit1.uhrzeit_von = zeit2.uhrzeit_von) and + (zeit1.uhrzeit_bis = zeit2.uhrzeit_bis) + ) + ) +) +and (zeit1.geloescht = 0); + +select * from v1 where oid = 21; +drop view v1; +drop table t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c1ebfe105b6..d0e34df5ac1 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -6043,6 +6043,7 @@ int QUICK_RANGE_SELECT::reset() DBUG_ENTER("QUICK_RANGE_SELECT::reset"); next=0; range= NULL; + in_range= FALSE; cur_range= (QUICK_RANGE**) ranges.buffer; if (file->inited == handler::NONE && (error= file->ha_index_init(index)))