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|null

Answers the transaction statement a statement is, if it is one.

Parameters

$sqlstringStatement as it was written

Returns

TransactionStatement|null What it does to the transaction, or null when it is not one
Called from 1
public function emptyResultSelect(): string

Answers a SELECT this dialect accepts and that yields no rows.

Returns

string The statement
Called 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

$sqlstringBatch as it was written

Returns

list<string> The statements, in the order they were written
Called from 1
public function rewrite(string $sql): RewritePlan

Answers the plan for a statement, or for the first of a batch.

Parameters

$sqlstringStatement as it was written

Returns

RewritePlan What ZTD will carry out instead of it

Throws

UnsupportedSqlException When ZTD cannot simulate the statement
UnknownSchemaException When the statement names a table nothing has described
Called from 1
public function rewriteMultiple(string $sql): MultiRewritePlan

Answers a plan for each statement of a batch.

Parameters

$sqlstringBatch as it was written

Returns

MultiRewritePlan What ZTD will carry out instead of each of them

Throws

UnsupportedSqlException When ZTD cannot simulate one of the statements
UnknownSchemaException When one of them names a table nothing has described

Test 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

Relations§

Implemented by 3
Method calls 5
Type declarations 3