3 # Waits until a variable from SHOW STATUS has returned a specified
4 # value, or until a timeout is reached.
8 # let $status_var= Threads_connected;
9 # let $status_var_value= 1;
10 # --source include/wait_for_status_var.inc
14 # $status_var, $status_var_value
15 # This macro will wait until the variable of SHOW STATUS
16 # named $status_var gets the value $status_var_value. See
19 # $status_type= GLOBAL|SESSION
20 # To specify the type (attribute) of status variable and
21 # run either SHOW GLOBAL STATUS or SHOW SESSION STATUS.
23 # $status_var_comparsion
24 # By default, this file waits until $status_var becomes equal to
25 # $status_var_value. If you want to wait until $status_var
26 # becomes *unequal* to $status_var_value, set this parameter to the
27 # string '!=', like this:
28 # let $status_var_comparsion= !=;
31 # The default timeout is 1 minute. You can change the timeout by
32 # setting $status_timeout. The unit is tenths of seconds.
35 if (`SELECT STRCMP(
'$status_type',
'') * STRCMP(UPPER(
'$status_type'),
'SESSION') * STRCMP(UPPER(
'$status_type'),
'GLOBAL')`)
37 --echo **** ERROR: Unknown
type of variable status_type: allowed values are: SESSION or GLOBAL ****
41 let $_status_timeout_counter= $status_timeout;
42 if (!$_status_timeout_counter)
44 let $_status_timeout_counter= 600;
47 let $_status_var_comparsion= $status_var_comparsion;
48 if (!$_status_var_comparsion)
50 let $_status_var_comparsion= =;
53 # Get type of variable
55 if (`SELECT
'$status_var_value' REGEXP
'^[\+\-]*[0-9]+(\.[0-9]+)*\$'`)
60 let $_show_status_value= query_get_value(
"SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
62 # Set way of comparing
63 let $_query= SELECT NOT(
'$_show_status_value' $_status_var_comparsion
'$status_var_value');
66 let $_query= SELECT NOT($_show_status_value $_status_var_comparsion $status_var_value);
71 if (!$_status_timeout_counter)
73 --echo **** ERROR: failed
while waiting
for $status_type $status_var $_status_var_comparsion $status_var_value ****
74 --echo Note: the following output may have changed since the failure was detected
75 --echo **** Showing
STATUS, PROCESSLIST ****
76 eval SHOW $status_type STATUS LIKE
'$status_var';
80 dec $_status_timeout_counter;
82 let $_show_status_value= query_get_value(
"SHOW $status_type STATUS LIKE '$status_var'", Value, 1);
83 let $_query= SELECT NOT(
'$_show_status_value' $_status_var_comparsion
'$status_var_value');
86 let $_query= SELECT NOT($_show_status_value $_status_var_comparsion $status_var_value);