mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 07:30:02 +00:00
Merge fix-978133-remove-pqd-priv-checks
This commit is contained in:
@@ -1763,42 +1763,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -405,42 +405,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
37
bin/pt-find
37
bin/pt-find
@@ -1802,42 +1802,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -2728,42 +2728,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -3000,42 +3000,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
37
bin/pt-kill
37
bin/pt-kill
@@ -2678,42 +2678,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -2912,42 +2912,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -5490,42 +5490,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -38,6 +38,7 @@ BEGIN {
|
||||
MemcachedEvent
|
||||
BinaryLogParser
|
||||
GeneralLogParser
|
||||
RawLogParser
|
||||
ProtocolParser
|
||||
HTTPProtocolParser
|
||||
ExecutionThrottler
|
||||
@@ -8318,42 +8319,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
@@ -13452,16 +13420,16 @@ sub main {
|
||||
$qv_dbh->do($sql);
|
||||
}
|
||||
|
||||
# Check for existence and the permissions to insert into the
|
||||
# table.
|
||||
# Check for the existence of the table.
|
||||
if ( !$tp->check_table(
|
||||
dbh => $qv_dbh,
|
||||
db => $db_tbl[0],
|
||||
tbl => $db_tbl[1],
|
||||
all_privs => 1) )
|
||||
dbh => $qv_dbh,
|
||||
db => $db_tbl[0],
|
||||
tbl => $db_tbl[1]) )
|
||||
{
|
||||
die "The query review table $db_tbl "
|
||||
. "does not exist or you do not have INSERT privileges";
|
||||
die "The query review table $db_tbl does not exist. "
|
||||
. "Specify --create-review-table to create it, "
|
||||
. "and ensure that the MySQL user has privileges to create "
|
||||
. "and update the table.\n";
|
||||
}
|
||||
|
||||
# Set up the new QueryReview object.
|
||||
@@ -13495,16 +13463,16 @@ sub main {
|
||||
$qv_dbh2->do($sql);
|
||||
}
|
||||
|
||||
# Check for existence and the permissions to insert into the
|
||||
# table.
|
||||
# Check for the existence of the table.
|
||||
if ( !$tp->check_table(
|
||||
dbh => $qv_dbh2,
|
||||
db => $hdb_tbl[0],
|
||||
tbl => $hdb_tbl[1],
|
||||
all_privs => 1) )
|
||||
tbl => $hdb_tbl[1]) )
|
||||
{
|
||||
die "The query review history table $hdb_tbl "
|
||||
. "does not exist or you do not have INSERT privileges";
|
||||
die "The query review history table $hdb_tbl does not exist. "
|
||||
. "Specify --create-review-history-table to create it, "
|
||||
. "and ensure that the MySQL user has privileges to create "
|
||||
. "and update the table.\n";
|
||||
}
|
||||
|
||||
# Inspect for MAGIC_history_cols. Add them to the --select list
|
||||
|
@@ -3904,42 +3904,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -2582,42 +2582,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -5839,42 +5839,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -677,42 +677,9 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
@@ -319,47 +319,11 @@ sub check_table {
|
||||
return 0;
|
||||
}
|
||||
|
||||
# Table exists, return true unless we have privs to check.
|
||||
PTDEBUG && _d('Table exists; no privs to check');
|
||||
return 1 unless $args{all_privs};
|
||||
|
||||
# Get privs select,insert,update.
|
||||
$sql = "SHOW FULL COLUMNS FROM $db_tbl";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$row = $dbh->selectrow_hashref($sql);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
PTDEBUG && _d($EVAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
if ( !scalar keys %$row ) {
|
||||
# This should never happen.
|
||||
PTDEBUG && _d('Table has no columns:', Dumper($row));
|
||||
return 0;
|
||||
}
|
||||
my $privs = $row->{privileges} || $row->{Privileges};
|
||||
|
||||
# Get delete priv since FULL COLUMNS doesn't show it.
|
||||
$sql = "DELETE FROM $db_tbl LIMIT 0";
|
||||
PTDEBUG && _d($sql);
|
||||
eval {
|
||||
$dbh->do($sql);
|
||||
};
|
||||
my $can_delete = $EVAL_ERROR ? 0 : 1;
|
||||
|
||||
PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
|
||||
($can_delete ? 'delete' : ''));
|
||||
|
||||
# Check that we have all privs.
|
||||
if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
|
||||
&& $can_delete) ) {
|
||||
PTDEBUG && _d('User does not have all privs');
|
||||
return 0;
|
||||
}
|
||||
|
||||
PTDEBUG && _d('User has all privs');
|
||||
PTDEBUG && _d('Table', $db, $tbl, 'exists');
|
||||
return 1;
|
||||
|
||||
# No more privs check:
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1036747
|
||||
}
|
||||
|
||||
sub get_engine {
|
||||
|
Reference in New Issue
Block a user