Commit d023ca78 authored by unknown's avatar unknown

- set 'updating' in both tables list if we have two of them (because of subquery) (BUG#13236)

- fixed test


mysql-test/r/rpl_multi_update2.result:
  fixed setting/reseting environment
  multi-update with subquery added
mysql-test/t/rpl_multi_update2.test:
  fixed setting/reseting environment
  multi-update with subquery added
sql/sql_update.cc:
  set 'updating' in both tables list if we have two of them (because of subquery)
parent 123be605
...@@ -4,6 +4,7 @@ reset master; ...@@ -4,6 +4,7 @@ reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave; start slave;
drop table if exists t1,t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
a int unsigned not null auto_increment primary key, a int unsigned not null auto_increment primary key,
b int unsigned b int unsigned
...@@ -40,3 +41,15 @@ SELECT * FROM t2 ORDER BY a; ...@@ -40,3 +41,15 @@ SELECT * FROM t2 ORDER BY a;
a b a b
1 0 1 0
2 1 2 1
drop table t1,t2;
reset master;
CREATE TABLE t1 ( a INT );
INSERT INTO t1 VALUES (0);
UPDATE t1, (SELECT 3 as b) AS x SET t1.a = x.b;
select * from t1;
a
3
select * from t1;
a
3
drop table t1;
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
source include/master-slave.inc; source include/master-slave.inc;
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
CREATE TABLE t1 ( CREATE TABLE t1 (
a int unsigned not null auto_increment primary key, a int unsigned not null auto_increment primary key,
b int unsigned b int unsigned
...@@ -32,4 +36,27 @@ sync_with_master; ...@@ -32,4 +36,27 @@ sync_with_master;
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
SELECT * FROM t2 ORDER BY a; SELECT * FROM t2 ORDER BY a;
connection master;
drop table t1,t2;
sync_slave_with_master;
#
# BUG#13236 multi-update with subquery & --replicate-ignore-table
#
reset master;
connection master;
CREATE TABLE t1 ( a INT );
INSERT INTO t1 VALUES (0);
UPDATE t1, (SELECT 3 as b) AS x SET t1.a = x.b;
select * from t1;
sync_slave_with_master;
connection slave;
select * from t1;
connection master;
drop table t1;
sync_slave_with_master;
# End of 4.1 tests # End of 4.1 tests
...@@ -569,7 +569,9 @@ int mysql_multi_update_lock(THD *thd, ...@@ -569,7 +569,9 @@ int mysql_multi_update_lock(THD *thd,
} }
DBUG_PRINT("info",("setting table `%s` for update", tl->alias)); DBUG_PRINT("info",("setting table `%s` for update", tl->alias));
tl->lock_type= thd->lex->multi_lock_option; tl->lock_type= thd->lex->multi_lock_option;
tl->updating= 1; tl->updating= 1; // loacal or only list
if (tl->table_list)
tl->table_list->updating= 1; // global list (if we have 2 lists)
wants= UPDATE_ACL; wants= UPDATE_ACL;
} }
else else
...@@ -579,7 +581,9 @@ int mysql_multi_update_lock(THD *thd, ...@@ -579,7 +581,9 @@ int mysql_multi_update_lock(THD *thd,
// correct order of statements. Otherwise, we use a TL_READ lock to // correct order of statements. Otherwise, we use a TL_READ lock to
// improve performance. // improve performance.
tl->lock_type= using_update_log ? TL_READ_NO_INSERT : TL_READ; tl->lock_type= using_update_log ? TL_READ_NO_INSERT : TL_READ;
tl->updating= 0; tl->updating= 0; // loacal or only list
if (tl->table_list)
tl->table_list->updating= 0; // global list (if we have 2 lists)
wants= SELECT_ACL; wants= SELECT_ACL;
} }
......
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