1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge mysql.com:/opt/local/work/mysql-4.1-root

into  mysql.com:/media/sda1/mysql/mysql-5.0-merge


mysql-test/r/select.result:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/ps.result:
  Manual merge (again).
mysql-test/t/ps.test:
  Manual merge (again).
mysql-test/t/select.test:
  Manual merge (again).
sql/item_func.cc:
  Manual merge (again).
sql/item_func.h:
  Manual merge (again).
sql/set_var.h:
  Manual merge (again).
This commit is contained in:
unknown
2005-07-16 13:45:32 +04:00
10 changed files with 150 additions and 48 deletions

View File

@ -5138,7 +5138,23 @@ inline void add_cond_and_fix(Item **e1, Item *e2)
(where othertbl is a non-const table and othertbl.field may be NULL)
and add them to conditions on correspoding tables (othertbl in this
example).
Exception from that is the case when referred_tab->join != join.
I.e. don't add NOT NULL constraints from any embedded subquery.
Consider this query:
SELECT A.f2 FROM t1 LEFT JOIN t2 A ON A.f2 = f1
WHERE A.f3=(SELECT MIN(f3) FROM t2 C WHERE A.f4 = C.f4) OR A.f3 IS NULL;
Here condition A.f3 IS NOT NULL is going to be added to the WHERE
condition of the embedding query.
Another example:
SELECT * FROM t10, t11 WHERE (t10.a < 10 OR t10.a IS NULL)
AND t11.b <=> t10.b AND (t11.a = (SELECT MAX(a) FROM t12
WHERE t12.b = t10.a ));
Here condition t10.a IS NOT NULL is going to be added.
In both cases addition of NOT NULL condition will erroneously reject
some rows of the result set.
referred_tab->join != join constraint would disallow such additions.
This optimization doesn't affect the choices that ref, range, or join
optimizer make. This was intentional because this was added after 4.1
was GA.
@ -5169,6 +5185,8 @@ static void add_not_null_conds(JOIN *join)
DBUG_ASSERT(item->type() == Item::FIELD_ITEM);
Item_field *not_null_item= (Item_field*)item;
JOIN_TAB *referred_tab= not_null_item->field->table->reginfo.join_tab;
if (referred_tab->join != join)
continue;
Item *notnull;
if (!(notnull= new Item_func_isnotnull(not_null_item)))
DBUG_VOID_RETURN;