classCreateUser
final class CreateUser
implements Statement
uses Snapshot
@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.
(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> $userspublic list<AccountName> $defaultRolespublic list<ResourceLimit> $resourcespublic list<AccountOption> $optionspublic bool $ifNotExistspublic TlsRequirement|null $tls = nullpublic UserComment|null $comment = nullMethods§
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
$ifNotExists | bool | Whether IF NOT EXISTS is written |
$users | list<UserSpecification> | The accounts in order; at least one |
$defaultRoles | list<AccountName> | The roles of DEFAULT ROLE; none when the clause is absent |
$tls | TlsRequirement|null | The REQUIRE clause, when written |
$resources | list<ResourceLimit> | The resource limits of the WITH clause in order |
$options | list<AccountOption> | The password and locking options in order |
$comment | UserComment|null | The ATTRIBUTE or COMMENT clause, when written |
Calls 6
- static-call Check::listOf() line 77
- class-const UserSpecification::class() line 77
- class-const AccountName::class() line 78
- class-const ResourceLimit::class() line 79
- class-const AccountOption::class() line 80
- static-call Check::input() line 82
public function deriveStatement(Derivation $derivation): voidReports the problems of the clauses.
Parameters
$derivation | Derivation |
Calls 4
- new AccountChecks line 91
- method-call AccountChecks::tls() line 92
- method-call AccountChecks::options() line 93
- method-call AccountChecks::comment() line 94
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 102
- method-call Output::list() line 106
- method-call Output::node() line 110
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
CreateUserTestcalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::definition() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:76
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::definition() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:77
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::definition() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:85