diff options
author | unknown <monty@donna.mysql.com> | 2000-09-16 04:27:21 +0300 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2000-09-16 04:27:21 +0300 |
commit | 19b678eefe59529761691ddebece604107dcb42b (patch) | |
tree | 6e20280a8abcc28d14385983250a3e1823639028 /sql/log.cc | |
parent | b35a18596c602e654b821ebef8e8a3147fae6dbf (diff) | |
download | mariadb-git-19b678eefe59529761691ddebece604107dcb42b.tar.gz |
Faster log::write() call, memory leak fix, flush master fix.
BUILD/compile-alpha-ccc:
remove deps to get things to compile better
Docs/manual.texi:
Small fixes
configure.in:
Fix for mlockmem()
include/my_sys.h:
Made key_cache_inited global
myisammrg/myrg_close.c:
Fixed memory leak
myisammrg/myrg_open.c:
Initialize queue to avoid memory leak bug
mysys/mf_format.c:
Added overflow check
mysys/mf_keycache.c:
Made key_cache_init more secure to use
mysys/my_static.h:
Make key_cache_inite global
sql/ChangeLog:
Changes
sql/lock.cc:
Added logging of locktime
sql/log.cc:
Added logging of locktime
sql/mysql_priv.h:
Added locked_in_memory
sql/mysqld.cc:
Added logging of locktime + locked in memory
sql/sql_acl.cc:
Added thd to log::write() for faster call
sql/sql_base.cc:
Use global key_cache variable
sql/sql_class.cc:
Added result row counting
sql/sql_class.h:
Added thd to log::write() for faster call
sql/sql_db.cc:
Added thd to log::write() for faster call
sql/sql_delete.cc:
Added thd to log::write() for faster call
sql/sql_insert.cc:
Added thd to log::write() for faster call
sql/sql_load.cc:
Added thd to log::write() for faster call
sql/sql_parse.cc:
Added thd to log::write() for faster call
sql/sql_rename.cc:
Added thd to log::write() for faster call
sql/sql_table.cc:
Added thd to log::write() for faster call
sql/sql_update.cc:
Added thd to log::write() for faster call
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/sql/log.cc b/sql/log.cc index 29ca0247a1b..c5862621cfd 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -338,7 +338,7 @@ void MYSQL_LOG::new_file() close(); open(old_name, log_type, new_name); my_free(old_name,MYF(0)); - if (!file) // Something got wrong + if (!file) // Something went wrong log_type=LOG_CLOSED; last_time=query_start=0; write_error=0; @@ -347,10 +347,10 @@ void MYSQL_LOG::new_file() } -void MYSQL_LOG::write(enum enum_server_command command, +void MYSQL_LOG::write(THD *thd,enum enum_server_command command, const char *format,...) { - if (name && (what_to_log & (1L << (uint) command))) + if (is_open() && (what_to_log & (1L << (uint) command))) { va_list args; va_start(args,format); @@ -359,7 +359,6 @@ void MYSQL_LOG::write(enum enum_server_command command, { time_t skr; ulong id; - THD *thd=current_thd; int error=0; if (thd) { // Normal thread @@ -423,14 +422,14 @@ void MYSQL_LOG::write(enum enum_server_command command, void MYSQL_LOG::write(Query_log_event* event_info) { - if (name) + if (is_open()) { VOID(pthread_mutex_lock(&LOCK_log)); - if(file) + if (file) { THD *thd=event_info->thd; if ((!(thd->options & OPTION_BIN_LOG) && - thd->master_access & PROCESS_ACL) || + thd->master_access & PROCESS_ACL) || !db_ok(event_info->db, binlog_do_db, binlog_ignore_db)) { VOID(pthread_mutex_unlock(&LOCK_log)); @@ -457,57 +456,50 @@ void MYSQL_LOG::write(Query_log_event* event_info) } } - if(event_info->write(file)) + if (event_info->write(file)) { sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno); } err: VOID(pthread_cond_broadcast(&COND_binlog_update)); - - VOID(pthread_mutex_unlock(&LOCK_log)); } + VOID(pthread_mutex_unlock(&LOCK_log)); } - } void MYSQL_LOG::write(Load_log_event* event_info) { - if(name) + if (is_open()) { VOID(pthread_mutex_lock(&LOCK_log)); - if(file) + if (file) { THD *thd=event_info->thd; - if (!(thd->options & OPTION_BIN_LOG) && - (thd->master_access & PROCESS_ACL)) + if ((thd->options & OPTION_BIN_LOG) || + !(thd->master_access & PROCESS_ACL)) { - VOID(pthread_mutex_unlock(&LOCK_log)); - return; + if (event_info->write(file)) + sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno); + VOID(pthread_cond_broadcast(&COND_binlog_update)); } - - - if (event_info->write(file)) - sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno); - VOID(pthread_cond_broadcast(&COND_binlog_update)); - - VOID(pthread_mutex_unlock(&LOCK_log)); } + VOID(pthread_mutex_unlock(&LOCK_log)); } } /* Write update log in a format suitable for incremental backup */ -void MYSQL_LOG::write(const char *query, uint query_length, - ulong time_for_query) +void MYSQL_LOG::write(THD *thd,const char *query, uint query_length, + time_t query_start) { - if (name) + if (is_open()) { + time_t current_time; VOID(pthread_mutex_lock(&LOCK_log)); if (file) { // Safety agains reopen int error=0; - THD *thd=current_thd; char buff[80],*end; end=buff; if (!(thd->options & OPTION_UPDATE_LOG) && @@ -518,13 +510,13 @@ void MYSQL_LOG::write(const char *query, uint query_length, } if (specialflag & SPECIAL_LONG_LOG_FORMAT) { - time_t skr=time(NULL); - if (skr != last_time) + current_time=time(NULL); + if (current_time != last_time) { - last_time=skr; + last_time=current_time; struct tm tm_tmp; struct tm *start; - localtime_r(&skr,&tm_tmp); + localtime_r(¤t_time,&tm_tmp); start=&tm_tmp; if (fprintf(file,"# Time: %02d%02d%02d %2d:%02d:%02d\n", start->tm_year % 100, @@ -542,8 +534,16 @@ void MYSQL_LOG::write(const char *query, uint query_length, thd->ip ? thd->ip : "") < 0) error=errno;; } - if (time_for_query) - fprintf(file,"# Time: %lu\n",time_for_query); + if (query_start) + { + /* For slow query log */ + if (!(specialflag & SPECIAL_LONG_LOG_FORMAT)) + current_time=time(NULL); + fprintf(file,"# Time: %lu Lock_time: %lu Rows_sent %lu\n", + (ulong) (current_time - query_start), + (ulong) (thd->time_after_lock - query_start), + (ulong) thd->sent_row_count); + } if (thd->db && strcmp(thd->db,db)) { // Database changed if (fprintf(file,"use %s;\n",thd->db) < 0) @@ -637,16 +637,15 @@ void MYSQL_LOG::close(bool exiting) name=0; } - if(exiting && index_file) + if (exiting && index_file) + { + if (my_fclose(index_file,MYF(0)) < 0 && ! write_error) { - if (my_fclose(index_file,MYF(0)) < 0 && ! write_error) - { - write_error=1; - sql_print_error(ER(ER_ERROR_ON_WRITE),name,errno); - } - index_file=0; - + write_error=1; + sql_print_error(ER(ER_ERROR_ON_WRITE),name,errno); } + index_file=0; + } } |