Safety and speedup fixes:
Changed is_open() to work as before. Added back inited argument to LOG
This commit is contained in:
parent
38595b1f28
commit
e1aa90a9bf
@ -14,4 +14,4 @@ slave start;
|
|||||||
flush logs;
|
flush logs;
|
||||||
show slave status;
|
show slave status;
|
||||||
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
|
||||||
127.0.0.1 root SLAVE_PORT 60 slave-bin.001 79 relay-log.002 119 slave-bin.001 Yes Yes 0 0 79 119
|
127.0.0.1 root SLAVE_PORT 60 slave-bin.001 79 relay-log.002 4 slave-bin.001 Yes Yes 0 0 79 4
|
||||||
|
@ -346,7 +346,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
|
|||||||
bool transaction_commited= 0;
|
bool transaction_commited= 0;
|
||||||
|
|
||||||
/* Update the binary log if we have cached some queries */
|
/* Update the binary log if we have cached some queries */
|
||||||
if (trans == &thd->transaction.all && mysql_bin_log.is_open(1) &&
|
if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
|
||||||
my_b_tell(&thd->transaction.trans_log))
|
my_b_tell(&thd->transaction.trans_log))
|
||||||
{
|
{
|
||||||
mysql_bin_log.write(thd, &thd->transaction.trans_log);
|
mysql_bin_log.write(thd, &thd->transaction.trans_log);
|
||||||
@ -385,7 +385,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
|
|||||||
if (transaction_commited && thd->transaction.changed_tables)
|
if (transaction_commited && thd->transaction.changed_tables)
|
||||||
query_cache.invalidate(thd->transaction.changed_tables);
|
query_cache.invalidate(thd->transaction.changed_tables);
|
||||||
#endif /*HAVE_QUERY_CACHE*/
|
#endif /*HAVE_QUERY_CACHE*/
|
||||||
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open(1))
|
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
|
||||||
sql_print_error("Error: Got error during commit; Binlog is not up to date!");
|
sql_print_error("Error: Got error during commit; Binlog is not up to date!");
|
||||||
thd->variables.tx_isolation=thd->session_tx_isolation;
|
thd->variables.tx_isolation=thd->session_tx_isolation;
|
||||||
if (operation_done)
|
if (operation_done)
|
||||||
|
@ -1504,7 +1504,7 @@ void item_user_lock_free(void)
|
|||||||
void item_user_lock_release(ULL *ull)
|
void item_user_lock_release(ULL *ull)
|
||||||
{
|
{
|
||||||
ull->locked=0;
|
ull->locked=0;
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
String tmp(buf,sizeof(buf));
|
String tmp(buf,sizeof(buf));
|
||||||
|
77
sql/log.cc
77
sql/log.cc
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
/* Copyright (C) 2000-2003 MySQL AB
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -82,14 +82,14 @@ static int find_uniq_filename(char *name)
|
|||||||
|
|
||||||
MYSQL_LOG::MYSQL_LOG()
|
MYSQL_LOG::MYSQL_LOG()
|
||||||
:bytes_written(0), last_time(0), query_start(0), name(0),
|
:bytes_written(0), last_time(0), query_start(0), name(0),
|
||||||
file_id(1), open_count(1), log_type(LOG_CLOSED), write_error(0),
|
file_id(1), open_count(1), log_type(LOG_CLOSED), write_error(0), inited(0),
|
||||||
need_start_event(1)
|
need_start_event(1)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
We don't want to initialize LOCK_Log here as such initialization depends on
|
We don't want to initialize LOCK_Log here as such initialization depends on
|
||||||
safe_mutex (when using safe_mutex) which depends on MY_INIT(), which is
|
safe_mutex (when using safe_mutex) which depends on MY_INIT(), which is
|
||||||
called only in main(). Doing initialization here would make it happen before
|
called only in main(). Doing initialization here would make it happen
|
||||||
main().
|
before main().
|
||||||
*/
|
*/
|
||||||
index_file_name[0] = 0;
|
index_file_name[0] = 0;
|
||||||
bzero((char*) &log_file,sizeof(log_file));
|
bzero((char*) &log_file,sizeof(log_file));
|
||||||
@ -102,35 +102,20 @@ MYSQL_LOG::~MYSQL_LOG()
|
|||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MYSQL_LOG::cleanup() /* this is called only once */
|
/* this is called only once */
|
||||||
|
|
||||||
|
void MYSQL_LOG::cleanup()
|
||||||
{
|
{
|
||||||
close(1);
|
if (inited)
|
||||||
(void) pthread_mutex_destroy(&LOCK_log);
|
{
|
||||||
(void) pthread_mutex_destroy(&LOCK_index);
|
inited= 0;
|
||||||
(void) pthread_cond_destroy(&update_cond);
|
close(1);
|
||||||
|
(void) pthread_mutex_destroy(&LOCK_log);
|
||||||
|
(void) pthread_mutex_destroy(&LOCK_index);
|
||||||
|
(void) pthread_cond_destroy(&update_cond);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MYSQL_LOG::is_open(bool need_mutex)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Since MySQL 4.0.14, LOCK_log is always inited:
|
|
||||||
* for log/update_log/slow_log/bin_log which are global objects, this is done in
|
|
||||||
main(), even if the server does not use these logs.
|
|
||||||
* for relay_log which belongs to rli which belongs to active_mi, this is
|
|
||||||
done in the constructor of rli.
|
|
||||||
In older versions, we were never 100% sure that LOCK_log was inited, which
|
|
||||||
was a problem.
|
|
||||||
*/
|
|
||||||
if (need_mutex)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&LOCK_log);
|
|
||||||
bool res= (log_type != LOG_CLOSED);
|
|
||||||
pthread_mutex_unlock(&LOCK_log);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return (log_type != LOG_CLOSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MYSQL_LOG::generate_new_name(char *new_name, const char *log_name)
|
int MYSQL_LOG::generate_new_name(char *new_name, const char *log_name)
|
||||||
{
|
{
|
||||||
@ -164,13 +149,17 @@ void MYSQL_LOG::init(enum_log_type log_type_arg,
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MYSQL_LOG::init_pthread_objects()
|
void MYSQL_LOG::init_pthread_objects()
|
||||||
{
|
{
|
||||||
|
DBUG_ASSERT(inited == 0);
|
||||||
|
inited= 1;
|
||||||
(void) pthread_mutex_init(&LOCK_log,MY_MUTEX_INIT_SLOW);
|
(void) pthread_mutex_init(&LOCK_log,MY_MUTEX_INIT_SLOW);
|
||||||
(void) pthread_mutex_init(&LOCK_index, MY_MUTEX_INIT_SLOW);
|
(void) pthread_mutex_init(&LOCK_index, MY_MUTEX_INIT_SLOW);
|
||||||
(void) pthread_cond_init(&update_cond, 0);
|
(void) pthread_cond_init(&update_cond, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Open a (new) log file.
|
Open a (new) log file.
|
||||||
|
|
||||||
@ -647,7 +636,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
|
|||||||
Assume that we have previously read the first log and
|
Assume that we have previously read the first log and
|
||||||
stored it in rli->relay_log_name
|
stored it in rli->relay_log_name
|
||||||
*/
|
*/
|
||||||
DBUG_ASSERT(is_open(1));
|
DBUG_ASSERT(is_open());
|
||||||
DBUG_ASSERT(rli->slave_running == 1);
|
DBUG_ASSERT(rli->slave_running == 1);
|
||||||
DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->relay_log_name));
|
DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->relay_log_name));
|
||||||
DBUG_ASSERT(rli->linfo.index_file_offset ==
|
DBUG_ASSERT(rli->linfo.index_file_offset ==
|
||||||
@ -818,7 +807,7 @@ void MYSQL_LOG::new_file(bool need_lock)
|
|||||||
enum_log_type save_log_type;
|
enum_log_type save_log_type;
|
||||||
|
|
||||||
DBUG_ENTER("MYSQL_LOG::new_file");
|
DBUG_ENTER("MYSQL_LOG::new_file");
|
||||||
if (!is_open(need_lock))
|
if (!is_open())
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info",("log is closed"));
|
DBUG_PRINT("info",("log is closed"));
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
@ -832,7 +821,7 @@ void MYSQL_LOG::new_file(bool need_lock)
|
|||||||
safe_mutex_assert_owner(&LOCK_log);
|
safe_mutex_assert_owner(&LOCK_log);
|
||||||
safe_mutex_assert_owner(&LOCK_index);
|
safe_mutex_assert_owner(&LOCK_index);
|
||||||
|
|
||||||
// Reuse old name if not binlog and not update log
|
/* Reuse old name if not binlog and not update log */
|
||||||
new_name_ptr= name;
|
new_name_ptr= name;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -971,11 +960,12 @@ err:
|
|||||||
bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
|
bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
|
||||||
const char *format,...)
|
const char *format,...)
|
||||||
{
|
{
|
||||||
if (what_to_log & (1L << (uint) command))
|
if (is_open() && (what_to_log & (1L << (uint) command)))
|
||||||
{
|
{
|
||||||
int error=0;
|
int error=0;
|
||||||
VOID(pthread_mutex_lock(&LOCK_log));
|
VOID(pthread_mutex_lock(&LOCK_log));
|
||||||
|
|
||||||
|
/* Test if someone closed between the is_open test and lock */
|
||||||
if (is_open())
|
if (is_open())
|
||||||
{
|
{
|
||||||
time_t skr;
|
time_t skr;
|
||||||
@ -1076,16 +1066,14 @@ bool MYSQL_LOG::write(Log_event* event_info)
|
|||||||
#else
|
#else
|
||||||
IO_CACHE *file = &log_file;
|
IO_CACHE *file = &log_file;
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
|
In the future we need to add to the following if tests like
|
||||||
|
"do the involved tables match (to be implemented)
|
||||||
|
binlog_[wild_]{do|ignore}_table?" (WL#1049)"
|
||||||
|
*/
|
||||||
if ((thd && !(thd->options & OPTION_BIN_LOG) &&
|
if ((thd && !(thd->options & OPTION_BIN_LOG) &&
|
||||||
(thd->master_access & SUPER_ACL)) ||
|
(thd->master_access & SUPER_ACL)) ||
|
||||||
(local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db))
|
(local_db && !db_ok(local_db, binlog_do_db, binlog_ignore_db)))
|
||||||
/*
|
|
||||||
This is the place for future tests like "do the involved tables match
|
|
||||||
(to be implemented) binlog_[wild_]{do|ignore}_table?" (WL#1049):
|
|
||||||
we will add a
|
|
||||||
&& ... to the if().
|
|
||||||
*/
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
VOID(pthread_mutex_unlock(&LOCK_log));
|
VOID(pthread_mutex_unlock(&LOCK_log));
|
||||||
DBUG_PRINT("error",("!db_ok"));
|
DBUG_PRINT("error",("!db_ok"));
|
||||||
@ -1390,6 +1378,8 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
|
|||||||
{
|
{
|
||||||
bool error=0;
|
bool error=0;
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
|
if (!is_open())
|
||||||
|
return 0;
|
||||||
VOID(pthread_mutex_lock(&LOCK_log));
|
VOID(pthread_mutex_lock(&LOCK_log));
|
||||||
if (is_open())
|
if (is_open())
|
||||||
{ // Safety agains reopen
|
{ // Safety agains reopen
|
||||||
@ -1503,6 +1493,7 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Wait until we get a signal that the binary log has been updated
|
Wait until we get a signal that the binary log has been updated
|
||||||
|
|
||||||
@ -1588,6 +1579,7 @@ void MYSQL_LOG::close(bool exiting)
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MYSQL_LOG::set_max_size(ulong max_size_arg)
|
void MYSQL_LOG::set_max_size(ulong max_size_arg)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -1605,6 +1597,7 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg)
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check if a string is a valid number
|
Check if a string is a valid number
|
||||||
|
|
||||||
|
@ -2167,7 +2167,7 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
|
|
||||||
int Slave_log_event::exec_event(struct st_relay_log_info* rli)
|
int Slave_log_event::exec_event(struct st_relay_log_info* rli)
|
||||||
{
|
{
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
mysql_bin_log.write(this);
|
mysql_bin_log.write(this);
|
||||||
return Log_event::exec_event(rli);
|
return Log_event::exec_event(rli);
|
||||||
}
|
}
|
||||||
@ -2217,7 +2217,7 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
slave_print_error(rli,my_errno, "Write to '%s' failed", fname_buf);
|
slave_print_error(rli,my_errno, "Write to '%s' failed", fname_buf);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
mysql_bin_log.write(this);
|
mysql_bin_log.write(this);
|
||||||
error=0; // Everything is ok
|
error=0; // Everything is ok
|
||||||
|
|
||||||
@ -2237,7 +2237,7 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
(void) my_delete(fname, MYF(MY_WME));
|
(void) my_delete(fname, MYF(MY_WME));
|
||||||
memcpy(p, ".info", 6);
|
memcpy(p, ".info", 6);
|
||||||
(void) my_delete(fname, MYF(MY_WME));
|
(void) my_delete(fname, MYF(MY_WME));
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
mysql_bin_log.write(this);
|
mysql_bin_log.write(this);
|
||||||
return Log_event::exec_event(rli);
|
return Log_event::exec_event(rli);
|
||||||
}
|
}
|
||||||
@ -2260,7 +2260,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
slave_print_error(rli,my_errno, "Write to '%s' failed", fname);
|
slave_print_error(rli,my_errno, "Write to '%s' failed", fname);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
mysql_bin_log.write(this);
|
mysql_bin_log.write(this);
|
||||||
error=0;
|
error=0;
|
||||||
|
|
||||||
@ -2319,7 +2319,7 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
(void) my_delete(fname, MYF(MY_WME));
|
(void) my_delete(fname, MYF(MY_WME));
|
||||||
memcpy(p, ".data", 6);
|
memcpy(p, ".data", 6);
|
||||||
(void) my_delete(fname, MYF(MY_WME));
|
(void) my_delete(fname, MYF(MY_WME));
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
mysql_bin_log.write(this);
|
mysql_bin_log.write(this);
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
|
|||||||
LINT_INIT(cmp_res);
|
LINT_INIT(cmp_res);
|
||||||
DBUG_ENTER("translate_master");
|
DBUG_ENTER("translate_master");
|
||||||
|
|
||||||
if (!mysql_bin_log.is_open(1))
|
if (!mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
strmov(errmsg,"Binary log is not open");
|
strmov(errmsg,"Binary log is not open");
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
@ -574,7 +574,7 @@ void close_temporary_tables(THD *thd)
|
|||||||
next=table->next;
|
next=table->next;
|
||||||
close_temporary(table);
|
close_temporary(table);
|
||||||
}
|
}
|
||||||
if (query && found_user_tables && mysql_bin_log.is_open(1))
|
if (query && found_user_tables && mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
/* The -1 is to remove last ',' */
|
/* The -1 is to remove last ',' */
|
||||||
Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0);
|
Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0);
|
||||||
|
@ -58,13 +58,10 @@ typedef struct st_log_info
|
|||||||
|
|
||||||
class Log_event;
|
class Log_event;
|
||||||
|
|
||||||
class MYSQL_LOG {
|
class MYSQL_LOG
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
/*
|
/* LOCK_log and LOCK_index are inited by init_pthread_objects() */
|
||||||
LOCK_log is inited by MYSQL_LOG::init(), so one should try to lock it only
|
|
||||||
if he is sure MYSQL_LOG::init() has been called (i.e. if 'inited' is true).
|
|
||||||
Same for LOCK_index.
|
|
||||||
*/
|
|
||||||
pthread_mutex_t LOCK_log, LOCK_index;
|
pthread_mutex_t LOCK_log, LOCK_index;
|
||||||
pthread_cond_t update_cond;
|
pthread_cond_t update_cond;
|
||||||
ulonglong bytes_written;
|
ulonglong bytes_written;
|
||||||
@ -84,7 +81,7 @@ class MYSQL_LOG {
|
|||||||
*/
|
*/
|
||||||
volatile enum_log_type log_type;
|
volatile enum_log_type log_type;
|
||||||
enum cache_type io_cache_type;
|
enum cache_type io_cache_type;
|
||||||
bool write_error;
|
bool write_error, inited;
|
||||||
bool need_start_event;
|
bool need_start_event;
|
||||||
bool no_auto_events; // for relay binlog
|
bool no_auto_events; // for relay binlog
|
||||||
/*
|
/*
|
||||||
@ -162,8 +159,7 @@ public:
|
|||||||
int find_next_log(LOG_INFO* linfo, bool need_mutex);
|
int find_next_log(LOG_INFO* linfo, bool need_mutex);
|
||||||
int get_current_log(LOG_INFO* linfo);
|
int get_current_log(LOG_INFO* linfo);
|
||||||
uint next_file_id();
|
uint next_file_id();
|
||||||
bool is_open(bool need_mutex=0);
|
inline bool is_open() { return log_type != LOG_CLOSED; }
|
||||||
|
|
||||||
inline char* get_index_fname() { return index_file_name;}
|
inline char* get_index_fname() { return index_file_name;}
|
||||||
inline char* get_log_fname() { return log_file_name; }
|
inline char* get_log_fname() { return log_file_name; }
|
||||||
inline pthread_mutex_t* get_log_lock() { return &LOCK_log; }
|
inline pthread_mutex_t* get_log_lock() { return &LOCK_log; }
|
||||||
|
@ -84,7 +84,7 @@ int mysql_create_db(THD *thd, char *db, uint create_options, bool silent)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd,thd->query, thd->query_length);
|
mysql_update_log.write(thd,thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
@ -174,7 +174,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
|||||||
thd->query= path;
|
thd->query= path;
|
||||||
}
|
}
|
||||||
mysql_update_log.write(thd, thd->query, thd->query_length);
|
mysql_update_log.write(thd, thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
|
@ -172,7 +172,7 @@ cleanup:
|
|||||||
if (deleted && (error <= 0 || !transactional_table))
|
if (deleted && (error <= 0 || !transactional_table))
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd,thd->query, thd->query_length);
|
mysql_update_log.write(thd,thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
log_delayed);
|
log_delayed);
|
||||||
@ -476,7 +476,7 @@ bool multi_delete::send_eof()
|
|||||||
if (deleted && (error <= 0 || normal_tables))
|
if (deleted && (error <= 0 || normal_tables))
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd,thd->query,thd->query_length);
|
mysql_update_log.write(thd,thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
log_delayed);
|
log_delayed);
|
||||||
@ -588,7 +588,7 @@ end:
|
|||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd,thd->query,thd->query_length);
|
mysql_update_log.write(thd,thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
thd->tmp_table);
|
thd->tmp_table);
|
||||||
|
@ -308,7 +308,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
|
|||||||
if ((info.copied || info.deleted) && (error <= 0 || !transactional_table))
|
if ((info.copied || info.deleted) && (error <= 0 || !transactional_table))
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd, thd->query, thd->query_length);
|
mysql_update_log.write(thd, thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
log_delayed);
|
log_delayed);
|
||||||
@ -1143,7 +1143,7 @@ bool delayed_insert::handle_inserts(void)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
uint max_rows;
|
uint max_rows;
|
||||||
bool using_ignore=0, using_bin_log=mysql_bin_log.is_open(1);
|
bool using_ignore=0, using_bin_log=mysql_bin_log.is_open();
|
||||||
delayed_row *row;
|
delayed_row *row;
|
||||||
DBUG_ENTER("handle_inserts");
|
DBUG_ENTER("handle_inserts");
|
||||||
|
|
||||||
@ -1361,7 +1361,7 @@ void select_insert::send_error(uint errcode,const char *err)
|
|||||||
if (last_insert_id)
|
if (last_insert_id)
|
||||||
thd->insert_id(last_insert_id); // For binary log
|
thd->insert_id(last_insert_id); // For binary log
|
||||||
mysql_update_log.write(thd,thd->query,thd->query_length);
|
mysql_update_log.write(thd,thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
table->file->has_transactions());
|
table->file->has_transactions());
|
||||||
@ -1387,7 +1387,7 @@ bool select_insert::send_eof()
|
|||||||
thd->insert_id(last_insert_id); // For binary log
|
thd->insert_id(last_insert_id); // For binary log
|
||||||
/* Write to binlog before commiting transaction */
|
/* Write to binlog before commiting transaction */
|
||||||
mysql_update_log.write(thd,thd->query,thd->query_length);
|
mysql_update_log.write(thd,thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
table->file->has_transactions());
|
table->file->has_transactions());
|
||||||
|
@ -219,7 +219,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
|||||||
DBUG_RETURN(-1); // Can't allocate buffers
|
DBUG_RETURN(-1); // Can't allocate buffers
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opt_old_rpl_compat && mysql_bin_log.is_open(1))
|
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
lf_info.thd = thd;
|
lf_info.thd = thd;
|
||||||
lf_info.ex = ex;
|
lf_info.ex = ex;
|
||||||
@ -281,7 +281,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
|||||||
{
|
{
|
||||||
if (transactional_table)
|
if (transactional_table)
|
||||||
ha_autocommit_or_rollback(thd,error);
|
ha_autocommit_or_rollback(thd,error);
|
||||||
if (!opt_old_rpl_compat && mysql_bin_log.is_open(1))
|
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
if (lf_info.wrote_create_file)
|
if (lf_info.wrote_create_file)
|
||||||
{
|
{
|
||||||
@ -315,7 +315,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
|||||||
|
|
||||||
if (!log_delayed)
|
if (!log_delayed)
|
||||||
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
|
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
if (opt_old_rpl_compat)
|
if (opt_old_rpl_compat)
|
||||||
{
|
{
|
||||||
@ -607,7 +607,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, String &field_term,
|
|||||||
cache.read_function = _my_b_net_read;
|
cache.read_function = _my_b_net_read;
|
||||||
|
|
||||||
need_end_io_cache = 1;
|
need_end_io_cache = 1;
|
||||||
if (!opt_old_rpl_compat && mysql_bin_log.is_open(1))
|
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
|
||||||
cache.pre_read = cache.pre_close =
|
cache.pre_read = cache.pre_close =
|
||||||
(IO_CACHE_CALLBACK) log_loaded_block;
|
(IO_CACHE_CALLBACK) log_loaded_block;
|
||||||
}
|
}
|
||||||
|
@ -2432,7 +2432,7 @@ mysql_execute_command(void)
|
|||||||
lex->sql_command == SQLCOM_REVOKE)))
|
lex->sql_command == SQLCOM_REVOKE)))
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd, thd->query, thd->query_length);
|
mysql_update_log.write(thd, thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
@ -2452,7 +2452,7 @@ mysql_execute_command(void)
|
|||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd, thd->query, thd->query_length);
|
mysql_update_log.write(thd, thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
|
@ -80,7 +80,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
|
|||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd,thd->query,thd->query_length);
|
mysql_update_log.write(thd,thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
|
@ -269,7 +269,7 @@ int purge_master_logs(THD* thd, const char* to_log)
|
|||||||
const char* errmsg = 0;
|
const char* errmsg = 0;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (!mysql_bin_log.is_open(1))
|
if (!mysql_bin_log.is_open())
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
mysql_bin_log.make_log_name(search_file_name, to_log);
|
mysql_bin_log.make_log_name(search_file_name, to_log);
|
||||||
@ -333,7 +333,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!mysql_bin_log.is_open(1))
|
if (!mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
errmsg = "Binary log is not open";
|
errmsg = "Binary log is not open";
|
||||||
my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
|
||||||
@ -970,7 +970,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
|
|||||||
|
|
||||||
int reset_master(THD* thd)
|
int reset_master(THD* thd)
|
||||||
{
|
{
|
||||||
if (!mysql_bin_log.is_open(1))
|
if (!mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG));
|
my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG));
|
||||||
return 1;
|
return 1;
|
||||||
@ -1008,7 +1008,7 @@ int show_binlog_events(THD* thd)
|
|||||||
if (send_fields(thd, field_list, 1))
|
if (send_fields(thd, field_list, 1))
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
|
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
|
LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
|
||||||
ha_rows event_count, limit_start, limit_end;
|
ha_rows event_count, limit_start, limit_end;
|
||||||
@ -1108,7 +1108,7 @@ int show_binlog_info(THD* thd)
|
|||||||
String* packet = &thd->packet;
|
String* packet = &thd->packet;
|
||||||
packet->length(0);
|
packet->length(0);
|
||||||
|
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
LOG_INFO li;
|
LOG_INFO li;
|
||||||
mysql_bin_log.get_current_log(&li);
|
mysql_bin_log.get_current_log(&li);
|
||||||
@ -1146,7 +1146,7 @@ int show_binlogs(THD* thd)
|
|||||||
String *packet = &thd->packet;
|
String *packet = &thd->packet;
|
||||||
uint length;
|
uint length;
|
||||||
|
|
||||||
if (!mysql_bin_log.is_open(1))
|
if (!mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
//TODO: Replace with ER() error message
|
//TODO: Replace with ER() error message
|
||||||
send_error(net, 0, "You are not using binary logging");
|
send_error(net, 0, "You are not using binary logging");
|
||||||
|
@ -235,7 +235,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
|||||||
if (!dont_log_query)
|
if (!dont_log_query)
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd, thd->query,thd->query_length);
|
mysql_update_log.write(thd, thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
tmp_table_deleted && !some_tables_deleted);
|
tmp_table_deleted && !some_tables_deleted);
|
||||||
@ -766,7 +766,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
|
|||||||
{
|
{
|
||||||
// Must be written before unlock
|
// Must be written before unlock
|
||||||
mysql_update_log.write(thd,thd->query, thd->query_length);
|
mysql_update_log.write(thd,thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
test(create_info->options &
|
test(create_info->options &
|
||||||
@ -1548,7 +1548,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd, thd->query, thd->query_length);
|
mysql_update_log.write(thd, thd->query, thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
@ -1918,7 +1918,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
mysql_update_log.write(thd, thd->query,thd->query_length);
|
mysql_update_log.write(thd, thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
@ -2050,7 +2050,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
}
|
}
|
||||||
thd->proc_info="end";
|
thd->proc_info="end";
|
||||||
mysql_update_log.write(thd, thd->query,thd->query_length);
|
mysql_update_log.write(thd, thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
|
||||||
mysql_bin_log.write(&qinfo);
|
mysql_bin_log.write(&qinfo);
|
||||||
|
@ -317,7 +317,7 @@ int mysql_update(THD *thd,
|
|||||||
if (updated && (error <= 0 || !transactional_table))
|
if (updated && (error <= 0 || !transactional_table))
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd,thd->query,thd->query_length);
|
mysql_update_log.write(thd,thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
log_delayed);
|
log_delayed);
|
||||||
@ -933,7 +933,7 @@ bool multi_update::send_eof()
|
|||||||
if (updated && (local_error <= 0 || !trans_safe))
|
if (updated && (local_error <= 0 || !trans_safe))
|
||||||
{
|
{
|
||||||
mysql_update_log.write(thd,thd->query,thd->query_length);
|
mysql_update_log.write(thd,thd->query,thd->query_length);
|
||||||
if (mysql_bin_log.is_open(1))
|
if (mysql_bin_log.is_open())
|
||||||
{
|
{
|
||||||
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
Query_log_event qinfo(thd, thd->query, thd->query_length,
|
||||||
log_delayed);
|
log_delayed);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user