interfaceSqlRewriter
interface SqlRewriter
Turns a statement into the plan ZTD will carry out instead of it.
Every dialect reads its own SQL, so each database package implements this; what the session does with the answer is the same whichever one it came from. Two things an implementation may refuse are part of the contract rather than accidents of it: a statement ZTD cannot simulate, and a table nothing has told it about. The session decides what to do about each, because what should happen is a matter of configuration.
Methods§
public function transactionStatement(string $sql): TransactionStatement|nullAnswers the transaction statement a statement is, if it is one.
Parameters
$sql | string | Statement as it was written |
Returns
TransactionStatement|null What it does to the transaction, or null when it is not oneCalled from 1
public function emptyResultSelect(): stringAnswers a SELECT this dialect accepts and that yields no rows.
Returns
string The statementCalled from 1
public function splitStatements(string $sql): list<string>Splits a batch into the statements it is written as.
Splitting is lexical: a semicolon inside a string, a comment or a dollar-quoted body does not end a statement, and which of those exist is a property of the dialect.
Parameters
$sql | string | Batch as it was written |
Returns
list<string> The statements, in the order they were writtenCalled from 1
public function rewrite(string $sql): RewritePlanAnswers the plan for a statement, or for the first of a batch.
Parameters
$sql | string | Statement as it was written |
Returns
RewritePlan What ZTD will carry out instead of itThrows
UnsupportedSqlException When ZTD cannot simulate the statementUnknownSchemaException When the statement names a table nothing has describedCalled from 1
public function rewriteMultiple(string $sql): MultiRewritePlanAnswers a plan for each statement of a batch.
Parameters
$sql | string | Batch as it was written |
Returns
MultiRewritePlan What ZTD will carry out instead of each of themThrows
UnsupportedSqlException When ZTD cannot simulate one of the statementsUnknownSchemaException When one of them names a table nothing has describedTest cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Other tests reaching this symbol 4
RewriterContractTestcallsExceptionThrowingRewritercallsFakeSqlRewritercallsFixedRewritercalls
Relations§
Implemented by 3
Method calls 5
- method-call ZtdQuery\Session::transactionStatement() packages/ztd-query-core/src/Session.php:230
- method-call ZtdQuery\Session::rewrite() packages/ztd-query-core/src/Session.php:317
- method-call ZtdQuery\Session::rewrite() packages/ztd-query-core/src/Session.php:321
- method-call ZtdQuery\Session::splitStatements() packages/ztd-query-core/src/Session.php:330
- method-call ZtdQuery\Shadow\ShadowApplication::apply() packages/ztd-query-core/src/Shadow/ShadowApplication.php:86