summaryrefslogtreecommitdiff
path: root/sql/sql_db.cc
diff options
context:
space:
mode:
authorunknown <mats@mysql.com>2004-12-03 12:13:51 +0100
committerunknown <mats@mysql.com>2004-12-03 12:13:51 +0100
commit220acb328e8f4e46fd16b60af6c5a23852e4feef (patch)
tree9bc3bd40e4b1f44785c9ff7e39f7d045b8960d70 /sql/sql_db.cc
parent6c81b518c059d362aedbf8781f574d6fb55d30b5 (diff)
downloadmariadb-git-220acb328e8f4e46fd16b60af6c5a23852e4feef.tar.gz
Bug#6391 (binlog-do-db rules ignored)
CREATE DATABASE statement used the current database instead of the database created when checking conditions for replication. CREATE/DROP/ALTER DATABASE statements are now replicated based on the manipulated database. mysql-test/t/rpl_until.test: Longer sleep to allow slave to stop. mysql-test/t/rpl_charset.test: Position change in binary file. mysql-test/r/drop_temp_table.result: Position change in binlog. mysql-test/r/rpl_loaddata_rule_m.result: Position change in binlog. mysql-test/r/rpl_charset.result: Position change in binlog. sql/log_event.h: Added new flag and parameter to suppress generation of USE statements. sql/log_event.cc: Added parameter and code to suppress generation of USE statements. sql/sql_db.cc: Suppress generation of USE before CREATE/ALTER/DROP DATABASE statements. sql/log.cc: Query_log_event have new extra parameter. sql/sql_table.cc: Query_log_event have new extra parameter. sql/sql_base.cc: Query_log_event have new extra parameter. sql/sql_update.cc: Query_log_event have new extra parameter. sql/sql_insert.cc: Query_log_event have new extra parameter. sql/sql_rename.cc: Query_log_event have new extra parameter. sql/sql_delete.cc: Query_log_event have new extra parameter. sql/sql_acl.cc: Query_log_event have new extra parameter. sql/handler.cc: Query_log_event have new extra parameter. sql/item_func.cc: Query_log_event have new extra parameter. sql/sql_parse.cc: Query_log_event have new extra parameter.
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r--sql/sql_db.cc44
1 files changed, 41 insertions, 3 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 350a7432990..e3ca0328382 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -467,7 +467,29 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
mysql_update_log.write(thd, query, query_length);
if (mysql_bin_log.is_open())
{
- Query_log_event qinfo(thd, query, query_length, 0);
+ Query_log_event qinfo(thd, query, query_length, 0,
+ /* suppress_use */ TRUE);
+
+ /*
+ Write should use the database being created as the "current
+ database" and not the threads current database, which is the
+ default. If we do not change the "current database" to the
+ database being created, the CREATE statement will not be
+ replicated when using --binlog-do-db to select databases to be
+ replicated.
+
+ An example (--binlog-do-db=sisyfos):
+
+ CREATE DATABASE bob; # Not replicated
+ USE bob; # 'bob' is the current database
+ CREATE DATABASE sisyfos; # Not replicated since 'bob' is
+ # current database.
+ USE sisyfos; # Will give error on slave since
+ # database does not exist.
+ */
+ qinfo.db = db;
+ qinfo.db_len = strlen(db);
+
mysql_bin_log.write(&qinfo);
}
send_ok(thd, result);
@@ -517,7 +539,15 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open())
{
- Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
+ Query_log_event qinfo(thd, thd->query, thd->query_length, 0,
+ /* suppress_use */ TRUE);
+
+ // Write should use the database being created as the "current
+ // database" and not the threads current database, which is the
+ // default.
+ qinfo.db = db;
+ qinfo.db_len = strlen(db);
+
thd->clear_error();
mysql_bin_log.write(&qinfo);
}
@@ -625,7 +655,15 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
mysql_update_log.write(thd, query, query_length);
if (mysql_bin_log.is_open())
{
- Query_log_event qinfo(thd, query, query_length, 0);
+ Query_log_event qinfo(thd, query, query_length, 0,
+ /* suppress_use */ TRUE);
+
+ // Write should use the database being created as the "current
+ // database" and not the threads current database, which is the
+ // default.
+ qinfo.db = db;
+ qinfo.db_len = strlen(db);
+
thd->clear_error();
mysql_bin_log.write(&qinfo);
}