From f87acb594a15b415b58a3053e76bfd1b27a6d594 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Aug 2007 15:27:03 +0500 Subject: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out Problem: using "mysqlbinlog | mysql" for recoveries the connection_id() result may differ from what was used when issuing the statement. Fix: if there is a connection_id() in a statement, write to binlog SET pseudo_thread_id= XXX; before it and use the value later on. mysql-test/r/mysqlbinlog.result: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out - test result. mysql-test/t/mysqlbinlog.test: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out - test case. sql/item_create.cc: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out - set thread_specific_used flag for the connection_id() function. sql/item_func.cc: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out - always return thd->variables.pseudo_thread_id as a connection_id() result, as it contains a proper value for both master and slave. sql/log_event.cc: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out - set LOG_EVENT_THREAD_SPECIFIC_F event flag if thread_specific_used is set. sql/sql_class.cc: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out - thd->thread_specific_used introduced, which is set if thread specific value(s) used in a statement. sql/sql_class.h: Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect restores from mysqlbinlog out - thd->thread_specific_used introduced, which is set if thread specific value(s) used in a statement. --- sql/item_create.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sql/item_create.cc') diff --git a/sql/item_create.cc b/sql/item_create.cc index 50db1c37371..3713fc9e380 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -70,7 +70,9 @@ Item *create_func_ceiling(Item* a) Item *create_func_connection_id(void) { - current_thd->lex->safe_to_cache_query= 0; + THD *thd= current_thd; + thd->lex->safe_to_cache_query= 0; + thd->thread_specific_used= TRUE; return new Item_func_connection_id(); } -- cgit v1.2.1