mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 14:39:28 +00:00
merged manual-for-pt-query-digest--type-binlog-is-ambiguous-1377888
This commit is contained in:
@@ -13181,6 +13181,13 @@ sub main {
|
||||
if ( $fh ) {
|
||||
PTDEBUG && _d('Reading', $filename);
|
||||
PTDEBUG && _d('File size:', $filesize);
|
||||
# catch if user is trying to use an uncoverted (raw) binlog # issue 1377888
|
||||
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";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
push @read_files, { name => ($filename || "STDIN"), size => $filesize };
|
||||
|
||||
# Read the file offset for --resume.
|
||||
@@ -14722,6 +14729,14 @@ sub sanitize_event {
|
||||
return;
|
||||
}
|
||||
|
||||
# make an effort to check if file is a raw binlog
|
||||
# (i.e. was not converted to text using mysqlbinlog)
|
||||
sub is_raw_binlog {
|
||||
my $filename = shift;
|
||||
|
||||
return -B $filename;
|
||||
}
|
||||
|
||||
sub _d {
|
||||
my ($package, undef, $line) = caller 0;
|
||||
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
||||
@@ -14798,7 +14813,8 @@ server. Before using this tool, please:
|
||||
|
||||
pt-query-digest is a sophisticated but easy to use tool for analyzing
|
||||
MySQL queries. It can analyze queries from MySQL slow, general, and binary
|
||||
logs, as well as C<SHOW PROCESSLIST> and MySQL protocol data from tcpdump.
|
||||
logs. (Binary logs must first be converted to text, see L<"--type">).
|
||||
It can also use C<SHOW PROCESSLIST> and MySQL protocol data from tcpdump.
|
||||
By default, the tool reports which queries are the slowest, and therefore
|
||||
the most important to optimize. More complex and custom-tailored reports
|
||||
can be created by using options like L<"--group-by">, L<"--filter">, and
|
||||
@@ -16134,7 +16150,13 @@ The type of input to parse. The permitted types are
|
||||
|
||||
=item binlog
|
||||
|
||||
Parse a binary log file.
|
||||
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.
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 3;
|
||||
use Test::More tests => 4;
|
||||
|
||||
use PerconaTest;
|
||||
require "$trunk/bin/pt-query-digest";
|
||||
@@ -46,6 +46,26 @@ ok(
|
||||
'Analysis for binlog011 - Handles 5.6 binlog with checksum CRC32',
|
||||
) or diag($test_diff);
|
||||
|
||||
|
||||
|
||||
# #############################################################################
|
||||
# Issue 1377888: refuse to parse raw binary log
|
||||
# #############################################################################
|
||||
|
||||
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