Loading mysql-test/r/multi_update.result +11 −0 Original line number Diff line number Diff line Loading @@ -464,3 +464,14 @@ ERROR HY000: You can't specify target table 't1' for update in FROM clause delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1; ERROR HY000: You can't specify target table 't1' for update in FROM clause drop table t1,t2; create table t1 ( aclid bigint not null primary key, status tinyint(1) not null ) engine = innodb; create table t2 ( refid bigint not null primary key, aclid bigint, index idx_acl(aclid) ) engine = innodb; 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; mysql-test/t/multi_update.test +15 −0 Original line number Diff line number Diff line Loading @@ -431,3 +431,18 @@ update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; -- error 1093 delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1; drop table t1,t2; # Test for BUG#5837 - delete with outer join and const tables create table t1 ( aclid bigint not null primary key, status tinyint(1) not null ) engine = innodb; create table t2 ( refid bigint not null primary key, aclid bigint, index idx_acl(aclid) ) engine = innodb; 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; sql/sql_select.cc +8 −2 Original line number Diff line number Diff line Loading @@ -6005,7 +6005,10 @@ join_read_system(JOIN_TAB *tab) { if (error != HA_ERR_END_OF_FILE) return report_error(table, error); table->null_row=1; // This is ok. if (tab->on_expr) mark_as_null_row(tab->table); else table->null_row=1; // Why do this for inner join? empty_record(table); // Make empty record return -1; } Loading Loading @@ -6035,6 +6038,9 @@ join_read_const(JOIN_TAB *tab) } if (error) { if (tab->on_expr) mark_as_null_row(tab->table); else table->null_row=1; empty_record(table); if (error != HA_ERR_KEY_NOT_FOUND) Loading sql/table.h +8 −2 Original line number Diff line number Diff line Loading @@ -131,8 +131,14 @@ struct st_table { int current_lock; /* Type of lock on table */ enum tmp_table_type tmp_table; my_bool copy_blobs; /* copy_blobs when storing */ my_bool null_row; /* All columns are null */ my_bool maybe_null,outer_join; /* Used with OUTER JOIN */ /* Used in outer joins: if true, all columns are considered to have NULL values, including columns declared as "not null". */ my_bool null_row; /* 0 or JOIN_TYPE_{LEFT|RIGHT}, same as TABLE_LIST::outer_join */ my_bool outer_join; my_bool maybe_null; /* true if (outer_join != 0) */ my_bool force_index; my_bool distinct,const_table,no_rows; my_bool key_read; Loading Loading
mysql-test/r/multi_update.result +11 −0 Original line number Diff line number Diff line Loading @@ -464,3 +464,14 @@ ERROR HY000: You can't specify target table 't1' for update in FROM clause delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1; ERROR HY000: You can't specify target table 't1' for update in FROM clause drop table t1,t2; create table t1 ( aclid bigint not null primary key, status tinyint(1) not null ) engine = innodb; create table t2 ( refid bigint not null primary key, aclid bigint, index idx_acl(aclid) ) engine = innodb; 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;
mysql-test/t/multi_update.test +15 −0 Original line number Diff line number Diff line Loading @@ -431,3 +431,18 @@ update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1; -- error 1093 delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1; drop table t1,t2; # Test for BUG#5837 - delete with outer join and const tables create table t1 ( aclid bigint not null primary key, status tinyint(1) not null ) engine = innodb; create table t2 ( refid bigint not null primary key, aclid bigint, index idx_acl(aclid) ) engine = innodb; 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;
sql/sql_select.cc +8 −2 Original line number Diff line number Diff line Loading @@ -6005,7 +6005,10 @@ join_read_system(JOIN_TAB *tab) { if (error != HA_ERR_END_OF_FILE) return report_error(table, error); table->null_row=1; // This is ok. if (tab->on_expr) mark_as_null_row(tab->table); else table->null_row=1; // Why do this for inner join? empty_record(table); // Make empty record return -1; } Loading Loading @@ -6035,6 +6038,9 @@ join_read_const(JOIN_TAB *tab) } if (error) { if (tab->on_expr) mark_as_null_row(tab->table); else table->null_row=1; empty_record(table); if (error != HA_ERR_KEY_NOT_FOUND) Loading
sql/table.h +8 −2 Original line number Diff line number Diff line Loading @@ -131,8 +131,14 @@ struct st_table { int current_lock; /* Type of lock on table */ enum tmp_table_type tmp_table; my_bool copy_blobs; /* copy_blobs when storing */ my_bool null_row; /* All columns are null */ my_bool maybe_null,outer_join; /* Used with OUTER JOIN */ /* Used in outer joins: if true, all columns are considered to have NULL values, including columns declared as "not null". */ my_bool null_row; /* 0 or JOIN_TYPE_{LEFT|RIGHT}, same as TABLE_LIST::outer_join */ my_bool outer_join; my_bool maybe_null; /* true if (outer_join != 0) */ my_bool force_index; my_bool distinct,const_table,no_rows; my_bool key_read; Loading