summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguilhem@mysql.com <>2004-08-29 14:13:51 +0200
committerguilhem@mysql.com <>2004-08-29 14:13:51 +0200
commit93101561fd3d49fde9b1408f1d2b9f036fcba658 (patch)
tree53851cfbb45764dc1cf49269f90ab871b9c6d0c9
parent4d1dedd70da4f5d325229d24d38bd81732ccbc99 (diff)
downloadmariadb-git-93101561fd3d49fde9b1408f1d2b9f036fcba658.tar.gz
Fix for BUG#4500 "set character set replicates incorrectly"
We must not reset the charset in slave after each statement, otherwise the SET CHARACTER SET is cancelled immediately. Instead, we write a SET CHARACTER SET DEFAULT to the master's binlog when needed (like we already do for SET FOREIGN_KEY_CHECKS); such writing is not necessary in 4.1 (in 4.1 the bug does not exist, as the SET ONE_SHOT syntax is used). I have written a test and it works, but I'm not pushing the test as it requires building with all charsets. I have noticed differences between what is inserted in the master's table in 4.0 and 4.1, and alerted Bar.
-rw-r--r--sql/log.cc22
-rw-r--r--sql/log_event.cc2
2 files changed, 17 insertions, 7 deletions
diff --git a/sql/log.cc b/sql/log.cc
index db7b80eb4f7..9927bfe8d17 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1208,12 +1208,24 @@ bool MYSQL_LOG::write(Log_event* event_info)
/* Write log events to reset the 'run environment' of the SQL command */
- if (thd && thd->options & OPTION_NO_FOREIGN_KEY_CHECKS)
+ if (thd)
{
- Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0);
- e.set_log_pos(this);
- if (e.write(file))
- goto err;
+ if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS)
+ {
+ Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0);
+ e.set_log_pos(this);
+ if (e.write(file))
+ goto err;
+ }
+#if MYSQL_VERSION_ID < 40100
+ if (thd->variables.convert_set)
+ {
+ Query_log_event e(thd, "SET CHARACTER SET DEFAULT", 25, 0);
+ e.set_log_pos(this);
+ if (e.write(file))
+ goto err;
+ }
+#endif
}
/*
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 3e1544adf14..5526795c9d1 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1932,8 +1932,6 @@ end:
thd->query= 0; // just to be sure
thd->query_length= 0;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
- // assume no convert for next query unless set explictly
- thd->variables.convert_set = 0;
close_thread_tables(thd);
free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC));
return (thd->query_error ? thd->query_error : Log_event::exec_event(rli));