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

CREATE USER [IF NOT EXISTS] account [auth], … [DEFAULT ROLE …] [REQUIRE …] [WITH limits] [options] [ATTRIBUTE|COMMENT '…']: a request to create accounts.

Mirrors SQLCOM_CREATE_USER (LEX users_list, default_roles, ssl_type, mqh, alter_password, alter_user_attribute). Rule: MYSQL-CREATE-USER-001. The accounts, their authentication methods and every clause are kept in source order; passwords keep their exact values. The problems of the clauses are reported by MYSQL-ACCOUNT-CHECKS-001. An account is not a relation: the statement provides no declaration. Source: https://dev.mysql.com/doc/refman/8.4/en/create-user.html. Status: Implemented.

Creating an account with a password and a lockdoctest
(new \SqlSemantics\Platform\MySql\Semantics())->analyze("create user if not exists app@'%' identified by 'pw' account lock")->toString() // => "CREATE USER IF NOT EXISTS app@`%` IDENTIFIED BY 'pw' ACCOUNT LOCK"

Properties§

public list<UserSpecification> $users
public list<AccountName> $defaultRoles
public list<ResourceLimit> $resources
public list<AccountOption> $options
public bool $ifNotExists
public TlsRequirement|null $tls = null
public UserComment|null $comment = null

Methods§

public function __construct(
    public bool $ifNotExists,
    list<UserSpecification> $users,
    list<AccountName> $defaultRoles = [],
    public TlsRequirement|null $tls = null,
    list<ResourceLimit> $resources = [],
    list<AccountOption> $options = [],
    public UserComment|null $comment = null,
)

Parameters

$ifNotExistsboolWhether IF NOT EXISTS is written
$userslist<UserSpecification>The accounts in order; at least one
$defaultRoleslist<AccountName>The roles of DEFAULT ROLE; none when the clause is absent
$tlsTlsRequirement|nullThe REQUIRE clause, when written
$resourceslist<ResourceLimit>The resource limits of the WITH clause in order
$optionslist<AccountOption>The password and locking options in order
$commentUserComment|nullThe ATTRIBUTE or COMMENT clause, when written
Calls 6
public function deriveStatement(Derivation $derivation): void

Reports the problems of the clauses.

Parameters

$derivationDerivation
Calls 4
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