classLimitRule
final class LimitRule
Lowers the LIMIT, OFFSET, FETCH and locking clauses.
Rule: PG-LIMIT-LOWER-001. Scope: opt_select_limit, select_limit, limit_clause, offset_clause, select_limit_value, select_offset_value, select_fetch_first_value, first_or_next, row_or_rows, opt_for_locking_clause, for_locking_clause, for_locking_items, for_locking_item, for_locking_strength, locked_rels_list, opt_nowait_or_skip. Constructors: RowLimit, LimitCount, CommaLimit, FetchFirst, Offset, LockingClause. FIRST and NEXT, ROW and ROWS are noise words; a plus sign before a numeric constant in FETCH and OFFSET … ROWS is dropped by the server, a minus sign negates it as it does in an expression. Termination: lists are flattened iteratively. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-LIMIT, https://www.postgresql.org/docs/17/sql-select.html#SQL-FOR-UPDATE-SHARE. Status: Implemented.
Methods§
Lowers opt_select_limit or select_limit; no clause is null.
Parameters
$limit | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 5
- method-call LimitRule::limit() line 70
- new RowLimit line 71
- method-call LimitRule::count() line 71
- method-call LimitRule::offset() line 71
- static-call ImplementationGap::production() line 75
public function count(Node $clause): LimitCount|CommaLimit|FetchFirstLowers limit_clause.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::limit() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:71
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::limit() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:72
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::limit() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:73
Calls 7
- new LimitCount line 89
- method-call LimitRule::limitValue() line 89
- new CommaLimit line 90
- method-call LimitRule::offsetValue() line 90
- method-call LimitRule::fetch() line 91
- method-call LimitRule::fetchValue() line 91
- static-call ImplementationGap::production() line 95
public function fetch(Form $form, ?Scalar $count, bool $withTies, int $rows): FetchFirstBuilds a FETCH FIRST clause after claiming its first_or_next and row_or_rows noise words.
Returns
Test cases 1
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::count() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:91
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::count() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:92
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::count() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:93
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::count() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:94
Calls 4
- method-call LimitRule::noise() line 104
- method-call Form::node() line 104
- method-call LimitRule::rows() line 105
- new FetchFirst line 107
Lowers offset_clause.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::limit() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:71
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::limit() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:72
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::limit() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:74
Calls 4
- new Offset line 120
- method-call LimitRule::offsetValue() line 120
- method-call LimitRule::rowsOffset() line 121
- static-call ImplementationGap::production() line 122
Lowers OFFSET select_fetch_first_value row_or_rows.
Parameters
$form | Form |
Returns
Test cases 1
Called from 1
Calls 4
- method-call LimitRule::rows() line 131
- method-call Form::node() line 131
- new Offset line 133
- method-call LimitRule::fetchValue() line 133
public function rows(Node $rows): voidClaims a row_or_rows noise word.
Parameters
$rows | Node |
Test cases 1
Called from 2
Calls 1
- method-call LimitRule::noise() line 141
public function noise(Node $node, string ...$signatures): voidChecks that a noise nonterminal is one of its productions.
Parameters
$node | Node | |
$signatures | string |
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 2
- function-call
in_arrayline 152 - static-call ImplementationGap::production() line 153
Lowers select_limit_value; ALL is null.
Parameters
$value | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 1
- static-call ImplementationGap::production() line 169
Lowers select_offset_value.
Parameters
$value | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 1
- static-call ImplementationGap::production() line 184
Lowers select_fetch_first_value.
Parameters
$value | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::count() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:91
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::count() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:92
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::rowsOffset() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:133
Calls 2
- new Constant line 199
- static-call ImplementationGap::production() line 201
public function locking(Node $clause): array{list<LockingClause>, bool}Lowers opt_for_locking_clause or for_locking_clause: the locking clauses and whether FOR READ ONLY is written.
Parameters
$clause | Node |
Returns
array{list<LockingClause>, bool}Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 3
- method-call LimitRule::locking() line 218
- method-call LimitRule::items() line 220
- static-call ImplementationGap::production() line 221
public function items(Node $items): list<LockingClause>Lowers for_locking_items.
Parameters
$items | Node |
Returns
list<LockingClause>Throws
ImplementationGap When an item has no ruleTest cases 1
Called from 1
Calls 5
- method-call Lowering::items() line 235
- static-call ImplementationGap::production() line 238
- new LockingClause line 242
- class-const LimitRule::STRENGTHS() line 243
- method-call LimitRule::wait() line 249
Lowers opt_nowait_or_skip; waiting is null.
Parameters
$wait | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 3
- class-const LockWait::NoWait() line 266
- class-const LockWait::SkipLocked() line 267
- static-call ImplementationGap::production() line 269
Private surface 2§
Implementation details, listed for orientation only.
private const STRENGTHS = ['for_locking_strength: FOR UPDATE' => \SqlSemantics\Platform\PostgreSql\Statem…private Lowering $loweringTest cases 13§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 13
LimitRuleTest::testCountLowersLimitAllcallsLimitRuleTest::testFetchReadsWithTiescallsLimitRuleTest::testFetchValueNegatesTheConstantcallsLimitRuleTest::testItemsLowersEveryClausecallsLimitRuleTest::testLimitKeepsTheOffsetFirstcallsLimitRuleTest::testLimitValueIsNullForAllcallsLimitRuleTest::testLockingReadsReadOnlycallsLimitRuleTest::testNoiseRefusesAnotherProductioncallsLimitRuleTest::testOffsetLowersTheStartcallsLimitRuleTest::testOffsetValueLowersTheExpressioncallsLimitRuleTest::testRowsClaimsTheNoiseWordcallsLimitRuleTest::testRowsOffsetLowersTheStandardSpellingcallsLimitRuleTest::testWaitReadsSkipLockedcalls
Relations§
Instantiated in 2
Method calls 2
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::options() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:63
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::options() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:64