summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2000-11-16 20:55:52 +0200
committerunknown <monty@narttu.mysql.fi>2000-11-16 20:55:52 +0200
commit24137ef26120c29263acda059d79e7c21fe59319 (patch)
tree73da460ce6a9f196fc94d6ac2b197566c0bf4958 /sql/log.cc
parent113fb0ffaa802ebb0550d3f5829d18eea916cf10 (diff)
parent2187c0c3f3f4d0e03fdb13b8610bdc1d1006e017 (diff)
downloadmariadb-git-24137ef26120c29263acda059d79e7c21fe59319.tar.gz
merge
mysys/my_open.c: Auto merged sql/mysqld.cc: Auto merged sql/sql_class.cc: Auto merged BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc37
1 files changed, 23 insertions, 14 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 87b5d2362cf..c697ae276fc 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -156,7 +156,7 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
do_magic = ((log_type == LOG_BIN) && !my_stat(log_file_name,
&tmp_stat, MYF(0)));
- if ((file=my_open(log_file_name,O_APPEND | O_WRONLY | O_BINARY|O_CREAT,
+ if ((file=my_open(log_file_name,O_CREAT | O_APPEND | O_WRONLY | O_BINARY,
MYF(MY_WME | ME_WAITTANG))) < 0 ||
init_io_cache(&log_file, file, IO_SIZE, WRITE_CACHE,
my_tell(file,MYF(MY_WME)), 0, MYF(MY_WME | MY_NABP)))
@@ -194,30 +194,39 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
}
else if (log_type == LOG_BIN)
{
- // Explanation of the boolean black magic:
- //
- // if we are supposed to write magic number try write
- // clean up if failed
- // then if index_file has not been previously opened, try to open it
- // clean up if failed
-
+ /*
+ Explanation of the boolean black magic:
+ if we are supposed to write magic number try write
+ clean up if failed
+ then if index_file has not been previously opened, try to open it
+ clean up if failed
+ */
if ((do_magic && my_b_write(&log_file, (byte*) BINLOG_MAGIC, 4)) ||
(index_file < 0 &&
(index_file = my_open(index_file_name,
- O_APPEND | O_BINARY | O_RDWR |O_CREAT,
+ O_APPEND | O_BINARY | O_RDWR | O_CREAT,
MYF(MY_WME))) < 0))
goto err;
Start_log_event s;
+ bool error;
s.write(&log_file);
flush_io_cache(&log_file);
pthread_mutex_lock(&LOCK_index);
- my_write(index_file, log_file_name,strlen(log_file_name), MYF(0));
- my_write(index_file, "\n",1, MYF(0));
+ error=(my_write(index_file, log_file_name,strlen(log_file_name),
+ MYF(MY_NABP | MY_WME)) ||
+ my_write(index_file, "\n", 1, MYF(MY_NABP | MY_WME)));
pthread_mutex_unlock(&LOCK_index);
+ if (error)
+ {
+ my_close(index_file,MYF(0));
+ index_file= -1;
+ goto err;
+ }
}
return;
err:
+ sql_print_error("Could not use %s for logging (error %d)", log_name,errno);
if (file >= 0)
my_close(file,MYF(0));
end_io_cache(&log_file);
@@ -411,7 +420,7 @@ int MYSQL_LOG::purge_logs(THD* thd, const char* to_log)
#ifdef HAVE_FTRUNCATE
if (ftruncate(index_file,0))
{
- sql_print_error("Ouch! Could not truncate the binlog index file \
+ sql_print_error("Could not truncate the binlog index file \
during log purge for write");
error = LOG_INFO_FATAL;
goto err;
@@ -421,10 +430,10 @@ during log purge for write");
my_close(index_file, MYF(MY_WME));
my_delete(index_file_name, MYF(MY_WME));
if(!(index_file = my_open(index_file_name,
- O_BINARY | O_RDWR | O_APPEND |O_CREAT,
+ O_CREAT | O_BINARY | O_RDWR | O_APPEND,
MYF(MY_WME))))
{
- sql_print_error("Ouch! Could not re-open the binlog index file \
+ sql_print_error("Could not re-open the binlog index file \
during log purge for write");
error = LOG_INFO_FATAL;
goto err;