possible bug: Execution of a query that uses index merge returns a wrong result

Bug #692419 reported by Stewart Smith
6
This bug affects 1 person
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_MERGE_SELECT creates
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_MERGE_SELECT
with clustered pk range.
The fix is always to use rr_quick if QUICK_INDEX_MERGE_SELECT
with clustered pk range is used.

1 out of 1 hunk FAILED -- saving rejects to file plugin/innobase/tests/r/innodb_mysql.result.rej
1 out of 1 hunk FAILED -- saving rejects to file plugin/innobase/tests/r/innodb_mysql.result.rej
1 out of 1 hunk FAILED -- saving rejects to file plugin/innobase/tests/t/innodb_mysql.test.rej
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!

Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

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;

Changed in drizzle:
importance: Undecided → Medium
status: New → Invalid
assignee: nobody → Stewart Smith (stewart)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.