classBlock
final class Block
The parts of one query block during lowering, before the clauses written after it are known.
A lowering-time value: the trailing clauses of the block are collected in a trailer until the block is finished into a selection. An INTO written after the clauses of a block that writes none of them is the INTO after the select list, which is how the parser reads its text. The ORDER BY and LIMIT a 5.6 subquery writes after a block are added by finish().
Properties§
public list<SelectOption> $optionspublic list<SelectExpression|Star|TableWildcard> $itemspublic IntoDestination|null $into = nullpublic Relation|null $from = nullpublic Scalar|null $where = nullpublic Grouping|null $groupBy = nullpublic Scalar|null $having = nullpublic list<WindowDefinition> $windows = []public Scalar|null $qualify = nullpublic Trailer $trailer = new \SqlSemantics\Platform\MySql\Lowering\Query\Shared\Trailer()Methods§
public function __construct(
public list<SelectOption> $options,
public list<SelectExpression|Star|TableWildcard> $items,
public IntoDestination|null $into = null,
public Relation|null $from = null,
public Scalar|null $where = null,
public Grouping|null $groupBy = null,
public Scalar|null $having = null,
public list<WindowDefinition> $windows = [],
public Scalar|null $qualify = null,
public Trailer $trailer = new \SqlSemantics\Platform\MySql\Lowering\Query\Shared\Trailer(),
)Parameters
$options | list<SelectOption> | The modifiers |
$items | list<SelectExpression|Star|TableWildcard> | The select list |
$into | IntoDestination|null | The INTO destination after the select list |
$from | Relation|null | The FROM clause |
$where | Scalar|null | The row predicate |
$groupBy | Grouping|null | The GROUP BY clause |
$having | Scalar|null | The group predicate |
$windows | list<WindowDefinition> | The named windows |
$qualify | Scalar|null | The QUALIFY predicate |
$trailer | Trailer | The clauses written after the block |
public function then(Trailer $later): selfAnswers the block with further clauses written after it.
Parameters
$later | Trailer |
Returns
selfThrows
AnalysisException When a clause is written twiceTest cases 11
ChainTest::testEarlierKeepsALimitBeforeTheLastOperandIn56callsChainTest::testEarlierRejectsALimitBeforeTheLastOperandIn57callsChainTest::testQueryKeepsTheOwnClausesOfAMiddleSelectInALeadingUnioncallsChainTest::testQueryLiftsTheClausesOfTheLastBlockcallsChainTest::testQueryOrdersAUnionAfterTheClausesOfItsLastBlockcallsBlockTest::testBareDropsTheClausesWrittenAfterTheBlockcallsBlockTest::testFinishKeepsALaterOrderingAfterTheLockingClausesAsTheBlocksOwncallsBlockTest::testFinishKeepsASecondLimitAsTheLimitThatReplacesTheFirstcallsBlockTest::testFinishOrdersTheRowsOfABlockThatLimitsItsRowscallsBlockTest::testSelectReadsATrailingIntoWithoutClausesAsTheIntoAfterTheSelectListcallsBlockTest::testThenAddsTheClausesWrittenAfterTheBlockcalls
Called from 1
Calls 2
- new
selfline 68 - method-call Trailer::then() line 68
Finishes the block with the ORDER BY and LIMIT a 5.6 subquery writes after it (opt_union_order_or_limit).
An ORDER BY after a block that already orders or limits its rows orders the rows of the block in a query level of its own (the 5.6 order_clause action adds a fake query block). Otherwise the clauses are the block's own: written in place when nothing of the block stands between, and kept as a late ordering after the block's locking clauses or after its own LIMIT, which a later LIMIT replaces.
Parameters
$later | Trailer |
Returns
Throws
AnalysisException When INTO is written twice (see `select()`)Called from 1
Calls 5
- method-call Trailer::empty() line 86
- method-call Block::select() line 87
- method-call Trailer::wrap() line 90
- new LateOrdering line 94
- method-call Block::then() line 97
public function bare(): selfpublic function select(LateOrdering|null $late = null): SelectFinishes the block into a selection.
Parameters
$late | LateOrdering|null | The ORDER BY and LIMIT a 5.6 subquery writes after the locking clauses or the LIMIT of the block |
Returns
Throws
AnalysisException When INTO is written twice, which the server rejects while parsing (ER_SYNTAX_ERROR of the 5.7 `select_part2` action, ER_MULTIPLE_INTO_CLAUSES of 8.0 `PT_select_stmt::make_cmd`, right after contextualizing; the 5.6 grammar has no such form)Test cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::finish() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:87
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::finish() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:90
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::finish() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:94
Calls 4
- new AnalysisException line 118
- class-const IntoPosition::AfterItems() line 121
- class-const IntoPosition::AfterQuery() line 124
- new Select line 128
Test cases 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
BlockTest::testBareDropsTheClausesWrittenAfterTheBlockcallsBlockTest::testFinishKeepsALaterOrderingAfterTheLockingClausesAsTheBlocksOwncallsBlockTest::testFinishKeepsASecondLimitAsTheLimitThatReplacesTheFirstcallsBlockTest::testFinishOrdersTheRowsOfABlockThatLimitsItsRowscallsBlockTest::testFinishWritesClausesInPlaceWhenNothingOfTheBlockPrecedesThemcallsBlockTest::testSelectReadsATrailingIntoWithoutClausesAsTheIntoAfterTheSelectListcallsBlockTest::testSelectRejectsTwoIntoClausescallsBlockTest::testThenAddsTheClausesWrittenAfterTheBlockcalls
Other tests reaching this symbol 9
ChainTest::testEarlierKeepsALimitBeforeTheLastOperandIn56callsChainTest::testEarlierRejectsALimitBeforeTheLastOperandIn57callsChainTest::testEarlierRejectsAnOrderingAfterTheFirstOperandOfASubqueryUnioncallsChainTest::testEnclosedKeepsTheClausesAfterTheFirstParenthesizedOperandcallsChainTest::testEnclosedRejectsAnOrderingAfterAParenthesizedOperandThatLimitsItselfcallsChainTest::testEnclosedRejectsClausesAfterALaterParenthesizedOperandcallsChainTest::testQueryKeepsTheOwnClausesOfAMiddleSelectInALeadingUnioncallsChainTest::testQueryLiftsTheClausesOfTheLastBlockcallsChainTest::testQueryOrdersAUnionAfterTheClausesOfItsLastBlockcalls
Relations§
Instantiated in 10
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:62
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:66
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:92
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:136
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:137
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:164
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:176
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:197
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::optional() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:223
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:90
Method calls 1
Type checks 6
- instanceof SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::query() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:73
- instanceof SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::query() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:77
- instanceof SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::query() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:85
- instanceof SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:119
- instanceof SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::body() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:150
- instanceof SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::body() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:153
Type declarations 15
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:51
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:80
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:131
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:157
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:188
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:218
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:234
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:252
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:103
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:135
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:110
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:187
- type SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:134
- type SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:65
- type SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:82