classTrailer
final class Trailer
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql\Lowering\Query". Code outside that scope must not name this declaration.
The clauses written after a query during lowering: ORDER BY, LIMIT, PROCEDURE ANALYSE, a trailing INTO and the locking clauses.
A lowering-time value: it collects the clauses until the query they belong to is known (MYSQL-SELECT-001) and is never part of a model.
Properties§
public list<OrderItem> $orderBy = []public Limit|null $limit = nullpublic ProcedureAnalyse|null $procedure = nullpublic list<LockingClause> $locking = []public IntoDestination|null $into = nullpublic IntoPosition|null $intoPosition = nullMethods§
public function __construct(
public list<OrderItem> $orderBy = [],
public Limit|null $limit = null,
public ProcedureAnalyse|null $procedure = null,
public list<LockingClause> $locking = [],
public IntoDestination|null $into = null,
public IntoPosition|null $intoPosition = null,
)Parameters
$orderBy | list<OrderItem> | The ORDER BY items |
$limit | Limit|null | The LIMIT clause |
$procedure | ProcedureAnalyse|null | The PROCEDURE ANALYSE clause |
$locking | list<LockingClause> | The locking clauses |
$into | IntoDestination|null | The trailing INTO destination |
$intoPosition | IntoPosition|null | Where the trailing INTO is written |
public function empty(): boolTells whether no clause is written.
Returns
boolTest cases 1
Called from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::earlier() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:115
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::enclosed() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:141
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::finish() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:86
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Trailer::then() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Trailer.php:66
public function then(self $later): selfCombines these clauses with the ones written after them around the same query.
Locking clauses accumulate in written order. A clause the server accepts only once is refused.
Parameters
$later | self |
Returns
selfThrows
AnalysisException When ORDER BY, INTO or PROCEDURE ANALYSE is written twice, which no grammar derives and the server rejects while parsing (ER_SYNTAX_ERROR)ImplementationGap When LIMIT is written twice, where the 5.6 server lets the later one replace the earlierTest cases 3
Called from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:136
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:140
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::then() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:68
Calls 5
- method-call Trailer::empty() line 66
- method-call
self::empty()line 69 - static-call ImplementationGap::rule() line 73
- new AnalysisException line 76
- new
selfline 79
Wraps a query that is not a single query block in the clauses: ordering and limit first, then INTO and locking.
Parameters
$query | Query |
Returns
Throws
AnalysisException When PROCEDURE ANALYSE follows a query that is not a single query block (ER_WRONG_USAGE of the 5.6 `procedure_analyse_clause` action and of 5.7 `PT_procedure_analyse::contextualize`: PROCEDURE ANALYSE belongs to the outermost first query block)Test cases 2
Called from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::enclosed() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:145
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:124
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:126
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::finish() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:90
Calls 3
Test cases 23§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
TrailerTest::testEmptyTellsWhetherAClauseIsWrittencallsTrailerTest::testThenAccumulatesLockingClausescallsTrailerTest::testThenCombinesTheClausesOfBothTrailerscallsTrailerTest::testThenRejectsAClauseWrittenTwicecallsTrailerTest::testWrapPutsTheOrderingAndTheLockingAroundAQuerycallsTrailerTest::testWrapRejectsProcedureAnalysecalls
Other tests reaching this symbol 17
ChainTest::testEarlierKeepsALimitBeforeTheLastOperandIn56callsChainTest::testEarlierRejectsALimitBeforeTheLastOperandIn57callsChainTest::testEarlierRejectsAnOrderingAfterTheFirstOperandOfASubqueryUnioncallsChainTest::testEnclosedKeepsTheClausesAfterTheFirstParenthesizedOperandcallsChainTest::testEnclosedRejectsAnOrderingAfterAParenthesizedOperandThatLimitsItselfcallsChainTest::testEnclosedRejectsClausesAfterALaterParenthesizedOperandcallsChainTest::testQueryKeepsTheOwnClausesOfAMiddleSelectInALeadingUnioncallsChainTest::testQueryLiftsTheClausesOfTheLastBlockcallsChainTest::testQueryOrdersAUnionAfterTheClausesOfItsLastBlockcallsBlockTest::testBareDropsTheClausesWrittenAfterTheBlockcallsBlockTest::testFinishKeepsALaterOrderingAfterTheLockingClausesAsTheBlocksOwncallsBlockTest::testFinishKeepsASecondLimitAsTheLimitThatReplacesTheFirstcallsBlockTest::testFinishOrdersTheRowsOfABlockThatLimitsItsRowscallsBlockTest::testFinishWritesClausesInPlaceWhenNothingOfTheBlockPrecedesThemcallsBlockTest::testSelectReadsATrailingIntoWithoutClausesAsTheIntoAfterTheSelectListcallsBlockTest::testSelectRejectsTwoIntoClausescallsBlockTest::testThenAddsTheClausesWrittenAfterTheBlockcalls
Relations§
Instantiated in 30
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:58
- 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:102
- 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:140
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:174
- 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:207
- 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\Legacy\BlockRule::optional() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:224
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:260
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::__construct() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:56
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\SubqueryRule::operand() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/SubqueryRule.php:106
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::chain() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:112
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::chain() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:114
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::chain() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:133
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:158
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:160
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:161
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::statement() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:77
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::statement() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:78
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:96
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:97
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:98
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:117
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::locked() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:210
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::locked() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:211
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::query() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:91
- new SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::__construct() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:57
Method calls 11
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:136
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:140
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::earlier() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:115
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::enclosed() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:141
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::enclosed() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:145
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:124
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:126
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::then() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:68
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::finish() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:86
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block::finish() packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:90
Type declarations 9
- 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\Chain packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:56
- 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\Chain packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:134
- type SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:152
- type SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:108
- type SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:57
- type SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:66
- type SqlSemantics\Platform\MySql\Lowering\Query\Shared\Block packages/sql-semantics-mysql/src/Lowering/Query/Shared/Block.php:83