mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-22 20:19:00 +00:00
Improved test. Changed test file location. Added doc example.
This commit is contained in:
@@ -13185,7 +13185,7 @@ sub main {
|
||||
if ( $filename && $o->get('type')->[0] eq 'binlog') {
|
||||
if (is_raw_binlog($filename)) {
|
||||
warn "Binlog file $filename must first be converted to text format using mysqlbinlog";
|
||||
exit 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
push @read_files, { name => ($filename || "STDIN"), size => $filesize };
|
||||
@@ -14730,21 +14730,11 @@ sub sanitize_event {
|
||||
}
|
||||
|
||||
# make an effort to check if file is a raw binlog
|
||||
# ( i.e was not converted to text using mysqlbinlog )
|
||||
# (i.e. was not converted to text using mysqlbinlog)
|
||||
sub is_raw_binlog {
|
||||
my $filename = shift;
|
||||
|
||||
my $output;
|
||||
eval {
|
||||
$output = `file $filename`;
|
||||
};
|
||||
|
||||
# if we can't determine file type, let's assume it's ok
|
||||
if ($EVAL_ERROR || !$output) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $output =~ /MySQL\s*replication/i;
|
||||
return -B $filename;
|
||||
}
|
||||
|
||||
sub _d {
|
||||
@@ -16160,7 +16150,13 @@ The type of input to parse. The permitted types are
|
||||
|
||||
=item binlog
|
||||
|
||||
Parse a binary log file that has been converted to text using mysqlbinlog.
|
||||
Parse a binary log file that has first been converted to text using mysqlbinlog.
|
||||
|
||||
For example:
|
||||
|
||||
mysqlbinlog mysql-bin.000441 > mysql-bin.000441.txt
|
||||
|
||||
pt-query-digest --type binlog mysql-bin.000441.txt
|
||||
|
||||
=item genlog
|
||||
|
||||
|
BIN
t/lib/samples/binlogs/raw_binlog.log
Normal file
BIN
t/lib/samples/binlogs/raw_binlog.log
Normal file
Binary file not shown.
@@ -52,12 +52,19 @@ ok(
|
||||
# Issue 1377888: refuse to parse raw binary log
|
||||
# #############################################################################
|
||||
|
||||
my $output = `$trunk/bin/pt-query-digest --type binlog '$trunk/t/pt-query-digest/samples/raw_binlog.log' 2>&1`;
|
||||
ok(
|
||||
$output =~ /mysqlbinlog/i ,
|
||||
'Refuses to parse raw binlog file.'
|
||||
my $output = output(
|
||||
sub { pt_query_digest::main(@args, "$trunk/t/lib/samples/binlogs/raw_binlog.log") },
|
||||
stderr => 1
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/mysqlbinlog/i,
|
||||
'Refuses to parse raw binlog file'
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
|
Reference in New Issue
Block a user