final class GrantPrivileges
    implements Statement
    uses Snapshot
Public API: explicitly declared with @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.

Granting table privileges with the grant optiondoctest
(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> $privileges
public list<UserSpecification> $grantees
public list<WithOption> $options
public ObjectKind $kind
public TlsRequirement|null $tls = null
public GrantAs|null $as = null

Methods§

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

$privilegeslist<Grantable>The granted privileges in order; ALL stands alone
$kindObjectKindThe kind of object the level names
$levelPrivilegeLevelThe privilege level
$granteeslist<UserSpecification>The accounts privileges are granted to; at least one
$tlsTlsRequirement|nullThe REQUIRE clause of MySQL 5.x, when written
$optionslist<WithOption>The options of the WITH clause in order
$asGrantAs|nullThe AS clause, when written
Calls 6
public function deriveStatement(Derivation $derivation): void

Derives the level, the table and the account clauses.

Parameters

$derivationDerivation
Calls 4
public function render(Output $out): void

Writes the request.

Parameters

$outOutput
Calls 3

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
Type declarations 1