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

A request to create a role, written as CREATE ROLE, CREATE USER or CREATE GROUP.

Rule: PG-ROLE-CREATE-001. Mirrors CreateRoleStmt: the statement word (RoleStmtType; CREATE USER makes LOGIN the default), the role name and the options in the order written. The optional WITH before the options is not kept. Reported: a name starting with pg_, an option filled twice, an unrecognized option word, UNENCRYPTED PASSWORD, a connection limit below -1 and PUBLIC in a role list (PG-ROLE-CHECK-001). A role is not a relation declaration: the statement provides none. Source: https://www.postgresql.org/docs/17/sql-createrole.html, https://www.postgresql.org/docs/17/sql-createuser.html, https://www.postgresql.org/docs/17/sql-creategroup.html. Status: Implemented.

Reading the options of a new roledoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("CREATE USER joe WITH LOGIN ENCRYPTED PASSWORD 'secret'");
    [$operation->statement->name->value, $operation->statement->options[0]->option(), $operation->toString()] // => ['joe', 'canlogin', "CREATE USER joe login PASSWORD 'secret'"]

Properties§

public list<RoleOption> $options
public RoleWord $word
public Name $name

Methods§

public function __construct(
    public RoleWord $word,
    public Name $name,
    list<RoleOption> $options = [],
)

Parameters

$wordRoleWordThe statement word: ROLE, USER or GROUP
$nameNameThe role name
$optionslist<RoleOption>The options in the order written
Calls 2
public function deriveStatement(Derivation $derivation): void

Reports the problems of the name and of the options.

Parameters

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

Writes the request.

Parameters

$outOutput
Calls 3

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 3