Commit 2b3c8b9d authored by lars@mysql.com's avatar lars@mysql.com

BUG#6883: Added tests for create/drop temporary table, UNLOCK TABLES

If a create table can not do implicit commit, the stmt now fails
CREATE/DROP TEMPORARY TABLE is now flushed to binlog
parent 54bf811a
...@@ -21,7 +21,9 @@ eval SELECT CONCAT('######## ','$my_stmt',' ########') as ""; ...@@ -21,7 +21,9 @@ eval SELECT CONCAT('######## ','$my_stmt',' ########') as "";
--enable_query_log --enable_query_log
### Predict the number of the current log ###############################################################
# Predict the number of the current log
###############################################################
# Disable the logging of the log number computation. # Disable the logging of the log number computation.
--disable_query_log --disable_query_log
# $_log_num_n should contain the number of the current binlog in numeric style. # $_log_num_n should contain the number of the current binlog in numeric style.
...@@ -38,7 +40,9 @@ let $_log_num_s= `select @aux`; ...@@ -38,7 +40,9 @@ let $_log_num_s= `select @aux`;
# eval SELECT '$log_num' ; # eval SELECT '$log_num' ;
--enable_query_log --enable_query_log
# INSERT + command to be tested + ROLLBACK ###############################################################
# INSERT
###############################################################
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
...@@ -49,6 +53,7 @@ eval INSERT INTO t1 SET f1= $MAX + 1; ...@@ -49,6 +53,7 @@ eval INSERT INTO t1 SET f1= $MAX + 1;
# results before DDL(to be tested) # results before DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
sync_slave_with_master; sync_slave_with_master;
...@@ -59,8 +64,12 @@ SELECT '-------- switch to slave --------' as ""; ...@@ -59,8 +64,12 @@ SELECT '-------- switch to slave --------' as "";
# results before DDL(to be tested) # results before DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
###############################################################
# command to be tested
###############################################################
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
...@@ -71,6 +80,7 @@ let $my_stmt= ERROR: YOU FORGOT TO FILL IN THE STATEMENT; ...@@ -71,6 +80,7 @@ let $my_stmt= ERROR: YOU FORGOT TO FILL IN THE STATEMENT;
# results after DDL(to be tested) # results after DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
sync_slave_with_master; sync_slave_with_master;
...@@ -81,8 +91,12 @@ SELECT '-------- switch to slave --------' as ""; ...@@ -81,8 +91,12 @@ SELECT '-------- switch to slave --------' as "";
# results after DDL(to be tested) # results after DDL(to be tested)
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
###############################################################
# ROLLBACK
###############################################################
connection master; connection master;
--disable_query_log --disable_query_log
SELECT '-------- switch to master -------' as ""; SELECT '-------- switch to master -------' as "";
...@@ -93,11 +107,15 @@ SELECT MAX(f1) FROM t1; ...@@ -93,11 +107,15 @@ SELECT MAX(f1) FROM t1;
# Try to detect if the DDL command caused that the INSERT is committed # Try to detect if the DDL command caused that the INSERT is committed
# $MAX holds the highest/last value just before the insert of MAX + 1 # $MAX holds the highest/last value just before the insert of MAX + 1
--disable_query_log --disable_query_log
eval SELECT CONCAT('TEST-INFO: MASTER: The INSERT is ', eval SELECT CONCAT(CONCAT('TEST-INFO: MASTER: The INSERT is ',
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')) AS "" IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
FROM d1.t1; IF((MAX(f1) = $MAX + 1) XOR NOT $my_master_commit,
' (Succeeded)',
' (Failed)')) AS ""
FROM mysqltest1.t1;
--enable_query_log --enable_query_log
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'master-bin.$_log_num_s';
sync_slave_with_master; sync_slave_with_master;
...@@ -108,13 +126,20 @@ SELECT '-------- switch to slave --------' as ""; ...@@ -108,13 +126,20 @@ SELECT '-------- switch to slave --------' as "";
# results after final ROLLBACK # results after final ROLLBACK
SELECT MAX(f1) FROM t1; SELECT MAX(f1) FROM t1;
--disable_query_log --disable_query_log
eval SELECT CONCAT('TEST-INFO: SLAVE: The INSERT is ', eval SELECT CONCAT(CONCAT('TEST-INFO: SLAVE: The INSERT is ',
IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')) AS "" IF(MAX(f1) = $MAX + 1, 'committed', 'not committed')),
FROM d1.t1; IF((MAX(f1) = $MAX + 1) XOR NOT $my_slave_commit,
' (Succeeded)',
' (Failed)')) AS ""
FROM mysqltest1.t1;
--enable_query_log --enable_query_log
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s'; eval SHOW BINLOG EVENTS IN 'slave-bin.$_log_num_s';
###############################################################
# Manipulate binlog
###############################################################
#let $manipulate= 0; #let $manipulate= 0;
let $manipulate= 1; let $manipulate= 1;
while ($manipulate) while ($manipulate)
......
This diff is collapsed.
This diff is collapsed.
...@@ -2410,10 +2410,19 @@ mysql_execute_command(THD *thd) ...@@ -2410,10 +2410,19 @@ mysql_execute_command(THD *thd)
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
{ {
/* If CREATE TABLE of non-temporary table, do implicit commit */ /* If CREATE TABLE of non-temporary table, do implicit commit */
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
end_active_trans(thd)) {
res= -1; if (end_active_trans(thd))
{
res= -1;
break;
}
}
else
{
/* So that CREATE TEMPORARY TABLE gets flushed to binlog */
thd->options|= (OPTION_STATUS_NO_TRANS_UPDATE);
}
/* Skip first table, which is the table we are creating */ /* Skip first table, which is the table we are creating */
TABLE_LIST *create_table, *create_table_local; TABLE_LIST *create_table, *create_table_local;
tables= lex->unlink_first_table(tables, &create_table, tables= lex->unlink_first_table(tables, &create_table,
...@@ -2979,6 +2988,9 @@ unsent_create_error: ...@@ -2979,6 +2988,9 @@ unsent_create_error:
*/ */
if (thd->slave_thread) if (thd->slave_thread)
lex->drop_if_exists= 1; lex->drop_if_exists= 1;
/* So that DROP TEMPORARY TABLE gets flushed to binlog */
thd->options|= (OPTION_STATUS_NO_TRANS_UPDATE);
} }
res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary); res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary);
} }
......
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