summaryrefslogtreecommitdiff
path: root/sql/sql_db.cc
diff options
context:
space:
mode:
authormonty@mysql.com <>2004-12-06 11:38:56 +0200
committermonty@mysql.com <>2004-12-06 11:38:56 +0200
commit0de4777187a869b4a070ba1e0da28a2ffe1abf05 (patch)
treea7bb331b7dac7ac2b3cda915e99bb8c1333f4fec /sql/sql_db.cc
parent86508ad9690c61e806acf308b57c6431b1a2dd99 (diff)
parentdededf09fa8cb1096549e74f543c84b81e413066 (diff)
downloadmariadb-git-0de4777187a869b4a070ba1e0da28a2ffe1abf05.tar.gz
Merge with 4.1
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 ad4887146d8..3e606029bec 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -468,7 +468,29 @@ bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
}
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 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
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);
}
@@ -623,7 +653,15 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
}
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);
}