1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Backport Bug#37148 to 5.1

This commit is contained in:
He Zhenxing
2010-01-24 15:03:23 +08:00
parent a365016f8b
commit 6bf8c119fe
28 changed files with 472 additions and 159 deletions

View File

@ -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);
}
@ -747,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);
}
@ -824,7 +828,8 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
qinfo.db_len = strlen(db);
/* 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);
@ -974,7 +979,11 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool 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;
}
}
thd->clear_error();
thd->server_status|= SERVER_STATUS_DB_DROPPED;
@ -1002,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;
}
@ -1015,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;
}
}
}
@ -1965,7 +1982,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 */