final class Constant
    implements Scalar, OutputNaming, IntegerValued
    uses Snapshot
Public API: explicitly declared with @visibility public.

A numeric, string or bit-string constant used as an expression.

Rule: PG-CONSTANT-001. Facts: an integer constant is integer when it fits 32 bits; a numeric constant written as an integer is bigint when it fits 64 bits and numeric otherwise, as make_const reads the text of a T_Float node first as int8 and then as numeric; a constant with a decimal point or exponent is numeric; a string constant is of the pseudo-type unknown until its context resolves it; a bit-string constant is bit. A constant is never NULL and gives a result column no name. Source: https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS, https://www.postgresql.org/docs/17/typeconv-overview.html, make_const in src/backend/parser/parse_node.c of PostgreSQL 17. Status: Implemented.

Reading the type of an integer constant too large for 32 bitsdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 3000000000');
    $query->field(0)->type->descriptor->name() // => 'bigint'

Properties§

Methods§

public function integerValue(): ?string

Answers the integer an integer constant, or a string constant spelling one, denotes.

Returns

?string
Test cases 1
Calls 3
public function outputName(): ?Name

Gives a result column no name.

Returns

Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the type of the constant; a constant is never NULL.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the constant.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 237§

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

Dedicated tests 6
Other tests reaching this symbol 231

Relations§

Instantiated in 7
Type checks 6