Commit d85fdc1b authored by unknown's avatar unknown

subselect.result, subselect.test:

  Added a test case for bug #9516.
item_subselect.h:
  Fixed bug #9516.
  The bug was due to that fact that the class Item_subselect
  inherited the generic implementation of the function
  not_null_tables that was not valid for the objects
  of this class. As a result evaluation of the
  not_null_tables attribute was not correct for subqueries.
  This caused invalid transformations of outer joins into
  inner joins.


sql/item_subselect.h:
  Fixed bug #9516.
  The bug was due to that fact that the class Item_subselect
  inherited the generic implementation of the function
  not_null_tables that was not valid for the objects
  of this class. As a result evaluation of the
  not_null_tables attribute was not correct for subqueries.
  This caused invalid transformations of outer joins into
  inner joins.
mysql-test/t/subselect.test:
  Added a test case for bug #9516.
mysql-test/r/subselect.result:
  Added a test case for bug #9516.
parent 2b92a78e
...@@ -2762,3 +2762,22 @@ WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) ); ...@@ -2762,3 +2762,22 @@ WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
c1 c2 c1 c2
1 1 1 1
DROP TABLE t1,t2; DROP TABLE t1,t2;
CREATE TABLE t1 ( c1 integer );
INSERT INTO t1 VALUES ( 1 );
INSERT INTO t1 VALUES ( 2 );
INSERT INTO t1 VALUES ( 3 );
INSERT INTO t1 VALUES ( 6 );
CREATE TABLE t2 ( c2 integer );
INSERT INTO t2 VALUES ( 1 );
INSERT INTO t2 VALUES ( 4 );
INSERT INTO t2 VALUES ( 5 );
INSERT INTO t2 VALUES ( 6 );
CREATE TABLE t3 ( c3 integer );
INSERT INTO t3 VALUES ( 7 );
INSERT INTO t3 VALUES ( 8 );
SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2
WHERE EXISTS (SELECT c3 FROM t3 WHERE c2 IS NULL );
c1 c2
2 NULL
3 NULL
DROP TABLE t1,t2,t3;
...@@ -1773,3 +1773,29 @@ SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2 ...@@ -1773,3 +1773,29 @@ SELECT * FROM t1 LEFT JOIN t2 ON c1 = c2
WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) ); WHERE c2 IN ( SELECT c2 FROM t2 WHERE c2 IN ( 1 ) );
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Test for bug #9516: wrong evaluation of not_null_tables attribute in SQ
#
CREATE TABLE t1 ( c1 integer );
INSERT INTO t1 VALUES ( 1 );
INSERT INTO t1 VALUES ( 2 );
INSERT INTO t1 VALUES ( 3 );
INSERT INTO t1 VALUES ( 6 );
CREATE TABLE t2 ( c2 integer );
INSERT INTO t2 VALUES ( 1 );
INSERT INTO t2 VALUES ( 4 );
INSERT INTO t2 VALUES ( 5 );
INSERT INTO t2 VALUES ( 6 );
CREATE TABLE t3 ( c3 integer );
INSERT INTO t3 VALUES ( 7 );
INSERT INTO t3 VALUES ( 8 );
SELECT c1,c2 FROM t1 LEFT JOIN t2 ON c1 = c2
WHERE EXISTS (SELECT c3 FROM t3 WHERE c2 IS NULL );
DROP TABLE t1,t2,t3;
...@@ -96,6 +96,7 @@ class Item_subselect :public Item_result_field ...@@ -96,6 +96,7 @@ class Item_subselect :public Item_result_field
virtual bool exec(); virtual bool exec();
virtual void fix_length_and_dec(); virtual void fix_length_and_dec();
table_map used_tables() const; table_map used_tables() const;
table_map not_null_tables() const { return 0; }
bool const_item() const; bool const_item() const;
inline table_map get_used_tables_cache() { return used_tables_cache; } inline table_map get_used_tables_cache() { return used_tables_cache; }
inline bool get_const_item_cache() { return const_item_cache; } inline bool get_const_item_cache() { return const_item_cache; }
......
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