Loading mysql-test/r/lock.result +10 −0 Original line number Diff line number Diff line Loading @@ -47,3 +47,13 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; create table t1 ( a int(11) not null auto_increment, primary key(a)); create table t2 ( a int(11) not null auto_increment, primary key(a)); lock tables t1 write, t2 read; delete from t1 using t1,t2 where t1.a=t2.a; delete t1 from t1,t2 where t1.a=t2.a; delete from t2 using t1,t2 where t1.a=t2.a; ERROR HY000: Table 't2' was locked with a READ lock and can't be updated delete t2 from t1,t2 where t1.a=t2.a; ERROR HY000: Table 't2' was locked with a READ lock and can't be updated drop table t1,t2; mysql-test/r/rpl_log.result +10 −6 Original line number Diff line number Diff line Loading @@ -68,14 +68,18 @@ master-bin.000002 260 Query 1 346 use `test`; create table t1 (n int) master-bin.000002 346 Query 1 434 use `test`; insert into t1 values (1) master-bin.000002 434 Query 1 510 use `test`; drop table t1 show binary logs; Log_name master-bin.000001 master-bin.000002 Log_name File_size master-bin.000001 0 master-bin.000002 510 Warnings: Error 29 File 'master-bin.000001' not found (Errcode: 2) start slave; show binary logs; Log_name slave-bin.000001 slave-bin.000002 Log_name File_size slave-bin.000001 0 slave-bin.000002 348 Warnings: Error 29 File 'slave-bin.000001' not found (Errcode: 2) show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 Loading mysql-test/r/rpl_rotate_logs.result +26 −16 Original line number Diff line number Diff line Loading @@ -26,10 +26,13 @@ create table t2(m int not null auto_increment primary key); insert into t2 values (34),(67),(123); flush logs; show binary logs; Log_name master-bin.000001 master-bin.000002 master-bin.000003 Log_name File_size master-bin.000001 0 master-bin.000002 0 master-bin.000003 98 Warnings: Error 29 File 'master-bin.000001' not found (Errcode: 2) Error 29 File 'master-bin.000002' not found (Errcode: 2) create table t3 select * from temp_table; select * from t3; a Loading @@ -42,18 +45,22 @@ set global sql_slave_skip_counter=1; start slave; purge master logs to 'master-bin.000002'; show master logs; Log_name master-bin.000002 master-bin.000003 Log_name File_size master-bin.000002 0 master-bin.000003 407 Warnings: Error 29 File 'master-bin.000002' not found (Errcode: 2) purge binary logs to 'master-bin.000002'; show binary logs; Log_name master-bin.000002 master-bin.000003 Log_name File_size master-bin.000002 0 master-bin.000003 407 Warnings: Error 29 File 'master-bin.000002' not found (Errcode: 2) purge master logs before now(); show binary logs; Log_name master-bin.000003 Log_name File_size master-bin.000003 407 insert into t2 values (65); show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Loading @@ -73,10 +80,13 @@ count(*) 100 create table t4 select * from temp_table; show binary logs; Log_name master-bin.000003 master-bin.000004 master-bin.000005 Log_name File_size master-bin.000003 0 master-bin.000004 0 master-bin.000005 2032 Warnings: Error 29 File 'master-bin.000003' not found (Errcode: 2) Error 29 File 'master-bin.000004' not found (Errcode: 2) show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000005 2032 Loading mysql-test/t/lock.test +14 −0 Original line number Diff line number Diff line Loading @@ -59,3 +59,17 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; # # Bug7241 - Invalid response when DELETE .. USING and LOCK TABLES used. # create table t1 ( a int(11) not null auto_increment, primary key(a)); create table t2 ( a int(11) not null auto_increment, primary key(a)); lock tables t1 write, t2 read; delete from t1 using t1,t2 where t1.a=t2.a; delete t1 from t1,t2 where t1.a=t2.a; --error 1099 delete from t2 using t1,t2 where t1.a=t2.a; --error 1099 delete t2 from t1,t2 where t1.a=t2.a; drop table t1,t2; sql/sql_parse.cc +13 −0 Original line number Diff line number Diff line Loading @@ -2326,6 +2326,10 @@ mysql_execute_command(THD *thd) } #endif /* !HAVE_REPLICATION */ /* When option readonly is set deny operations which change tables. Except for the replication thread and the 'super' users. Loading Loading @@ -5198,6 +5202,7 @@ void mysql_init_multi_delete(LEX *lex) lex->select_lex.select_limit= lex->unit.select_limit_cnt= HA_POS_ERROR; lex->select_lex.table_list.save_and_clear(&lex->auxilliary_table_list); lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; lex->query_tables= 0; lex->query_tables_last= &lex->query_tables; } Loading Loading @@ -6776,6 +6781,14 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } walk->lock_type= target_tbl->lock_type; target_tbl->correspondent_table= walk; // Remember corresponding table /* in case of subselects, we need to set lock_type in * corresponding table in list of all tables */ if (walk->correspondent_table) { target_tbl->correspondent_table= walk->correspondent_table; walk->correspondent_table->lock_type= walk->lock_type; } } DBUG_RETURN(FALSE); } Loading Loading
mysql-test/r/lock.result +10 −0 Original line number Diff line number Diff line Loading @@ -47,3 +47,13 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; create table t1 ( a int(11) not null auto_increment, primary key(a)); create table t2 ( a int(11) not null auto_increment, primary key(a)); lock tables t1 write, t2 read; delete from t1 using t1,t2 where t1.a=t2.a; delete t1 from t1,t2 where t1.a=t2.a; delete from t2 using t1,t2 where t1.a=t2.a; ERROR HY000: Table 't2' was locked with a READ lock and can't be updated delete t2 from t1,t2 where t1.a=t2.a; ERROR HY000: Table 't2' was locked with a READ lock and can't be updated drop table t1,t2;
mysql-test/r/rpl_log.result +10 −6 Original line number Diff line number Diff line Loading @@ -68,14 +68,18 @@ master-bin.000002 260 Query 1 346 use `test`; create table t1 (n int) master-bin.000002 346 Query 1 434 use `test`; insert into t1 values (1) master-bin.000002 434 Query 1 510 use `test`; drop table t1 show binary logs; Log_name master-bin.000001 master-bin.000002 Log_name File_size master-bin.000001 0 master-bin.000002 510 Warnings: Error 29 File 'master-bin.000001' not found (Errcode: 2) start slave; show binary logs; Log_name slave-bin.000001 slave-bin.000002 Log_name File_size slave-bin.000001 0 slave-bin.000002 348 Warnings: Error 29 File 'slave-bin.000001' not found (Errcode: 2) show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 Loading
mysql-test/r/rpl_rotate_logs.result +26 −16 Original line number Diff line number Diff line Loading @@ -26,10 +26,13 @@ create table t2(m int not null auto_increment primary key); insert into t2 values (34),(67),(123); flush logs; show binary logs; Log_name master-bin.000001 master-bin.000002 master-bin.000003 Log_name File_size master-bin.000001 0 master-bin.000002 0 master-bin.000003 98 Warnings: Error 29 File 'master-bin.000001' not found (Errcode: 2) Error 29 File 'master-bin.000002' not found (Errcode: 2) create table t3 select * from temp_table; select * from t3; a Loading @@ -42,18 +45,22 @@ set global sql_slave_skip_counter=1; start slave; purge master logs to 'master-bin.000002'; show master logs; Log_name master-bin.000002 master-bin.000003 Log_name File_size master-bin.000002 0 master-bin.000003 407 Warnings: Error 29 File 'master-bin.000002' not found (Errcode: 2) purge binary logs to 'master-bin.000002'; show binary logs; Log_name master-bin.000002 master-bin.000003 Log_name File_size master-bin.000002 0 master-bin.000003 407 Warnings: Error 29 File 'master-bin.000002' not found (Errcode: 2) purge master logs before now(); show binary logs; Log_name master-bin.000003 Log_name File_size master-bin.000003 407 insert into t2 values (65); show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Loading @@ -73,10 +80,13 @@ count(*) 100 create table t4 select * from temp_table; show binary logs; Log_name master-bin.000003 master-bin.000004 master-bin.000005 Log_name File_size master-bin.000003 0 master-bin.000004 0 master-bin.000005 2032 Warnings: Error 29 File 'master-bin.000003' not found (Errcode: 2) Error 29 File 'master-bin.000004' not found (Errcode: 2) show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000005 2032 Loading
mysql-test/t/lock.test +14 −0 Original line number Diff line number Diff line Loading @@ -59,3 +59,17 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; # # Bug7241 - Invalid response when DELETE .. USING and LOCK TABLES used. # create table t1 ( a int(11) not null auto_increment, primary key(a)); create table t2 ( a int(11) not null auto_increment, primary key(a)); lock tables t1 write, t2 read; delete from t1 using t1,t2 where t1.a=t2.a; delete t1 from t1,t2 where t1.a=t2.a; --error 1099 delete from t2 using t1,t2 where t1.a=t2.a; --error 1099 delete t2 from t1,t2 where t1.a=t2.a; drop table t1,t2;
sql/sql_parse.cc +13 −0 Original line number Diff line number Diff line Loading @@ -2326,6 +2326,10 @@ mysql_execute_command(THD *thd) } #endif /* !HAVE_REPLICATION */ /* When option readonly is set deny operations which change tables. Except for the replication thread and the 'super' users. Loading Loading @@ -5198,6 +5202,7 @@ void mysql_init_multi_delete(LEX *lex) lex->select_lex.select_limit= lex->unit.select_limit_cnt= HA_POS_ERROR; lex->select_lex.table_list.save_and_clear(&lex->auxilliary_table_list); lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; lex->query_tables= 0; lex->query_tables_last= &lex->query_tables; } Loading Loading @@ -6776,6 +6781,14 @@ bool multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } walk->lock_type= target_tbl->lock_type; target_tbl->correspondent_table= walk; // Remember corresponding table /* in case of subselects, we need to set lock_type in * corresponding table in list of all tables */ if (walk->correspondent_table) { target_tbl->correspondent_table= walk->correspondent_table; walk->correspondent_table->lock_type= walk->lock_type; } } DBUG_RETURN(FALSE); } Loading