File: rpl_get_end_of_relay_log.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (80 lines) | stat: -rw-r--r-- 2,604 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# ==== Purpose ====
#
# Get the file name and file size of the last relay log.
#
# ==== Usage ====
#
# [--let $rpl_channel_name= 'NAME']
# --source include/rpl_get_end_of_relay_log.inc
# --echo Last relay log: $relay_log_file
# --echo Size of last relay log: $relay_log_size

--let $include_filename= include/rpl_get_end_of_relay_log.inc
if ($rpl_channel_name)
{
  --let $include_filename= $include_filename [FOR CHANNEL $rpl_channel_name]
}
--source include/begin_include_file.inc

--let _RGEORL_CHANNEL_NAME= $rpl_channel_name
--let _RGEORL_OUTPUT_FILE= `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/_end_of_relay_log-', UUID(), '.txt')`
--let _RGEORL_INDEX_FILE= `SELECT @@GLOBAL.RELAY_LOG_INDEX`
--let _RGEORL_DATADIR= `SELECT @@GLOBAL.DATADIR`
if ($rpl_debug)
{
  --echo _RGEORL_OUTPUT_FILE='$_RGEORL_OUTPUT_FILE'
  --echo _RGEORL_INDEX_FILE='$_RGEORL_INDEX_FILE'
  --echo _RGEORL_DATADIR='$_RGEORL_DATADIR'
}

perl;
  # Compute relay log filename.
  my $index_file= $ENV{'_RGEORL_INDEX_FILE'};
  my $channel_name= $ENV{'_RGEORL_CHANNEL_NAME'};
  # Remove the single quotes from $channel_name
  $channel_name=~ s/\'//g;
  if ($channel_name) {
    $index_file =~ s/(.*)(\.index)/$1-$channel_name$2/;
  }

  # Read relay log filename.
  open FILE, "$index_file" or die "Error $? opening $index_file: $!";
  my $relay_log_file= '';
  while (<FILE>) {
    $relay_log_file= $_;
  }
  chomp($relay_log_file);
  $relay_log_file =~ s{^\.[/\\]}{};
  close FILE or die "Error $? closing $index_file: $!";

  # Get relay log size.
  my $datadir= $ENV{'_RGEORL_DATADIR'};
  my $relay_log_size= (stat("$datadir/$relay_log_file"))[7];

  # Write output file.
  my $output_file= $ENV{'_RGEORL_OUTPUT_FILE'};
  open FILE, "> $output_file" or die "Error $? opening $output_file: $!";
  printf FILE "% 10d%s", $relay_log_size, $relay_log_file or die "Error $? writing to $output_file: $!";
  close FILE or die "Error $? writing to $output_file: $!";
EOF

# Read output file into mtr variables
--let $size_and_file= `SELECT LOAD_FILE('$_RGEORL_OUTPUT_FILE')`
--remove_file $_RGEORL_OUTPUT_FILE
--let $relay_log_size= `SELECT TRIM(SUBSTR('$size_and_file', 1, 10))`
--let $relay_log_file= `SELECT TRIM(SUBSTR('$size_and_file', 11))`

# Take into account the encryption header if necessary
--let $_binlog_encryption=`SELECT @@GLOBAL.binlog_encryption`
if ($_binlog_encryption)
{
  --let $relay_log_size=`SELECT $relay_log_size - 512`
}

if ($rpl_debug)
{
  --echo relay_log_file=$relay_log_file relay_log_size=$relay_log_size
}

--let $include_filename= include/rpl_get_end_of_relay_log.inc
--source include/end_include_file.inc