| 1 |
############################################################################### |
| 2 |
# # |
| 3 |
# Variable Name: wait_timeout # |
| 4 |
# Scope: GLOBAL | SESSION # |
| 5 |
# Access Type: Dynamic # |
| 6 |
# Data Type: numeric # |
| 7 |
# Default Value: # |
| 8 |
# Range: # |
| 9 |
# # |
| 10 |
# # |
| 11 |
# Creation Date: 2008-03-07 # |
| 12 |
# Author: Salman Rawala # |
| 13 |
# # |
| 14 |
# Modified: HHunger 2008-08-27 Simplified the test and replaced the sleeps. # |
| 15 |
# # |
| 16 |
# Description: Test Cases of Dynamic System Variable wait_timeout # |
| 17 |
# that checks the functionality of this variable # |
| 18 |
# # |
| 19 |
# Reference: # |
| 20 |
# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html # |
| 21 |
# # |
| 22 |
############################################################################### |
| 23 |
|
| 24 |
--source include/not_threadpool.inc |
| 25 |
|
| 26 |
SET @start_value= @@global.wait_timeout; |
| 27 |
|
| 28 |
|
| 29 |
--echo '#--------------------FN_DYNVARS_186_01-------------------------#' |
| 30 |
####################################################################### |
| 31 |
# 1. test of scope session |
| 32 |
####################################################################### |
| 33 |
|
| 34 |
SET @start_time= UNIX_TIMESTAMP(); |
| 35 |
--echo connect (test_con1, localhost, root,,); |
| 36 |
connect (test_con1, localhost, root,,); |
| 37 |
connection test_con1; |
| 38 |
|
| 39 |
# If not explicitly changed, @@session.wait_timeout equals @@global.wait_timeout. |
| 40 |
SELECT @@session.wait_timeout = @@global.wait_timeout AS 'Expect 1'; |
| 41 |
|
| 42 |
# Find a small value <> @@global.wait_timeout. |
| 43 |
let $session_value = |
| 44 |
`SELECT IF(@@global.wait_timeout <> 2 OR @@global.wait_timeout IS NULL, 2, 3)`; |
| 45 |
--replace_result $session_value <session_value> |
| 46 |
eval SET @@session.wait_timeout = $session_value; |
| 47 |
|
| 48 |
--echo connect (test_con2, localhost, root,,); |
| 49 |
connect (test_con2, localhost, root,,); |
| 50 |
connection test_con2; |
| 51 |
|
| 52 |
--replace_result $session_value <session_value> |
| 53 |
eval SET @@session.wait_timeout = $session_value - 1; |
| 54 |
|
| 55 |
--echo connection default; |
| 56 |
connection default; |
| 57 |
|
| 58 |
--echo wait until connections ready |
| 59 |
let $wait_condition= SELECT COUNT(*) = 2 FROM information_schema.processlist; |
| 60 |
--source include/wait_condition.inc |
| 61 |
SELECT info FROM information_schema.processlist ORDER BY info; |
| 62 |
|
| 63 |
--echo '#--------------------FN_DYNVARS_186_03-------------------------#' |
| 64 |
####################################################################### |
| 65 |
# 2. test of scope global |
| 66 |
####################################################################### |
| 67 |
|
| 68 |
# Find a small value <> @@global.wait_timeout. |
| 69 |
let $global_value = $session_value + 1; |
| 70 |
--replace_result $global_value <global_value> |
| 71 |
eval SET @@global.wait_timeout= $global_value; |
| 72 |
|
| 73 |
# Changing the @@global.wait_timeout has no influence on the |
| 74 |
# @@session.wait_timeout of already established sessions. |
| 75 |
SELECT @@session.wait_timeout = @start_value AS 'Expect 1'; |
| 76 |
|
| 77 |
--echo connect (test_con3, localhost, root,,); |
| 78 |
connect (test_con3, localhost, root,,); |
| 79 |
connection test_con3; |
| 80 |
|
| 81 |
# If not explicitly changed, @@session.wait_timeout equals @@global.wait_timeout. |
| 82 |
SELECT @@session.wait_timeout = @@global.wait_timeout AS 'Expect 1'; |
| 83 |
|
| 84 |
--echo connection default; |
| 85 |
connection default; |
| 86 |
# We can be sure that the connections test_con1 and test_con2 must be |
| 87 |
# established because both have already executed a SET @@session.wait_timeout. |
| 88 |
# This means they are or at least were visible within the processlist. |
| 89 |
# Therefore we can now simply wait till both disappear from the processlist. |
| 90 |
let $wait_condition= SELECT COUNT(*) = 2 FROM information_schema.processlist; |
| 91 |
--source include/wait_condition.inc |
| 92 |
SELECT info FROM information_schema.processlist ORDER BY info; |
| 93 |
|
| 94 |
--replace_result $global_value <global_value> $session_value <session_value>; |
| 95 |
eval SELECT UNIX_TIMESTAMP() - @start_time >= $global_value + $session_value; |
| 96 |
SET @@global.wait_timeout= @start_value; |
| 97 |
|