classStatementRewriter
final class StatementRewriter
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Statement rewriter operations for PostgreSQL session.
Methods§
public function __construct(
PgSqlCteShadowComposer $cteComposer,
PgSqlQueryGuard $guard,
PgSqlMutationResolver $mutationResolver,
PgSqlParser $parser,
PgSqlPartitionPredicateRenderer $partitionPredicateRenderer,
TableDefinitionRegistry $registry,
PgSqlReturningProjectionParser $returningProjectionParser,
ShadowStore $shadowStore,
PgSqlTransformer $transformer,
ViewDefinitionSet $views,
)Supplies the dependencies used by this StatementRewriter.
Parameters
$cteComposer | PgSqlCteShadowComposer | |
$guard | PgSqlQueryGuard | |
$mutationResolver | PgSqlMutationResolver | |
$parser | PgSqlParser | |
$partitionPredicateRenderer | PgSqlPartitionPredicateRenderer | |
$registry | TableDefinitionRegistry | |
$returningProjectionParser | PgSqlReturningProjectionParser | |
$shadowStore | ShadowStore | |
$transformer | PgSqlTransformer | |
$views | ViewDefinitionSet |
public function rewriteStatement(string $sql): RewritePlanRewrite statement.
Parameters
$sql | string |
Returns
Test cases 1
Called from 2
Calls 13
- static-call PgSqlReadOnlyDiagnosticStatement::isSafe() line 66
- new RewritePlan line 67
- class-const QueryKind::READ() line 67
- method-call PgSqlQueryGuard::classify() line 69
- new UnsupportedSqlException line 71
- class-const QueryKind::SKIPPED() line 74
- method-call PgSqlParser::classifyStatement() line 78
- method-call TableContext::buildTableContext() line 82
- new TableContext line 82
- method-call ShadowStore::getAll() line 82
- method-call StatementRewriter::validateReadTables() line 85
- method-call PgSqlTransformer::transform() line 87
- method-call StatementRewriter::rewriteMutation() line 92
public function validateReadTables(string $sql): voidRejects unknown physical relations while allowing CTE names declared by the statement.
Parameters
$sql | string |
Throws
Test cases 1
Called from 1
Calls 8
- method-call TableContext::hasSchemaContext() line 101
- new TableContext line 101
- method-call PgSqlParser::extractSelectTableNames() line 102
- function-call
array_fill_keysline 103 - method-call PgSqlCteShadowComposer::declaredCteNames() line 103
- function-call
strtolowerline 105 - method-call TableContext::tableExists() line 108
- new UnknownSchemaException line 109
public function rewriteMutation<T>(
string $sql,
QueryKind $kind,
?string $statementType,
array<string, array{viewSql: string}|array{rows: array<int, array<string, T>>, columns: array<int, string>, columnTypes: array<string, ColumnDeclaration>, columnDefaults: array<string, string>, identityStrategies: array<string, IdentityGenerationStrategy>, generatedExpressions: array<string, string>, sourceSql?: string, storageTable?: string}> $tableContext,
): RewritePlanConstructs the DDL or DML result-select plan and its simulated mutation.
Parameters
$sql | string | |
$kind | QueryKind | |
$statementType | ?string | |
$tableContext | array<string, array{viewSql: string}|array{rows: array<int, array<string, T>>, columns: array<int, string>, columnTypes: array<string, ColumnDeclaration>, columnDefaults: array<string, string>, identityStrategies: array<string, IdentityGenerationStrategy>, generatedExpressions: array<string, string>, sourceSql?: string, storageTable?: string}> |
Returns
Test cases 1
Called from 1
Calls 10
- class-const QueryKind::DDL_SIMULATED() line 123
- method-call PgSqlMutationResolver::resolve() line 124
- method-call PgSqlParser::hasCreateTableAsSelect() line 126
- method-call PgSqlParser::extractCreateTableSelectSql() line 127
- method-call PgSqlTransformer::transform() line 129
- new RewritePlan line 131
- class-const QueryKind::WRITE_SIMULATED() line 141
- method-call PgSqlReturningProjectionParser::parse() line 150
- class-const AffectedRowsMode::Changed() line 151
- class-const AffectedRowsMode::Matched() line 151
Private surface 10§
Implementation details, listed for orientation only.
private PgSqlCteShadowComposer $cteComposerprivate PgSqlQueryGuard $guardprivate PgSqlMutationResolver $mutationResolverprivate PgSqlParser $parserprivate PgSqlPartitionPredicateRenderer $partitionPredicateRendererprivate TableDefinitionRegistry $registryprivate PgSqlReturningProjectionParser $returningProjectionParserprivate ShadowStore $shadowStoreprivate PgSqlTransformer $transformerprivate ViewDefinitionSet $viewsTest cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 2
PgSqlSessionFactoryTestcallsPgSqlRewriterTestcalls