summaryrefslogtreecommitdiff
path: root/mysql-test/include/wait_for_status_var.inc.moved
blob: 4c168da7f1a780da596f931afc055d23b4591118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# ==== Purpose ====
#
# Waits until a variable from SHOW STATUS has returned a specified 
# value, or until a timeout is reached.
#
# ==== Usage ====
#
# let $status_var= Threads_connected;
# let $status_var_value= 1;
# --source include/wait_for_status_var.inc
#
# Parameters:
#
# $status_var, $status_var_value
#   This macro will wait until the variable of SHOW STATUS 
#   named $status_var gets the value $status_var_value.  See
#   the example above.
# 
# $status_type= GLOBAL|SESSION
#   To specify the type (attribute) of status variable and
#   run either SHOW GLOBAL STATUS or SHOW SESSION STATUS.
# 
# $status_var_comparsion
#   By default, this file waits until $status_var becomes equal to
#   $status_var_value.  If you want to wait until $status_var
#   becomes *unequal* to $status_var_value, set this parameter to the
#   string '!=', like this:
#     let $status_var_comparsion= !=;
#
# $status_timeout
#   The default timeout is 1 minute. You can change the timeout by
#   setting $status_timeout. The unit is tenths of seconds.
#

if (`SELECT STRCMP('$status_type', '') * STRCMP(UPPER('$status_type'), 'SESSION') * STRCMP(UPPER('$status_type'), 'GLOBAL')`)
{
  --echo **** ERROR: Unknown type of variable status_type: allowed values are: SESSION or GLOBAL ****
  exit;
}

let $_status_timeout_counter= $status_timeout;
if (!$_status_timeout_counter)
{
  let $_status_timeout_counter= 600;
}

let $_status_var_comparsion= $status_var_comparsion;
if (`SELECT '$_status_var_comparsion' = ''`)
{
  let $_status_var_comparsion= =;
}

let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
while (`SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_value')`)
{
  if (!$_status_timeout_counter)
  {
    --echo **** ERROR: failed while waiting for $status_type $status_var $_status_var_comparison $status_var_value ****
    --echo Note: the following output may have changed since the failure was detected
    --echo **** Showing STATUS, PROCESSLIST ****
    eval SHOW $status_type STATUS LIKE '$status_var';
    SHOW PROCESSLIST;
    exit;
  }
  dec $_status_timeout_counter;
  sleep 0.1;
  let $_show_status_value= query_get_value("SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
}