Commit b8e5174d authored by unknown's avatar unknown

fixed not_null_tables() for IN() (BUG#9393)

(IN() remove NULL rows only for tables from first argument (value which we looking for in IN() list) but not for tables from IN() list)
Also it will be better change Item::not_null_tables() to prohibit this optimisation by default for new created items in 5.0 or 5.1.


mysql-test/r/select.result:
  IN with outer join condition
mysql-test/t/select.test:
  IN with outer join condition
sql/item_cmpfunc.h:
  correct not_null_tables() for IN
parent ef260b9e
......@@ -2515,3 +2515,12 @@ SELECT b FROM t1 WHERE b=0x8000000000000000;
b
9223372036854775808
DROP TABLE t1;
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
INSERT INTO `t2` VALUES (0,'READ');
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
INSERT INTO `t3` VALUES (1,'fs');
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
id name gid uid ident level
1 fs NULL NULL 0 READ
drop table t1,t2,t3;
......@@ -2060,3 +2060,18 @@ CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
INSERT INTO t1 VALUES (0x8000000000000000);
SELECT b FROM t1 WHERE b=0x8000000000000000;
DROP TABLE t1;
#
# IN with outer join condition (BUG#9393)
#
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
INSERT INTO `t2` VALUES (0,'READ');
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
INSERT INTO `t3` VALUES (1,'fs');
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
drop table t1,t2,t3;
......@@ -769,6 +769,12 @@ class Item_func_in :public Item_int_func
bool nulls_in_row();
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
/*
IN() protect from NULL only first argument, if construction like
"expression IN ()" will be allowed, we will need to check number of
argument here, because "NOT(NULL IN ())" is TRUE.
*/
table_map not_null_tables() const { return args[0]->not_null_tables(); }
};
/* Functions used by where clause */
......
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