classAlterRole
final class AlterRole
implements Statement
uses Snapshot
@visibility public.A request to change the attributes of a role, written as ALTER ROLE or ALTER USER.
Rule: PG-ROLE-ALTER-001. Mirrors AlterRoleStmt with action +1: the role and the options in the order written. ALTER accepts the options of AlterOptRoleElem only, so SYSID, ADMIN, ROLE, IN ROLE and IN GROUP cannot be written; USER lists members to add. The optional WITH is not kept. Reported: PUBLIC or a pg_ name as the role, and the option problems of PG-ROLE-CHECK-001. Source: https://www.postgresql.org/docs/17/sql-alterrole.html, https://www.postgresql.org/docs/17/sql-alteruser.html. Status: Implemented.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER ROLE joe WITH NOSUPERUSER');
[$operation->statement->role->name?->value, $operation->statement->options[0]->flag()?->enabled()] // => ['joe', false]Properties§
public list<RoleOption> $optionspublic RoleWord $wordpublic RoleSpec $roleMethods§
public function __construct(
public RoleWord $word,
public RoleSpec $role,
list<RoleOption> $options = [],
)Parameters
$word | RoleWord | The statement word: ROLE or USER |
$role | RoleSpec | The role to change |
$options | list<RoleOption> | The options in the order written |
Calls 5
- static-call Check::input() line 49
- class-const RoleWord::Group() line 49
- static-call Check::listOf() line 50
- class-const RoleOption::class() line 50
- class-const RoleMembersKind::User() line 52
public function deriveStatement(Derivation $derivation): voidReports the problems of the role and of the options.
Parameters
$derivation | Derivation |
Calls 3
- new RoleChecks line 61
- method-call RoleChecks::alterable() line 62
- method-call RoleChecks::options() line 63
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 71
- method-call Output::node() line 73
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.