diff options
author | Jan Lindström <jplindst@mariadb.org> | 2013-11-15 15:24:42 +0200 |
---|---|---|
committer | Jan Lindström <jplindst@mariadb.org> | 2013-11-15 15:24:42 +0200 |
commit | e730c91688226931aba17fc1ba790bda7e156830 (patch) | |
tree | b78fc582c027e34f38c77c8762b730158124286b | |
parent | 338587d2f4f1c0e977af8e924b13de7428007097 (diff) | |
download | mariadb-git-e730c91688226931aba17fc1ba790bda7e156830.tar.gz |
Added test case for new system variable innodb_use_stacktrace and made sure that it can be used only on startup. Fixed compiler problems on solaris and other platforms that do not contain necessary headers and functions.
-rw-r--r-- | mysql-test/suite/sys_vars/r/all_vars.result | 1 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/innodb_use_stacktrace_basic.result | 48 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/innodb_use_stacktrace_basic.test | 56 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 4 | ||||
-rw-r--r-- | storage/xtradb/include/os0stacktrace.h | 6 | ||||
-rw-r--r-- | storage/xtradb/os/os0stacktrace.c | 5 |
6 files changed, 114 insertions, 6 deletions
diff --git a/mysql-test/suite/sys_vars/r/all_vars.result b/mysql-test/suite/sys_vars/r/all_vars.result index 435b8a68ee8..1bd4e394f6a 100644 --- a/mysql-test/suite/sys_vars/r/all_vars.result +++ b/mysql-test/suite/sys_vars/r/all_vars.result @@ -10,6 +10,5 @@ there should be *no* long test name listed below: select distinct variable_name as `there should be *no* variables listed below:` from t2 left join t1 on variable_name=test_name where test_name is null; there should be *no* variables listed below: -innodb_use_stacktrace drop table t1; drop table t2; diff --git a/mysql-test/suite/sys_vars/r/innodb_use_stacktrace_basic.result b/mysql-test/suite/sys_vars/r/innodb_use_stacktrace_basic.result new file mode 100644 index 00000000000..5db1880219d --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_use_stacktrace_basic.result @@ -0,0 +1,48 @@ +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +COUNT(@@GLOBAL.innodb_use_stacktrace) +1 +1 Expected +SET @@GLOBAL.innodb_use_stacktrace=1; +ERROR HY000: Variable 'innodb_use_stacktrace' is a read only variable +Expected error 'Read only variable' +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +COUNT(@@GLOBAL.innodb_use_stacktrace) +1 +1 Expected +SELECT IF(@@GLOBAL.innodb_use_stacktrace, 'ON', 'OFF') = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_use_stacktrace'; +IF(@@GLOBAL.innodb_use_stacktrace, 'ON', 'OFF') = VARIABLE_VALUE +1 +1 Expected +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +COUNT(@@GLOBAL.innodb_use_stacktrace) +1 +1 Expected +SELECT COUNT(VARIABLE_VALUE) +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_use_stacktrace'; +COUNT(VARIABLE_VALUE) +1 +1 Expected +SELECT @@innodb_use_stacktrace = @@GLOBAL.innodb_use_stacktrace; +@@innodb_use_stacktrace = @@GLOBAL.innodb_use_stacktrace +1 +1 Expected +SELECT COUNT(@@innodb_use_stacktrace); +COUNT(@@innodb_use_stacktrace) +1 +1 Expected +SELECT COUNT(@@local.innodb_use_stacktrace); +ERROR HY000: Variable 'innodb_use_stacktrace' is a GLOBAL variable +Expected error 'Variable is a GLOBAL variable' +SELECT COUNT(@@SESSION.innodb_use_stacktrace); +ERROR HY000: Variable 'innodb_use_stacktrace' is a GLOBAL variable +Expected error 'Variable is a GLOBAL variable' +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +COUNT(@@GLOBAL.innodb_use_stacktrace) +1 +1 Expected +SELECT innodb_use_stacktrace = @@SESSION.innodb_use_stacktrace; +ERROR 42S22: Unknown column 'innodb_use_stacktrace' in 'field list' +Expected error 'Readonly variable' diff --git a/mysql-test/suite/sys_vars/t/innodb_use_stacktrace_basic.test b/mysql-test/suite/sys_vars/t/innodb_use_stacktrace_basic.test new file mode 100644 index 00000000000..b7da1dae3d4 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_use_stacktrace_basic.test @@ -0,0 +1,56 @@ +--source include/have_xtradb.inc + +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +--echo 1 Expected + +#################################################################### +# Check if Value can set # +#################################################################### + +--error ER_INCORRECT_GLOBAL_LOCAL_VAR +SET @@GLOBAL.innodb_use_stacktrace=1; +--echo Expected error 'Read only variable' + +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +--echo 1 Expected + +################################################################# +# Check if the value in GLOBAL Table matches value in variable # +################################################################# + +SELECT IF(@@GLOBAL.innodb_use_stacktrace, 'ON', 'OFF') = VARIABLE_VALUE +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_use_stacktrace'; +--echo 1 Expected + +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +--echo 1 Expected + +SELECT COUNT(VARIABLE_VALUE) +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES +WHERE VARIABLE_NAME='innodb_use_stacktrace'; +--echo 1 Expected + +################################################################################ +# Check if accessing variable with and without GLOBAL point to same variable # +################################################################################ +SELECT @@innodb_use_stacktrace = @@GLOBAL.innodb_use_stacktrace; +--echo 1 Expected + +SELECT COUNT(@@innodb_use_stacktrace); +--echo 1 Expected + +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT COUNT(@@local.innodb_use_stacktrace); +--echo Expected error 'Variable is a GLOBAL variable' + +--Error ER_INCORRECT_GLOBAL_LOCAL_VAR +SELECT COUNT(@@SESSION.innodb_use_stacktrace); +--echo Expected error 'Variable is a GLOBAL variable' + +SELECT COUNT(@@GLOBAL.innodb_use_stacktrace); +--echo 1 Expected + +--Error ER_BAD_FIELD_ERROR +SELECT innodb_use_stacktrace = @@SESSION.innodb_use_stacktrace; +--echo Expected error 'Readonly variable' diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 7f3e3770809..4add8a0be97 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -13473,8 +13473,8 @@ static MYSQL_SYSVAR_BOOL(print_all_deadlocks, srv_print_all_deadlocks, NULL, NULL, FALSE); static MYSQL_SYSVAR_BOOL(use_stacktrace, srv_use_stacktrace, - PLUGIN_VAR_OPCMDARG, - "Print stacktrace on long semaphore wait (off by default)", + PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, + "Print stacktrace on long semaphore wait (off by default supported only on linux)", NULL, NULL, FALSE); static struct st_mysql_sys_var* innobase_system_variables[]= { diff --git a/storage/xtradb/include/os0stacktrace.h b/storage/xtradb/include/os0stacktrace.h index 15921a11be0..58e9a528593 100644 --- a/storage/xtradb/include/os0stacktrace.h +++ b/storage/xtradb/include/os0stacktrace.h @@ -20,8 +20,10 @@ this program; if not, write to the Free Software Foundation, Inc., #ifndef os0stacktrace_h #define os0stacktrace_h -#ifndef __WIN__ +#ifdef __linux__ +#if HAVE_EXECINFO_H #include <execinfo.h> +#endif #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -38,5 +40,5 @@ os_stacktrace_print( siginfo_t* info, /*!< in: signal information */ void* ucontext);/*!< in: signal context */ -#endif /* ! __WIN__ */ +#endif /* __linux__ */ #endif /* os0stacktrace.h */ diff --git a/storage/xtradb/os/os0stacktrace.c b/storage/xtradb/os/os0stacktrace.c index 0fbb751c949..4d52e625057 100644 --- a/storage/xtradb/os/os0stacktrace.c +++ b/storage/xtradb/os/os0stacktrace.c @@ -19,9 +19,12 @@ this program; if not, write to the Free Software Foundation, Inc., #include "os0thread.h" -#ifdef __linux__ +#if defined (__linux__) && HAVE_BACKTRACE && HAVE_BACKTRACE_SYMBOLS +#if HAVE_EXECINFO_H #include <execinfo.h> +#endif + #include <signal.h> #include <stdio.h> #include <stdlib.h> |