diff options
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r-- | sql/sql_db.cc | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index adc1aab9976..94be8a5f240 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -178,13 +178,13 @@ uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length, Helper function to write a query to binlog used by mysql_rm_db() */ -static inline void write_to_binlog(THD *thd, char *query, uint q_len, - char *db, uint db_len) +static inline int write_to_binlog(THD *thd, char *query, uint q_len, + char *db, uint db_len) { Query_log_event qinfo(thd, query, q_len, 0, 0, 0); qinfo.db= db; qinfo.db_len= db_len; - mysql_bin_log.write(&qinfo); + return mysql_bin_log.write(&qinfo); } @@ -618,7 +618,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, DBUG_ENTER("mysql_create_db"); /* do not create 'information_schema' db */ - if (!my_strcasecmp(system_charset_info, db, INFORMATION_SCHEMA_NAME.str)) + if (is_schema_db(db)) { my_error(ER_DB_CREATE_EXISTS, MYF(0), db); DBUG_RETURN(-1); @@ -695,6 +695,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, file. In this case it's best to just continue as if nothing has happened. (This is a very unlikely senario) */ + thd->clear_error(); } not_silent: @@ -746,7 +747,11 @@ not_silent: qinfo.db_len = strlen(db); /* These DDL methods and logging protected with LOCK_mysql_create_db */ - mysql_bin_log.write(&qinfo); + if (mysql_bin_log.write(&qinfo)) + { + error= -1; + goto exit; + } } my_ok(thd, result); } @@ -810,9 +815,9 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, TRUE); + thd->clear_error(); Query_log_event qinfo(thd, thd->query(), thd->query_length(), 0, - /* suppress_use */ TRUE, errcode); + /* suppress_use */ TRUE, 0); /* Write should use the database being created as the "current @@ -822,9 +827,9 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) qinfo.db = db; qinfo.db_len = strlen(db); - thd->clear_error(); /* These DDL methods and logging protected with LOCK_mysql_create_db */ - mysql_bin_log.write(&qinfo); + if ((error= mysql_bin_log.write(&qinfo))) + goto exit; } my_ok(thd, result); @@ -962,9 +967,9 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) } if (mysql_bin_log.is_open()) { - int errcode= query_error_code(thd, TRUE); + thd->clear_error(); Query_log_event qinfo(thd, query, query_length, 0, - /* suppress_use */ TRUE, errcode); + /* suppress_use */ TRUE, 0); /* Write should use the database being created as the "current database" and not the threads current database, which is the @@ -973,9 +978,12 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) qinfo.db = db; qinfo.db_len = strlen(db); - thd->clear_error(); /* These DDL methods and logging protected with LOCK_mysql_create_db */ - mysql_bin_log.write(&qinfo); + if (mysql_bin_log.write(&qinfo)) + { + error= -1; + goto exit; + } } thd->clear_error(); thd->server_status|= SERVER_STATUS_DB_DROPPED; @@ -1003,7 +1011,11 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) if (query_pos + tbl_name_len + 1 >= query_end) { /* These DDL methods and logging protected with LOCK_mysql_create_db */ - write_to_binlog(thd, query, query_pos -1 - query, db, db_len); + if (write_to_binlog(thd, query, query_pos -1 - query, db, db_len)) + { + error= -1; + goto exit; + } query_pos= query_data_start; } @@ -1016,7 +1028,11 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) if (query_pos != query_data_start) { /* These DDL methods and logging protected with LOCK_mysql_create_db */ - write_to_binlog(thd, query, query_pos -1 - query, db, db_len); + if (write_to_binlog(thd, query, query_pos -1 - query, db, db_len)) + { + error= -1; + goto exit; + } } } @@ -1554,8 +1570,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch) } } - if (my_strcasecmp(system_charset_info, new_db_name->str, - INFORMATION_SCHEMA_NAME.str) == 0) + if (is_schema_db(new_db_name->str, new_db_name->length)) { /* Switch the current database to INFORMATION_SCHEMA. */ @@ -1963,7 +1978,7 @@ bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db) Query_log_event qinfo(thd, thd->query(), thd->query_length(), 0, TRUE, errcode); thd->clear_error(); - mysql_bin_log.write(&qinfo); + error|= mysql_bin_log.write(&qinfo); } /* Step9: Let's do "use newdb" if we renamed the current database */ |