summaryrefslogtreecommitdiff
path: root/sql/repl_failsafe.cc
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2003-09-11 23:17:28 +0200
committerunknown <guilhem@mysql.com>2003-09-11 23:17:28 +0200
commit69b8b3ff7c37dd72a5f5f265e92e801783e7b9bd (patch)
tree17368ba287e00c5ee8a4b28a65a34bbf5fb4e4f5 /sql/repl_failsafe.cc
parent8272be9412ecf6566192260df7217a1bec7ffc99 (diff)
downloadmariadb-git-69b8b3ff7c37dd72a5f5f265e92e801783e7b9bd.tar.gz
* Fix for BUG#1248: "LOAD DATA FROM MASTER drops the slave's db unexpectedly".
Now LOAD DATA FROM MASTER does not drop the database, instead it only tries to create it, and drops/creates table-by-table. * replicate_wild_ignore_table='db1.%' is now considered as "ignore the 'db1' database as a whole", as it already works for CREATE DATABASE and DROP DATABASE. mysql-test/r/rpl000009.result: result update mysql-test/t/rpl000009.test: test that LOAD DATA FROM MASTER does not drop databases, but rather table by table, thus preserving non-replicated tables. Test that LOAD DATA FROM MASTER reports the error when a table could not be dropped (system's "permission denied" for example). Test that LOAD TABLE FROM MASTER reports the error when the table already exists. sql/repl_failsafe.cc: * replicate_wild_ignore_table='db1.%' is now considered as "ignore the 'db1' database as a whole", as it already works for CREATE DATABASE and DROP DATABASE. * If a db matches replicate_*_db rules, we don't drop/recreate it because this could drop some tables in this db which could be slave-specific. Instead, we do a CREATE DATABASE IF EXISTS, and we will drop each table which has an equivalent on the master, table-by-table. sql/slave.cc: New argument to drop the table in create_table_from_dump() (LOAD TABLE/DATA FROM MASTER are the only places where this function is used). This is needed because LOAD DATA FROM MASTER does not drop the database anymore. The behaviour when the table exists is unchanged: LOAD DATA silently replaces the table, LOAD TABLE gives error. sql/slave.h: new argument to drop the table in fetch_master_table sql/sql_parse.cc: do not drop the table in LOAD TABLE FROM MASTER (this behaviour is already true; but changes in LOAD DATA FROM MASTER made the argument needed).
Diffstat (limited to 'sql/repl_failsafe.cc')
-rw-r--r--sql/repl_failsafe.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index dc3f3c87dde..8deb23e8586 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -717,7 +717,8 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db,
if (!tables_ok(thd, &table))
continue;
}
- if ((error= fetch_master_table(thd, db, table_name, mi, mysql)))
+ /* download master's table and overwrite slave's table */
+ if ((error= fetch_master_table(thd, db, table_name, mi, mysql, 1)))
return error;
}
return 0;
@@ -819,8 +820,11 @@ int load_master_data(THD* thd)
char* db = row[0];
/*
- Do not replicate databases excluded by rules
- also skip mysql database - in most cases the user will
+ Do not replicate databases excluded by rules. We also test
+ replicate_wild_*_table rules (replicate_wild_ignore_table='db1.%' will
+ be considered as "ignore the 'db1' database as a whole, as it already
+ works for CREATE DATABASE and DROP DATABASE).
+ Also skip 'mysql' database - in most cases the user will
mess up and not exclude mysql database with the rules when
he actually means to - in this case, he is up for a surprise if
his priv tables get dropped and downloaded from master
@@ -830,14 +834,14 @@ int load_master_data(THD* thd)
*/
if (!db_ok(db, replicate_do_db, replicate_ignore_db) ||
+ !db_ok_with_wild_table(db) ||
!strcmp(db,"mysql"))
{
*cur_table_res = 0;
continue;
}
- if (mysql_rm_db(thd, db, 1,1) ||
- mysql_create_db(thd, db, 0, 1))
+ if (mysql_create_db(thd, db, HA_LEX_CREATE_IF_NOT_EXISTS, 1))
{
send_error(&thd->net, 0, 0);
cleanup_mysql_results(db_res, cur_table_res - 1, table_res);