mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user