1# ==== Purpose ====
2#
3# The same as 'connection $rpl_connection_name', but it can also
4# prints the connection name.  The connection is printed if $rpl_debug
5# is set, or if rpl_connection.inc is not called between two
6# invocations of begin_include_file.inc/end_include_file.inc.
7# Otherwise the connection name is not printed.
8#
9#
10# ==== Usage ====
11#
12# --let $rpl_connection_name= master
13# [--let $rpl_debug= 1]
14# --source include/rpl_connection.inc
15#
16# Parameters:
17#   $rpl_connection_name
18#     Name of the connection to connect to.
19#
20#   $rpl_debug
21#     By default, the connection name is printed only when this file
22#     is sourced from a top-level test script. If $rpl_debug is set,
23#     the connection name is also printed whenever auxiliary files
24#     like rpl_init.inc change connection.
25
26
27if (!$rpl_connection_name)
28{
29  --die ERROR IN TEST: you must set $rpl_connection_name before sourcing rpl_connection.inc
30}
31
32# This is the same as "if (!$_rpl_include_file_depth || $rpl_debug)",
33# but the mysqltest language doesn't have boolean operations.
34
35if (!$_include_file_depth)
36{
37  --echo [connection $rpl_connection_name]
38}
39if ($_include_file_depth)
40{
41  if ($rpl_debug)
42  {
43    --echo [connection $rpl_connection_name]
44  }
45}
46disable_connect_log;
47--connection $rpl_connection_name
48enable_connect_log;
49--let $rpl_connection_name=
50