MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wait_for_slave_sql_error.inc
1 # ==== Purpose ====
2 #
3 # Waits until the SQL thread of the current connection has got an
4 # error, or until a timeout is reached. Also waits until the SQL
5 # thread has completely stopped.
6 #
7 # ==== Usage ====
8 #
9 # --let $slave_sql_errno= NUMBER
10 # [--let $show_slave_sql_error= 1]
11 # [--let $rpl_debug= 1]
12 # [--let $slave_timeout= NUMBER]
13 # --source include/wait_for_slave_sql_error.inc
14 #
15 # Parameters:
16 # $slave_sql_errno
17 # The expected SQL error number. This is required.
18 # (After BUG#41956 has been fixed, this will be required to be a
19 # symbolic name instead of a number.)
20 #
21 # $show_slave_sql_error
22 # If set, will print the error to the query log.
23 #
24 # $slave_timeout
25 # See include/wait_for_slave_param.inc
26 #
27 # $rpl_debug
28 # See include/rpl_init.inc
29 
30 
31 --let $include_filename= wait_for_slave_sql_error.inc [errno=$slave_sql_errno]
32 --source include/begin_include_file.inc
33 
34 
35 # Note: here, we should not wait for Slave_SQL_Errno!=0.
36 # Slave_SQL_Errno and Slave_SQL_Running are not set atomically.
37 # Slave_SQL_Errno is set first, then Slave_SQL_Running. So we wait
38 # until Slave_SQL_Running=No to be sure that both conditions hold.
39 let $slave_param= Slave_SQL_Running;
40 let $slave_param_value= No;
41 source include/wait_for_slave_param.inc;
42 
43 let $_wfsse_errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
44 
45 if ($slave_sql_errno == '') {
46  --echo !!!ERROR IN TEST: you must set \$slave_sql_errno before you source
47  --echo !!!wait_for_slave_sql_error.inc. The error we got this time was '$_wfsse_errno',
48  --echo !!!so you probably want to add the following line to your test case:
49  --echo !!! --let \$slave_sql_errno= $_wfsse_errno
50  --die !!!ERROR IN TEST: you must set \$slave_sql_errno before sourcing wait_for_slave_sql_error.inc
51 }
52 
53 if (`SELECT $_wfsse_errno NOT IN ($slave_sql_errno)`) {
54  --echo **** Slave stopped with wrong error code: $_wfsse_errno (expected $slave_sql_errno) ****
55  source include/show_rpl_debug_info.inc;
56  --echo **** Slave stopped with wrong error code: $_wfsse_errno (expected $slave_sql_errno) ****
57  --die Slave stopped with wrong error code
58 }
59 
60 if ($show_slave_sql_error)
61 {
62  --let $_wait_for_slave_sql_error_error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1)
63  # remove timestamp and mask absolute path
64  --let $_wait_for_slave_sql_error_error= `SELECT REPLACE("$_wait_for_slave_sql_error_error", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
65  --echo Last_SQL_Error = '$_wait_for_slave_sql_error_error'
66 }
67 
68 
69 --let $include_filename= wait_for_slave_sql_error.inc [errno=$slave_sql_errno]
70 --source include/end_include_file.inc