final class SetNames
    implements SetItem
    uses Snapshot
Public API: explicitly declared with @visibility public.

SET NAMES: sets the client, connection and result character sets, and the connection collation.

Rule: MYSQL-SET-NAMES-001. SET NAMES cs [COLLATE co] sets character_set_client, character_set_connection and character_set_results to cs and collation_connection to co, or to the default collation of cs; SET NAMES DEFAULT maps the three to the default character set. The character set and collation are names the server resolves; the context holds no character set catalog, so a collation of another character set (ER_COLLATION_CHARSET_MISMATCH) is not detected. Facts: none. Terminates: the parts are leaves. Source: https://dev.mysql.com/doc/refman/8.4/en/set-names.html. Status: Implemented.

Reading SET NAMESdoctest
$set = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SET NAMES 'utf8mb4' COLLATE utf8mb4_bin");
    [$set->statement->items[0]->charset->name?->value, $set->statement->items[0]->collation?->name?->value, $set->toString()] // => ['utf8mb4', 'utf8mb4_bin', 'SET NAMES utf8mb4 COLLATE utf8mb4_bin']

Properties§

public CharsetName $charset
public CollationName|null $collation = null

Methods§

public function __construct(
    public CharsetName $charset,
    public CollationName|null $collation = null,
)

Parameters

$charsetCharsetNameThe character set, or DEFAULT
$collationCollationName|nullThe collation of the connection; MySQL 5.x also accepts COLLATE DEFAULT
public function deriveItem(Derivation $derivation): void

Derives nothing: the names are resolved by the server.

Parameters

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

Writes NAMES, the character set and the collation.

Parameters

$outOutput
Calls 1

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