From fb774125e807de66294da40aaabc596d444e1d93 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 20 Aug 2003 15:33:21 +0300 Subject: [PATCH] item_func.h: Fix for a bug with LEAST() in WHERE clause ha_innodb.cc: Fix for a configure bug multi_update.result, multi_update.test: Fix for the update with NULL's in the result set sql_update.cc: Fix for the update with NULL's in the result set Fix for the update with NULL's in the result set Fix for the update with NULL's in the result set --- mysql-test/r/multi_update.result | 9 +++++++++ mysql-test/t/multi_update.test | 7 +++++++ sql/ha_innodb.cc | 1 - sql/item_func.h | 1 + sql/sql_update.cc | 6 +++++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 91170f885a3..350cea420b6 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -318,3 +318,12 @@ create table t2(Z varchar(15)); insert into t2(Z) select concat(a.a,b.a,c.a,d.a) from t1 as a, t1 as b, t1 as c, t1 as d; update t2,t3 set Z =param_scenario_costs; drop table t1,t2,t3; +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1),(2,1),(3,1); +insert into t2 values (1,1), (3,1); +update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL; +select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL; +a b a b +2 2 NULL NULL +drop table t1,t2; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 0c7ad6160ee..7aa4e74cec0 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -260,3 +260,10 @@ create table t2(Z varchar(15)); insert into t2(Z) select concat(a.a,b.a,c.a,d.a) from t1 as a, t1 as b, t1 as c, t1 as d; update t2,t3 set Z =param_scenario_costs; drop table t1,t2,t3; +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1),(2,1),(3,1); +insert into t2 values (1,1), (3,1); +update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL; +select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL; +drop table t1,t2; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 09119a4eb54..3619fefdd1b 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -28,7 +28,6 @@ InnoDB */ #include "mysql_priv.h" #include "slave.h" -#include "sql_cache.h" #ifdef HAVE_INNOBASE_DB #include diff --git a/sql/item_func.h b/sql/item_func.h index 8a4cace0b87..bccd0ca7adb 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -514,6 +514,7 @@ public: void fix_length_and_dec(); enum Item_result result_type () const { return cmp_type; } unsigned int size_of() { return sizeof(*this);} + table_map not_null_tables() const { return 0; } }; class Item_func_min :public Item_func_min_max diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 3179c8e0f24..2f3f917a962 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -575,6 +575,7 @@ multi_update::initialize_tables(JOIN *join) { TABLE *table=table_ref->table; uint cnt= table_ref->shared; + Item_field *If; List temp_fields= *fields_for_table[cnt]; ORDER group; @@ -598,7 +599,10 @@ multi_update::initialize_tables(JOIN *join) /* ok to be on stack as this is not referenced outside of this func */ Field_string offset(table->file->ref_length, 0, "offset", table, 1); - if (temp_fields.push_front(new Item_field(((Field *) &offset)))) + if (!(If=new Item_field(((Field *) &offset)))) + DBUG_RETURN(1); + If->maybe_null=0; + if (temp_fields.push_front(If)) DBUG_RETURN(1); /* Make an unique key over the first field to avoid duplicated updates */