final class RadixLiteral
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A hexadecimal or bit-value literal: its exact digits and its optional character set introducer.

X'1F' and 0x1F are one literal, as are b'101' and 0b101; the spelling is not kept by the literal (an unaliased select list item, which MySQL names after its text, keeps it in its layout). The digits are kept exactly, leading zeros included.

Rule: MYSQL-RADIX-LITERAL-001. Facts: by default a binary string, VARBINARY; with an introducer a character string, VARCHAR, of the introduced character set; never NULL. In a numeric context the server converts the value, which is a rule of the operator, not of the literal. Precision: the type family is exact; the length is not derived. Diagnostics: none. Source: https://dev.mysql.com/doc/refman/8.4/en/hexadecimal-literals.html, https://dev.mysql.com/doc/refman/8.4/en/bit-value-literals.html. Status: Implemented.

Reading one literal from either spellingdoctest
$semantics = new \SqlSemantics\Platform\MySql\Semantics();
    [$semantics->analyze("SELECT a FROM t WHERE a = X'1F'")->statement->where->right->digits, $semantics->analyze('SELECT a FROM t WHERE a = 0x1F')->toString()] // => ['1F', "SELECT a FROM t WHERE a = x'1F'"]

Properties§

public Radix $radix
public string $digits
public Name|null $introducer = null

Methods§

public function __construct(
    public Radix $radix,
    public string $digits,
    public Name|null $introducer = null,
)

Parameters

$radixRadixThe digit system
$digitsstringThe digits exactly as written
$introducerName|nullThe introduced character set, in lower case
Calls 5
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the string type; a literal is never NULL.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 9
public function render(Output $out): void

Writes the introducer and the digits in a spelling that reads back as the same digits.

Parameters

$outOutput
Calls 5

Test cases 14§

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

Dedicated tests 8
Other tests reaching this symbol 6

Relations§

Instantiated in 4
Type checks 3