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_table.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_table.cc')
-rw-r--r-- | sql/sql_table.cc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8682b98a69a..bdff1f52d04 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -254,7 +254,17 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } } thd->tmp_table_used= tmp_table_deleted; - if (some_tables_deleted || tmp_table_deleted) + error= 0; + if (wrong_tables.length()) + { + if (!foreign_key_error) + my_error(ER_BAD_TABLE_ERROR,MYF(0), wrong_tables.c_ptr()); + else + my_error(ER_ROW_IS_REFERENCED, MYF(0)); + error= 1; + } + + if (some_tables_deleted || tmp_table_deleted || !error) { query_cache_invalidate3(thd, tables, 0); if (!dont_log_query) @@ -262,7 +272,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, mysql_update_log.write(thd, thd->query,thd->query_length); if (mysql_bin_log.is_open()) { - thd->clear_error(); + if (!error) + thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, tmp_table_deleted && !some_tables_deleted); mysql_bin_log.write(&qinfo); @@ -271,15 +282,6 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, } unlock_table_names(thd, tables); - error= 0; - if (wrong_tables.length()) - { - if (!foreign_key_error) - my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr()); - else - my_error(ER_ROW_IS_REFERENCED,MYF(0)); - error= 1; - } DBUG_RETURN(error); } |