Commit c4a8325d authored by unknown's avatar unknown

opt_range.cc:

  Fixed buf #11487.
  Added a call of  QUICK_RANGE_SELECT::init to the
  QUICK_RANGE_SELECT::reset method. Without it the second
  evaluation of a subquery employing the range access failed.
subselect.result, subselect.test:
  Added a test case for bug #11487.


mysql-test/t/subselect.test:
  Added a test case for bug #11487.
mysql-test/r/subselect.result:
  Added a test case for bug #11487.
sql/opt_range.cc:
  Fixed buf #11487.
  Added a call of  QUICK_RANGE_SELECT::init to the
  QUICK_RANGE_SELECT::reset method. Without it the second
  evaluation of a subquery employing the range access failed.
parent e5245b34
...@@ -2816,3 +2816,24 @@ select * from t1; ...@@ -2816,3 +2816,24 @@ select * from t1;
EMPNUM EMPNUM
E1 E1
DROP TABLE t1,t2; DROP TABLE t1,t2;
CREATE TABLE t1(select_id BIGINT, values_id BIGINT);
INSERT INTO t1 VALUES (1, 1);
CREATE TABLE t2 (select_id BIGINT, values_id BIGINT,
PRIMARY KEY(select_id,values_id));
INSERT INTO t2 VALUES (0, 1), (0, 2), (0, 3), (1, 5);
SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id IN (1, 0));
values_id
1
SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id BETWEEN 0 AND 1);
values_id
1
SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id = 0 OR select_id = 1);
values_id
1
DROP TABLE t1, t2;
...@@ -1837,3 +1837,25 @@ WHERE t1.EMPNUM NOT IN ...@@ -1837,3 +1837,25 @@ WHERE t1.EMPNUM NOT IN
WHERE t1.EMPNUM = t2.EMPNUM); WHERE t1.EMPNUM = t2.EMPNUM);
select * from t1; select * from t1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Test for bug #11487: range access in a subquery
#
CREATE TABLE t1(select_id BIGINT, values_id BIGINT);
INSERT INTO t1 VALUES (1, 1);
CREATE TABLE t2 (select_id BIGINT, values_id BIGINT,
PRIMARY KEY(select_id,values_id));
INSERT INTO t2 VALUES (0, 1), (0, 2), (0, 3), (1, 5);
SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id IN (1, 0));
SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id BETWEEN 0 AND 1);
SELECT values_id FROM t1
WHERE values_id IN (SELECT values_id FROM t2
WHERE select_id = 0 OR select_id = 1);
DROP TABLE t1, t2;
...@@ -5992,7 +5992,10 @@ int QUICK_RANGE_SELECT::reset() ...@@ -5992,7 +5992,10 @@ int QUICK_RANGE_SELECT::reset()
next=0; next=0;
range= NULL; range= NULL;
cur_range= (QUICK_RANGE**) ranges.buffer; cur_range= (QUICK_RANGE**) ranges.buffer;
if (file->inited == handler::NONE && (error= file->ha_index_init(index)))
DBUG_RETURN(error);
/* Do not allocate the buffers twice. */ /* Do not allocate the buffers twice. */
if (multi_range_length) if (multi_range_length)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment