Skip to content
This repository
Browse code

Merge branch 'MYSQL-15' into twitter-dev

  • Loading branch information...
commit 8efbad7c19e89b81a0f6b752d8088a27c6944c8e 2 parents d47f9d1 + 7fc0322
Davi Arnaut authored

Showing 54 changed files with 2,356 additions and 40 deletions. Show diff stats Hide diff stats

  1. +4 0 config.h.cmake
  2. +17 0 configure.cmake
  3. +14 3 include/my_global.h
  4. +69 0 include/my_timer.h
  5. +7 0 include/mysql/plugin.h
  6. +1 0  include/mysql/plugin_audit.h.pp
  7. +1 0  include/mysql/plugin_auth.h.pp
  8. +1 0  include/mysql/plugin_ftparser.h.pp
  9. +3 0  libmysqld/CMakeLists.txt
  10. +4 0 mysql-test/include/have_statement_timeout.inc
  11. +3 0  mysql-test/r/grant.result
  12. +2 0  mysql-test/r/have_statement_timeout.require
  13. +157 0 mysql-test/r/max_statement_time.result
  14. +3 3 mysql-test/r/ps.result
  15. +1 0  mysql-test/r/system_mysql_db.result
  16. +2 0  mysql-test/suite/funcs_1/r/is_columns_mysql.result
  17. +33 0 mysql-test/suite/funcs_1/r/is_user_privileges.result
  18. 0  mysql-test/suite/randgen/r/max_statement_time.result
  19. +16 0 mysql-test/suite/randgen/t/max_statement_time.test
  20. +53 0 mysql-test/suite/sys_vars/r/have_statement_timeout_basic.result
  21. +91 0 mysql-test/suite/sys_vars/r/max_statement_time_basic.result
  22. +66 0 mysql-test/suite/sys_vars/r/max_statement_time_func.result
  23. +55 0 mysql-test/suite/sys_vars/t/have_statement_timeout_basic.test
  24. +78 0 mysql-test/suite/sys_vars/t/max_statement_time_basic.test
  25. +75 0 mysql-test/suite/sys_vars/t/max_statement_time_func.test
  26. +220 0 mysql-test/t/max_statement_time.test
  27. +8 0 mysys/CMakeLists.txt
  28. +219 0 mysys/kqueue_timers.c
  29. +256 0 mysys/posix_timers.c
  30. +1 1  scripts/mysql_system_tables.sql
  31. +4 4 scripts/mysql_system_tables_data.sql
  32. +4 0 scripts/mysql_system_tables_fix.sql
  33. +4 0 sql/CMakeLists.txt
  34. +18 0 sql/handler.cc
  35. +4 0 sql/handler.h
  36. +1 0  sql/lex.h
  37. +22 0 sql/mysqld.cc
  38. +1 0  sql/set_var.h
  39. +4 1 sql/share/errmsg-utf8.txt
  40. +3 0  sql/signal_handler.cc
  41. +40 2 sql/sql_acl.cc
  42. +42 16 sql/sql_class.cc
  43. +11 0 sql/sql_class.h
  44. +3 0  sql/sql_lex.cc
  45. +3 0  sql/sql_lex.h
  46. +92 1 sql/sql_parse.cc
  47. +233 0 sql/sql_timer.cc
  48. +50 0 sql/sql_timer.h
  49. +37 5 sql/sql_yacc.yy
  50. +3 1 sql/structs.h
  51. +10 0 sql/sys_vars.cc
  52. +34 3 storage/innobase/handler/ha_innodb.cc
  53. +4 0 unittest/mysys/CMakeLists.txt
  54. +269 0 unittest/mysys/my_timer-t.c
4 config.h.cmake
@@ -308,6 +308,10 @@
308 308 #cmakedefine STRUCT_DIRENT_HAS_D_NAMLEN 1
309 309 #cmakedefine SPRINTF_RETURNS_INT 1
310 310
  311 +#cmakedefine HAVE_POSIX_TIMERS 1
  312 +#cmakedefine HAVE_KQUEUE_TIMERS 1
  313 +#cmakedefine HAVE_MY_TIMER 1
  314 +
311 315 #define USE_MB 1
312 316 #define USE_MB_IDENT 1
313 317
17 configure.cmake
@@ -147,6 +147,7 @@ IF(UNIX)
147 147 IF(NOT LIBRT)
148 148 MY_SEARCH_LIBS(clock_gettime rt LIBRT)
149 149 ENDIF()
  150 + MY_SEARCH_LIBS(timer_create rt LIBRT)
150 151 FIND_PACKAGE(Threads)
151 152
152 153 SET(CMAKE_REQUIRED_LIBRARIES
@@ -454,6 +455,9 @@ CHECK_FUNCTION_EXISTS (valloc HAVE_VALLOC)
454 455 CHECK_FUNCTION_EXISTS (memalign HAVE_MEMALIGN)
455 456 CHECK_FUNCTION_EXISTS (chown HAVE_CHOWN)
456 457 CHECK_FUNCTION_EXISTS (nl_langinfo HAVE_NL_LANGINFO)
  458 +CHECK_FUNCTION_EXISTS (timer_create HAVE_TIMER_CREATE)
  459 +CHECK_FUNCTION_EXISTS (timer_settime HAVE_TIMER_SETTIME)
  460 +CHECK_FUNCTION_EXISTS (kqueue HAVE_KQUEUE)
457 461
458 462 #--------------------------------------------------------------------
459 463 # Support for WL#2373 (Use cycle counter for timing)
@@ -495,6 +499,8 @@ CHECK_SYMBOL_EXISTS(FIONREAD "sys/ioctl.h" FIONREAD_IN_SYS_IOCTL)
495 499 CHECK_SYMBOL_EXISTS(TIOCSTAT "sys/ioctl.h" TIOCSTAT_IN_SYS_IOCTL)
496 500 CHECK_SYMBOL_EXISTS(FIONREAD "sys/filio.h" FIONREAD_IN_SYS_FILIO)
497 501 CHECK_SYMBOL_EXISTS(gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY)
  502 +CHECK_SYMBOL_EXISTS(SIGEV_THREAD_ID "signal.h;time.h" HAVE_SIGEV_THREAD_ID)
  503 +CHECK_SYMBOL_EXISTS(EVFILT_TIMER "sys/types.h;sys/event.h;sys/time.h" HAVE_EVFILT_TIMER)
498 504
499 505 CHECK_SYMBOL_EXISTS(finite "math.h" HAVE_FINITE_IN_MATH_H)
500 506 IF(HAVE_FINITE_IN_MATH_H)
@@ -514,7 +520,18 @@ int main() {
514 520 return 0;
515 521 }" HAVE_ISINF)
516 522
  523 +# Check for the Linux-specific POSIX timers API.
  524 +IF(HAVE_TIMER_CREATE AND HAVE_TIMER_SETTIME AND HAVE_SIGEV_THREAD_ID)
  525 + SET(HAVE_POSIX_TIMERS 1 CACHE INTERNAL "Have POSIX timer-related functions")
  526 +ENDIF()
  527 +
  528 +IF(HAVE_KQUEUE AND HAVE_EVFILT_TIMER)
  529 + SET(HAVE_KQUEUE_TIMERS 1 CACHE INTERNAL "Have kqueue timer-related filter")
  530 +ENDIF()
517 531
  532 +IF(HAVE_POSIX_TIMERS OR HAVE_KQUEUE_TIMERS)
  533 + SET(HAVE_MY_TIMER 1 CACHE INTERNAL "Have mysys timer-related functions")
  534 +ENDIF()
518 535
519 536 #
520 537 # Test for endianess
17 include/my_global.h
@@ -377,6 +377,19 @@ C_MODE_END
377 377 #include <crypt.h>
378 378 #endif
379 379
  380 +/**
  381 + Cast a member of a structure to the structure that contains it.
  382 +
  383 + @param ptr Pointer to the member.
  384 + @param type Type of the structure that contains the member.
  385 + @param member Name of the member within the structure.
  386 +*/
  387 +#define my_container_of(ptr, type, member) \
  388 + ({ \
  389 + const typeof(((type *)0)->member) *__mptr= (ptr); \
  390 + (type *)((char *)__mptr - offsetof(type, member)); \
  391 + })
  392 +
380 393 /*
381 394 A lot of our programs uses asserts, so better to always include it
382 395 This also fixes a problem when people uses DBUG_ASSERT without including
@@ -1418,9 +1431,7 @@ do { doubleget_union _tmp; \
1418 1431 #define NEED_EXPLICIT_SYNC_DIR 1
1419 1432 #endif
1420 1433
1421   -#if !defined(__cplusplus) && !defined(bool)
1422   -#define bool In_C_you_should_use_my_bool_instead()
1423   -#endif
  1434 +#include <stdbool.h>
1424 1435
1425 1436 /* Provide __func__ macro definition for platforms that miss it. */
1426 1437 #if __STDC_VERSION__ < 199901L
69 include/my_timer.h
... ... @@ -0,0 +1,69 @@
  1 +/* Copyright (c) 2012, Twitter, Inc. All rights reserved.
  2 +
  3 + This program is free software; you can redistribute it and/or modify
  4 + it under the terms of the GNU General Public License as published by
  5 + the Free Software Foundation; version 2 of the License.
  6 +
  7 + This program is distributed in the hope that it will be useful,
  8 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  9 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10 + GNU General Public License for more details.
  11 +
  12 + You should have received a copy of the GNU General Public License along
  13 + with this program; if not, write to the Free Software Foundation, Inc.,
  14 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  15 +
  16 +#ifndef MY_TIMER_H
  17 +#define MY_TIMER_H
  18 +
  19 +#include "my_global.h" /* C_MODE_START, C_MODE_END */
  20 +#include "my_config.h" /* HAVE_*_TIMERS */
  21 +
  22 +/* POSIX timers API. */
  23 +#ifdef HAVE_POSIX_TIMERS
  24 +# include <time.h> /* timer_t */
  25 + typedef timer_t os_timer_t;
  26 +#elif HAVE_KQUEUE_TIMERS
  27 +# include <sys/types.h> /* uintptr_t */
  28 + typedef uintptr_t os_timer_t;
  29 +#endif
  30 +
  31 +/* Whether timer API is implemented. */
  32 +#ifdef HAVE_MY_TIMER
  33 +
  34 +C_MODE_START
  35 +
  36 +typedef struct st_my_timer my_timer_t;
  37 +
  38 +/** Non-copyable timer object. */
  39 +struct st_my_timer
  40 +{
  41 + /** Timer ID used to identify the timer in timer requests. */
  42 + os_timer_t id;
  43 +
  44 + /** Timer expiration notification function. */
  45 + void (*notify_function)(my_timer_t *);
  46 +};
  47 +
  48 +/* Initialize internal components. */
  49 +int my_timer_init_ext(void);
  50 +
  51 +/* Release any resources acquired. */
  52 +void my_timer_deinit(void);
  53 +
  54 +/* Create a timer object. */
  55 +int my_timer_create(my_timer_t *timer);
  56 +
  57 +/* Set the time (in milliseconds) until the next expiration of the timer. */
  58 +int my_timer_set(my_timer_t *timer, unsigned long time);
  59 +
  60 +/* Reset the time until the next expiration of the timer. */
  61 +int my_timer_reset(my_timer_t *timer, bool *state);
  62 +
  63 +/* Delete a timer object. */
  64 +void my_timer_delete(my_timer_t *timer);
  65 +
  66 +C_MODE_END
  67 +
  68 +#endif /* HAVE_MY_TIMER */
  69 +#endif /* MY_TIMER_H */
7 include/mysql/plugin.h
@@ -584,6 +584,13 @@ int thd_killed(const MYSQL_THD thd);
584 584
585 585
586 586 /**
  587 + Set the killed status of the current statement.
  588 +
  589 + @param thd user thread connection handle
  590 +*/
  591 +void thd_set_kill_status(const MYSQL_THD thd);
  592 +
  593 +/**
587 594 Return the thread id of a user thread
588 595
589 596 @param thd user thread connection handle
1  include/mysql/plugin_audit.h.pp
@@ -189,6 +189,7 @@
189 189 int mysql_tmpfile(const char *prefix);
190 190 void* thd_get_current_thd();
191 191 int thd_killed(const void* thd);
  192 +void thd_set_kill_status(const void* thd);
192 193 unsigned long thd_get_thread_id(const void* thd);
193 194 void thd_get_xid(const void* thd, MYSQL_XID *xid);
194 195 void mysql_query_cache_invalidate4(void* thd,
1  include/mysql/plugin_auth.h.pp
@@ -189,6 +189,7 @@
189 189 int mysql_tmpfile(const char *prefix);
190 190 void* thd_get_current_thd();
191 191 int thd_killed(const void* thd);
  192 +void thd_set_kill_status(const void* thd);
192 193 unsigned long thd_get_thread_id(const void* thd);
193 194 void thd_get_xid(const void* thd, MYSQL_XID *xid);
194 195 void mysql_query_cache_invalidate4(void* thd,
1  include/mysql/plugin_ftparser.h.pp
@@ -142,6 +142,7 @@
142 142 int mysql_tmpfile(const char *prefix);
143 143 void* thd_get_current_thd();
144 144 int thd_killed(const void* thd);
  145 +void thd_set_kill_status(const void* thd);
145 146 unsigned long thd_get_thread_id(const void* thd);
146 147 void thd_get_xid(const void* thd, MYSQL_XID *xid);
147 148 void mysql_query_cache_invalidate4(void* thd,
3  libmysqld/CMakeLists.txt
@@ -92,6 +92,9 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
92 92 ${MYSYS_LIBWRAP_SOURCE}
93 93 )
94 94
  95 +IF(HAVE_MY_TIMER)
  96 + SET(SQL_EMBEDDED_SOURCES ${SQL_EMBEDDED_SOURCES} ../sql/sql_timer.cc)
  97 +ENDIF()
95 98
96 99 ADD_CONVENIENCE_LIBRARY(sql_embedded ${SQL_EMBEDDED_SOURCES})
97 100 DTRACE_INSTRUMENT(sql_embedded)
4 mysql-test/include/have_statement_timeout.inc
... ... @@ -0,0 +1,4 @@
  1 +-- require r/have_statement_timeout.require
  2 +disable_query_log;
  3 +show variables like 'have_statement_timeout';
  4 +enable_query_log;
3  mysql-test/r/grant.result
@@ -55,6 +55,7 @@ max_connections 0
55 55 max_user_connections 0
56 56 plugin
57 57 authentication_string NULL
  58 +max_statement_time 0
58 59 show grants for mysqltest_1@localhost;
59 60 Grants for mysqltest_1@localhost
60 61 GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA'
@@ -126,6 +127,7 @@ max_connections 0
126 127 max_user_connections 0
127 128 plugin
128 129 authentication_string NULL
  130 +max_statement_time 0
129 131 show grants for mysqltest_1@localhost;
130 132 Grants for mysqltest_1@localhost
131 133 GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10
@@ -173,6 +175,7 @@ max_connections 30
173 175 max_user_connections 0
174 176 plugin
175 177 authentication_string NULL
  178 +max_statement_time 0
176 179 show grants for mysqltest_1@localhost;
177 180 Grants for mysqltest_1@localhost
178 181 GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' WITH MAX_QUERIES_PER_HOUR 10 MAX_UPDATES_PER_HOUR 20 MAX_CONNECTIONS_PER_HOUR 30
2  mysql-test/r/have_statement_timeout.require
... ... @@ -0,0 +1,2 @@
  1 +Variable_name Value
  2 +have_statement_timeout YES
157 mysql-test/r/max_statement_time.result
... ... @@ -0,0 +1,157 @@
  1 +
  2 +# Test MAX_STATEMENT_TIME option syntax.
  3 +
  4 +CREATE TABLE t1 (a INT);
  5 +SET @var = (SELECT MAX_STATEMENT_TIME=0 1);
  6 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1)' at line 1
  7 +SELECT 1 FROM t1 WHERE a IN (SELECT MAX_STATEMENT_TIME=0 1);
  8 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1)' at line 1
  9 +SELECT (SELECT MAX_STATEMENT_TIME=0 a FROM t1);
  10 +ERROR 42S22: Unknown column 'MAX_STATEMENT_TIME' in 'field list'
  11 +SELECT a FROM t1 WHERE a IN (SELECT MAX_STATEMENT_TIME=0 a FROM t1);
  12 +ERROR 42S22: Unknown column 'MAX_STATEMENT_TIME' in 'field list'
  13 +SELECT * FROM t1 WHERE a IN (SELECT MAX_STATEMENT_TIME=0 a FROM t1);
  14 +ERROR 42S22: Unknown column 'MAX_STATEMENT_TIME' in 'field list'
  15 +SELECT MAX_STATEMENT_TIME=0 * FROM t1
  16 +WHERE a IN (SELECT MAX_STATEMENT_TIME=0 a FROM t1);
  17 +ERROR 42S22: Unknown column 'MAX_STATEMENT_TIME' in 'field list'
  18 +SELECT * FROM t1
  19 +WHERE a IN (SELECT a FROM t1 UNION SELECT MAX_STATEMENT_TIME=0 a FROM t1);
  20 +ERROR 42S22: Unknown column 'MAX_STATEMENT_TIME' in 'field list'
  21 +SELECT MAX_STATEMENT_TIME=0 * FROM t1
  22 +WHERE a IN (SELECT a FROM t1 UNION SELECT MAX_STATEMENT_TIME=0 a FROM t1);
  23 +ERROR 42S22: Unknown column 'MAX_STATEMENT_TIME' in 'field list'
  24 +SELECT * FROM t1 UNION SELECT MAX_STATEMENT_TIME=0 * FROM t1;
  25 +ERROR 42000: Incorrect usage/placement of 'MAX_STATEMENT_TIME'
  26 +SELECT MAX_STATEMENT_TIME=0 * FROM t1
  27 +UNION SELECT MAX_STATEMENT_TIME=0 * FROM t1;
  28 +ERROR 42000: Incorrect usage/placement of 'MAX_STATEMENT_TIME'
  29 +INSERT INTO t1 SELECT MAX_STATEMENT_TIME=0 * FROM t1;
  30 +ERROR 42000: Incorrect usage/placement of 'MAX_STATEMENT_TIME'
  31 +CREATE TABLE t1 AS SELECT MAX_STATEMENT_TIME=0 * FROM t1;
  32 +ERROR 42000: Incorrect usage/placement of 'MAX_STATEMENT_TIME'
  33 +CREATE TABLE t1 AS SELECT 1 A UNION SELECT 2 UNION SELECT MAX_STATEMENT_TIME=0 3;
  34 +ERROR 42000: Incorrect usage/placement of 'MAX_STATEMENT_TIME'
  35 +SELECT MAX_STATEMENT_TIME=0 * FROM t1;
  36 +a
  37 +DROP TABLE t1;
  38 +
  39 +# Test the MAX_STATEMENT_TIME option.
  40 +
  41 +SELECT MAX_STATEMENT_TIME=1 SLEEP(1);
  42 +SLEEP(1)
  43 +1
  44 +CREATE TABLE t1 (a INT, b VARCHAR(300));
  45 +INSERT INTO t1 VALUES (1, 'string');
  46 +SELECT 996;
  47 +996
  48 +996
  49 +DROP TABLE t1;
  50 +
  51 +# Test the MAX_STATEMENT_TIME option with SF.
  52 +
  53 +CREATE TABLE t1 (a INT, b VARCHAR(300));
  54 +INSERT INTO t1 VALUES (1, 'string');
  55 +CREATE FUNCTION f1() RETURNS INT
  56 +BEGIN
  57 +WHILE true DO
  58 +INSERT INTO t1 SELECT * FROM t1;
  59 +END WHILE;
  60 +RETURN 1;
  61 +END|
  62 +SELECT MAX_STATEMENT_TIME=500 f1();
  63 +ERROR 70100: Query execution was interrupted, max_statement_time exceeded
  64 +DROP FUNCTION f1;
  65 +DROP TABLE t1;
  66 +
  67 +# MAX_STATEMENT_TIME option takes precedence over @@max_statement_time.
  68 +
  69 +SET @@SESSION.max_statement_time = 100;
  70 +SELECT MAX_STATEMENT_TIME=2000 SLEEP(1);
  71 +SLEEP(1)
  72 +0
  73 +SET @@SESSION.max_statement_time = DEFAULT;
  74 +
  75 +# MAX_STATEMENT_TIME account resource
  76 +
  77 +GRANT USAGE ON *.* TO user1@localhost WITH MAX_STATEMENT_TIME 5000;
  78 +# con1
  79 +SELECT @@max_statement_time;
  80 +@@max_statement_time
  81 +5000
  82 +# restart and reconnect
  83 +SELECT @@max_statement_time;
  84 +@@max_statement_time
  85 +5000
  86 +DROP USER user1@localhost;
  87 +
  88 +# MAX_STATEMENT_TIME status variables.
  89 +
  90 +SELECT CONVERT(VARIABLE_VALUE, UNSIGNED) INTO @time_set
  91 +FROM INFORMATION_SCHEMA.GLOBAL_STATUS
  92 +WHERE VARIABLE_NAME = 'MAX_STATEMENT_TIME_SET';
  93 +SELECT CONVERT(VARIABLE_VALUE, UNSIGNED) INTO @time_exceeded
  94 +FROM INFORMATION_SCHEMA.GLOBAL_STATUS
  95 +WHERE VARIABLE_NAME = 'MAX_STATEMENT_TIME_EXCEEDED';
  96 +SELECT MAX_STATEMENT_TIME=10 SLEEP(1);
  97 +SLEEP(1)
  98 +1
  99 +# Ensure that the counters for:
  100 +# - statements that are time limited; and
  101 +# - statements that exceeded their maximum execution time
  102 +# are incremented.
  103 +SELECT 1 AS STATUS FROM INFORMATION_SCHEMA.GLOBAL_STATUS
  104 +WHERE VARIABLE_NAME = 'MAX_STATEMENT_TIME_SET'
  105 + AND CONVERT(VARIABLE_VALUE, UNSIGNED) > @time_set;
  106 +STATUS
  107 +1
  108 +SELECT 1 AS STATUS FROM INFORMATION_SCHEMA.GLOBAL_STATUS
  109 +WHERE VARIABLE_NAME = 'MAX_STATEMENT_TIME_EXCEEDED'
  110 + AND CONVERT(VARIABLE_VALUE, UNSIGNED) > @time_exceeded;
  111 +STATUS
  112 +1
  113 +
  114 +# Check that the appropriate error status is set.
  115 +
  116 +CREATE TABLE t1 (a INT) ENGINE=InnoDB;
  117 +INSERT INTO t1 VALUES (1);
  118 +START TRANSACTION;
  119 +SELECT * FROM t1 FOR UPDATE;
  120 +a
  121 +1
  122 +SET @@SESSION.max_statement_time = 500;
  123 +UPDATE t1 SET a = 2;
  124 +ERROR 70100: Query execution was interrupted, max_statement_time exceeded
  125 +SHOW WARNINGS;
  126 +Level Code Message
  127 +Error 996 Query execution was interrupted, max_statement_time exceeded
  128 +Error 996 Query execution was interrupted, max_statement_time exceeded
  129 +ROLLBACK;
  130 +DROP TABLE t1;
  131 +
  132 +# Test interaction with lock waits.
  133 +
  134 +CREATE TABLE t1 (a INT) ENGINE=InnoDB;
  135 +INSERT INTO t1 VALUES (1);
  136 +SET @@SESSION.max_statement_time = 500;
  137 +LOCK TABLES t1 WRITE;
  138 +LOCK TABLES t1 READ;
  139 +ERROR 70100: Query execution was interrupted, max_statement_time exceeded
  140 +UNLOCK TABLES;
  141 +BEGIN;
  142 +SELECT * FROM t1;
  143 +a
  144 +1
  145 +ALTER TABLE t1 ADD COLUMN b INT;
  146 +ERROR 70100: Query execution was interrupted, max_statement_time exceeded
  147 +ROLLBACK;
  148 +SELECT GET_LOCK('lock', 1);
  149 +GET_LOCK('lock', 1)
  150 +1
  151 +SELECT GET_LOCK('lock', 1);
  152 +GET_LOCK('lock', 1)
  153 +NULL
  154 +SELECT RELEASE_LOCK('lock');
  155 +RELEASE_LOCK('lock')
  156 +1
  157 +DROP TABLE t1;
6 mysql-test/r/ps.result
@@ -1194,13 +1194,13 @@ SET @aux= "SELECT COUNT(*)
1194 1194 prepare my_stmt from @aux;
1195 1195 execute my_stmt;
1196 1196 COUNT(*)
1197   -42
  1197 +43
1198 1198 execute my_stmt;
1199 1199 COUNT(*)
1200   -42
  1200 +43
1201 1201 execute my_stmt;
1202 1202 COUNT(*)
1203   -42
  1203 +43
1204 1204 deallocate prepare my_stmt;
1205 1205 drop procedure if exists p1|
1206 1206 drop table if exists t1|
1  mysql-test/r/system_mysql_db.result
@@ -122,6 +122,7 @@ user CREATE TABLE `user` (
122 122 `max_user_connections` int(11) unsigned NOT NULL DEFAULT '0',
123 123 `plugin` char(64) COLLATE utf8_bin DEFAULT '',
124 124 `authentication_string` text COLLATE utf8_bin,
  125 + `max_statement_time` int(11) unsigned NOT NULL DEFAULT '0',
125 126 PRIMARY KEY (`Host`,`User`)
126 127 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges'
127 128 show create table func;
2  mysql-test/suite/funcs_1/r/is_columns_mysql.result
@@ -204,6 +204,7 @@ def mysql user Insert_priv 5 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('
204 204 def mysql user Lock_tables_priv 21 N NO enum 1 3 NULL NULL utf8 utf8_general_ci enum('N','Y') select,insert,update,references
205 205 def mysql user max_connections 39 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
206 206 def mysql user max_questions 37 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
  207 +def mysql user max_statement_time 43 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
207 208 def mysql user max_updates 38 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
208 209 def mysql user max_user_connections 40 0 NO int NULL NULL 10 0 NULL NULL int(11) unsigned select,insert,update,references
209 210 def mysql user Password 3 NO char 41 41 NULL NULL latin1 latin1_bin char(41) select,insert,update,references
@@ -518,3 +519,4 @@ NULL mysql user max_connections int NULL NULL NULL NULL int(11) unsigned
518 519 NULL mysql user max_user_connections int NULL NULL NULL NULL int(11) unsigned
519 520 3.0000 mysql user plugin char 64 192 utf8 utf8_bin char(64)
520 521 1.0000 mysql user authentication_string text 65535 65535 utf8 utf8_bin text
  522 +NULL mysql user max_statement_time int NULL NULL NULL NULL int(11) unsigned
33 mysql-test/suite/funcs_1/r/is_user_privileges.result
@@ -129,6 +129,7 @@ max_connections 0
129 129 max_user_connections 0
130 130 plugin
131 131 authentication_string NULL
  132 +max_statement_time 0
132 133 Host localhost
133 134 User testuser2
134 135 Password
@@ -171,6 +172,7 @@ max_connections 0
171 172 max_user_connections 0
172 173 plugin
173 174 authentication_string NULL
  175 +max_statement_time 0
174 176 Host localhost
175 177 User testuser3
176 178 Password
@@ -213,6 +215,7 @@ max_connections 0
213 215 max_user_connections 0
214 216 plugin
215 217 authentication_string NULL
  218 +max_statement_time 0
216 219 #
217 220 # Add GRANT OPTION db_datadict.* to testuser1;
218 221 GRANT UPDATE ON db_datadict.* TO 'testuser1'@'localhost' WITH GRANT OPTION;
@@ -279,6 +282,7 @@ max_connections 0
279 282 max_user_connections 0
280 283 plugin
281 284 authentication_string NULL
  285 +max_statement_time 0
282 286 Host localhost
283 287 User testuser2
284 288 Password
@@ -321,6 +325,7 @@ max_connections 0
321 325 max_user_connections 0
322 326 plugin
323 327 authentication_string NULL
  328 +max_statement_time 0
324 329 Host localhost
325 330 User testuser3
326 331 Password
@@ -363,6 +368,7 @@ max_connections 0
363 368 max_user_connections 0
364 369 plugin
365 370 authentication_string NULL
  371 +max_statement_time 0
366 372 # Establish connection testuser1 (user=testuser1)
367 373 SELECT * FROM information_schema.user_privileges
368 374 WHERE grantee LIKE '''testuser%'''
@@ -415,6 +421,7 @@ max_connections 0
415 421 max_user_connections 0
416 422 plugin
417 423 authentication_string NULL
  424 +max_statement_time 0
418 425 Host localhost
419 426 User testuser2
420 427 Password
@@ -457,6 +464,7 @@ max_connections 0
457 464 max_user_connections 0
458 465 plugin
459 466 authentication_string NULL
  467 +max_statement_time 0
460 468 Host localhost
461 469 User testuser3
462 470 Password
@@ -499,6 +507,7 @@ max_connections 0
499 507 max_user_connections 0
500 508 plugin
501 509 authentication_string NULL
  510 +max_statement_time 0
502 511 SHOW GRANTS;
503 512 Grants for testuser1@localhost
504 513 GRANT USAGE ON *.* TO 'testuser1'@'localhost'
@@ -573,6 +582,7 @@ max_connections 0
573 582 max_user_connections 0
574 583 plugin
575 584 authentication_string NULL
  585 +max_statement_time 0
576 586 Host localhost
577 587 User testuser2
578 588 Password
@@ -615,6 +625,7 @@ max_connections 0
615 625 max_user_connections 0
616 626 plugin
617 627 authentication_string NULL
  628 +max_statement_time 0
618 629 Host localhost
619 630 User testuser3
620 631 Password
@@ -657,6 +668,7 @@ max_connections 0
657 668 max_user_connections 0
658 669 plugin
659 670 authentication_string NULL
  671 +max_statement_time 0
660 672 GRANT SELECT ON *.* TO 'testuser1'@'localhost' WITH GRANT OPTION;
661 673 #
662 674 # Here <SELECT YES> is shown correctly for testuser1;
@@ -723,6 +735,7 @@ max_connections 0
723 735 max_user_connections 0
724 736 plugin
725 737 authentication_string NULL
  738 +max_statement_time 0
726 739 Host localhost
727 740 User testuser2
728 741 Password
@@ -765,6 +778,7 @@ max_connections 0
765 778 max_user_connections 0
766 779 plugin
767 780 authentication_string NULL
  781 +max_statement_time 0
768 782 Host localhost
769 783 User testuser3
770 784 Password
@@ -807,6 +821,7 @@ max_connections 0
807 821 max_user_connections 0
808 822 plugin
809 823 authentication_string NULL
  824 +max_statement_time 0
810 825 # Switch to connection testuser1
811 826 SELECT * FROM information_schema.user_privileges
812 827 WHERE grantee LIKE '''testuser%'''
@@ -859,6 +874,7 @@ max_connections 0
859 874 max_user_connections 0
860 875 plugin
861 876 authentication_string NULL
  877 +max_statement_time 0
862 878 Host localhost
863 879 User testuser2
864 880 Password
@@ -901,6 +917,7 @@ max_connections 0
901 917 max_user_connections 0
902 918 plugin
903 919 authentication_string NULL
  920 +max_statement_time 0
904 921 Host localhost
905 922 User testuser3
906 923 Password
@@ -943,6 +960,7 @@ max_connections 0
943 960 max_user_connections 0
944 961 plugin
945 962 authentication_string NULL
  963 +max_statement_time 0
946 964 SHOW GRANTS;
947 965 Grants for testuser1@localhost
948 966 GRANT SELECT ON *.* TO 'testuser1'@'localhost' WITH GRANT OPTION
@@ -1047,6 +1065,7 @@ max_connections 0
1047 1065 max_user_connections 0
1048 1066 plugin
1049 1067 authentication_string NULL
  1068 +max_statement_time 0
1050 1069 Host localhost
1051 1070 User testuser2
1052 1071 Password
@@ -1089,6 +1108,7 @@ max_connections 0
1089 1108 max_user_connections 0
1090 1109 plugin
1091 1110 authentication_string NULL
  1111 +max_statement_time 0
1092 1112 Host localhost
1093 1113 User testuser3
1094 1114 Password
@@ -1131,6 +1151,7 @@ max_connections 0
1131 1151 max_user_connections 0
1132 1152 plugin
1133 1153 authentication_string NULL
  1154 +max_statement_time 0
1134 1155 # Switch to connection testuser1
1135 1156 SELECT * FROM information_schema.user_privileges
1136 1157 WHERE grantee LIKE '''testuser%'''
@@ -1230,6 +1251,7 @@ max_connections 0
1230 1251 max_user_connections 0
1231 1252 plugin
1232 1253 authentication_string NULL
  1254 +max_statement_time 0
1233 1255 Host localhost
1234 1256 User testuser2
1235 1257 Password
@@ -1272,6 +1294,7 @@ max_connections 0
1272 1294 max_user_connections 0
1273 1295 plugin
1274 1296 authentication_string NULL
  1297 +max_statement_time 0
1275 1298 Host localhost
1276 1299 User testuser3
1277 1300 Password
@@ -1314,6 +1337,7 @@ max_connections 0
1314 1337 max_user_connections 0
1315 1338 plugin
1316 1339 authentication_string NULL
  1340 +max_statement_time 0
1317 1341 # Switch to connection testuser1
1318 1342 SELECT * FROM information_schema.user_privileges
1319 1343 WHERE grantee LIKE '''testuser%'''
@@ -1366,6 +1390,7 @@ max_connections 0
1366 1390 max_user_connections 0
1367 1391 plugin
1368 1392 authentication_string NULL
  1393 +max_statement_time 0
1369 1394 Host localhost
1370 1395 User testuser2
1371 1396 Password
@@ -1408,6 +1433,7 @@ max_connections 0
1408 1433 max_user_connections 0
1409 1434 plugin
1410 1435 authentication_string NULL
  1436 +max_statement_time 0
1411 1437 Host localhost
1412 1438 User testuser3
1413 1439 Password
@@ -1450,6 +1476,7 @@ max_connections 0
1450 1476 max_user_connections 0
1451 1477 plugin
1452 1478 authentication_string NULL
  1479 +max_statement_time 0
1453 1480 SHOW GRANTS;
1454 1481 Grants for testuser1@localhost
1455 1482 GRANT USAGE ON *.* TO 'testuser1'@'localhost'
@@ -1509,6 +1536,7 @@ max_connections 0
1509 1536 max_user_connections 0
1510 1537 plugin
1511 1538 authentication_string NULL
  1539 +max_statement_time 0
1512 1540 Host localhost
1513 1541 User testuser2
1514 1542 Password
@@ -1551,6 +1579,7 @@ max_connections 0
1551 1579 max_user_connections 0
1552 1580 plugin
1553 1581 authentication_string NULL
  1582 +max_statement_time 0
1554 1583 Host localhost
1555 1584 User testuser3
1556 1585 Password
@@ -1593,6 +1622,7 @@ max_connections 0
1593 1622 max_user_connections 0
1594 1623 plugin
1595 1624 authentication_string NULL
  1625 +max_statement_time 0
1596 1626 SHOW GRANTS;
1597 1627 Grants for testuser1@localhost
1598 1628 GRANT USAGE ON *.* TO 'testuser1'@'localhost'
@@ -1667,6 +1697,7 @@ max_connections 0
1667 1697 max_user_connections 0
1668 1698 plugin
1669 1699 authentication_string NULL
  1700 +max_statement_time 0
1670 1701 Host localhost
1671 1702 User testuser2
1672 1703 Password
@@ -1709,6 +1740,7 @@ max_connections 0
1709 1740 max_user_connections 0
1710 1741 plugin
1711 1742 authentication_string NULL
  1743 +max_statement_time 0
1712 1744 Host localhost
1713 1745 User testuser3
1714 1746 Password
@@ -1751,6 +1783,7 @@ max_connections 0
1751 1783 max_user_connections 0
1752 1784 plugin
1753 1785 authentication_string NULL
  1786 +max_statement_time 0
1754 1787 # Switch to connection testuser1
1755 1788 SELECT * FROM information_schema.user_privileges
1756 1789 WHERE grantee LIKE '''testuser%'''
0  mysql-test/suite/randgen/r/max_statement_time.result
No changes.
16 mysql-test/suite/randgen/t/max_statement_time.test
... ... @@ -0,0 +1,16 @@
  1 +--source include/have_statement_timeout.inc
  2 +--source suite/randgen/include/setup_rqg.inc
  3 +
  4 +let RQG_LOG_FILE = $RQG_LOG_DIR/rqg_example.log;
  5 +
  6 +exec perl $RQG_HOME/gentest.pl
  7 + --dsn=dbi:mysql:host=127.0.0.1:port=$MASTER_MYPORT:user=root:database=test
  8 + --logconf=$MYSQLTEST_VARDIR/std_data/randgen/log.conf
  9 + --gendata=$RQG_HOME/conf/twitter/max_statement_time.zz
  10 + --grammar=$RQG_HOME/conf/twitter/max_statement_time.yy
  11 + --engine=$RQG_ENGINE
  12 + --queries=100K
  13 + --threads=25
  14 + --duration=600;
  15 +
  16 +--source suite/randgen/include/cleanup.inc
53 mysql-test/suite/sys_vars/r/have_statement_timeout_basic.result
... ... @@ -0,0 +1,53 @@
  1 +# Displaying default value
  2 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  3 +COUNT(@@GLOBAL.have_statement_timeout)
  4 +1
  5 +1 Expected
  6 +# Check if Value can set
  7 +SET @@GLOBAL.have_statement_timeout=1;
  8 +ERROR HY000: Variable 'have_statement_timeout' is a read only variable
  9 +Expected error 'Read only variable'
  10 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  11 +COUNT(@@GLOBAL.have_statement_timeout)
  12 +1
  13 +1 Expected
  14 +# Check if the value in GLOBAL Table matches value in variable
  15 +SELECT @@GLOBAL.have_statement_timeout = VARIABLE_VALUE
  16 +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
  17 +WHERE VARIABLE_NAME='have_statement_timeout';
  18 +@@GLOBAL.have_statement_timeout = VARIABLE_VALUE
  19 +1
  20 +1 Expected
  21 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  22 +COUNT(@@GLOBAL.have_statement_timeout)
  23 +1
  24 +1 Expected
  25 +SELECT COUNT(VARIABLE_VALUE)
  26 +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
  27 +WHERE VARIABLE_NAME='have_statement_timeout';
  28 +COUNT(VARIABLE_VALUE)
  29 +1
  30 +1 Expected
  31 +# Check if accessing variable with and without GLOBAL point to same variable
  32 +SELECT @@have_statement_timeout = @@GLOBAL.have_statement_timeout;
  33 +@@have_statement_timeout = @@GLOBAL.have_statement_timeout
  34 +1
  35 +1 Expected
  36 +# Check if have_statement_timeout can be accessed with and without @@ sign
  37 +SELECT COUNT(@@have_statement_timeout);
  38 +COUNT(@@have_statement_timeout)
  39 +1
  40 +1 Expected
  41 +SELECT COUNT(@@local.have_statement_timeout);
  42 +ERROR HY000: Variable 'have_statement_timeout' is a GLOBAL variable
  43 +Expected error 'Variable is a GLOBAL variable'
  44 +SELECT COUNT(@@SESSION.have_statement_timeout);
  45 +ERROR HY000: Variable 'have_statement_timeout' is a GLOBAL variable
  46 +Expected error 'Variable is a GLOBAL variable'
  47 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  48 +COUNT(@@GLOBAL.have_statement_timeout)
  49 +1
  50 +1 Expected
  51 +SELECT have_statement_timeout = @@SESSION.have_statement_timeout;
  52 +ERROR 42S22: Unknown column 'have_statement_timeout' in 'field list'
  53 +Expected error 'Readonly variable'
91 mysql-test/suite/sys_vars/r/max_statement_time_basic.result
... ... @@ -0,0 +1,91 @@
  1 +# Save initial value
  2 +SET @start_session_value = @@session.max_statement_time;
  3 +SELECT @start_session_value;
  4 +@start_session_value
  5 +0
  6 +# Display the DEFAULT value of max_statement_time
  7 +SET @@session.max_statement_time = 20000;
  8 +SET @@session.max_statement_time = DEFAULT;
  9 +SELECT @@session.max_statement_time;
  10 +@@session.max_statement_time
  11 +0
  12 +# Check the DEFAULT value of max_statement_time
  13 +SET @@session.max_statement_time = DEFAULT;
  14 +SELECT @@session.max_statement_time = 28800;
  15 +@@session.max_statement_time = 28800
  16 +0
  17 +# Change the value of max_statement_time to a valid value for SESSION scope
  18 +SET @@session.max_statement_time = 10000;
  19 +SELECT @@session.max_statement_time;
  20 +@@session.max_statement_time
  21 +10000
  22 +SET @@session.max_statement_time = 50050;
  23 +SELECT @@session.max_statement_time;
  24 +@@session.max_statement_time
  25 +50050
  26 +SET @@session.max_statement_time = 65535;
  27 +SELECT @@session.max_statement_time;
  28 +@@session.max_statement_time
  29 +65535
  30 +# Change the value of max_statement_time to an invalid value #
  31 +SET @@session.max_statement_time = 0;
  32 +SELECT @@session.max_statement_time;
  33 +@@session.max_statement_time
  34 +0
  35 +SET @@session.max_statement_time = -2;
  36 +Warnings:
  37 +Warning 1292 Truncated incorrect max_statement_time value: '-2'
  38 +SELECT @@session.max_statement_time;
  39 +@@session.max_statement_time
  40 +0
  41 +SET @@session.max_statement_time = 65530.34;
  42 +ERROR 42000: Incorrect argument type to variable 'max_statement_time'
  43 +SET @@session.max_statement_time = 100000000;
  44 +SELECT @@session.max_statement_time;
  45 +@@session.max_statement_time
  46 +100000000
  47 +SET @@session.max_statement_time = test;
  48 +ERROR 42000: Incorrect argument type to variable 'max_statement_time'
  49 +SELECT @@session.max_statement_time;
  50 +@@session.max_statement_time
  51 +100000000
  52 +# Check if the value in SESSION Table matches value in variable
  53 +SELECT @@session.max_statement_time = VARIABLE_VALUE
  54 +FROM INFORMATION_SCHEMA.SESSION_VARIABLES
  55 +WHERE VARIABLE_NAME='max_statement_time';
  56 +@@session.max_statement_time = VARIABLE_VALUE
  57 +1
  58 +# Check if TRUE and FALSE values can be used on variable
  59 +SET @@session.max_statement_time = TRUE;
  60 +SELECT @@session.max_statement_time;
  61 +@@session.max_statement_time
  62 +1
  63 +SET @@session.max_statement_time = FALSE;
  64 +SELECT @@session.max_statement_time;
  65 +@@session.max_statement_time
  66 +0
  67 +# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable
  68 +SET @@max_statement_time = 10000;
  69 +SELECT @@max_statement_time = @@local.max_statement_time;
  70 +@@max_statement_time = @@local.max_statement_time
  71 +1
  72 +SELECT @@local.max_statement_time = @@session.max_statement_time;
  73 +@@local.max_statement_time = @@session.max_statement_time
  74 +1
  75 +# Check if max_statement_time can be accessed with and without @@ sign
  76 +SET max_statement_time = 10000;
  77 +SELECT @@max_statement_time;
  78 +@@max_statement_time
  79 +10000
  80 +SELECT local.max_statement_time;
  81 +ERROR 42S02: Unknown table 'local' in field list
  82 +SELECT session.max_statement_time;
  83 +ERROR 42S02: Unknown table 'session' in field list
  84 +# Check that the variable is a SESSION-only variable
  85 +SET @@global.max_statement_time = 0;
  86 +ERROR HY000: Variable 'max_statement_time' is a SESSION variable and can't be used with SET GLOBAL
  87 +# Restore initial value
  88 +SET @@session.max_statement_time = @start_session_value;
  89 +SELECT @@session.max_statement_time;
  90 +@@session.max_statement_time
  91 +0
66 mysql-test/suite/sys_vars/r/max_statement_time_func.result
... ... @@ -0,0 +1,66 @@
  1 +#
  2 +# Test max statement time interruption precision.
  3 +# Note that if SLEEP() is interrupted, it returns 1.
  4 +#
  5 +SET @@SESSION.max_statement_time = 100;
  6 +SELECT SLEEP(1);
  7 +SLEEP(1)
  8 +1
  9 +SET @@SESSION.max_statement_time = 250;
  10 +SELECT SLEEP(1);
  11 +SLEEP(1)
  12 +1
  13 +SET @@SESSION.max_statement_time = 500;
  14 +SELECT SLEEP(1);
  15 +SLEEP(1)
  16 +1
  17 +SET @@SESSION.max_statement_time = 750;
  18 +SELECT SLEEP(1);
  19 +SLEEP(1)
  20 +1
  21 +SET @@SESSION.max_statement_time = 1250;
  22 +SELECT SLEEP(1);
  23 +SLEEP(1)
  24 +0
  25 +SET @@SESSION.max_statement_time = 1500;
  26 +SELECT SLEEP(1);
  27 +SLEEP(1)
  28 +0
  29 +SET @@SESSION.max_statement_time = 0;
  30 +#
  31 +# Timeout only applies to the top-level statement.
  32 +#
  33 +CREATE PROCEDURE p1()
  34 +BEGIN
  35 +SELECT SLEEP(0.5); -- 0.5
  36 +SELECT SLEEP(0.5); -- 1.0
  37 +SELECT SLEEP(1.5); -- 1.5
  38 +END|
  39 +SET @@SESSION.max_statement_time = 750;
  40 +CALL p1();
  41 +SLEEP(0.5)
  42 +0
  43 +SLEEP(0.5)
  44 +1
  45 +SLEEP(1.5)
  46 +0
  47 +SET @@SESSION.max_statement_time = 0;
  48 +DROP PROCEDURE p1;
  49 +#
  50 +# Interrupt a statement that changes data.
  51 +#
  52 +CREATE TABLE t1 (a INT);
  53 +CREATE FUNCTION f1() RETURNS INT
  54 +BEGIN
  55 +WHILE true DO
  56 +INSERT INTO t1 VALUES (1);
  57 +END WHILE;
  58 +RETURN 1;
  59 +END|
  60 +SET @@SESSION.max_statement_time = 500;
  61 +SELECT f1();
  62 +ERROR 70100: Query execution was interrupted, max_statement_time exceeded
  63 +SET @@SESSION.max_statement_time = 0;
  64 +DROP FUNCTION f1;
  65 +DROP TABLE t1;
  66 +SET @@SESSION.max_statement_time = default;
55 mysql-test/suite/sys_vars/t/have_statement_timeout_basic.test
... ... @@ -0,0 +1,55 @@
  1 +--source include/have_statement_timeout.inc
  2 +
  3 +--echo # Displaying default value
  4 +
  5 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  6 +--echo 1 Expected
  7 +
  8 +--echo # Check if Value can set
  9 +
  10 +--error ER_INCORRECT_GLOBAL_LOCAL_VAR
  11 +SET @@GLOBAL.have_statement_timeout=1;
  12 +--echo Expected error 'Read only variable'
  13 +
  14 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  15 +--echo 1 Expected
  16 +
  17 +--echo # Check if the value in GLOBAL Table matches value in variable
  18 +
  19 +SELECT @@GLOBAL.have_statement_timeout = VARIABLE_VALUE
  20 +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
  21 +WHERE VARIABLE_NAME='have_statement_timeout';
  22 +--echo 1 Expected
  23 +
  24 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  25 +--echo 1 Expected
  26 +
  27 +SELECT COUNT(VARIABLE_VALUE)
  28 +FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
  29 +WHERE VARIABLE_NAME='have_statement_timeout';
  30 +--echo 1 Expected
  31 +
  32 +--echo # Check if accessing variable with and without GLOBAL point to same variable
  33 +
  34 +SELECT @@have_statement_timeout = @@GLOBAL.have_statement_timeout;
  35 +--echo 1 Expected
  36 +
  37 +--echo # Check if have_statement_timeout can be accessed with and without @@ sign
  38 +
  39 +SELECT COUNT(@@have_statement_timeout);
  40 +--echo 1 Expected
  41 +
  42 +--error ER_INCORRECT_GLOBAL_LOCAL_VAR
  43 +SELECT COUNT(@@local.have_statement_timeout);
  44 +--echo Expected error 'Variable is a GLOBAL variable'
  45 +
  46 +--error ER_INCORRECT_GLOBAL_LOCAL_VAR
  47 +SELECT COUNT(@@SESSION.have_statement_timeout);
  48 +--echo Expected error 'Variable is a GLOBAL variable'
  49 +
  50 +SELECT COUNT(@@GLOBAL.have_statement_timeout);
  51 +--echo 1 Expected
  52 +
  53 +--error ER_BAD_FIELD_ERROR
  54 +SELECT have_statement_timeout = @@SESSION.have_statement_timeout;
  55 +--echo Expected error 'Readonly variable'
78 mysql-test/suite/sys_vars/t/max_statement_time_basic.test
... ... @@ -0,0 +1,78 @@
  1 +--source include/have_statement_timeout.inc
  2 +
  3 +--echo # Save initial value
  4 +
  5 +SET @start_session_value = @@session.max_statement_time;
  6 +SELECT @start_session_value;
  7 +
  8 +--echo # Display the DEFAULT value of max_statement_time
  9 +
  10 +SET @@session.max_statement_time = 20000;
  11 +SET @@session.max_statement_time = DEFAULT;
  12 +SELECT @@session.max_statement_time;
  13 +
  14 +--echo # Check the DEFAULT value of max_statement_time
  15 +
  16 +SET @@session.max_statement_time = DEFAULT;
  17 +SELECT @@session.max_statement_time = 28800;
  18 +
  19 +--echo # Change the value of max_statement_time to a valid value for SESSION scope
  20 +
  21 +SET @@session.max_statement_time = 10000;
  22 +SELECT @@session.max_statement_time;
  23 +SET @@session.max_statement_time = 50050;
  24 +SELECT @@session.max_statement_time;
  25 +SET @@session.max_statement_time = 65535;
  26 +SELECT @@session.max_statement_time;
  27 +
  28 +--echo # Change the value of max_statement_time to an invalid value #
  29 +
  30 +SET @@session.max_statement_time = 0;
  31 +SELECT @@session.max_statement_time;
  32 +SET @@session.max_statement_time = -2;
  33 +SELECT @@session.max_statement_time;
  34 +--error ER_WRONG_TYPE_FOR_VAR
  35 +SET @@session.max_statement_time = 65530.34;
  36 +SET @@session.max_statement_time = 100000000;
  37 +SELECT @@session.max_statement_time;
  38 +
  39 +--error ER_WRONG_TYPE_FOR_VAR
  40 +SET @@session.max_statement_time = test;
  41 +SELECT @@session.max_statement_time;
  42 +
  43 +--echo # Check if the value in SESSION Table matches value in variable
  44 +
  45 +SELECT @@session.max_statement_time = VARIABLE_VALUE
  46 +FROM INFORMATION_SCHEMA.SESSION_VARIABLES
  47 +WHERE VARIABLE_NAME='max_statement_time';
  48 +
  49 +--echo # Check if TRUE and FALSE values can be used on variable
  50 +
  51 +SET @@session.max_statement_time = TRUE;
  52 +SELECT @@session.max_statement_time;
  53 +SET @@session.max_statement_time = FALSE;
  54 +SELECT @@session.max_statement_time;
  55 +
  56 +--echo # Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable
  57 +
  58 +SET @@max_statement_time = 10000;
  59 +SELECT @@max_statement_time = @@local.max_statement_time;
  60 +SELECT @@local.max_statement_time = @@session.max_statement_time;
  61 +
  62 +--echo # Check if max_statement_time can be accessed with and without @@ sign
  63 +
  64 +SET max_statement_time = 10000;
  65 +SELECT @@max_statement_time;
  66 +--error ER_UNKNOWN_TABLE
  67 +SELECT local.max_statement_time;
  68 +--error ER_UNKNOWN_TABLE
  69 +SELECT session.max_statement_time;
  70 +
  71 +--echo # Check that the variable is a SESSION-only variable
  72