diff options
-rw-r--r-- | sql/mysql_priv.h | 17 | ||||
-rw-r--r-- | sql/sql_class.h | 26 |
2 files changed, 29 insertions, 14 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 3972a01f7ba..173bfe678e8 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -302,6 +302,14 @@ inline THD *_current_thd(void) } #define current_thd _current_thd() +/* log.cc */ +void sql_perror(const char *message); + +void vprint_msg_to_log( enum loglevel level, const char *format, va_list args ); +void sql_print_error( const char *format, ... ); +void sql_print_warning( const char *format, ...); +void sql_print_information( const char *format, ...); + #include "sql_string.h" #include "sql_list.h" #include "sql_map.h" @@ -657,15 +665,6 @@ void key_unpack(String *to,TABLE *form,uint index); bool check_if_key_used(TABLE *table, uint idx, List<Item> &fields); void init_errmessage(void); -void sql_perror(const char *message); - -void vprint_msg_to_log( enum loglevel level, const char *format, va_list args ); -void sql_print_error( const char *format, ... ); -void sql_print_warning( const char *format, ...); -void sql_print_information( const char *format, ...); - - - bool fn_format_relative_to_data_home(my_string to, const char *name, const char *dir, const char *extension); bool open_log(MYSQL_LOG *log, const char *hostname, diff --git a/sql/sql_class.h b/sql/sql_class.h index 17d371d3dc0..25828ac2b7e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -569,17 +569,33 @@ public: proc_info = old_msg; pthread_mutex_unlock(&mysys_var->mutex); } + + static inline void safe_time(time_t *t) + { + /** + Wrapper around time() which retries on error (-1) + + @details + This is needed because, despite the documentation, time() may fail + in some circumstances. Here we retry time() until it succeeds, and + log the failure so that performance problems related to this can be + identified. + */ + while(unlikely(time(t) == ((time_t) -1))) + sql_print_information("time() failed with %d", errno); + } + inline time_t query_start() { query_start_used=1; return start_time; } - inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else time_after_lock=time(&start_time); } - inline void end_time() { time(&start_time); } + inline void set_time() { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }} + inline void end_time() { safe_time(&start_time); } inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; } - inline void lock_time() { time(&time_after_lock); } + inline void lock_time() { safe_time(&time_after_lock); } inline void insert_id(ulonglong id) { last_insert_id=id; insert_id_used=1; } inline ulonglong insert_id(void) { if (!last_insert_id_used) - { + { last_insert_id_used=1; current_insert_id=last_insert_id; } @@ -588,7 +604,7 @@ public: inline ulonglong found_rows(void) { return limit_found_rows; - } + } inline bool active_transaction() { #ifdef USING_TRANSACTIONS |