Commit 4b49cbfb authored by unknown's avatar unknown

sql_select.cc:

  Fixed bug #11479.
  The JOIN::reinit method cannot call setup_tables
  after the optimization phase since this function
  removes some optimization settings for joined
  tables. E.g. it resets values of the null_row flag to 0.
subselect.result, subselect.test:
  Added a test case for bug #11479.


mysql-test/t/subselect.test:
  Added a test case for bug #11479.
mysql-test/r/subselect.result:
  Added a test case for bug #11479.
sql/sql_select.cc:
  Fixed bug #11479.
  The JOIN::reinit method cannot call setup_tables
  after the optimization phase since this function
  removes some optimization settings for joined
  tables. E.g. it resets values of the null_row flag to 0.
parent 000a09ba
......@@ -2817,3 +2817,19 @@ SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb'));
a b
aaa aaa
DROP TABLE t1;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int, b int);
CREATE TABLE t3 (b int NOT NULL);
INSERT INTO t1 VALUES (1), (2), (3), (4);
INSERT INTO t2 VALUES (1,10), (3,30);
SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b
WHERE t3.b IS NOT NULL OR t2.a > 10;
a b b
SELECT * FROM t1
WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b
WHERE t3.b IS NOT NULL OR t2.a > 10);
a
1
2
3
4
......@@ -1796,4 +1796,20 @@ SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb'));
DROP TABLE t1;
#
# Bug #11479: subquery over left join with an empty inner table
#
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int, b int);
CREATE TABLE t3 (b int NOT NULL);
INSERT INTO t1 VALUES (1), (2), (3), (4);
INSERT INTO t2 VALUES (1,10), (3,30);
SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b
WHERE t3.b IS NOT NULL OR t2.a > 10;
SELECT * FROM t1
WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b
WHERE t3.b IS NOT NULL OR t2.a > 10);
# End of 4.1 tests
......@@ -984,7 +984,7 @@ JOIN::reinit()
if (unit->select_limit_cnt == HA_POS_ERROR)
select_lex->options&= ~OPTION_FOUND_ROWS;
if (setup_tables(tables_list))
if (!optimized && setup_tables(tables_list))
DBUG_RETURN(1);
/* Reset of sum functions */
......
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