File: rpl_log_file_max_number.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 (73 lines) | stat: -rw-r--r-- 1,921 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
# ==== Purpose ====
#
# Determine the maximum number of the log file list matched by the provided
# pattern.
#
# ==== Usage ====
#
# --let $pattern_to_match = TEXT
# --source include/rpl_log_file_max_number.inc
#
# Parameters:
#
#   $pattern_to_match
#     File and/or directory pattern matching to be searched for when determining
#     the max number of the log file list.
#
# ==== References ====
#
# BUG#28684376 MAKE GR REPLICATION CHANNELS ROTATE RELAY LOG ON FLUSH LOGS
#

if ($pattern_to_match == '')
{
  --die !!!ERROR IN TEST: you must set $pattern_to_match
}

--let $include_filename = rpl_log_file_max_number.inc
--source include/begin_include_file.inc

--let $result_file1 = `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/max_log_file_', UUID(), '.inc')`
--let $result_file2 = `SELECT CONCAT('$MYSQLTEST_VARDIR/tmp/max_log_file_', UUID(), '.inc')`
--let DIR_STATE_MATCH_PATTERN = $pattern_to_match
--let DIR_STATE_RESULT_FILE_1 = $result_file1
--let DIR_STATE_RESULT_FILE_2 = $result_file2

--perl SCRIPT
  my $match_pattern = $ENV{'DIR_STATE_MATCH_PATTERN'};
  my $out1 = $ENV{'DIR_STATE_RESULT_FILE_1'};
  my $out2 = $ENV{'DIR_STATE_RESULT_FILE_2'};
  my @files = glob($match_pattern);
  my $max = 0;
  my $max_ext;

  foreach my $file (@files)
  {
    my @parts = split(/\./, $file);
    my $ext = $parts[scalar(@parts) - 1];
    my $num = $ext + 0;

    if ($num > $max)
    {
      $max = $num;
      $max_ext = $ext;
    }
  }

  open OUT, "> $out1" or die("Unable to open $out: $!\n");
  print OUT $max;
  close OUT;
  open OUT, "> $out2" or die("Unable to open $out: $!\n");
  print OUT $max_ext;
  close OUT;
#END OF
SCRIPT

--let $log_file_max_number = `SELECT LOAD_FILE('$result_file1')`
--remove_file $result_file1

--let $log_file_max_extension = `SELECT LOAD_FILE('$result_file2')`
--remove_file $result_file2

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