diff options
author | guilhem@mysql.com <> | 2004-06-09 16:07:01 +0200 |
---|---|---|
committer | guilhem@mysql.com <> | 2004-06-09 16:07:01 +0200 |
commit | 2b20e84ff8c5df05c42d3dfedf0b38649fea8308 (patch) | |
tree | 1003fd9ceb90dc1ddeb6db7ff4e98d8da2cc51c4 /sql/sql_db.cc | |
parent | c75b24a73a0852daafec21d3c9cadd3cbe892c9d (diff) | |
download | mariadb-git-2b20e84ff8c5df05c42d3dfedf0b38649fea8308.tar.gz |
Making DROP TABLE IF EXISTS, DROP DATABASE IF EXISTS, DELETE FROM, UPDATE be logged to
binlog even if they changed nothing, and a test for this.
This is useful when users use these commands to clean up their master and slave by issuing
one command on master (assume master and slave have slightly different data for some
reason and you want to clean up both).
Note that I have not changed multi-table DELETE and multi-table UPDATE because their
error-reporting mechanism is more complicated.
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r-- | sql/sql_db.cc | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 48c355b6cd9..9db2198268a 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -358,15 +358,25 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) { error= -1; my_error(ER_DB_DROP_EXISTS,MYF(0),db); + goto exit; } else - { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_DB_DROP_EXISTS, ER(ER_DB_DROP_EXISTS), db); - if (!silent) - send_ok(thd,0); + } + else + { + pthread_mutex_lock(&LOCK_open); + remove_db_from_cache(db); + pthread_mutex_unlock(&LOCK_open); + + error= -1; + if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0)) >= 0) + { + ha_drop_database(path); + query_cache_invalidate1(db); + error = 0; } - goto exit; } if (lower_case_table_names) { @@ -375,42 +385,30 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) my_casedn_str(files_charset_info, tmp_db); db= tmp_db; } - - pthread_mutex_lock(&LOCK_open); - remove_db_from_cache(db); - pthread_mutex_unlock(&LOCK_open); - - error = -1; - if ((deleted=mysql_rm_known_files(thd, dirp, db, path,0)) >= 0 && thd) + if (!silent && deleted>=0 && thd) { - ha_drop_database(path); - query_cache_invalidate1(db); - if (!silent) + const char *query; + ulong query_length; + if (!thd->query) { - const char *query; - ulong query_length; - if (!thd->query) - { - /* The client used the old obsolete mysql_drop_db() call */ - query= path; - query_length = (uint) (strxmov(path,"drop database `", db, "`", - NullS)- path); - } - else - { - query=thd->query; - query_length=thd->query_length; - } - mysql_update_log.write(thd, query, query_length); - if (mysql_bin_log.is_open()) - { - Query_log_event qinfo(thd, query, query_length, 0); - thd->clear_error(); - mysql_bin_log.write(&qinfo); - } - send_ok(thd,(ulong) deleted); + /* The client used the old obsolete mysql_drop_db() call */ + query= path; + query_length= (uint) (strxmov(path, "drop database `", db, "`", + NullS) - path); + } + else + { + query =thd->query; + query_length= thd->query_length; + } + mysql_update_log.write(thd, query, query_length); + if (mysql_bin_log.is_open()) + { + Query_log_event qinfo(thd, query, query_length, 0); + thd->clear_error(); + mysql_bin_log.write(&qinfo); } - error = 0; + send_ok(thd, (ulong) deleted); } exit: |