final class Fetch
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

FETCH or MOVE: rows read from a cursor, or the cursor only repositioned.

Mirrors PostgreSQL's FetchStmt (direction, howMany, portalname, ismove). FROM or IN before the cursor name are noise words. Rule: PG-FETCH-001: the cursor is session state, so FETCH returns an open shape that depends on it; MOVE returns no rows. Source: https://www.postgresql.org/docs/17/sql-fetch.html, https://www.postgresql.org/docs/17/sql-move.html. Status: Implemented.

Reading a FETCHdoctest
$fetch = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('FETCH ABSOLUTE 3 IN c');
    [$fetch->statement->count->magnitude->digits, $fetch->shape()->complete(), $fetch->toString()] // => ['3', false, 'FETCH ABSOLUTE 3 c']
Refusing a count where the movement takes nonedoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Cursor\Fetch(false, \SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Cursor\FetchMovement::Next, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\SignedNumber(false, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('1')), new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('c')) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public bool $move
public FetchMovement $movement
public SignedNumber|null $count
public Name $cursor

Methods§

public function __construct(
    public bool $move,
    public FetchMovement $movement,
    public SignedNumber|null $count,
    public Name $cursor,
)

Parameters

$moveboolWhether the statement is MOVE, which returns no rows
$movementFetchMovementWhere the cursor moves
$countSignedNumber|nullThe count of a counted movement
$cursorNameThe cursor name

Throws

InvalidConstruction When the count does not fit the movement, or is not an integer
Calls 2
public function deriveStatement(Derivation $derivation): void

Records the open rows of the cursor for FETCH.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 4

Test cases 3§

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

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 1
Type declarations 1