mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
fix for LP bug#994392
The not_null_tables() of Item_func_not_all and Item_in_optimizer was inherited from Item_func by mistake. It made the optimizer think that subquery predicates with ALL/ANY/IN were null-rejecting. This could trigger invalid conversions of outer joins into inner joins.
This commit is contained in:
@@ -1596,3 +1596,27 @@ f
|
|||||||
1
|
1
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
End of 5.1 tests
|
End of 5.1 tests
|
||||||
|
#
|
||||||
|
# LP BUG#994392: Wrong result with RIGHT/LEFT JOIN and ALL subquery
|
||||||
|
# predicate in WHERE condition.
|
||||||
|
#
|
||||||
|
CREATE TABLE t1(a INT);
|
||||||
|
INSERT INTO t1 VALUES(9);
|
||||||
|
CREATE TABLE t2(b INT);
|
||||||
|
INSERT INTO t2 VALUES(8);
|
||||||
|
CREATE TABLE t3(c INT);
|
||||||
|
INSERT INTO t3 VALUES(3);
|
||||||
|
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
b c
|
||||||
|
NULL 3
|
||||||
|
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
c b
|
||||||
|
3 NULL
|
||||||
|
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
b c
|
||||||
|
NULL 3
|
||||||
|
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
c b
|
||||||
|
3 NULL
|
||||||
|
drop table t1,t2,t3;
|
||||||
|
End of 5.2 tests
|
||||||
|
@@ -1162,3 +1162,22 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
|
|
||||||
--echo End of 5.1 tests
|
--echo End of 5.1 tests
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # LP BUG#994392: Wrong result with RIGHT/LEFT JOIN and ALL subquery
|
||||||
|
--echo # predicate in WHERE condition.
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1(a INT);
|
||||||
|
INSERT INTO t1 VALUES(9);
|
||||||
|
CREATE TABLE t2(b INT);
|
||||||
|
INSERT INTO t2 VALUES(8);
|
||||||
|
CREATE TABLE t3(c INT);
|
||||||
|
INSERT INTO t3 VALUES(3);
|
||||||
|
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b < ALL(SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
SELECT * FROM t2 RIGHT JOIN t3 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
SELECT * FROM t3 LEFT JOIN t2 ON(c = b) WHERE b not in (SELECT a FROM t1 WHERE a <= 7);
|
||||||
|
drop table t1,t2,t3;
|
||||||
|
|
||||||
|
--echo End of 5.2 tests
|
||||||
|
@@ -257,6 +257,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
bool fix_fields(THD *, Item **);
|
bool fix_fields(THD *, Item **);
|
||||||
bool fix_left(THD *thd, Item **ref);
|
bool fix_left(THD *thd, Item **ref);
|
||||||
|
table_map not_null_tables() const { return 0; }
|
||||||
bool is_null();
|
bool is_null();
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
@@ -473,6 +474,7 @@ public:
|
|||||||
show(0)
|
show(0)
|
||||||
{}
|
{}
|
||||||
virtual void top_level_item() { abort_on_null= 1; }
|
virtual void top_level_item() { abort_on_null= 1; }
|
||||||
|
table_map not_null_tables() const { return 0; }
|
||||||
bool top_level() { return abort_on_null; }
|
bool top_level() { return abort_on_null; }
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
enum Functype functype() const { return NOT_ALL_FUNC; }
|
enum Functype functype() const { return NOT_ALL_FUNC; }
|
||||||
|
Reference in New Issue
Block a user