Below is the list of changes that have just been committed into a local
4.1 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2361 05/07/16 04:34:35 evgen@stripped +3 -0
Fix bug#11868 Update with subquery crashes server
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.
mysql-test/r/update.result
1.23 05/07/16 04:34:08 evgen@stripped +11 -0
Test case for bug#11868 update with subquery fails
mysql-test/t/update.test
1.20 05/07/16 04:33:34 evgen@stripped +12 -0
Test case for bug#11868 update with subquery fails
sql/sql_select.cc
1.421 05/07/16 04:31:51 evgen@stripped +6 -1
Fix bug #11868 update with subquery fails
Added check for NULL before dereferencing pointer.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /work/mysql-4.1-bug-11868
--- 1.420/sql/sql_select.cc 2005-07-16 03:14:29 +04:00
+++ 1.421/sql/sql_select.cc 2005-07-16 04:31:51 +04:00
@@ -3555,7 +3555,12 @@
DBUG_ASSERT(item->type() == Item::FIELD_ITEM);
Item_field *not_null_item= (Item_field*)item;
JOIN_TAB *referred_tab= not_null_item->field->table->reginfo.join_tab;
- if (referred_tab->join != join)
+ /*
+ For UPDATE queries such as:
+ UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
+ not_null_item is the t1.f1, but it's referred_tab is 0.
+ */
+ if (!referred_tab || referred_tab->join != join)
continue;
Item *notnull;
if (!(notnull= new Item_func_isnotnull(not_null_item)))
--- 1.22/mysql-test/r/update.result 2005-04-18 05:21:40 +04:00
+++ 1.23/mysql-test/r/update.result 2005-07-16 04:34:08 +04:00
@@ -240,3 +240,14 @@
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;
--- 1.19/mysql-test/t/update.test 2005-04-18 05:21:41 +04:00
+++ 1.20/mysql-test/t/update.test 2005-07-16 04:33:34 +04:00
@@ -201,3 +201,15 @@
update t1, t2 set t1.a = t2.a where t2.b = t1.b;
show warnings;
drop table t1, t2;
+
+#
+# Bug #11868 update with subquery fails
+#
+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;
| Thread |
|---|
| • bk commit into 4.1 tree (evgen:1.2361) BUG#11868 | eugene | 15 Jul |