1# ==== Purpose ====
2#
3# Wait for slave SQL error, skip the erroneous statement and restart
4# slave
5#
6# ==== Usage ====
7#
8# --let $slave_sql_error= NUMBER
9# [--let $show_sql_error= 1]
10# [--let $slave_skip_counter= 1]
11# [--let $not_switch_connection= 1]
12# [--let $rpl_debug= 1]
13# [--let $slave_timeout= NUMBER]
14# --source include/wait_for_slave_sql_error_and_skip.inc
15#
16# Parameters:
17#
18#   $slave_sql_errno
19#     The error number to wait for. This is required. (See
20#     wait_for_slave_sql_error.inc)
21#
22#   $show_sql_error
23#     If set, will print the error to the query log.
24#
25#   $slave_skip_counter
26#     If set, skip this number of events. If not set, skip one event.
27#
28#   $not_switch_connection
29#     By default, this script executes on the connection 'slave'.  If
30#     $not_switch_connection is set, this script executes on the current
31#     connection.  In any case, the original connection is restored.
32#
33#   $slave_timeout
34#     See include/wait_for_slave_param.inc
35#
36#   $rpl_debug
37#     See include/rpl_init.inc
38
39
40--let $include_filename= wait_for_slave_sql_error_and_skip.inc [errno=$slave_sql_errno]
41--source include/begin_include_file.inc
42
43
44if (!$rpl_debug)
45{
46  --disable_query_log
47}
48
49
50if (!$not_switch_connection)
51{
52  --let $rpl_connection_name= slave
53  --source include/rpl_connection.inc
54}
55
56
57source include/wait_for_slave_sql_error.inc;
58
59
60# skip the erroneous statement
61if ($slave_skip_counter) {
62  eval SET GLOBAL SQL_SLAVE_SKIP_COUNTER= $slave_skip_counter;
63}
64if (!$slave_skip_counter) {
65  SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
66}
67source include/start_slave.inc;
68
69# start_slave.inc returns when Slave_SQL_Running=Yes. But the slave
70# thread sets it before clearing Last_SQL_Errno. So we have to wait
71# for Last_SQL_Errno=0 separately.
72
73let $slave_param= Last_SQL_Errno;
74let $slave_param_value= 0;
75source include/wait_for_slave_param.inc;
76
77--let $include_filename= wait_for_slave_sql_error_and_skip.inc [errno=$slave_sql_errno]
78--source include/end_include_file.inc
79