diff --git a/bin/pt-archiver b/bin/pt-archiver index 81e4f0b3..3e3ad730 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -3964,9 +3964,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -3975,23 +3973,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index e178eeae..0348390b 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -420,9 +420,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -431,23 +429,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-kill b/bin/pt-kill index 287db914..5e5bc3ba 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -4238,9 +4238,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -4249,23 +4247,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 43f063fa..43284cc1 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -4529,9 +4529,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -4540,23 +4538,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 5f91b150..4f9a22ae 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -10835,9 +10835,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -10846,23 +10844,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-replica-find b/bin/pt-replica-find index aeed7ccb..963fa719 100755 --- a/bin/pt-replica-find +++ b/bin/pt-replica-find @@ -2567,9 +2567,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -2578,23 +2576,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-replica-restart b/bin/pt-replica-restart index 9b3ae3b6..b3ecc220 100755 --- a/bin/pt-replica-restart +++ b/bin/pt-replica-restart @@ -2981,9 +2981,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -2992,23 +2990,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index dc04478d..d6ca759a 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -5484,9 +5484,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -5495,23 +5493,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/bin/pt-table-sync b/bin/pt-table-sync index bf02c3d9..0283fbec 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -7014,9 +7014,7 @@ sub _find_replicas_by_hosts { sub get_connected_replicas { my ( $self, $dbh ) = @_; - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -7025,23 +7023,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; } diff --git a/lib/MasterSlave.pm b/lib/MasterSlave.pm index e9fadb90..f018f78a 100644 --- a/lib/MasterSlave.pm +++ b/lib/MasterSlave.pm @@ -382,9 +382,7 @@ sub get_connected_replicas { my ( $self, $dbh ) = @_; # Check for the PROCESS privilege. - my $show = "SHOW GRANTS FOR "; - my $user = 'CURRENT_USER()'; - my $sql = $show . $user; + my $sql = "SHOW GRANTS"; PTDEBUG && _d($dbh, $sql); my $proc; @@ -393,26 +391,9 @@ sub get_connected_replicas { m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ } @{$dbh->selectcol_arrayref($sql)}; }; - if ( $EVAL_ERROR ) { - - if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) { - # Try again without a host. - PTDEBUG && _d('Retrying SHOW GRANTS without host; error:', - $EVAL_ERROR); - ($user) = split('@', $user); - $sql = $show . $user; - PTDEBUG && _d($sql); - eval { - $proc = grep { - m/ALL PRIVILEGES.*?\*\.\*|PROCESS/ - } @{$dbh->selectcol_arrayref($sql)}; - }; - } - - # The 2nd try above might have cleared $EVAL_ERROR. - # If not, die now. - die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; - } + + die "Failed to $sql: $EVAL_ERROR" if $EVAL_ERROR; + if ( !$proc ) { die "You do not have the PROCESS privilege"; }