3 # Relocates the relay logs and index file from
4 # a directory into another. The logs relocated
5 # are the one listed in the index file.
9 # [--let $relocate_disable_query_log= 1]
10 # [--let $rpl_debug= 1]
11 # [--let $relocate_is_windows= 0]
12 # [--let $relocate_recreate_index= 0]
13 # [--let $relocate_fix_relay_log_info= 0]
14 # --let $relocate_from= DIR
15 # --let $relocate_to= DIR
16 # --let $relocate_index_file= FNAME
17 # --source include/relocate_binlogs.inc
19 if ($relocate_disable_query_log)
24 --let $_path_separator=/
25 if ($relocate_is_windows)
27 --let $_path_separator=\
30 if ($relocate_index_file)
33 CREATE TEMPORARY
TABLE tmp(
id INT AUTO_INCREMENT PRIMARY
KEY, filename VARCHAR(1024));
36 --let $_index_file= $relocate_index_file
37 --let $_index_file_basename= `SELECT RIGHT(RTRIM(
"$_index_file"), LOCATE(
"$_path_separator",REVERSE(RTRIM(
"$_index_file"))) -1)`
38 --let $_from= $relocate_from
39 --let $_to= $relocate_into
41 # chmod to allow the following LOAD DATA
42 --chmod 0666 $_index_file
44 --eval LOAD DATA INFILE
'$_index_file' INTO
TABLE tmp (filename)
45 --let $count= `SELECT count(*) FROM tmp`
49 --let $_filename= `select filename from tmp where
id=$count`
51 --let $_filename= `SELECT RIGHT(RTRIM(
"$_filename"), LOCATE(
"$_path_separator",REVERSE(RTRIM(
"$_filename"))) -1)`
52 --move_file $_from/$_filename $_to/$_filename
54 if ($relocate_recreate_index)
57 if ($relocate_is_windows)
59 --let $_write_var=$_to\$_filename\n
61 if (!$relocate_is_windows)
63 --let $_write_var=$_to/$_filename\n
67 --let $write_var=$_write_var
70 if (!`SELECT STRCMP(
'$write_var',
'$_write_var') = 0`)
72 --let $write_var=$_write_var$write_var
79 if (!$relocate_recreate_index)
81 --move_file $_index_file $_to/$_index_file_basename
84 if ($relocate_recreate_index)
86 --let $write_to_file= $_to/$_index_file_basename
87 --source include/write_var_to_file.inc
88 --remove_file $_index_file
91 DROP TEMPORARY
TABLE tmp;
93 if ($relocate_fix_relay_log_info)
95 CREATE TEMPORARY
TABLE tmp(
id INT AUTO_INCREMENT PRIMARY KEY,
entry VARCHAR(1024));
98 # chmod to allow the following LOAD DATA
99 --chmod 0666 $relocate_fix_relay_log_info
101 --eval LOAD DATA INFILE
'$relocate_fix_relay_log_info' INTO
TABLE tmp (
entry)
102 --let $count= `SELECT count(*) FROM tmp`
104 --let $_curr_entry= `SELECT
entry FROM tmp WHERE
id=2`
105 --let $_curr_entry_basename= `SELECT RIGHT(RTRIM("$_curr_entry"), LOCATE("$_path_separator",REVERSE(RTRIM("$_curr_entry"))) -1)`
107 if ($relocate_is_windows)
109 --eval UPDATE tmp SET
entry=
'$_to\$_curr_entry_basename' WHERE
id=2
111 if (!$relocate_is_windows)
113 --eval UPDATE tmp SET
entry=
'$_to/$_curr_entry_basename' WHERE
id=2
116 --remove_file $relocate_fix_relay_log_info
120 --let $_write_var= `SELECT
entry FROM tmp WHERE
id= $count`
121 --let $write_var=$_write_var\n$write_var
125 --let $write_to_file= $relocate_fix_relay_log_info
126 --source include/write_var_to_file.inc
128 DROP TEMPORARY
TABLE tmp;
134 if ($relocate_disable_query_log)