diff options
author | unknown <tnurnberg@sin.intern.azundris.com> | 2007-07-16 22:38:50 +0200 |
---|---|---|
committer | unknown <tnurnberg@sin.intern.azundris.com> | 2007-07-16 22:38:50 +0200 |
commit | e587830c50ede0fd40f2efe372f0ea25774e7a76 (patch) | |
tree | 0db2f9182648850d47ffcf6b4ce41fb1ea128ed6 | |
parent | ee7519a5d5ca7df345e301cb982c07b03b4d178e (diff) | |
parent | a7e5f73abb9da35a1c199b89df84596cffe59901 (diff) | |
download | mariadb-git-e587830c50ede0fd40f2efe372f0ea25774e7a76.tar.gz |
Merge sin.intern.azundris.com:/home/tnurnberg/27198/40-27198
into sin.intern.azundris.com:/home/tnurnberg/27198/41-27198
sql/mysql_priv.h:
Bug #27198: Error returns from time() are ignored
manual merge
sql/sql_class.h:
Bug #27198: Error returns from time() are ignored
manual merge
-rw-r--r-- | sql/mysql_priv.h | 18 | ||||
-rw-r--r-- | sql/sql_class.h | 22 |
2 files changed, 29 insertions, 11 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6bd60280399..b5100c15473 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -408,6 +408,16 @@ int insert_precheck(THD *thd, TABLE_LIST *tables); int create_table_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *create_table); Item *negate_expression(THD *thd, Item *expr); + +/* 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, ...) ATTRIBUTE_FORMAT(printf, 1, 2); +void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2); +void sql_print_information(const char *format, ...) + ATTRIBUTE_FORMAT(printf, 1, 2); + #include "sql_class.h" #include "sql_acl.h" #include "tztime.h" @@ -842,14 +852,6 @@ bool check_if_key_used(TABLE *table, uint idx, List<Item> &fields); int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length); bool 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, ...) ATTRIBUTE_FORMAT(printf, 1, 2); -void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2); -void sql_print_information(const char *format, ...) - ATTRIBUTE_FORMAT(printf, 1, 2); - bool fn_format_relative_to_data_home(my_string to, const char *name, const char *dir, const char *extension); diff --git a/sql/sql_class.h b/sql/sql_class.h index eb2c8637651..c1ea678b3b1 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1018,11 +1018,27 @@ 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_arg) { last_insert_id= id_arg; |