pt-show-grants - order output of column privileges - lp1523730

This commit is contained in:
frank-cizmich
2015-12-12 21:28:26 -03:00
parent 9616c8a415
commit e784d226e6
6 changed files with 11 additions and 5 deletions

View File

@@ -1998,6 +1998,11 @@ sub split_grants {
) )
(?:,\s)? # Separted from the next grant, if any, by a comma (?:,\s)? # Separted from the next grant, if any, by a comma
/xg; /xg;
# sort columns in column-level permissions (bug lp-1523730)
@grants = map {
$_ =~ s/(INSERT|SELECT|UPDATE)\s\((.+?)\)/"$1 (" . join(', ',sort(split(', ',$2))) . ')'/me;
$_;
} @grants;
} }
else { else {
PTDEBUG && _d('Splitting grants on comma:', $grants); PTDEBUG && _d('Splitting grants on comma:', $grants);

View File

@@ -108,6 +108,7 @@ ok(
"Column-level grants (bug 866075)" "Column-level grants (bug 866075)"
); );
ok( ok(
no_diff( no_diff(
sub { pt_show_grants::main('-F', $cnf, qw(--only sally --no-header), sub { pt_show_grants::main('-F', $cnf, qw(--only sally --no-header),

View File

@@ -1,4 +1,4 @@
-- Grants for 'sally'@'%' -- Grants for 'sally'@'%'
GRANT INSERT (city), SELECT, SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%'; GRANT INSERT (city), SELECT, SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%';
GRANT SELECT (SANumber, DateCreated, PaymentStat, PckPrice) ON `test`.`t` TO 'sally'@'%'; GRANT SELECT (DateCreated, PaymentStat, PckPrice, SANumber) ON `test`.`t` TO 'sally'@'%';
GRANT USAGE ON *.* TO 'sally'@'%'; GRANT USAGE ON *.* TO 'sally'@'%';

View File

@@ -1,10 +1,10 @@
-- Revoke statements for 'sally'@'%' -- Revoke statements for 'sally'@'%'
REVOKE INSERT (city) ON `sakila`.`city` FROM 'sally'@'%'; REVOKE INSERT (city) ON `sakila`.`city` FROM 'sally'@'%';
REVOKE SELECT (SANumber, DateCreated, PaymentStat, PckPrice) ON `test`.`t` FROM 'sally'@'%'; REVOKE SELECT (DateCreated, PaymentStat, PckPrice, SANumber) ON `test`.`t` FROM 'sally'@'%';
REVOKE SELECT (city_id) ON `sakila`.`city` FROM 'sally'@'%'; REVOKE SELECT (city_id) ON `sakila`.`city` FROM 'sally'@'%';
REVOKE USAGE ON *.* FROM 'sally'@'%'; REVOKE USAGE ON *.* FROM 'sally'@'%';
-- Grants for 'sally'@'%' -- Grants for 'sally'@'%'
GRANT INSERT (city) ON `sakila`.`city` TO 'sally'@'%'; GRANT INSERT (city) ON `sakila`.`city` TO 'sally'@'%';
GRANT SELECT (SANumber, DateCreated, PaymentStat, PckPrice) ON `test`.`t` TO 'sally'@'%'; GRANT SELECT (DateCreated, PaymentStat, PckPrice, SANumber) ON `test`.`t` TO 'sally'@'%';
GRANT SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%'; GRANT SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%';
GRANT USAGE ON *.* TO 'sally'@'%'; GRANT USAGE ON *.* TO 'sally'@'%';

View File

@@ -1,5 +1,5 @@
-- Grants for 'sally'@'%' -- Grants for 'sally'@'%'
GRANT INSERT (city) ON `sakila`.`city` TO 'sally'@'%'; GRANT INSERT (city) ON `sakila`.`city` TO 'sally'@'%';
GRANT SELECT (SANumber, DateCreated, PaymentStat, PckPrice) ON `test`.`t` TO 'sally'@'%'; GRANT SELECT (DateCreated, PaymentStat, PckPrice, SANumber) ON `test`.`t` TO 'sally'@'%';
GRANT SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%'; GRANT SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%';
GRANT USAGE ON *.* TO 'sally'@'%'; GRANT USAGE ON *.* TO 'sally'@'%';

View File

@@ -1,4 +1,4 @@
-- Grants for 'sally'@'%' -- Grants for 'sally'@'%'
GRANT INSERT (city), SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%'; GRANT INSERT (city), SELECT (city_id) ON `sakila`.`city` TO 'sally'@'%';
GRANT SELECT (SANumber, DateCreated, PaymentStat, PckPrice) ON `test`.`t` TO 'sally'@'%'; GRANT SELECT (DateCreated, PaymentStat, PckPrice, SANumber) ON `test`.`t` TO 'sally'@'%';
GRANT USAGE ON *.* TO 'sally'@'%'; GRANT USAGE ON *.* TO 'sally'@'%';