classPrivilegeRule
final class PrivilegeRule
Lowers the privilege lists, column lists and privilege levels of GRANT and REVOKE.
Rule: MYSQL-ACCOUNT-PRIVILEGE-001. Scope: role_or_privilege_list, role_or_privilege (8.0+), grant_privileges, object_privilege_list, object_privilege (5.x), opt_privileges, opt_column_list, column_list, column_list_id, grant_ident, opt_acl_type. A static privilege maps to its PrivilegeKind by the words written; a name alone is a role in a role list and a dynamic privilege in a privilege list, as the server reads PT_role_or_dynamic_privilege; a name with a column list is a dynamic privilege (PT_dynamic_privilege); a name with a host is a role (PT_role_at_host). ALL [PRIVILEGES] is AllPrivileges. The level is *.*, *, db.* or an object name; an absent or TABLE kind is a table. Constructs: StaticPrivilege, DynamicPrivilege, GrantedRole, AllPrivileges, GlobalLevel, CurrentDatabaseLevel, DatabaseLevel, ObjectLevel. Terminates: lists are flattened iteratively; every other child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/grant.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers the items of an 8.0 role_or_privilege_list, reading a name alone as a role or as a dynamic privilege.
Parameters
$list | Node | |
$roles | bool |
Returns
non-empty-list<Grantable>Throws
ImplementationGap When a production has no ruleCalled from 5
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:63
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:68
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:126
- method-call SqlSemantics\Platform\MySql\Lowering\Account\PrivilegeRule::privileges() packages/sql-semantics-mysql/src/Lowering/Account/PrivilegeRule.php:205
Calls 3
- method-call PrivilegeRule::spine() line 145
- method-call PrivilegeRule::item() line 146
- static-call Check::invariant() line 148
Lowers one role_or_privilege or object_privilege.
Parameters
$item | Node | |
$roles | bool |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 8
- method-call Lowering::form() line 160
- static-call ImplementationGap::production() line 162
- class-const PrivilegeRule::STATIC() line 164
- new StaticPrivilege line 166
- method-call PrivilegeRule::columns() line 166
- new GrantedRole line 171
- new AccountName line 171
- method-call PrivilegeRule::named() line 172
Reads a name with its column list: a role in a role list when no columns are written, a dynamic privilege otherwise.
Returns
Called from 1
Calls 3
Lowers a MySQL 5.x grant_privileges: ALL [PRIVILEGES] or a list of privileges.
Parameters
$privileges | Node |
Returns
non-empty-list<Grantable>Throws
ImplementationGap When a production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:82
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:115
Calls 5
- method-call Lowering::form() line 195
- method-call PrivilegeRule::words() line 197
- new AllPrivileges line 199
- static-call ImplementationGap::production() line 202
- method-call PrivilegeRule::items() line 205
public function words(Node $optional): voidConfirms an opt_privileges production: PRIVILEGES is an optional word.
Parameters
$optional | Node |
Throws
ImplementationGap When the production has no ruleCalled from 5
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::all() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:91
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revokeAll() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:149
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::everything() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:159
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:105
- method-call SqlSemantics\Platform\MySql\Lowering\Account\PrivilegeRule::privileges() packages/sql-semantics-mysql/src/Lowering/Account/PrivilegeRule.php:197
Calls 2
- method-call Lowering::form() line 215
- static-call ImplementationGap::production() line 217
Lowers an opt_column_list; an absent list is empty.
Parameters
$optional | Node |
Returns
list<Name>Throws
ImplementationGap When a production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Account\PrivilegeRule::item() packages/sql-semantics-mysql/src/Lowering/Account/PrivilegeRule.php:166
- method-call SqlSemantics\Platform\MySql\Lowering\Account\PrivilegeRule::item() packages/sql-semantics-mysql/src/Lowering/Account/PrivilegeRule.php:172
Calls 4
- method-call Lowering::form() line 229
- static-call ImplementationGap::production() line 234
- method-call PrivilegeRule::spine() line 237
- method-call PrivilegeRule::column() line 238
Lowers one column of a column list.
Parameters
$column | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 2
- method-call Lowering::form() line 254
- static-call ImplementationGap::production() line 256
public function level(Node $level): PrivilegeLevelLowers a grant_ident.
Parameters
$level | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 6
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:70
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::all() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:128
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revokeAll() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:151
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:84
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:115
Calls 7
- method-call Lowering::form() line 269
- new GlobalLevel line 273
- new CurrentDatabaseLevel line 274
- new DatabaseLevel line 275
- new ObjectLevel line 276
- new QualifiedName line 276
- static-call ImplementationGap::production() line 279
public function kind(Node $kind): ObjectKindLowers an 8.0 opt_acl_type: TABLE and an absent kind are a table.
Parameters
$kind | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:69
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::all() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:127
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revokeAll() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:151
Calls 5
- method-call Lowering::form() line 290
- class-const ObjectKind::Table() line 293
- class-const ObjectKind::Function() line 294
- class-const ObjectKind::Procedure() line 295
- static-call ImplementationGap::production() line 296
Answers the items of a list production of this rule, in source order.
Parameters
$list | Node |
Returns
list<Node>Throws
ImplementationGap When the production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Account\PrivilegeRule::items() packages/sql-semantics-mysql/src/Lowering/Account/PrivilegeRule.php:145
- method-call SqlSemantics\Platform\MySql\Lowering\Account\PrivilegeRule::columns() packages/sql-semantics-mysql/src/Lowering/Account/PrivilegeRule.php:237
Calls 5
- method-call Lowering::form() line 308
- class-const PrivilegeRule::LISTS() line 309
- static-call ImplementationGap::production() line 310
- method-call Lists::items() line 313
- new Lists line 313
Private surface 3§
Implementation details, listed for orientation only.
private const STATIC = ['object_privilege: ALTER' => \SqlSemantics\Platform\MySql\Statement\Account\Pr…private const LISTS = ['role_or_privilege_list: role_or_privilege' => true, 'role_or_privilege_list: …private Lowering $loweringTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
PrivilegeRuleTestcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::__construct() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:48
- new SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:79
- new SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:103
Method calls 20
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:63
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:68
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:69
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:70
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::all() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:91
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::all() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::all() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:126
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:127
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:128
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revokeAll() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:149
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revokeAll() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:151
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::revokeAll() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:151
- method-call SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::everything() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:159
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:82
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:84
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:105
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:115
- method-call SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::revoke() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:115