merge of the fix for bug 17417 5.0-opt->5.1-opt
This commit is contained in:
parent
86d9a7f92a
commit
8e1ec7ab5e
@ -316,121 +316,3 @@ disconnect con3;
|
|||||||
connection con4;
|
connection con4;
|
||||||
select get_lock("a",10); # wait for rollback to finish
|
select get_lock("a",10); # wait for rollback to finish
|
||||||
|
|
||||||
#
|
|
||||||
# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
|
|
||||||
# bug #28960 non-trans temp table changes with insert .. select
|
|
||||||
# not binlogged after rollback
|
|
||||||
#
|
|
||||||
# testing appearence of insert into temp_table in binlog.
|
|
||||||
# There are two branches of execution that require different setup.
|
|
||||||
|
|
||||||
## send_eof() branch
|
|
||||||
|
|
||||||
# prepare
|
|
||||||
|
|
||||||
create temporary table tt (a int unique);
|
|
||||||
create table ti (a int) engine=innodb;
|
|
||||||
reset master;
|
|
||||||
show master status;
|
|
||||||
|
|
||||||
# action
|
|
||||||
|
|
||||||
begin;
|
|
||||||
insert into ti values (1);
|
|
||||||
insert into ti values (2) ;
|
|
||||||
insert into tt select * from ti;
|
|
||||||
rollback;
|
|
||||||
|
|
||||||
# check
|
|
||||||
|
|
||||||
select count(*) from tt /* 2 */;
|
|
||||||
show master status;
|
|
||||||
--replace_column 2 # 5 #
|
|
||||||
show binlog events from 98;
|
|
||||||
select count(*) from ti /* zero */;
|
|
||||||
insert into ti select * from tt;
|
|
||||||
select * from ti /* that is what slave would miss - a bug */;
|
|
||||||
|
|
||||||
|
|
||||||
## send_error() branch
|
|
||||||
delete from ti;
|
|
||||||
delete from tt where a=1;
|
|
||||||
reset master;
|
|
||||||
show master status;
|
|
||||||
|
|
||||||
# action
|
|
||||||
|
|
||||||
begin;
|
|
||||||
insert into ti values (1);
|
|
||||||
insert into ti values (2) /* to make the dup error in the following */;
|
|
||||||
--error ER_DUP_ENTRY
|
|
||||||
insert into tt select * from ti /* one affected and error */;
|
|
||||||
rollback;
|
|
||||||
|
|
||||||
# check
|
|
||||||
|
|
||||||
show master status;
|
|
||||||
--replace_column 2 # 5 #
|
|
||||||
show binlog events from 98;
|
|
||||||
select count(*) from ti /* zero */;
|
|
||||||
insert into ti select * from tt;
|
|
||||||
select * from tt /* that is what otherwise slave missed - the bug */;
|
|
||||||
|
|
||||||
drop table ti;
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
|
|
||||||
#
|
|
||||||
# Testing asserts: if there is a side effect of modifying non-transactional
|
|
||||||
# table thd->no_trans_update.stmt must be TRUE;
|
|
||||||
# the assert is active with debug build
|
|
||||||
#
|
|
||||||
|
|
||||||
--disable_warnings
|
|
||||||
drop function if exists bug27417;
|
|
||||||
drop table if exists t1,t2;
|
|
||||||
--enable_warnings
|
|
||||||
# side effect table
|
|
||||||
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
|
|
||||||
# target tables
|
|
||||||
CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a));
|
|
||||||
|
|
||||||
delimiter |;
|
|
||||||
create function bug27417(n int)
|
|
||||||
RETURNS int(11)
|
|
||||||
begin
|
|
||||||
insert into t1 values (null);
|
|
||||||
return n;
|
|
||||||
end|
|
|
||||||
delimiter ;|
|
|
||||||
|
|
||||||
reset master;
|
|
||||||
|
|
||||||
# execute
|
|
||||||
|
|
||||||
insert into t2 values (bug27417(1));
|
|
||||||
insert into t2 select bug27417(2);
|
|
||||||
reset master;
|
|
||||||
|
|
||||||
--error ER_DUP_ENTRY
|
|
||||||
insert into t2 values (bug27417(2));
|
|
||||||
show master status; /* only (!) with fixes for #23333 will show there is the query */;
|
|
||||||
select count(*) from t1 /* must be 3 */;
|
|
||||||
|
|
||||||
reset master;
|
|
||||||
select count(*) from t2;
|
|
||||||
delete from t2 where a=bug27417(3);
|
|
||||||
select count(*) from t2 /* nothing got deleted */;
|
|
||||||
show master status; /* the query must be in regardless of #23333 */;
|
|
||||||
select count(*) from t1 /* must be 5 */;
|
|
||||||
|
|
||||||
--enable_info
|
|
||||||
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
|
|
||||||
--disable_info
|
|
||||||
select count(*) from t1 /* must be 7 */;
|
|
||||||
|
|
||||||
drop function bug27417;
|
|
||||||
drop table t1,t2;
|
|
||||||
|
|
||||||
--echo end of tests
|
|
||||||
|
@ -380,12 +380,12 @@ select
|
|||||||
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%"
|
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%" @a not like "%#%error_code=%error_code=%"
|
||||||
1 1
|
1 1
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
create temporary table tt (a int unique);
|
create table tt (a int unique);
|
||||||
create table ti (a int) engine=innodb;
|
create table ti (a int) engine=innodb;
|
||||||
reset master;
|
reset master;
|
||||||
show master status;
|
show master status;
|
||||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||||
master-bin.000001 98
|
master-bin.000001 106
|
||||||
begin;
|
begin;
|
||||||
insert into ti values (1);
|
insert into ti values (1);
|
||||||
insert into ti values (2) ;
|
insert into ti values (2) ;
|
||||||
@ -398,8 +398,8 @@ count(*)
|
|||||||
2
|
2
|
||||||
show master status;
|
show master status;
|
||||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||||
master-bin.000001 507
|
master-bin.000001 515
|
||||||
show binlog events from 98;
|
show binlog events from 106;
|
||||||
Log_name Pos Event_type Server_id End_log_pos Info
|
Log_name Pos Event_type Server_id End_log_pos Info
|
||||||
master-bin.000001 # Query 1 # use `test`; BEGIN
|
master-bin.000001 # Query 1 # use `test`; BEGIN
|
||||||
master-bin.000001 # Query 1 # use `test`; insert into ti values (1)
|
master-bin.000001 # Query 1 # use `test`; insert into ti values (1)
|
||||||
@ -419,19 +419,19 @@ delete from tt where a=1;
|
|||||||
reset master;
|
reset master;
|
||||||
show master status;
|
show master status;
|
||||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||||
master-bin.000001 98
|
master-bin.000001 106
|
||||||
begin;
|
begin;
|
||||||
insert into ti values (1);
|
insert into ti values (1);
|
||||||
insert into ti values (2) /* to make the dup error in the following */;
|
insert into ti values (2) /* to make the dup error in the following */;
|
||||||
insert into tt select * from ti /* one affected and error */;
|
insert into tt select * from ti /* one affected and error */;
|
||||||
ERROR 23000: Duplicate entry '2' for key 1
|
ERROR 23000: Duplicate entry '2' for key 'a'
|
||||||
rollback;
|
rollback;
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
||||||
show master status;
|
show master status;
|
||||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||||
master-bin.000001 581
|
master-bin.000001 589
|
||||||
show binlog events from 98;
|
show binlog events from 106;
|
||||||
Log_name Pos Event_type Server_id End_log_pos Info
|
Log_name Pos Event_type Server_id End_log_pos Info
|
||||||
master-bin.000001 # Query 1 # use `test`; BEGIN
|
master-bin.000001 # Query 1 # use `test`; BEGIN
|
||||||
master-bin.000001 # Query 1 # use `test`; insert into ti values (1)
|
master-bin.000001 # Query 1 # use `test`; insert into ti values (1)
|
||||||
@ -446,7 +446,7 @@ select * from tt /* that is what otherwise slave missed - the bug */;
|
|||||||
a
|
a
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
drop table ti;
|
drop table ti,tt;
|
||||||
drop function if exists bug27417;
|
drop function if exists bug27417;
|
||||||
drop table if exists t1,t2;
|
drop table if exists t1,t2;
|
||||||
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
|
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
|
||||||
@ -462,10 +462,10 @@ insert into t2 values (bug27417(1));
|
|||||||
insert into t2 select bug27417(2);
|
insert into t2 select bug27417(2);
|
||||||
reset master;
|
reset master;
|
||||||
insert into t2 values (bug27417(2));
|
insert into t2 values (bug27417(2));
|
||||||
ERROR 23000: Duplicate entry '2' for key 1
|
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
|
||||||
show master status;
|
show master status;
|
||||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||||
master-bin.000001 98
|
master-bin.000001 218
|
||||||
/* only (!) with fixes for #23333 will show there is the query */;
|
/* only (!) with fixes for #23333 will show there is the query */;
|
||||||
select count(*) from t1 /* must be 3 */;
|
select count(*) from t1 /* must be 3 */;
|
||||||
count(*)
|
count(*)
|
||||||
@ -480,7 +480,7 @@ count(*)
|
|||||||
2
|
2
|
||||||
show master status;
|
show master status;
|
||||||
File Position Binlog_Do_DB Binlog_Ignore_DB
|
File Position Binlog_Do_DB Binlog_Ignore_DB
|
||||||
master-bin.000001 195
|
master-bin.000001 223
|
||||||
/* the query must be in regardless of #23333 */;
|
/* the query must be in regardless of #23333 */;
|
||||||
select count(*) from t1 /* must be 5 */;
|
select count(*) from t1 /* must be 5 */;
|
||||||
count(*)
|
count(*)
|
||||||
|
@ -21,4 +21,124 @@ is not null;
|
|||||||
eval select
|
eval select
|
||||||
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%",
|
@a like "%#%error_code=0%ROLLBACK/*!*/;%ROLLBACK /* added by mysqlbinlog */;%",
|
||||||
@a not like "%#%error_code=%error_code=%";
|
@a not like "%#%error_code=%error_code=%";
|
||||||
|
|
||||||
drop table t1, t2;
|
drop table t1, t2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
|
||||||
|
# bug #28960 non-trans temp table changes with insert .. select
|
||||||
|
# not binlogged after rollback
|
||||||
|
#
|
||||||
|
# testing appearence of insert into temp_table in binlog.
|
||||||
|
# There are two branches of execution that require different setup.
|
||||||
|
|
||||||
|
## send_eof() branch
|
||||||
|
|
||||||
|
# prepare
|
||||||
|
|
||||||
|
create table tt (a int unique);
|
||||||
|
create table ti (a int) engine=innodb;
|
||||||
|
reset master;
|
||||||
|
show master status;
|
||||||
|
|
||||||
|
# action
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into ti values (1);
|
||||||
|
insert into ti values (2) ;
|
||||||
|
insert into tt select * from ti;
|
||||||
|
rollback;
|
||||||
|
|
||||||
|
# check
|
||||||
|
|
||||||
|
select count(*) from tt /* 2 */;
|
||||||
|
show master status;
|
||||||
|
--replace_column 2 # 5 #
|
||||||
|
show binlog events from 106;
|
||||||
|
select count(*) from ti /* zero */;
|
||||||
|
insert into ti select * from tt;
|
||||||
|
select * from ti /* that is what slave would miss - a bug */;
|
||||||
|
|
||||||
|
|
||||||
|
## send_error() branch
|
||||||
|
delete from ti;
|
||||||
|
delete from tt where a=1;
|
||||||
|
reset master;
|
||||||
|
show master status;
|
||||||
|
|
||||||
|
# action
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into ti values (1);
|
||||||
|
insert into ti values (2) /* to make the dup error in the following */;
|
||||||
|
--error ER_DUP_ENTRY
|
||||||
|
insert into tt select * from ti /* one affected and error */;
|
||||||
|
rollback;
|
||||||
|
|
||||||
|
# check
|
||||||
|
|
||||||
|
show master status;
|
||||||
|
--replace_column 2 # 5 #
|
||||||
|
show binlog events from 106;
|
||||||
|
select count(*) from ti /* zero */;
|
||||||
|
insert into ti select * from tt;
|
||||||
|
select * from tt /* that is what otherwise slave missed - the bug */;
|
||||||
|
|
||||||
|
drop table ti,tt;
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #27417 thd->no_trans_update.stmt lost value inside of SF-exec-stack
|
||||||
|
#
|
||||||
|
# Testing asserts: if there is a side effect of modifying non-transactional
|
||||||
|
# table thd->no_trans_update.stmt must be TRUE;
|
||||||
|
# the assert is active with debug build
|
||||||
|
#
|
||||||
|
|
||||||
|
--disable_warnings
|
||||||
|
drop function if exists bug27417;
|
||||||
|
drop table if exists t1,t2;
|
||||||
|
--enable_warnings
|
||||||
|
# side effect table
|
||||||
|
CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM;
|
||||||
|
# target tables
|
||||||
|
CREATE TABLE t2 (a int NOT NULL auto_increment, PRIMARY KEY (a));
|
||||||
|
|
||||||
|
delimiter |;
|
||||||
|
create function bug27417(n int)
|
||||||
|
RETURNS int(11)
|
||||||
|
begin
|
||||||
|
insert into t1 values (null);
|
||||||
|
return n;
|
||||||
|
end|
|
||||||
|
delimiter ;|
|
||||||
|
|
||||||
|
reset master;
|
||||||
|
|
||||||
|
# execute
|
||||||
|
|
||||||
|
insert into t2 values (bug27417(1));
|
||||||
|
insert into t2 select bug27417(2);
|
||||||
|
reset master;
|
||||||
|
|
||||||
|
--error ER_DUP_ENTRY
|
||||||
|
insert into t2 values (bug27417(2));
|
||||||
|
show master status; /* only (!) with fixes for #23333 will show there is the query */;
|
||||||
|
select count(*) from t1 /* must be 3 */;
|
||||||
|
|
||||||
|
reset master;
|
||||||
|
select count(*) from t2;
|
||||||
|
delete from t2 where a=bug27417(3);
|
||||||
|
select count(*) from t2 /* nothing got deleted */;
|
||||||
|
show master status; /* the query must be in regardless of #23333 */;
|
||||||
|
select count(*) from t1 /* must be 5 */;
|
||||||
|
|
||||||
|
--enable_info
|
||||||
|
delete t2 from t2 where t2.a=bug27417(100) /* must not affect t2 */;
|
||||||
|
--disable_info
|
||||||
|
select count(*) from t1 /* must be 7 */;
|
||||||
|
|
||||||
|
drop function bug27417;
|
||||||
|
drop table t1,t2;
|
||||||
|
|
||||||
|
--echo end of tests
|
||||||
|
@ -2573,7 +2573,7 @@ extern "C" int thd_slave_thread(const MYSQL_THD thd)
|
|||||||
|
|
||||||
extern "C" int thd_non_transactional_update(const MYSQL_THD thd)
|
extern "C" int thd_non_transactional_update(const MYSQL_THD thd)
|
||||||
{
|
{
|
||||||
return(thd->no_trans_update.all);
|
return(thd->transaction.all.modified_non_trans_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int thd_binlog_format(const MYSQL_THD thd)
|
extern "C" int thd_binlog_format(const MYSQL_THD thd)
|
||||||
|
@ -3188,7 +3188,7 @@ void select_insert::abort() {
|
|||||||
table->file->has_transactions(), FALSE);
|
table->file->has_transactions(), FALSE);
|
||||||
if (!thd->current_stmt_binlog_row_based && !table->s->tmp_table &&
|
if (!thd->current_stmt_binlog_row_based && !table->s->tmp_table &&
|
||||||
!can_rollback_data())
|
!can_rollback_data())
|
||||||
thd->no_trans_update.all= TRUE;
|
thd->transaction.all.modified_non_trans_table= TRUE;
|
||||||
query_cache_invalidate3(thd, table, 1);
|
query_cache_invalidate3(thd, table, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5176,7 +5176,7 @@ void mysql_reset_thd_for_next_command(THD *thd)
|
|||||||
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
|
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
|
||||||
{
|
{
|
||||||
thd->options&= ~OPTION_KEEP_LOG;
|
thd->options&= ~OPTION_KEEP_LOG;
|
||||||
thd->no_trans_update.all= FALSE;
|
thd->transaction.all.modified_non_trans_table= FALSE;
|
||||||
}
|
}
|
||||||
DBUG_ASSERT(thd->security_ctx== &thd->main_security_ctx);
|
DBUG_ASSERT(thd->security_ctx== &thd->main_security_ctx);
|
||||||
thd->tmp_table_used= 0;
|
thd->tmp_table_used= 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user