diff options
-rw-r--r-- | mysql-test/r/multi_update.result | 8 | ||||
-rw-r--r-- | mysql-test/t/multi_update.test | 9 | ||||
-rw-r--r-- | sql/sql_base.cc | 14 |
3 files changed, 10 insertions, 21 deletions
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index d10a4bf65f5..f5c4e19af64 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -476,9 +476,7 @@ aclid bigint, index idx_acl(aclid) insert into t2 values(1,null); delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1'; drop table t1, t2; -set @ttype_save=@@storage_engine; -set @@storage_engine=innodb; -create table t1 ( c char(8) not null ); +create table t1 ( c char(8) not null ) engine=innodb; insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); alter table t1 add b char(8) not null; @@ -489,8 +487,7 @@ create table t2 like t1; insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; drop table t1,t2; -set @@storage_engine=bdb; -create table t1 ( c char(8) not null ); +create table t1 ( c char(8) not null ) engine=bdb; insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); alter table t1 add b char(8) not null; @@ -500,7 +497,6 @@ update t1 set a=c, b=c; create table t2 like t1; insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; -set @@storage_engine=@ttype_save; drop table t1,t2; create table t1 (a int, b int); insert into t1 values (1, 2), (2, 3), (3, 4); diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index de66218c4a6..bc82de50f6f 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -452,11 +452,8 @@ drop table t1, t2; # # Test for bug #1980. # -set @ttype_save=@@storage_engine; - --disable_warnings -set @@storage_engine=innodb; -create table t1 ( c char(8) not null ); +create table t1 ( c char(8) not null ) engine=innodb; --enable_warnings insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); @@ -475,8 +472,7 @@ delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; drop table t1,t2; --disable_warnings -set @@storage_engine=bdb; -create table t1 ( c char(8) not null ); +create table t1 ( c char(8) not null ) engine=bdb; --enable_warnings insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); @@ -492,7 +488,6 @@ insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; -set @@storage_engine=@ttype_save; drop table t1,t2; create table t1 (a int, b int); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4d34ce425b1..4b29f125764 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2247,12 +2247,12 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, if (item->cached_table) { /* - This shortcut is used by prepared statements. We assuming that - TABLE_LIST *tables is not changed during query execution (which - is true for all queries except RENAME but luckily RENAME doesn't + This shortcut is used by prepared statements. We assuming that + TABLE_LIST *tables is not changed during query execution (which + is true for all queries except RENAME but luckily RENAME doesn't use fields...) so we can rely on reusing pointer to its member. With this optimization we also miss case when addition of one more - field makes some prepared query ambiguous and so erroneous, but we + field makes some prepared query ambiguous and so erroneous, but we accept this trade off. */ if (item->cached_table->table) @@ -2268,7 +2268,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, else { TABLE_LIST *table= item->cached_table; - Field *find= find_field_in_table(thd, table, name, item->name, length, + found= find_field_in_table(thd, table, name, item->name, length, ref, (table->table && test(table->table->grant. @@ -2391,9 +2391,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, { if (field == WRONG_GRANT) return (Field*) 0; - item->cached_table= tables; - if (!tables->cacheable_table) - item->cached_table= 0; + item->cached_table= (!tables->cacheable_table || found) ? 0 : tables; if (found) { if (!thd->where) // Returns first found |