summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2005-07-16 05:31:16 +0400
committerevgen@moonbone.local <>2005-07-16 05:31:16 +0400
commit81d93df1ae8a1aff17345b18188ce0ddecdb9e19 (patch)
treec21e35b6f6825f000bb1346323f85a72645eb05a /mysql-test
parent0298bc347aad0ad0ed0083781d84d412a921459d (diff)
downloadmariadb-git-81d93df1ae8a1aff17345b18188ce0ddecdb9e19.tar.gz
Fix bug#11868 NOT NULL ref optimization in subquery used in update must be
disabled if ref is built with a key from the updated table Problem was in add_not_null_conds() optimization function. It contains following code: JOIN_TAB *referred_tab= not_null_item->field->table->reginfo.join_tab; ... add_cond_and_fix(&referred_tab->select_cond, notnull); For UPDATE described in bug report referred_tab is 0 and dereferencing it crashes the server.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/update.result11
-rw-r--r--mysql-test/t/update.test13
2 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index d83952e118b..e35d4e29fe4 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -240,3 +240,14 @@ update t1, t2 set t1.a = t2.a where t2.b = t1.b;
show warnings;
Level Code Message
drop table t1, t2;
+create table t1(f1 int, f2 int);
+create table t2(f3 int, f4 int);
+create index idx on t2(f3);
+insert into t1 values(1,0),(2,0);
+insert into t2 values(1,1),(2,2);
+UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
+select * from t1;
+f1 f2
+1 1
+2 2
+drop table t1,t2;
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index 6a90fb95760..41f7d37e6d0 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -201,3 +201,16 @@ analyze table t1,t2;
update t1, t2 set t1.a = t2.a where t2.b = t1.b;
show warnings;
drop table t1, t2;
+
+#
+# Bug #11868 Update with subquery with ref built with a key from the updated
+# table crashes server
+#
+create table t1(f1 int, f2 int);
+create table t2(f3 int, f4 int);
+create index idx on t2(f3);
+insert into t1 values(1,0),(2,0);
+insert into t2 values(1,1),(2,2);
+UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
+select * from t1;
+drop table t1,t2;