diff options
author | Seppo Jaakola <seppo.jaakola@codership.com> | 2012-04-26 13:59:35 +0300 |
---|---|---|
committer | Seppo Jaakola <seppo.jaakola@codership.com> | 2012-04-26 13:59:35 +0300 |
commit | e0015163515d1fe5d3747c6f859461a30c2ecfd6 (patch) | |
tree | e8602e5ae53ae2cef06322a338205b501efe8d2a /include | |
parent | f96fd3f40f37c0080e71e45f85e53bd156aa27f5 (diff) | |
parent | b6ad03cde9367e4fae45f8d84d8175599fab61e9 (diff) | |
download | mariadb-git-e0015163515d1fe5d3747c6f859461a30c2ecfd6.tar.gz |
Merge with mariaDB 5.5.23: bzr merge lp:maria/5.5
Diffstat (limited to 'include')
-rw-r--r-- | include/CMakeLists.txt | 14 | ||||
-rw-r--r-- | include/m_ctype.h | 5 | ||||
-rw-r--r-- | include/m_string.h | 4 | ||||
-rw-r--r-- | include/my_global.h | 6 | ||||
-rw-r--r-- | include/my_stacktrace.h | 52 | ||||
-rw-r--r-- | include/my_sys.h | 10 | ||||
-rw-r--r-- | include/my_valgrind.h | 2 | ||||
-rw-r--r-- | include/myisam.h | 4 | ||||
-rw-r--r-- | include/mysql.h.pp | 4 | ||||
-rw-r--r-- | include/mysql/plugin.h | 6 | ||||
-rw-r--r-- | include/mysql/plugin_audit.h.pp | 20 | ||||
-rw-r--r-- | include/mysql/plugin_auth.h.pp | 20 | ||||
-rw-r--r-- | include/mysql/plugin_ftparser.h.pp | 20 | ||||
-rw-r--r-- | include/mysql/service_debug_sync.h | 354 | ||||
-rw-r--r-- | include/mysql/service_logger.h | 98 | ||||
-rw-r--r-- | include/mysql/services.h | 3 | ||||
-rw-r--r-- | include/mysql_com.h | 5 | ||||
-rw-r--r-- | include/service_versions.h | 2 | ||||
-rw-r--r-- | include/welcome_copyright_notice.h | 2 |
19 files changed, 390 insertions, 241 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 052df5d3276..3046c3f7614 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -20,22 +20,14 @@ ${CMAKE_CURRENT_BINARY_DIR}/mysqld_ername.h ${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h ${CMAKE_CURRENT_BINARY_DIR}/sql_state.h ) -SET(HEADERS_ABI + +SET(HEADERS mysql.h mysql_com.h mysql_time.h my_list.h my_alloc.h typelib.h - mysql/plugin.h - mysql/plugin_audit.h - mysql/plugin_ftparser.h - mysql/plugin_auth.h - mysql/client_plugin.h -) - -SET(HEADERS - ${HEADERS_ABI} my_dbug.h m_string.h my_sys.h @@ -61,4 +53,4 @@ SET(HEADERS ) INSTALL(FILES ${HEADERS} DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development) -INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR}/mysql COMPONENT Development FILES_MATCHING PATTERN "*.h") +INSTALL(DIRECTORY mysql/ DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT Development FILES_MATCHING PATTERN "*.h") diff --git a/include/m_ctype.h b/include/m_ctype.h index 8e0344356d5..969cb0058ac 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2010, Oracle and/or its affiliates. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,7 +71,7 @@ struct unicase_info_st extern MY_UNICASE_INFO *const my_unicase_default[256]; extern MY_UNICASE_INFO *const my_unicase_turkish[256]; -extern MY_UNICASE_INFO *my_unicase_mysql500[256]; +extern MY_UNICASE_INFO *const my_unicase_mysql500[256]; #define MY_UCA_MAX_CONTRACTION 4 #define MY_UCA_MAX_WEIGHT_SIZE 8 @@ -356,6 +356,7 @@ extern struct charset_info_st my_charset_ucs2_bin; extern struct charset_info_st my_charset_ucs2_general_ci; extern struct charset_info_st my_charset_ucs2_general_mysql500_ci; extern struct charset_info_st my_charset_ucs2_unicode_ci; +extern struct charset_info_st my_charset_ucs2_general_mysql500_ci; extern struct charset_info_st my_charset_ujis_bin; extern struct charset_info_st my_charset_ujis_japanese_ci; extern struct charset_info_st my_charset_utf16_bin; diff --git a/include/m_string.h b/include/m_string.h index 7c95c7319dc..9fc6cda4764 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -66,7 +66,9 @@ # define bcmp(A,B,C) memcmp((A),(B),(C)) #endif -#if !defined(bzero) && (!defined(HAVE_BZERO) || !defined(HAVE_DECL_BZERO)) +#if !defined(bzero) && (!defined(HAVE_BZERO) || !HAVE_DECL_BZERO || defined(_AIX)) +/* See autoconf doku: "HAVE_DECL_symbol" will be defined after configure, to 0 or 1 */ +/* AIX has bzero() as a function, but the declaration prototype is strangely hidden */ # define bzero(A,B) memset((A),0,(B)) #endif diff --git a/include/my_global.h b/include/my_global.h index 3ab736ba1fc..8170ce381af 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2001, 2011, Oracle and/or its affiliates. + Copyright (c) 2001, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -446,6 +446,10 @@ extern "C" int madvise(void *addr, size_t len, int behav); #define SIGNAL_HANDLER_RESET_ON_DELIVERY #endif +#ifndef STDERR_FILENO +#define STDERR_FILENO 2 +#endif + /* Deprecated workaround for false-positive uninitialized variables warnings. Those should be silenced using tool-specific heuristics. diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index ebc30ed8b59..ad05a7df9ab 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -50,11 +50,13 @@ void my_safe_print_str(const char* val, int max_len); void my_write_core(int sig); #if BACKTRACE_DEMANGLE char *my_demangle(const char *mangled_name, int *status); -#endif +#endif /* BACKTRACE_DEMANGLE */ #ifdef __WIN__ void my_set_exception_pointers(EXCEPTION_POINTERS *ep); -#endif -#endif +#endif /* __WIN__ */ +#else +#define my_init_stacktrace() do { } while(0) +#endif /* ! (defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)) */ #ifndef _WIN32 #define MY_ADDR_RESOLVE_FORK @@ -82,50 +84,6 @@ const char *my_addr_resolve_init(); void my_write_core(int sig); #endif - - -/** - Async-signal-safe utility functions used by signal handler routines. - Declared here in order to unit-test them. - These are not general-purpose, but tailored to the signal handling routines. -*/ -/** - Converts a longlong value to string. - @param base 10 for decimal, 16 for hex values (0..9a..f) - @param val The value to convert - @param buf Assumed to point to the *end* of the buffer. - @returns Pointer to the first character of the converted string. - Negative values: - for base-10 the return string will be prepended with '-' - for base-16 the return string will contain 16 characters - Implemented with simplicity, and async-signal-safety in mind. -*/ -char *my_safe_itoa(int base, longlong val, char *buf); - -/** - Converts a ulonglong value to string. - @param base 10 for decimal, 16 for hex values (0..9a..f) - @param val The value to convert - @param buf Assumed to point to the *end* of the buffer. - @returns Pointer to the first character of the converted string. - Implemented with simplicity, and async-signal-safety in mind. -*/ -char *my_safe_utoa(int base, ulonglong val, char *buf); - -/** - A (very) limited version of snprintf. - @param to Destination buffer. - @param n Size of destination buffer. - @param fmt printf() style format string. - @returns Number of bytes written, including terminating '\0' - Supports 'd' 'i' 'u' 'x' 'p' 's' conversion. - Supports 'l' and 'll' modifiers for integral types. - Does not support any width/precision. - Implemented with simplicity, and async-signal-safety in mind. -*/ -size_t my_safe_snprintf(char* to, size_t n, const char* fmt, ...) - ATTRIBUTE_FORMAT(printf, 3, 4); - /** A (very) limited version of snprintf, which writes the result to STDERR. @sa my_safe_snprintf diff --git a/include/my_sys.h b/include/my_sys.h index 3fcaea95f7b..a02c390fe4b 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -157,16 +157,6 @@ extern char *my_strndup(const char *from, size_t length, myf MyFlags); extern int sf_leaking_memory; /* set to 1 to disable memleak detection */ -#if defined(ENABLED_DEBUG_SYNC) -extern void (*debug_sync_C_callback_ptr)(const char *, size_t); -#define DEBUG_SYNC_C(_sync_point_name_) do { \ - if (debug_sync_C_callback_ptr != NULL) \ - (*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \ - while(0) -#else -#define DEBUG_SYNC_C(_sync_point_name_) -#endif /* defined(ENABLED_DEBUG_SYNC) */ - #ifdef HAVE_LARGE_PAGES extern uint my_get_large_page_size(void); extern uchar * my_large_malloc(size_t size, myf my_flags); diff --git a/include/my_valgrind.h b/include/my_valgrind.h index 5af3a14cf10..31651f6c3ed 100644 --- a/include/my_valgrind.h +++ b/include/my_valgrind.h @@ -23,7 +23,7 @@ #define IF_VALGRIND(A,B) B #endif -#if defined(HAVE_VALGRIND) +#if defined(HAVE_VALGRIND) && defined(HAVE_valgrind) # include <valgrind/memcheck.h> # define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len) # define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len) diff --git a/include/myisam.h b/include/myisam.h index 3d4eecb7cbe..eaa6b2dbd1f 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2000, 2012, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -421,7 +421,7 @@ int flush_pending_blocks(MI_SORT_PARAM *param); int sort_ft_buf_flush(MI_SORT_PARAM *sort_param); int thr_write_keys(MI_SORT_PARAM *sort_param); int sort_write_record(MI_SORT_PARAM *sort_param); -int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulong); +int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulonglong); #ifdef __cplusplus } diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 002b3f2e2ea..ce577146581 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -66,9 +66,7 @@ enum mysql_enum_shutdown_level { SHUTDOWN_WAIT_TRANSACTIONS= (unsigned char)(1 << 1), SHUTDOWN_WAIT_UPDATES= (unsigned char)(1 << 3), SHUTDOWN_WAIT_ALL_BUFFERS= ((unsigned char)(1 << 3) << 1), - SHUTDOWN_WAIT_CRITICAL_BUFFERS= ((unsigned char)(1 << 3) << 1) + 1, - SHUTDOWN_KILL_QUERY= 254, - SHUTDOWN_KILL_CONNECTION= 255 + SHUTDOWN_WAIT_CRITICAL_BUFFERS= ((unsigned char)(1 << 3) << 1) + 1 }; enum enum_cursor_type { diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 614bb028a0d..b73f2d75193 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2005, 2010, Oracle and/or its affiliates - Copyright (C) 2009-2011 Monty Program Ab +/* Copyright (c) 2005, 2011, Oracle and/or its affiliates + Copyright (C) 2009, 2011, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -72,7 +72,7 @@ typedef struct st_mysql_xid MYSQL_XID; #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0103 /* MariaDB plugin interface version */ -#define MARIA_PLUGIN_INTERFACE_VERSION 0x0102 +#define MARIA_PLUGIN_INTERFACE_VERSION 0x0103 /* The allowable types of plugins diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index dd7dde7973c..b987f690592 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -80,24 +80,8 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_logger.h> -typedef struct logger_handle_st LOGGER_HANDLE; -extern struct logger_service_st { - LOGGER_HANDLE* (*open)(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int (*close)(LOGGER_HANDLE *log); - int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...); - int (*rotate)(LOGGER_HANDLE *log); -} *logger_service; - LOGGER_HANDLE *logger_open(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int logger_close(LOGGER_HANDLE *log); - int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int logger_rotate(LOGGER_HANDLE *log); - int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); +#include <mysql/service_debug_sync.h> +extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index cf3b60d128b..113aaf62d19 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -80,24 +80,8 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_logger.h> -typedef struct logger_handle_st LOGGER_HANDLE; -extern struct logger_service_st { - LOGGER_HANDLE* (*open)(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int (*close)(LOGGER_HANDLE *log); - int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...); - int (*rotate)(LOGGER_HANDLE *log); -} *logger_service; - LOGGER_HANDLE *logger_open(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int logger_close(LOGGER_HANDLE *log); - int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int logger_rotate(LOGGER_HANDLE *log); - int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); +#include <mysql/service_debug_sync.h> +extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 14129aec85e..6011e7f7519 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -80,24 +80,8 @@ void thd_progress_next_stage(void* thd); void thd_progress_end(void* thd); const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); -#include <mysql/service_logger.h> -typedef struct logger_handle_st LOGGER_HANDLE; -extern struct logger_service_st { - LOGGER_HANDLE* (*open)(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int (*close)(LOGGER_HANDLE *log); - int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...); - int (*rotate)(LOGGER_HANDLE *log); -} *logger_service; - LOGGER_HANDLE *logger_open(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int logger_close(LOGGER_HANDLE *log); - int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int logger_rotate(LOGGER_HANDLE *log); - int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); +#include <mysql/service_debug_sync.h> +extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); struct st_mysql_xid { long formatID; long gtrid_length; diff --git a/include/mysql/service_debug_sync.h b/include/mysql/service_debug_sync.h new file mode 100644 index 00000000000..f7bab99ac97 --- /dev/null +++ b/include/mysql/service_debug_sync.h @@ -0,0 +1,354 @@ +#ifndef MYSQL_SERVICE_DEBUG_SYNC_INCLUDED +/* Copyright (c) 2009, 2010, Oracle and/or its affiliates. + Copyright (c) 2012, Monty Program Ab + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file + == Debug Sync Facility == + + The Debug Sync Facility allows placement of synchronization points in + the server code by using the DEBUG_SYNC macro: + + open_tables(...) + + DEBUG_SYNC(thd, "after_open_tables"); + + lock_tables(...) + + When activated, a sync point can + + - Emit a signal and/or + - Wait for a signal + + Nomenclature: + + - signal: A value of a global variable that persists + until overwritten by a new signal. The global + variable can also be seen as a "signal post" + or "flag mast". Then the signal is what is + attached to the "signal post" or "flag mast". + + - emit a signal: Assign the value (the signal) to the global + variable ("set a flag") and broadcast a + global condition to wake those waiting for + a signal. + + - wait for a signal: Loop over waiting for the global condition until + the global value matches the wait-for signal. + + By default, all sync points are inactive. They do nothing (except to + burn a couple of CPU cycles for checking if they are active). + + A sync point becomes active when an action is requested for it. + To do so, put a line like this in the test case file: + + SET DEBUG_SYNC= 'after_open_tables SIGNAL opened WAIT_FOR flushed'; + + This activates the sync point 'after_open_tables'. It requests it to + emit the signal 'opened' and wait for another thread to emit the signal + 'flushed' when the thread's execution runs through the sync point. + + For every sync point there can be one action per thread only. Every + thread can request multiple actions, but only one per sync point. In + other words, a thread can activate multiple sync points. + + Here is an example how to activate and use the sync points: + + --connection conn1 + SET DEBUG_SYNC= 'after_open_tables SIGNAL opened WAIT_FOR flushed'; + send INSERT INTO t1 VALUES(1); + --connection conn2 + SET DEBUG_SYNC= 'now WAIT_FOR opened'; + SET DEBUG_SYNC= 'after_abort_locks SIGNAL flushed'; + FLUSH TABLE t1; + + When conn1 runs through the INSERT statement, it hits the sync point + 'after_open_tables'. It notices that it is active and executes its + action. It emits the signal 'opened' and waits for another thread to + emit the signal 'flushed'. + + conn2 waits immediately at the special sync point 'now' for another + thread to emit the 'opened' signal. + + A signal remains in effect until it is overwritten. If conn1 signals + 'opened' before conn2 reaches 'now', conn2 will still find the 'opened' + signal. It does not wait in this case. + + When conn2 reaches 'after_abort_locks', it signals 'flushed', which lets + conn1 awake. + + Normally the activation of a sync point is cleared when it has been + executed. Sometimes it is necessary to keep the sync point active for + another execution. You can add an execute count to the action: + + SET DEBUG_SYNC= 'name SIGNAL sig EXECUTE 3'; + + This sets the signal point's activation counter to 3. Each execution + decrements the counter. After the third execution the sync point + becomes inactive. + + One of the primary goals of this facility is to eliminate sleeps from + the test suite. In most cases it should be possible to rewrite test + cases so that they do not need to sleep. (But this facility cannot + synchronize multiple processes.) However, to support test development, + and as a last resort, sync point waiting times out. There is a default + timeout, but it can be overridden: + + SET DEBUG_SYNC= 'name WAIT_FOR sig TIMEOUT 10 EXECUTE 2'; + + TIMEOUT 0 is special: If the signal is not present, the wait times out + immediately. + + When a wait timed out (even on TIMEOUT 0), a warning is generated so + that it shows up in the test result. + + You can throw an error message and kill the query when a synchronization + point is hit a certain number of times: + + SET DEBUG_SYNC= 'name HIT_LIMIT 3'; + + Or combine it with signal and/or wait: + + SET DEBUG_SYNC= 'name SIGNAL sig EXECUTE 2 HIT_LIMIT 3'; + + Here the first two hits emit the signal, the third hit returns the error + message and kills the query. + + For cases where you are not sure that an action is taken and thus + cleared in any case, you can force to clear (deactivate) a sync point: + + SET DEBUG_SYNC= 'name CLEAR'; + + If you want to clear all actions and clear the global signal, use: + + SET DEBUG_SYNC= 'RESET'; + + This is the only way to reset the global signal to an empty string. + + For testing of the facility itself you can execute a sync point just + as if it had been hit: + + SET DEBUG_SYNC= 'name TEST'; + + + === Formal Syntax === + + The string to "assign" to the DEBUG_SYNC variable can contain: + + {RESET | + <sync point name> TEST | + <sync point name> CLEAR | + <sync point name> {{SIGNAL <signal name> | + WAIT_FOR <signal name> [TIMEOUT <seconds>]} + [EXECUTE <count>] &| HIT_LIMIT <count>} + + Here '&|' means 'and/or'. This means that one of the sections + separated by '&|' must be present or both of them. + + + === Activation/Deactivation === + + The facility is an optional part of the MySQL server. + It is enabled in a debug server by default. + + ./configure --enable-debug-sync + + The Debug Sync Facility, when compiled in, is disabled by default. It + can be enabled by a mysqld command line option: + + --debug-sync-timeout[=default_wait_timeout_value_in_seconds] + + 'default_wait_timeout_value_in_seconds' is the default timeout for the + WAIT_FOR action. If set to zero, the facility stays disabled. + + The facility is enabled by default in the test suite, but can be + disabled with: + + mysql-test-run.pl ... --debug-sync-timeout=0 ... + + Likewise the default wait timeout can be set: + + mysql-test-run.pl ... --debug-sync-timeout=10 ... + + The command line option influences the readable value of the system + variable 'debug_sync'. + + * If the facility is not compiled in, the system variable does not exist. + + * If --debug-sync-timeout=0 the value of the variable reads as "OFF". + + * Otherwise the value reads as "ON - current signal: " followed by the + current signal string, which can be empty. + + The readable variable value is the same, regardless if read as global + or session value. + + Setting the 'debug-sync' system variable requires 'SUPER' privilege. + You can never read back the string that you assigned to the variable, + unless you assign the value that the variable does already have. But + that would give a parse error. A syntactically correct string is + parsed into a debug sync action and stored apart from the variable value. + + + === Implementation === + + Pseudo code for a sync point: + + #define DEBUG_SYNC(thd, sync_point_name) + if (unlikely(opt_debug_sync_timeout)) + debug_sync(thd, STRING_WITH_LEN(sync_point_name)) + + The sync point performs a binary search in a sorted array of actions + for this thread. + + The SET DEBUG_SYNC statement adds a requested action to the array or + overwrites an existing action for the same sync point. When it adds a + new action, the array is sorted again. + + + === A typical synchronization pattern === + + There are quite a few places in MySQL, where we use a synchronization + pattern like this: + + mysql_mutex_lock(&mutex); + thd->enter_cond(&condition_variable, &mutex, new_message); + #if defined(ENABLE_DEBUG_SYNC) + if (!thd->killed && !end_of_wait_condition) + DEBUG_SYNC(thd, "sync_point_name"); + #endif + while (!thd->killed && !end_of_wait_condition) + mysql_cond_wait(&condition_variable, &mutex); + thd->exit_cond(old_message); + + Here some explanations: + + thd->enter_cond() is used to register the condition variable and the + mutex in thd->mysys_var. This is done to allow the thread to be + interrupted (killed) from its sleep. Another thread can find the + condition variable to signal and mutex to use for synchronization in + this thread's THD::mysys_var. + + thd->enter_cond() requires the mutex to be acquired in advance. + + thd->exit_cond() unregisters the condition variable and mutex and + releases the mutex. + + If you want to have a Debug Sync point with the wait, please place it + behind enter_cond(). Only then you can safely decide, if the wait will + be taken. Also you will have THD::proc_info correct when the sync + point emits a signal. DEBUG_SYNC sets its own proc_info, but restores + the previous one before releasing its internal mutex. As soon as + another thread sees the signal, it does also see the proc_info from + before entering the sync point. In this case it will be "new_message", + which is associated with the wait that is to be synchronized. + + In the example above, the wait condition is repeated before the sync + point. This is done to skip the sync point, if no wait takes place. + The sync point is before the loop (not inside the loop) to have it hit + once only. It is possible that the condition variable is signaled + multiple times without the wait condition to be true. + + A bit off-topic: At some places, the loop is taken around the whole + synchronization pattern: + + while (!thd->killed && !end_of_wait_condition) + { + mysql_mutex_lock(&mutex); + thd->enter_cond(&condition_variable, &mutex, new_message); + if (!thd->killed [&& !end_of_wait_condition]) + { + [DEBUG_SYNC(thd, "sync_point_name");] + mysql_cond_wait(&condition_variable, &mutex); + } + thd->exit_cond(old_message); + } + + Note that it is important to repeat the test for thd->killed after + enter_cond(). Otherwise the killing thread may kill this thread after + it tested thd->killed in the loop condition and before it registered + the condition variable and mutex in enter_cond(). In this case, the + killing thread does not know that this thread is going to wait on a + condition variable. It would just set THD::killed. But if we would not + test it again, we would go asleep though we are killed. If the killing + thread would kill us when we are after the second test, but still + before sleeping, we hold the mutex, which is registered in mysys_var. + The killing thread would try to acquire the mutex before signaling + the condition variable. Since the mutex is only released implicitly in + mysql_cond_wait(), the signaling happens at the right place. We + have a safe synchronization. + + === Co-work with the DBUG facility === + + When running the MySQL test suite with the --debug-dbug command line + option, the Debug Sync Facility writes trace messages to the DBUG + trace. The following shell commands proved very useful in extracting + relevant information: + + egrep 'query:|debug_sync_exec:' mysql-test/var/log/mysqld.1.trace + + It shows all executed SQL statements and all actions executed by + synchronization points. + + Sometimes it is also useful to see, which synchronization points have + been run through (hit) with or without executing actions. Then add + "|debug_sync_point:" to the egrep pattern. + + === Further reading === + + For a discussion of other methods to synchronize threads see + http://forge.mysql.com/wiki/MySQL_Internals_Test_Synchronization + + For complete syntax tests, functional tests, and examples see the test + case debug_sync.test. + + See also http://forge.mysql.com/worklog/task.php?id=4259 +*/ + +#ifndef MYSQL_ABI_CHECK +#include <stdlib.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef MYSQL_DYNAMIC_PLUGIN +extern void (*debug_sync_service)(MYSQL_THD, const char *, size_t); +#else +#define debug_sync_service debug_sync_C_callback_ptr +extern void (*debug_sync_C_callback_ptr)(MYSQL_THD, const char *, size_t); +#endif + +#ifdef ENABLED_DEBUG_SYNC +#define DEBUG_SYNC(thd, name) \ + do { \ + if (debug_sync_service) \ + debug_sync_service(thd, name, sizeof(name)-1); \ + } while(0) +#else +#define DEBUG_SYNC(thd,name) do { } while(0) +#endif + +/* compatibility macro */ +#define DEBUG_SYNC_C(name) DEBUG_SYNC(NULL, name) + +#ifdef __cplusplus +} +#endif + +#define MYSQL_SERVICE_DEBUG_SYNC_INCLUDED +#endif diff --git a/include/mysql/service_logger.h b/include/mysql/service_logger.h deleted file mode 100644 index 47a478ef5b4..00000000000 --- a/include/mysql/service_logger.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 2012 Monty Program Ab - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef MYSQL_SERVICE_LOGGER_INCLUDED -#define MYSQL_SERVICE_LOGGER_INCLUDED - -#ifndef MYSQL_ABI_CHECK -#include <stdarg.h> -#endif - -/** - @file - logger service - - Log file with rotation implementation. - - This service implements logging with possible rotation - of the log files. Interface intentionally tries to be similar to FILE* - related functions. - - So that one can open the log with logger_open(), specifying - the limit on the logfile size and the rotations number. - - Then it's possible to write messages to the log with - logger_printf or logger_vprintf functions. - - As the size of the logfile grows over the specified limit, - it is renamed to 'logfile.1'. The former 'logfile.1' becomes - 'logfile.2', etc. The file 'logfile.rotations' is removed. - That's how the rotation works. - - The rotation can be forced with the logger_rotate() call. - - Finally the log should be closed with logger_close(). - -@notes: - Implementation checks the size of the log file before it starts new - printf into it. So the size of the file gets over the limit when it rotates. - - The access is secured with the mutex, so the log is threadsafe. -*/ - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct logger_handle_st LOGGER_HANDLE; - -extern struct logger_service_st { - LOGGER_HANDLE* (*open)(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int (*close)(LOGGER_HANDLE *log); - int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...); - int (*rotate)(LOGGER_HANDLE *log); -} *logger_service; - -#ifdef MYSQL_DYNAMIC_PLUGIN - -#define logger_open(path, size_limit, rotations) \ - (logger_service->open(path, size_limit, rotations)) -#define logger_close(log) (logger_service->close(log)) -#define logger_rotate(log) (logger_service->rotate(log)) -#define logger_vprintf(log, fmt, argptr) (logger_service->\ - vprintf(log, fmt, argptr)) -#define logger_printf logger_service->printf -#else - - LOGGER_HANDLE *logger_open(const char *path, - unsigned long long size_limit, - unsigned int rotations); - int logger_close(LOGGER_HANDLE *log); - int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr); - int logger_rotate(LOGGER_HANDLE *log); - int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /*MYSQL_SERVICE_LOGGER_INCLUDED*/ - diff --git a/include/mysql/services.h b/include/mysql/services.h index 258f7b90658..8eb506e1c37 100644 --- a/include/mysql/services.h +++ b/include/mysql/services.h @@ -23,8 +23,7 @@ extern "C" { #include <mysql/service_thd_wait.h> #include <mysql/service_thread_scheduler.h> #include <mysql/service_progress_report.h> -#include <mysql/service_logger.h> - +#include <mysql/service_debug_sync.h> #ifdef __cplusplus } diff --git a/include/mysql_com.h b/include/mysql_com.h index b35e8961bbb..0988d20f97f 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -435,10 +435,7 @@ enum mysql_enum_shutdown_level { /* flush InnoDB buffers and other storage engines' buffers*/ SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), /* don't flush InnoDB buffers, flush other storage engines' buffers*/ - SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, - /* Now the 2 levels of the KILL command */ - SHUTDOWN_KILL_QUERY= 254, - SHUTDOWN_KILL_CONNECTION= 255 + SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1 }; /* Compatibility */ diff --git a/include/service_versions.h b/include/service_versions.h index 8a397d71b12..436941643ec 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -24,4 +24,4 @@ #define VERSION_thd_wait 0x0100 #define VERSION_my_thread_scheduler 0x0100 #define VERSION_progress_report 0x0100 -#define VERSION_logger 0x0100 +#define VERSION_debug_sync 0x1000 diff --git a/include/welcome_copyright_notice.h b/include/welcome_copyright_notice.h index 9e40c17efca..739aeb4ede8 100644 --- a/include/welcome_copyright_notice.h +++ b/include/welcome_copyright_notice.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011, Oracle and/or its affiliates. +/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by |