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

A positional parameter reference, written $1, $2 and so on.

Rule: PG-PARAMETER-001. Facts: inside a list that declares parameter types (the parameters of a routine with an SQL-standard body, the types of PREPARE) the parameter has the declared type of its position and can be NULL; a number beyond the parameters of a routine is an undefined parameter, a number beyond the types of PREPARE is inferred from its use. Anywhere else the type and NULL fact depend on the value bound to the parameter, which no context declares. $0 and a number above 268435455 are undefined parameters. PostgreSQL 17 rejects a number above 2147483647 while scanning; PostgreSQL 16 converts it with C integer conversion, so there the bound parameter is the number reduced to 32 bits. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-EXPRESSIONS-PARAMETERS-POSITIONAL, https://www.postgresql.org/docs/17/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS, https://www.postgresql.org/docs/17/sql-prepare.html. Status: Implemented.

Reading the missing input of a parameterdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT $1');
    [$query->statement->targets[0]->expression->number, $query->field(0)->type->missing[0]->describe()] // => ['1', 'the value bound to parameter $1']

Properties§

public string $number

Methods§

public function __construct(public string $number)

Parameters

$numberstringThe parameter number as canonical decimal digits
Calls 2
public function outputName(): ?Name

Gives a result column no name.

Returns

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

Derives the declared type of the parameter, facts that depend on the bound value, or the diagnostic of an undefined parameter.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the parameter marker.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 14§

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

Dedicated tests 9
Other tests reaching this symbol 5

Relations§

Instantiated in 1
Type checks 1