classAlterUser
final class AlterUser
implements Statement
uses Snapshot
@visibility public.ALTER USER [IF EXISTS] account [auth], … [REQUIRE …] [WITH limits] [options] [ATTRIBUTE|COMMENT '…']: a request to change accounts.
Mirrors SQLCOM_ALTER_USER. Rule: MYSQL-ALTER-USER-001. An entry sets a new authentication method with the 8.0 password management words (REPLACE, RETAIN CURRENT PASSWORD, DISCARD OLD PASSWORD) or changes authentication factors (8.0.27+). ALTER USER USER() … changes the session's own account and is written alone, with a new password or DISCARD OLD PASSWORD. The problems of the clauses are reported by MYSQL-ACCOUNT-CHECKS-001; MySQL 5.7, whose grammar shares the account list of GRANT, rejects IDENTIFIED BY PASSWORD here (RejectedPasswordHash). Source: https://dev.mysql.com/doc/refman/8.4/en/alter-user.html, https://dev.mysql.com/doc/refman/5.7/en/alter-user.html. Status: Implemented.
(new \SqlSemantics\Platform\MySql\Semantics())->analyze("alter user if exists u identified by 'new' replace 'old' retain current password")->toString() // => "ALTER USER IF EXISTS u IDENTIFIED BY 'new' REPLACE 'old' RETAIN CURRENT PASSWORD"Properties§
public list<UserAlteration> $userspublic list<ResourceLimit> $resourcespublic list<AccountOption> $optionspublic bool $ifExistspublic TlsRequirement|null $tls = nullpublic UserComment|null $comment = nullMethods§
public function __construct(
public bool $ifExists,
list<UserAlteration> $users,
public TlsRequirement|null $tls = null,
list<ResourceLimit> $resources = [],
list<AccountOption> $options = [],
public UserComment|null $comment = null,
)Parameters
$ifExists | bool | Whether IF EXISTS is written |
$users | list<UserAlteration> | The account entries in order; at least one |
$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 UserAlteration::class() line 77
- class-const ResourceLimit::class() line 78
- class-const AccountOption::class() line 79
- static-call Check::input() line 81
- function-call
countline 84
public function deriveStatement(Derivation $derivation): voidReports the problems of the clauses and of the factor changes.
Parameters
$derivation | Derivation |
Calls 8
- new AccountChecks line 95
- method-call AccountChecks::factors() line 98
- class-const Credential::PasswordHash() line 99
- method-call Derivation::report() line 100
- new RejectedPasswordHash line 100
- method-call AccountChecks::tls() line 103
- method-call AccountChecks::options() line 104
- method-call AccountChecks::comment() line 105
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 113
- method-call Output::list() line 117
- method-call Output::node() line 121
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
AlterUserTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 5
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::definition() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:95
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::definition() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:102
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:133
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:142
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:150