| 1 |
## Script wait_for_status_variables.inc |
| 2 |
# |
| 3 |
# $wait_for_status_variable - |
| 4 |
# Name of status variables on which application should |
| 5 |
# wait. Multiple variables are separated by comma. |
| 6 |
# |
| 7 |
# $wait_for_status_value - |
| 8 |
# Value of status variable. Application must wait |
| 9 |
# until the status variable gets this value. |
| 10 |
# |
| 11 |
# $wait_quiet - |
| 12 |
# If this variable is set to "1", then its going to |
| 13 |
# disable the output of this script. |
| 14 |
# |
| 15 |
## Usage |
| 16 |
# |
| 17 |
# --let $wait_quiet = 0[,1] |
| 18 |
# --let $wait_for_status_value = UNSIGNED INT[,NEXT[,NEXT...]] |
| 19 |
# --let $wait_for_status_variable = 'STATUS VARIABLE NAME'[,NEXT[,NEXT...]] |
| 20 |
# --source ../include/wait_for_status_variables.inc |
| 21 |
# |
| 22 |
|
| 23 |
if($wait_quiet=="") |
| 24 |
{ |
| 25 |
let $wait_quiet=0; |
| 26 |
} |
| 27 |
|
| 28 |
if (!$wait_for_status_variable) |
| 29 |
{ |
| 30 |
die wait_for_status_variables.inc requires 'wait_for_status_variable' variable to be set; |
| 31 |
} |
| 32 |
|
| 33 |
if (`SELECT LENGTH("$wait_for_status_value") = 0`) |
| 34 |
{ |
| 35 |
if ($wait_for_status_value != "0") |
| 36 |
{ |
| 37 |
die wait_for_status_variables.inc requires 'wait_for_status_value' variable to be set; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
let $status=$wait_for_status_variable; |
| 42 |
let $value=$wait_for_status_value; |
| 43 |
|
| 44 |
while($status) |
| 45 |
{ |
| 46 |
# |
| 47 |
# split status variable names using "," as delimiter |
| 48 |
# |
| 49 |
let $status_element=`SELECT TRIM(REPLACE(SUBSTRING_INDEX("$status", ",", 1),"\n",""))`; |
| 50 |
let $status=`SELECT TRIM(SUBSTRING("$status", LENGTH("$status_element") + 2))`; |
| 51 |
|
| 52 |
# |
| 53 |
# split status variable values using "," as delimiter |
| 54 |
# |
| 55 |
let $value_element=`SELECT TRIM(REPLACE(SUBSTRING_INDEX("$value", ",", 1),"\n",""))`; |
| 56 |
let $value=`SELECT TRIM(SUBSTRING("$value", LENGTH("$value_element") + 2))`; |
| 57 |
if ($wait_quiet!=1) |
| 58 |
{ |
| 59 |
echo # Syncing with status [ $status_element == $value_element ]; |
| 60 |
} |
| 61 |
|
| 62 |
let $wait_condition= |
| 63 |
SELECT VARIABLE_VALUE = $value_element |
| 64 |
FROM performance_schema.global_status |
| 65 |
WHERE VARIABLE_NAME = $status_element; |
| 66 |
--source include/wait_condition_or_abort.inc |
| 67 |
} |
| 68 |
|
| 69 |
--let $wait_for_status_variable= |
| 70 |
--let $wait_for_status_value= |
| 71 |
--let $wait_quiet= |