final class AlterUser
    implements Statement
    uses Snapshot
Public API: explicitly declared with @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.

Changing a password and keeping the old onedoctest
(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> $users
public list<ResourceLimit> $resources
public list<AccountOption> $options
public bool $ifExists
public TlsRequirement|null $tls = null
public UserComment|null $comment = null

Methods§

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

$ifExistsboolWhether IF EXISTS is written
$userslist<UserAlteration>The account entries in order; at least one
$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 and of the factor changes.

Parameters

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

Writes the request.

Parameters

$outOutput
Calls 3

Test cases 2§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 1

Relations§

Instantiated in 5