summaryrefslogtreecommitdiff
path: root/sql/sql_udf.cc
diff options
context:
space:
mode:
authorunknown <Dao-Gang.Qu@sun.com>2010-01-22 17:38:21 +0800
committerunknown <Dao-Gang.Qu@sun.com>2010-01-22 17:38:21 +0800
commit3cae7d1187795a8089b6f54ac60cf2a0e579cf89 (patch)
tree38a04f7b1df366f29044950c701f98334c2d062b /sql/sql_udf.cc
parent132b46e96eb48b8d9d993583ed7b9ecd87e53674 (diff)
downloadmariadb-git-3cae7d1187795a8089b6f54ac60cf2a0e579cf89.tar.gz
Bug #49132 Replication failure on temporary table + DDL
In RBR, DDL statement will change binlog format to non row-based format before it is binlogged, but the binlog format was not be restored, and then manipulating a temporary table can not reset binlog format to row-based format rightly. So that the manipulated statement is binlogged with statement-based format. To fix the problem, restore the state of binlog format after the DDL statement is binlogged. mysql-test/extra/rpl_tests/rpl_tmp_table_and_DDL.test: Added the test file to verify if executing DDL statement before trying to manipulate a temporary table causes row-based replication to break with error 'table does not exist'. mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result: Correct the test result, all the above binlog event should be row-based after the bug49132 is fixed IN RBR. mysql-test/suite/ndb/r/ndb_tmp_table_and_DDL.result: Test result for bug#49132 base on ndb engine. mysql-test/suite/ndb/t/ndb_tmp_table_and_DDL.test: Added the test file to verify if executing DDL statement before trying to manipulate a temporary table causes row-based replication to break with error 'table does not exist' base on ndb engine. mysql-test/suite/rpl/r/rpl_tmp_table_and_DDL.result: Test result for bug#49132 base on myisam engine. mysql-test/suite/rpl/t/rpl_tmp_table_and_DDL.test: Added the test file to verify if executing DDL statement before trying to manipulate a temporary table causes row-based replication to break with error 'table does not exist' base on myisam engine. sql/event_db_repository.cc: Added code to restore the state of binlog format after the DDL statement is binlogged. sql/events.cc: Added code to restore the state of binlog format after the DDL statement is binlogged. sql/sp.cc: Added code to restore the state of binlog format after the DDL statement is binlogged. sql/sql_acl.cc: Added code to restore the state of binlog format after the DDL statement is binlogged. sql/sql_udf.cc: Added code to restore the state of binlog format after the DDL statement is binlogged.
Diffstat (limited to 'sql/sql_udf.cc')
-rw-r--r--sql/sql_udf.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index c6b41b59a3f..76cadc79c6f 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -398,6 +398,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
TABLE *table;
TABLE_LIST tables;
udf_func *u_d;
+ bool save_binlog_row_based;
DBUG_ENTER("mysql_create_function");
if (!initialized)
@@ -437,8 +438,8 @@ int mysql_create_function(THD *thd,udf_func *udf)
Turn off row binlogging of this statement and use statement-based
so that all supporting tables are updated for CREATE FUNCTION command.
*/
- if (thd->current_stmt_binlog_row_based)
- thd->clear_current_stmt_binlog_row_based();
+ save_binlog_row_based= thd->current_stmt_binlog_row_based;
+ thd->clear_current_stmt_binlog_row_based();
rw_wrlock(&THR_LOCK_udf);
if ((hash_search(&udf_hash,(uchar*) udf->name.str, udf->name.length)))
@@ -508,12 +509,16 @@ int mysql_create_function(THD *thd,udf_func *udf)
/* Binlog the create function. */
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
+ /* Restore the state of binlog format */
+ thd->current_stmt_binlog_row_based= save_binlog_row_based;
DBUG_RETURN(0);
err:
if (new_dl)
dlclose(dl);
rw_unlock(&THR_LOCK_udf);
+ /* Restore the state of binlog format */
+ thd->current_stmt_binlog_row_based= save_binlog_row_based;
DBUG_RETURN(1);
}
@@ -525,6 +530,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
udf_func *udf;
char *exact_name_str;
uint exact_name_len;
+ bool save_binlog_row_based;
DBUG_ENTER("mysql_drop_function");
if (!initialized)
@@ -540,8 +546,8 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
Turn off row binlogging of this statement and use statement-based
so that all supporting tables are updated for DROP FUNCTION command.
*/
- if (thd->current_stmt_binlog_row_based)
- thd->clear_current_stmt_binlog_row_based();
+ save_binlog_row_based= thd->current_stmt_binlog_row_based;
+ thd->clear_current_stmt_binlog_row_based();
rw_wrlock(&THR_LOCK_udf);
if (!(udf=(udf_func*) hash_search(&udf_hash,(uchar*) udf_name->str,
@@ -583,9 +589,13 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name)
/* Binlog the drop function. */
write_bin_log(thd, TRUE, thd->query(), thd->query_length());
+ /* Restore the state of binlog format */
+ thd->current_stmt_binlog_row_based= save_binlog_row_based;
DBUG_RETURN(0);
err:
rw_unlock(&THR_LOCK_udf);
+ /* Restore the state of binlog format */
+ thd->current_stmt_binlog_row_based= save_binlog_row_based;
DBUG_RETURN(1);
}