classGrantPrivileges
final class GrantPrivileges
implements Statement
uses Snapshot
@visibility public.GRANT privileges ON [kind] level TO accounts [REQUIRE …] [WITH …] [AS user [WITH ROLE …]]: a request to grant privileges.
Mirrors the SQLCOM_GRANT path of LEX (grant, columns, type, users_list, grant_as). Rule: MYSQL-GRANT-001. The level and its table are derived by MYSQL-PRIVILEGE-CHECKS-001: a table level records the resolution of the table as the relation fact of the level. MySQL 5.x also writes an IDENTIFIED clause per account, a REQUIRE clause and resource limits in the WITH clause, which set the account as CREATE USER and ALTER USER do; their problems are reported by MYSQL-ACCOUNT-CHECKS-001. The statement provides no declaration. ON TABLE and ON are the same request; ALL and ALL PRIVILEGES are the same request. Source: https://dev.mysql.com/doc/refman/8.4/en/grant.html, https://dev.mysql.com/doc/refman/5.7/en/grant.html. Status: Implemented.
(new \SqlSemantics\Platform\MySql\Semantics())->analyze('grant select, insert on table shop.t to app@localhost with grant option')->toString() // => 'GRANT SELECT, INSERT ON shop.t TO app@localhost WITH GRANT OPTION'Properties§
public list<Grantable> $privilegespublic list<UserSpecification> $granteespublic list<WithOption> $optionspublic ObjectKind $kindpublic PrivilegeLevel $levelpublic TlsRequirement|null $tls = nullpublic GrantAs|null $as = nullMethods§
public function __construct(
list<Grantable> $privileges,
public ObjectKind $kind,
public PrivilegeLevel $level,
list<UserSpecification> $grantees,
public TlsRequirement|null $tls = null,
list<WithOption> $options = [],
public GrantAs|null $as = null,
)Parameters
$privileges | list<Grantable> | The granted privileges in order; ALL stands alone |
$kind | ObjectKind | The kind of object the level names |
$level | PrivilegeLevel | The privilege level |
$grantees | list<UserSpecification> | The accounts privileges are granted to; at least one |
$tls | TlsRequirement|null | The REQUIRE clause of MySQL 5.x, when written |
$options | list<WithOption> | The options of the WITH clause in order |
$as | GrantAs|null | The AS clause, when written |
Calls 6
- static-call Check::listOf() line 78
- class-const Grantable::class() line 78
- class-const UserSpecification::class() line 79
- class-const WithOption::class() line 80
- static-call Check::input() line 82
- function-call
countline 82
public function deriveStatement(Derivation $derivation): voidDerives the level, the table and the account clauses.
Parameters
$derivation | Derivation |
Calls 4
- method-call PrivilegeChecks::grant() line 95
- new PrivilegeChecks line 95
- method-call AccountChecks::tls() line 96
- new AccountChecks line 96
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 104
- method-call ObjectKind::keyword() line 105
- method-call Output::node() line 109
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Other tests reaching this symbol 4
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:67
- new SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::all() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:94
- new SqlSemantics\Platform\MySql\Lowering\Account\LegacyGrantRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/LegacyGrantRule.php:81