possible bug: Execution of a query that uses index merge returns a wrong result
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Drizzle |
Invalid
|
Medium
|
Stewart Smith | ||
7.0 |
Invalid
|
Medium
|
Stewart Smith |
Bug Description
(found when merging innobase, somebody needs to look at it to see if we have this bug too)
Merge Revision revid:<email address hidden> from MySQL InnoDB
Original revid:<email address hidden>
Original Authors: Sergey Glukhov <email address hidden>
Original commit message:
Bug#56862 Execution of a query that uses index merge returns a wrong result
In case of low memory sort buffer QUICK_INDEX_
temporary file where is stores row ids which meet QUICK_SELECT ranges
except of clustered pk range, clustered range is processed separately.
In init_read_record we check if temporary file is used and choose
appropriate record access method. It does not take into account that
temporary file contains partial result in case of QUICK_INDEX_
with clustered pk range.
The fix is always to use rr_quick if QUICK_INDEX_
with clustered pk range is used.
1 out of 1 hunk FAILED -- saving rejects to file plugin/
1 out of 1 hunk FAILED -- saving rejects to file plugin/
1 out of 1 hunk FAILED -- saving rejects to file plugin/
2 out of 2 hunks FAILED -- saving rejects to file sql/opt_range.h.rej
1 out of 1 hunk FAILED -- saving rejects to file sql/records.cc.rej
Applying Patch Failed!
Marking as invalid as the test case run with Drizzle shows the correct results:
CREATE TABLE t1 (
pk int NOT NULL AUTO_INCREMENT PRIMARY KEY,
a int,
b int,
INDEX idx(a))
ENGINE=INNODB;
INSERT INTO t1(a,b) VALUES
(11, 1100), (2, 200), (1, 100), (14, 1400), (5, 500),
(3, 300), (17, 1700), (4, 400), (12, 1200), (8, 800),
(6, 600), (18, 1800), (9, 900), (10, 1000), (7, 700),
(13, 1300), (15, 1500), (19, 1900), (16, 1600), (20, 2000);
INSERT INTO t1(a,b) SELECT a+20, b+2000 FROM t1;
INSERT INTO t1(a,b) SELECT a+40, b+4000 FROM t1;
INSERT INTO t1(a,b) SELECT a+80, b+8000 FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1(a,b) SELECT a,b FROM t1;
INSERT INTO t1 VALUES (1000000, 0, 0);
SET SESSION sort_buffer_size = 1024*36;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SELECT COUNT(*) FROM
(SELECT * FROM t1
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
EXPLAIN
SELECT COUNT(*) FROM
(SELECT * FROM t1 IGNORE INDEX(idx)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
SELECT COUNT(*) FROM
(SELECT * FROM t1 IGNORE INDEX(idx)
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
DROP TABLE t1;