classFetch
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.
$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']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\InvalidConstructionProperties§
public bool $movepublic FetchMovement $movementpublic SignedNumber|null $countpublic Name $cursorMethods§
public function __construct(
public bool $move,
public FetchMovement $movement,
public SignedNumber|null $count,
public Name $cursor,
)Parameters
$move | bool | Whether the statement is MOVE, which returns no rows |
$movement | FetchMovement | Where the cursor moves |
$count | SignedNumber|null | The count of a counted movement |
$cursor | Name | The cursor name |
Throws
InvalidConstruction When the count does not fit the movement, or is not an integerCalls 2
- static-call Check::input() line 51
- method-call FetchMovement::counted() line 51
public function deriveStatement(Derivation $derivation): voidRecords the open rows of the cursor for FETCH.
Parameters
$derivation | Derivation |
Calls 4
- method-call Derivation::output() line 61
- new QueryFact line 61
- new OpenStar line 61
- new SessionState line 61
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 70
- method-call FetchMovement::write() line 71
- method-call Output::node() line 72
- class-const NameUse::Column() line 72
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
FetchTestcalls