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

SUBSTRING (string FROM start FOR count) and its partial forms.

The server calls pg_catalog.substring(string, start[, count]). With FOR alone it passes 1 as the start and the count cast to integer; FOR may also be written before FROM, which the model keeps because the tokens differ. With FROM alone and a text start the call is the POSIX pattern form. Rule: PG-SUBSTRING-001. Facts: those of the call (PG-CALL-RESULT-001; the type of the string for text, bytea and bit). The result column is named substring. Source: https://www.postgresql.org/docs/17/functions-string.html. Status: Implemented.

Reading a substring with a count onlydoctest
$substring = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Substring(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral(), null, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral());
    [$substring->start, $substring->outputName()->value] // => [null, 'substring']
Rejecting a substring without start and countdoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Text\Substring(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public Scalar $string
public Scalar|null $start = null
public Scalar|null $count = null
public bool $countFirst = false

Methods§

public function __construct(
    public Scalar $string,
    public Scalar|null $start = null,
    public Scalar|null $count = null,
    public bool $countFirst = false,
)

Parameters

$stringScalarThe string
$startScalar|nullThe position of the first character, after FROM
$countScalar|nullThe number of characters, after FOR
$countFirstboolWhether FOR is written before FROM
Calls 1
public function outputName(): Name

Names an unaliased result column after the function the server calls.

Returns

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

Derives the operands and the result of pg_catalog.substring.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes SUBSTRING with FROM and FOR in the order written.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 5§

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

Dedicated tests 5

Relations§

Instantiated in 4