Commit ea8314fd authored by unknown's avatar unknown

LP bug#994275 fix.

In 5.3 we substitute constants in ref access values it can't be null so we do not need add NOT NULL for early NULL filtering.
parent d335b471
......@@ -5101,3 +5101,15 @@ Warning 1292 Incorrect datetime value: 'aa'
DROP TABLE t1;
DROP VIEW v1;
SET optimizer_switch=@save_optimizer_switch;
#
# LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed
# in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK
#
CREATE TABLE t1 ( a INT(6) ZEROFILL );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 ( b INT PRIMARY KEY );
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b
drop table t1,t2;
End of 5.3 tests
......@@ -5112,6 +5112,18 @@ Warning 1292 Incorrect datetime value: 'aa'
DROP TABLE t1;
DROP VIEW v1;
SET optimizer_switch=@save_optimizer_switch;
#
# LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed
# in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK
#
CREATE TABLE t1 ( a INT(6) ZEROFILL );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 ( b INT PRIMARY KEY );
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b
drop table t1,t2;
End of 5.3 tests
set join_cache_level=default;
show variables like 'join_cache_level';
Variable_name Value
......
......@@ -5101,3 +5101,15 @@ Warning 1292 Incorrect datetime value: 'aa'
DROP TABLE t1;
DROP VIEW v1;
SET optimizer_switch=@save_optimizer_switch;
#
# LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed
# in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK
#
CREATE TABLE t1 ( a INT(6) ZEROFILL );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 ( b INT PRIMARY KEY );
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b
drop table t1,t2;
End of 5.3 tests
......@@ -4272,3 +4272,18 @@ DROP TABLE t1;
DROP VIEW v1;
SET optimizer_switch=@save_optimizer_switch;
--echo #
--echo # LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed
--echo # in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK
--echo #
CREATE TABLE t1 ( a INT(6) ZEROFILL );
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 ( b INT PRIMARY KEY );
INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b;
drop table t1,t2;
--echo End of 5.3 tests
......@@ -7998,6 +7998,16 @@ static void add_not_null_conds(JOIN *join)
Item *item= tab->ref.items[keypart];
Item *notnull;
Item *real= item->real_item();
if (real->basic_const_item())
{
/*
It could be constant instead of field after constant
propagation.
*/
DBUG_ASSERT(real->is_expensive() || // prevent early expensive eval
!real->is_null()); // NULLs are not propagated
continue;
}
DBUG_ASSERT(real->type() == Item::FIELD_ITEM);
Item_field *not_null_item= (Item_field*)real;
JOIN_TAB *referred_tab= not_null_item->field->table->reginfo.join_tab;
......
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