Commit 37cdb0fb authored by svoj@may.pils.ru's avatar svoj@may.pils.ru

BUG#18036 - update of table joined to self reports table as crashed

Certain updates of table joined to self results in unexpected
behavior.

The problem was that record cache was mistakenly enabled for
self-joined table updates. Normally record cache must be disabled
for such updates.

Fixed wrong condition in code that determines whether to use
record cache for self-joined table updates.

Only MyISAM tables were affected.
parent fe018746
...@@ -748,3 +748,11 @@ select count(id1) from t1 where id2 = 10; ...@@ -748,3 +748,11 @@ select count(id1) from t1 where id2 = 10;
count(id1) count(id1)
5 5
drop table t1; drop table t1;
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
SELECT * FROM t1;
a b
xxxxxxxxx bbbbbb
xxxxxxxxx bbbbbb
DROP TABLE t1;
...@@ -705,4 +705,13 @@ select count(*) from t1 where id2 = 10; ...@@ -705,4 +705,13 @@ select count(*) from t1 where id2 = 10;
select count(id1) from t1 where id2 = 10; select count(id1) from t1 where id2 = 10;
drop table t1; drop table t1;
#
# BUG#18036 - update of table joined to self reports table as crashed
#
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)) ENGINE=MyISAM;
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
SELECT * FROM t1;
DROP TABLE t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -862,7 +862,7 @@ int multi_update::prepare(List<Item> &not_used_values, ...@@ -862,7 +862,7 @@ int multi_update::prepare(List<Item> &not_used_values,
for (table_ref= all_tables; table_ref; table_ref=table_ref->next) for (table_ref= all_tables; table_ref; table_ref=table_ref->next)
{ {
TABLE *table=table_ref->table; TABLE *table=table_ref->table;
if (!(tables_to_update & table->map) && if ((tables_to_update & table->map) &&
mysql_lock_have_duplicate(thd, table, update_tables)) mysql_lock_have_duplicate(thd, table, update_tables))
table->no_cache= 1; // Disable row cache table->no_cache= 1; // Disable row cache
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment