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

SET PASSWORD [FOR account] {= 'password' | TO RANDOM} [REPLACE 'current'] [RETAIN CURRENT PASSWORD]: a request to set an account's password.

Mirrors PT_option_value_no_option_type_password and its _for form (8.0), and set_var_password (5.x). Rule: MYSQL-SET-PASSWORD-001. Without FOR the session's own account is changed. The password is an operand with its exact value; TO RANDOM (8.0.18+) asks the server to generate one and return it as a result row. MySQL 5.x writes PASSWORD() or OLD_PASSWORD() around the string (Password). Source: https://dev.mysql.com/doc/refman/8.4/en/set-password.html, https://dev.mysql.com/doc/refman/5.7/en/set-password.html. Status: Implemented.

Setting the password of another accountdoctest
(new \SqlSemantics\Platform\MySql\Semantics())->analyze("set password for app = 'pw' retain current password")->toString() // => "SET PASSWORD FOR app = 'pw' RETAIN CURRENT PASSWORD"

Properties§

public Account|null $user
public Password|null $password
public Text|null $replace = null
public bool $retainCurrent = false

Methods§

public function __construct(
    public Account|null $user,
    public Password|null $password,
    public Text|null $replace = null,
    public bool $retainCurrent = false,
)

Parameters

$userAccount|nullThe account of FOR, when written
$passwordPassword|nullThe password; null for TO RANDOM
$replaceText|nullThe current password REPLACE names
$retainCurrentboolWhether RETAIN CURRENT PASSWORD is written
Calls 1
public function deriveStatement(Derivation $derivation): void

Derives nothing: the statement names no relation and no expression.

Parameters

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

Writes the request.

Parameters

$outOutput
Calls 2

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 2
Type declarations 1