summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2004-12-11 15:51:52 +0300
committerunknown <sergefp@mysql.com>2004-12-11 15:51:52 +0300
commit8e4251dd855e81215281b958e97a3dc6b9153a4b (patch)
tree1d9994a8d04ec084c5f016e008c4b0c8b0c051cd
parent96a927b5dd531249a8b7f6ef2827c0e5f841e021 (diff)
downloadmariadb-git-8e4251dd855e81215281b958e97a3dc6b9153a4b.tar.gz
Fix for BUG#5837 - attempt 3.
Call mark_as_null_row in join_read_const and join_read_system. mysql-test/r/multi_update.result: Testcase for BUG#5837 mysql-test/t/multi_update.test: Testcase for BUG#5837 sql/table.h: Added comments
-rw-r--r--mysql-test/r/multi_update.result6
-rw-r--r--mysql-test/t/multi_update.test9
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/table.h10
4 files changed, 31 insertions, 4 deletions
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index fc414f2f46b..5e7b392b503 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -399,3 +399,9 @@ select * from t2;
c2_id c2_p_id c2_note c2_active
1 1 A Note 1
drop table t1, t2;
+drop table if exists t2, t1;
+create table t1(aclid bigint not null primary key, status tinyint(1) not null ) type = innodb;
+create table t2(refid bigint not null primary key, aclid bigint, index idx_acl(aclid) )type = innodb;
+insert into t2 values(1,null);
+delete t2, t1 from t2 as a left join t1 as b on (a.aclid=b.aclid) where a.refid='1';
+drop table t1, t2;
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 3494126f890..2d6770f77ed 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -337,3 +337,12 @@ update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2;
select * from t1;
select * from t2;
drop table t1, t2;
+
+# Test for BUG#5837 - delete with outer join and const tables
+drop table if exists t2, t1;
+create table t1(aclid bigint not null primary key, status tinyint(1) not null ) type = innodb;
+create table t2(refid bigint not null primary key, aclid bigint, index idx_acl(aclid) )type = innodb;
+insert into t2 values(1,null);
+delete t2, t1 from t2 as a left join t1 as b on (a.aclid=b.aclid) where a.refid='1';
+drop table t1, t2;
+
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index e46b7fb8b97..2df0d45f8ed 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4951,7 +4951,10 @@ join_read_system(JOIN_TAB *tab)
table->file->print_error(error,MYF(0));
return 1;
}
- 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;
}
@@ -4981,7 +4984,10 @@ join_read_const(JOIN_TAB *tab)
}
if (error)
{
- table->null_row=1;
+ 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)
{
diff --git a/sql/table.h b/sql/table.h
index 84df7ba127e..0a1d1893531 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -89,8 +89,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, bulk_insert;