Merge lp:~percona-toolkit-dev/percona-toolkit/pt-query-digest-waits-for-STDIN-if-file-dosnt-exist-1404313 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.14

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 629
Merged at revision: 620
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-query-digest-waits-for-STDIN-if-file-dosnt-exist-1404313
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.14
Diff against target: 14 lines (+4/-0)
1 file modified
bin/pt-query-digest (+4/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-query-digest-waits-for-STDIN-if-file-dosnt-exist-1404313
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+253745@code.launchpad.net

Description of the change

Problem:
When an single file is given as input, if it is does not exist the tool considers it to be a DSN (used for special purposes within the tool , specifically to parse mysql style dates when the --since or --until option are used)
Since the tool assumes no log file was given, it defaults to STDIN input.
This is confusing for the user since it seems the tool is just doing nothing.

Note:
This is very tricky to solve completely (throw a proper error) given the current options format described in the documentation, since many strings can be considered either a file or a dsn. (a single string like "thisisafile" is parsed as dsn host=thisisafile)

Solution:
Detect when a file handle is of type STDIN and issue a message to user that the tool is waiting for STDIN input.

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-query-digest'
2--- bin/pt-query-digest 2015-01-23 10:19:56 +0000
3+++ bin/pt-query-digest 2015-03-20 21:46:44 +0000
4@@ -13186,6 +13186,10 @@
5 # Open the next file.
6 my ($fh, $filename, $filesize) = $next_file->();
7 if ( $fh ) {
8+ my $fileno = fileno $fh;
9+ if ($fileno == 0) {
10+ print "Reading from STDIN ...\n";
11+ }
12 PTDEBUG && _d('Reading', $filename);
13 PTDEBUG && _d('File size:', $filesize);
14 # catch if user is trying to use an uncoverted (raw) binlog # issue 1377888

Subscribers

People subscribed via source and target branches

to all changes: