final class GrantRoles
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

GRANT role, … TO account, … [WITH ADMIN OPTION] (8.0+): a request to grant roles.

Mirrors PT_grant_roles. Rule: MYSQL-GRANT-ROLES-001. The grammar reads any item of the list; an item that is no role (a static privilege, or a dynamic privilege with a column list) is a RoleOrPrivilegeMismatch by MYSQL-PRIVILEGE-CHECKS-001. A dynamic privilege written without columns reads as a role here and is not accepted by the constructor. Source: https://dev.mysql.com/doc/refman/8.4/en/grant.html#grant-roles. Status: Implemented.

Granting roles with the admin optiondoctest
(new \SqlSemantics\Platform\MySql\Semantics())->analyze("grant r1, 'r2'@'%' to u with admin option")->toString() // => 'GRANT r1, r2@`%` TO u WITH ADMIN OPTION'

Properties§

public list<Grantable> $roles
public list<Account> $users
public bool $withAdminOption = false

Methods§

public function __construct(
    list<Grantable> $roles,
    list<Account> $users,
    public bool $withAdminOption = false,
)

Parameters

$roleslist<Grantable>The granted roles in order; at least one
$userslist<Account>The accounts the roles are granted to; at least one
$withAdminOptionboolWhether WITH ADMIN OPTION is written
Calls 4
public function deriveStatement(Derivation $derivation): void

Reports the items that are no roles.

Parameters

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

Writes the request.

Parameters

$outOutput
Calls 1

Test cases 1§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1

Relations§

Instantiated in 1