Commit c4381bb0 authored by unknown's avatar unknown

Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.0

into mysql.r18.ru:/usr/home/ram/work/4.0

parents 1a45c839 d1b9076e
......@@ -71,6 +71,7 @@ mysqldev@build.mysql2.com
nick@mysql.com
nick@nick.leippe.com
paul@central.snake.net
paul@ice.local
paul@teton.kitebird.com
pem@mysql.com
peter@linux.local
......
......@@ -38,11 +38,13 @@ $opt_export_only= undef;
$opt_help= $opt_verbose= 0;
$opt_log= undef;
$opt_mail= "";
$opt_revision= undef;
$opt_suffix= "";
$opt_test= undef;
$opt_skip_check= undef;
$opt_skip_manual= undef;
$version= "unknown";
$major=$minor=$release=0;
GetOptions(
"build-command|b=s",
......@@ -149,6 +151,7 @@ if (!$opt_dry_run)
{
m/^AM_INIT_AUTOMAKE\(mysql, ([1-9]\.[0-9]{1,2}\.[0-9]{1,2}.*)\)/;
$version= $1;
($major, $minor, $release) = split(/\./,$version);
}
&logger("Found version string: $version");
......@@ -218,7 +221,7 @@ if (defined $opt_changelog)
{
if (!$opt_revision)
{
$revision= `bk changes -t -d':REV:' -n $REPO | head -1`;
$revision= `bk changes -t -d':REV:::TAG:' -n $REPO | grep mysql-$major.$minor | head -1 | cut -f1 -d ":"`;
}
else
{
......
......@@ -111,7 +111,7 @@ static void usage(void)
{
print_version();
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
printf("Print a description for a system error code or a error code from\na MyISAM/ISAM/BDB table handler.\n");
printf("Print a description for a system error code or an error code from\na MyISAM/ISAM/BDB table handler.\n");
printf("If you want to get the error for a negative error code, you should use\n-- before the first error code to tell perror that there was no more options.\n\n");
printf("Usage: %s [OPTIONS] [ERRORCODE [ERRORCODE...]]\n",my_progname);
my_print_help(my_long_options);
......
......@@ -175,7 +175,11 @@ os_file_create(
file is created (if exists, error), OS_FILE_OVERWRITE
if a new file is created or an old overwritten */
ulint purpose,/* in: OS_FILE_AIO, if asynchronous, non-buffered i/o
is desired, OS_FILE_NORMAL, if any normal file */
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_.. and srv_..
variables whether we really use async i/o or
unbuffered i/o: look in the function source code for
the exact rules */
ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success);/* out: TRUE if succeed, FALSE if error */
/***************************************************************************
......
......@@ -168,6 +168,7 @@ what these mean */
#define SRV_UNIX_O_DSYNC 2
#define SRV_UNIX_LITTLESYNC 3
#define SRV_UNIX_NOSYNC 4
#define SRV_UNIX_O_DIRECT 5
/* Alternatives for file i/o in Windows */
#define SRV_WIN_IO_NORMAL 1
......
......@@ -211,9 +211,9 @@ os_file_get_last_error(void)
if (err != ERROR_DISK_FULL && err != ERROR_FILE_EXISTS) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Operating system error number %li in a file operation.\n"
" InnoDB: Operating system error number %lu in a file operation.\n"
"InnoDB: See http://www.innodb.com/ibman.html for installation help.\n",
(long) err);
err);
if (err == ERROR_PATH_NOT_FOUND) {
fprintf(stderr,
......@@ -255,9 +255,9 @@ os_file_get_last_error(void)
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Operating system error number %li in a file operation.\n"
" InnoDB: Operating system error number %lu in a file operation.\n"
"InnoDB: See http://www.innodb.com/ibman.html for installation help.\n",
(long) err);
err);
if (err == ENOENT) {
fprintf(stderr,
......@@ -351,7 +351,8 @@ os_file_handle_error(
fprintf(stderr, "InnoDB: File name %s\n", name);
}
fprintf(stderr, "InnoDB: System call %s.\n", operation);
fprintf(stderr, "InnoDB: File operation call: '%s'.\n",
operation);
fprintf(stderr, "InnoDB: Cannot continue operation.\n");
fflush(stderr);
......@@ -599,7 +600,11 @@ os_file_create(
file is created (if exists, error), OS_FILE_OVERWRITE
if a new is created or an old overwritten */
ulint purpose,/* in: OS_FILE_AIO, if asynchronous, non-buffered i/o
is desired, OS_FILE_NORMAL, if any normal file */
is desired, OS_FILE_NORMAL, if any normal file;
NOTE that it also depends on type, os_aio_.. and srv_..
variables whether we really use async i/o or
unbuffered i/o: look in the function source code for
the exact rules */
ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */
ibool* success)/* out: TRUE if succeed, FALSE if error */
{
......@@ -624,8 +629,8 @@ os_file_create(
}
if (purpose == OS_FILE_AIO) {
/* use asynchronous (overlapped) io and no buffering
of writes in the OS */
/* If specified, use asynchronous (overlapped) io and no
buffering of writes in the OS */
attributes = 0;
#ifdef WIN_ASYNC_IO
if (os_aio_use_native_aio) {
......@@ -633,17 +638,13 @@ os_file_create(
}
#endif
#ifdef UNIV_NON_BUFFERED_IO
if (type == OS_LOG_FILE) {
if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) {
/* Do not use unbuffered i/o to log files because
to allow group commit to work when MySQL binlogging
is used we must separate log file write and log
file flush to disk. */
} else {
if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes
| FILE_FLAG_NO_BUFFERING;
}
value 2 denotes that we do not flush the log at every
commit, but only once per second */
} else if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes | FILE_FLAG_NO_BUFFERING;
}
#endif
} else if (purpose == OS_FILE_NORMAL) {
......@@ -653,12 +654,9 @@ os_file_create(
/* Do not use unbuffered i/o to log files because
value 2 denotes that we do not flush the log at every
commit, but only once per second */
} else {
if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes
| FILE_FLAG_NO_BUFFERING;
}
} else if (srv_win_file_flush_method ==
SRV_WIN_IO_UNBUFFERED) {
attributes = attributes | FILE_FLAG_NO_BUFFERING;
}
#endif
} else {
......@@ -700,29 +698,69 @@ os_file_create(
os_file_t file;
int create_flag;
ibool retry;
const char* mode_str = NULL;
const char* type_str = NULL;
const char* purpose_str = NULL;
try_again:
ut_a(name);
if (create_mode == OS_FILE_OPEN) {
mode_str = "OPEN";
create_flag = O_RDWR;
} else if (create_mode == OS_FILE_CREATE) {
mode_str = "CREATE";
create_flag = O_RDWR | O_CREAT | O_EXCL;
} else if (create_mode == OS_FILE_OVERWRITE) {
mode_str = "OVERWRITE";
create_flag = O_RDWR | O_CREAT | O_TRUNC;
} else {
create_flag = 0;
ut_error;
}
UT_NOT_USED(purpose);
if (type == OS_LOG_FILE) {
type_str = "LOG";
} else if (type == OS_DATA_FILE) {
type_str = "DATA";
} else {
ut_a(0);
}
if (purpose == OS_FILE_AIO) {
purpose_str = "AIO";
} else if (purpose == OS_FILE_NORMAL) {
purpose_str = "NORMAL";
} else {
ut_a(0);
}
/* printf("Opening file %s, mode %s, type %s, purpose %s\n",
name, mode_str, type_str, purpose_str); */
#ifdef O_SYNC
if ((!srv_use_doublewrite_buf || type != OS_DATA_FILE)
/* We let O_SYNC only affect log files; note that we map O_DSYNC to
O_SYNC because the datasync options seemed to corrupt files in 2001
in both Linux and Solaris */
if (type == OS_LOG_FILE
&& srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) {
/* printf("Using O_SYNC for file %s\n", name); */
create_flag = create_flag | O_SYNC;
}
#endif
#ifdef O_DIRECT
/* We let O_DIRECT only affect data files */
if (type != OS_LOG_FILE
&& srv_unix_file_flush_method == SRV_UNIX_O_DIRECT) {
/* printf("Using O_DIRECT for file %s\n", name); */
create_flag = create_flag | O_DIRECT;
}
#endif
if (create_mode == OS_FILE_CREATE) {
file = open(name, create_flag, os_innodb_umask);
......@@ -1319,6 +1357,7 @@ os_file_write(
DWORD high;
ulint i;
ulint n_retries = 0;
ulint err;
ut_a((offset & 0xFFFFFFFF) == offset);
......@@ -1386,18 +1425,27 @@ os_file_write(
if (!os_has_said_disk_full) {
err = (ulint)GetLastError();
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: Write to file %s failed at offset %lu %lu.\n"
"InnoDB: %lu bytes should have been written, only %lu were written.\n"
"InnoDB: Operating system error number %lu.\n"
"InnoDB: Look from section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: what the error number means.\n"
"InnoDB: Check that your OS and file system support files of this size.\n"
"InnoDB: Check also that the disk is not full or a disk quota exceeded.\n",
name, offset_high, offset, n, (ulint)len,
(ulint)GetLastError());
err);
if (strerror((int)err) != NULL) {
fprintf(stderr,
"InnoDB: Error number %lu means '%s'.\n", err, strerror((int)err));
}
fprintf(stderr,
"InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: about operating system error numbers.\n");
os_has_said_disk_full = TRUE;
}
......@@ -1421,12 +1469,19 @@ os_file_write(
" InnoDB: Error: Write to file %s failed at offset %lu %lu.\n"
"InnoDB: %lu bytes should have been written, only %ld were written.\n"
"InnoDB: Operating system error number %lu.\n"
"InnoDB: Look from section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: what the error number means or use the perror program of MySQL.\n"
"InnoDB: Check that your OS and file system support files of this size.\n"
"InnoDB: Check also that the disk is not full or a disk quota exceeded.\n",
name, offset_high, offset, n, (long int)ret,
(ulint)errno);
if (strerror(errno) != NULL) {
fprintf(stderr,
"InnoDB: Error number %lu means '%s'.\n", (ulint)errno, strerror(errno));
}
fprintf(stderr,
"InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n"
"InnoDB: about operating system error numbers.\n");
os_has_said_disk_full = TRUE;
}
......
......@@ -1739,7 +1739,7 @@ srv_conc_enter_innodb(
trx_t* trx) /* in: transaction object associated with the
thread */
{
ibool has_slept = FALSE;
ibool has_slept = FALSE;
srv_conc_slot_t* slot;
ulint i;
char err_buf[1000];
......@@ -1758,9 +1758,9 @@ srv_conc_enter_innodb(
return;
}
retry:
os_fast_mutex_lock(&srv_conc_mutex);
os_fast_mutex_lock(&srv_conc_mutex);
retry:
if (trx->declared_to_be_inside_innodb) {
ut_print_timestamp(stderr);
......@@ -1769,6 +1769,9 @@ srv_conc_enter_innodb(
fprintf(stderr,
" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
"InnoDB: it already is declared.\n%s\n", err_buf);
os_fast_mutex_unlock(&srv_conc_mutex);
return;
}
if (srv_conc_n_threads < (lint)srv_thread_concurrency) {
......@@ -1782,21 +1785,27 @@ srv_conc_enter_innodb(
return;
}
/* If the transaction is not holding resources, let it sleep
for 100 milliseconds, and try again then */
/* If the transaction is not holding resources, let it sleep for 50
milliseconds, and try again then */
if (!has_slept && !trx->has_search_latch
&& NULL == UT_LIST_GET_FIRST(trx->trx_locks)) {
has_slept = TRUE; /* We let is sleep only once to avoid
starvation */
has_slept = TRUE; /* We let is sleep only once to avoid
starvation */
os_fast_mutex_unlock(&srv_conc_mutex);
srv_conc_n_waiting_threads++;
os_thread_sleep(100000);
os_fast_mutex_unlock(&srv_conc_mutex);
os_thread_sleep(50000);
os_fast_mutex_lock(&srv_conc_mutex);
srv_conc_n_waiting_threads--;
goto retry;
}
}
/* Too many threads inside: put the current thread to a queue */
......@@ -2110,7 +2119,8 @@ srv_suspend_mysql_thread(
os_event_t event;
double wait_time;
trx_t* trx;
ibool had_dict_lock = FALSE;
ibool had_dict_lock = FALSE;
ibool was_declared_inside_innodb = FALSE;
ut_ad(!mutex_own(&kernel_mutex));
......@@ -2158,11 +2168,16 @@ srv_suspend_mysql_thread(
mutex_exit(&kernel_mutex);
/* We must declare this OS thread to exit InnoDB, since a possible
other thread holding a lock which this thread waits for must be
allowed to enter, sooner or later */
if (trx->declared_to_be_inside_innodb) {
was_declared_inside_innodb = TRUE;
srv_conc_force_exit_innodb(thr_get_trx(thr));
/* We must declare this OS thread to exit InnoDB, since a
possible other thread holding a lock which this thread waits
for must be allowed to enter, sooner or later */
srv_conc_force_exit_innodb(trx);
}
/* Release possible foreign key check latch */
if (trx->dict_operation_lock_mode == RW_S_LATCH) {
......@@ -2183,9 +2198,12 @@ srv_suspend_mysql_thread(
row_mysql_freeze_data_dictionary(trx);
}
/* Return back inside InnoDB */
if (was_declared_inside_innodb) {
/* Return back inside InnoDB */
srv_conc_force_enter_innodb(thr_get_trx(thr));
srv_conc_force_enter_innodb(trx);
}
mutex_enter(&kernel_mutex);
......
......@@ -1055,6 +1055,10 @@ innobase_start_or_create_for_mysql(void)
(char*)"O_DSYNC")) {
srv_unix_file_flush_method = SRV_UNIX_O_DSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str,
(char*)"O_DIRECT")) {
srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
} else if (0 == ut_strcmp(srv_file_flush_method_str,
(char*)"littlesync")) {
srv_unix_file_flush_method = SRV_UNIX_LITTLESYNC;
......
......@@ -9,7 +9,7 @@ insert into t1 values (1),(1);
Duplicate entry '1' for key 1
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
127.0.0.1 root 9306 1 master-bin.001 213 slave-relay-bin.002 254 master-bin.001 Yes Yes 0 0 213 254
127.0.0.1 root MASTER_PORT 1 master-bin.001 213 slave-relay-bin.002 254 master-bin.001 Yes Yes 0 0 213 254
show tables like 't1';
Tables_in_test (t1)
drop table t1;
......@@ -12,6 +12,9 @@ save_master_pos;
connection slave;
# as the t1 table is ignored on the slave, the slave should be able to sync
sync_with_master;
# The port number is different when doing the release build with
# Do-compile, hence we have to replace the port number here accordingly
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
show slave status;
# check that the table has been ignored, because otherwise the test is nonsense
show tables like 't1';
......
......@@ -346,7 +346,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
bool transaction_commited= 0;
/* Update the binary log if we have cached some queries */
if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
if (trans == &thd->transaction.all && mysql_bin_log.is_open(1) &&
my_b_tell(&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)
query_cache.invalidate(thd->transaction.changed_tables);
#endif /*HAVE_QUERY_CACHE*/
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open(1))
sql_print_error("Error: Got error during commit; Binlog is not up to date!");
thd->variables.tx_isolation=thd->session_tx_isolation;
if (operation_done)
......
......@@ -1504,7 +1504,7 @@ void item_user_lock_free(void)
void item_user_lock_release(ULL *ull)
{
ull->locked=0;
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
char buf[256];
String tmp(buf,sizeof(buf));
......
This diff is collapsed.
......@@ -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)
{
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
mysql_bin_log.write(this);
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);
goto err;
}
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
mysql_bin_log.write(this);
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));
memcpy(p, ".info", 6);
(void) my_delete(fname, MYF(MY_WME));
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
mysql_bin_log.write(this);
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);
goto err;
}
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
mysql_bin_log.write(this);
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));
memcpy(p, ".data", 6);
(void) my_delete(fname, MYF(MY_WME));
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
mysql_bin_log.write(this);
error = 0;
......
......@@ -1966,12 +1966,9 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
if (type == LOG_BIN)
{
char *p = fn_ext(opt_name);
if (p)
{
uint length=(uint) (p-opt_name);
strmake(tmp,opt_name,min(length,FN_REFLEN));
opt_name=tmp;
}
uint length=(uint) (p-opt_name);
strmake(tmp,opt_name,min(length,FN_REFLEN));
opt_name=tmp;
}
return log->open(opt_name, type, 0, index_file_name,
(read_append) ? SEQ_READ_APPEND : WRITE_CACHE,
......@@ -2019,6 +2016,17 @@ int main(int argc, char **argv)
}
#endif
/*
Init mutexes for the global MYSQL_LOG objects.
As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of
global MYSQL_LOGs in their constructors, because then they would be inited
before MY_INIT(). So we do it here.
*/
mysql_log.init_pthread_objects();
mysql_update_log.init_pthread_objects();
mysql_slow_log.init_pthread_objects();
mysql_bin_log.init_pthread_objects();
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql");
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
......
......@@ -265,7 +265,7 @@ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg)
LINT_INIT(cmp_res);
DBUG_ENTER("translate_master");
if (!mysql_bin_log.is_open())
if (!mysql_bin_log.is_open(1))
{
strmov(errmsg,"Binary log is not open");
DBUG_RETURN(1);
......
......@@ -1736,6 +1736,7 @@ st_relay_log_info::st_relay_log_info()
pthread_cond_init(&start_cond, NULL);
pthread_cond_init(&stop_cond, NULL);
pthread_cond_init(&log_space_cond, NULL);
relay_log.init_pthread_objects();
}
......@@ -3443,14 +3444,18 @@ void rotate_relay_log(MASTER_INFO* mi)
{
DBUG_ENTER("rotate_relay_log");
RELAY_LOG_INFO* rli= &mi->rli;
/* If this server is not a slave (or RESET SLAVE has just been run) */
lock_slave_threads(mi);
pthread_mutex_lock(&rli->data_lock);
/*
We need to test inited because otherwise, new_file() will attempt to lock
LOCK_log, which may not be inited (if we're not a slave).
*/
if (!rli->inited)
{
DBUG_PRINT("info", ("rli->inited == 0"));
DBUG_VOID_RETURN;
goto end;
}
lock_slave_threads(mi);
pthread_mutex_lock(&rli->data_lock);
/* If the relay log is closed, new_file() will do nothing. */
rli->relay_log.new_file(1);
......@@ -3469,6 +3474,7 @@ void rotate_relay_log(MASTER_INFO* mi)
0 as they probably have been harvested.
*/
rli->relay_log.harvest_bytes_written(&rli->log_space_total);
end:
pthread_mutex_unlock(&rli->data_lock);
unlock_slave_threads(mi);
DBUG_VOID_RETURN;
......
......@@ -574,7 +574,7 @@ void close_temporary_tables(THD *thd)
next=table->next;
close_temporary(table);
}
if (query && found_user_tables && mysql_bin_log.is_open())
if (query && found_user_tables && mysql_bin_log.is_open(1))
{
/* The -1 is to remove last ',' */
Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0);
......
......@@ -39,7 +39,6 @@ enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
#define LOG_INFO_IO -2
#define LOG_INFO_INVALID -3
#define LOG_INFO_SEEK -4
#define LOG_INFO_PURGE_NO_ROTATE -5
#define LOG_INFO_MEM -6
#define LOG_INFO_FATAL -7
#define LOG_INFO_IN_USE -8
......@@ -61,6 +60,11 @@ class Log_event;
class MYSQL_LOG {
private:
/*
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_cond_t update_cond;
ulonglong bytes_written;
......@@ -80,8 +84,7 @@ class MYSQL_LOG {
*/
volatile enum_log_type log_type;
enum cache_type io_cache_type;
bool write_error,inited;
bool no_rotate;
bool write_error;
bool need_start_event;
bool no_auto_events; // for relay binlog
/*
......@@ -123,6 +126,7 @@ class MYSQL_LOG {
void init(enum_log_type log_type_arg,
enum cache_type io_cache_type_arg,
bool no_auto_events_arg, ulong max_size);
void init_pthread_objects();
void cleanup();
bool open(const char *log_name,enum_log_type log_type,
const char *new_name, const char *index_file_name_arg,
......@@ -158,8 +162,8 @@ class MYSQL_LOG {
int find_next_log(LOG_INFO* linfo, bool need_mutex);
int get_current_log(LOG_INFO* linfo);
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_log_fname() { return log_file_name; }
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);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
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;
}
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
......
......@@ -172,7 +172,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
if (deleted && (error <= 0 || !transactional_table))
{
mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
log_delayed);
......@@ -476,7 +476,7 @@ bool multi_delete::send_eof()
if (deleted && (error <= 0 || normal_tables))
{
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
log_delayed);
......@@ -588,7 +588,7 @@ int mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
if (!error)
{
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
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))
{
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
log_delayed);
......@@ -1143,7 +1143,7 @@ bool delayed_insert::handle_inserts(void)
{
int error;
uint max_rows;
bool using_ignore=0, using_bin_log=mysql_bin_log.is_open();
bool using_ignore=0, using_bin_log=mysql_bin_log.is_open(1);
delayed_row *row;
DBUG_ENTER("handle_inserts");
......@@ -1361,7 +1361,7 @@ void select_insert::send_error(uint errcode,const char *err)
if (last_insert_id)
thd->insert_id(last_insert_id); // For binary log
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
table->file->has_transactions());
......@@ -1387,7 +1387,7 @@ bool select_insert::send_eof()
thd->insert_id(last_insert_id); // For binary log
/* Write to binlog before commiting transaction */
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
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
}
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
if (!opt_old_rpl_compat && mysql_bin_log.is_open(1))
{
lf_info.thd = thd;
lf_info.ex = ex;
......@@ -281,7 +281,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{
if (transactional_table)
ha_autocommit_or_rollback(thd,error);
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
if (!opt_old_rpl_compat && mysql_bin_log.is_open(1))
{
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)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
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;
need_end_io_cache = 1;
if (!opt_old_rpl_compat && mysql_bin_log.is_open())
if (!opt_old_rpl_compat && mysql_bin_log.is_open(1))
cache.pre_read = cache.pre_close =
(IO_CACHE_CALLBACK) log_loaded_block;
}
......
......@@ -2432,7 +2432,7 @@ mysql_execute_command(void)
lex->sql_command == SQLCOM_REVOKE)))
{
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
......@@ -2452,7 +2452,7 @@ mysql_execute_command(void)
if (!res)
{
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
......
......@@ -80,7 +80,7 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
if (!error)
{
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
......
......@@ -269,7 +269,7 @@ int purge_master_logs(THD* thd, const char* to_log)
const char* errmsg = 0;
int res;
if (!mysql_bin_log.is_open())
if (!mysql_bin_log.is_open(1))
goto end;
mysql_bin_log.make_log_name(search_file_name, to_log);
......@@ -282,8 +282,6 @@ int purge_master_logs(THD* thd, const char* to_log)
case LOG_INFO_INVALID: errmsg = "Server configuration does not permit \
binlog purge"; break;
case LOG_INFO_SEEK: errmsg = "Failed on fseek()"; break;
case LOG_INFO_PURGE_NO_ROTATE: errmsg = "Cannot purge unrotatable log";
break;
case LOG_INFO_MEM: errmsg = "Out of memory"; break;
case LOG_INFO_FATAL: errmsg = "Fatal error during purge"; break;
case LOG_INFO_IN_USE: errmsg = "A purgeable log is in use, will not purge";
......@@ -335,7 +333,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
}
#endif
if (!mysql_bin_log.is_open())
if (!mysql_bin_log.is_open(1))
{
errmsg = "Binary log is not open";
my_errno= ER_MASTER_FATAL_ERROR_READING_BINLOG;
......@@ -972,7 +970,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
int reset_master(THD* thd)
{
if (!mysql_bin_log.is_open())
if (!mysql_bin_log.is_open(1))
{
my_error(ER_FLUSH_MASTER_BINLOG_CLOSED, MYF(ME_BELL+ME_WAITTANG));
return 1;
......@@ -1010,7 +1008,7 @@ int show_binlog_events(THD* thd)
if (send_fields(thd, field_list, 1))
DBUG_RETURN(-1);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
LEX_MASTER_INFO *lex_mi = &thd->lex.mi;
ha_rows event_count, limit_start, limit_end;
......@@ -1110,7 +1108,7 @@ int show_binlog_info(THD* thd)
String* packet = &thd->packet;
packet->length(0);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
LOG_INFO li;
mysql_bin_log.get_current_log(&li);
......@@ -1128,7 +1126,7 @@ int show_binlog_info(THD* thd)
/*
Send a lost of all binary logs to client
Send a list of all binary logs to client
SYNOPSIS
show_binlogs()
......@@ -1148,7 +1146,7 @@ int show_binlogs(THD* thd)
String *packet = &thd->packet;
uint length;
if (!mysql_bin_log.is_open())
if (!mysql_bin_log.is_open(1))
{
//TODO: Replace with ER() error message
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)
{
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
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
mysql_update_log.write(thd,thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
test(create_info->options &
......@@ -1548,7 +1548,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (!error)
{
mysql_update_log.write(thd, thd->query, thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
......@@ -1918,7 +1918,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
goto err;
}
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
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";
mysql_update_log.write(thd, thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length, 0);
mysql_bin_log.write(&qinfo);
......
......@@ -317,7 +317,7 @@ int mysql_update(THD *thd,
if (updated && (error <= 0 || !transactional_table))
{
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
log_delayed);
......@@ -933,7 +933,7 @@ bool multi_update::send_eof()
if (updated && (local_error <= 0 || !trans_safe))
{
mysql_update_log.write(thd,thd->query,thd->query_length);
if (mysql_bin_log.is_open())
if (mysql_bin_log.is_open(1))
{
Query_log_event qinfo(thd, thd->query, thd->query_length,
log_delayed);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment