classTableContext
final class TableContext
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Schema context operations for PostgreSQL session.
Methods§
public function __construct(
PgSqlPartitionPredicateRenderer $partitionPredicateRenderer,
TableDefinitionRegistry $registry,
ShadowStore $shadowStore,
ViewDefinitionSet $views,
)Supplies the dependencies used by this TableContext.
Parameters
$partitionPredicateRenderer | PgSqlPartitionPredicateRenderer | |
$registry | TableDefinitionRegistry | |
$shadowStore | ShadowStore | |
$views | ViewDefinitionSet |
public function buildTableContext<T>(array<string, array<int, array<string, T>>> $allData): 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}>Build the table context map for transformers.
Parameters
$allData | array<string, array<int, array<string, T>>> |
Returns
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}>Test cases 1
Called from 1
Calls 6
- method-call TableContext::dataContext() line 55
- method-call TableContext::fillDefinitions() line 56
- method-call TableContext::applyPartitions() line 57
- method-call PgSqlViewShadowRenderer::render() line 59
- new PgSqlViewShadowRenderer line 59
- function-call
array_keysline 59
public function tableExists(string $tableName): boolTable exists.
Parameters
$tableName | string |
Returns
boolCalled from 1
Calls 3
- method-call ShadowStore::has() line 74
- method-call TableDefinitionRegistry::has() line 78
- method-call ViewDefinitionSet::has() line 82
public function hasSchemaContext(): boolHas schema context.
Returns
boolTest cases 1
Called from 1
Calls 3
- method-call ShadowStore::getAll() line 94
- method-call TableDefinitionRegistry::hasAnyTables() line 98
- method-call ViewDefinitionSet::hasAnyViews() line 102
public function dataContext<T>(array<string, array<int, array<string, T>>> $allData): array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}>Derives declaration metadata and columns for materialized shadow rows.
Parameters
$allData | array<string, array<int, array<string, T>>> |
Returns
array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}>Test cases 3
Called from 1
Calls 3
- method-call TableDefinitionRegistry::get() line 119
- function-call
array_keysline 122 - function-call
in_arrayline 125
public function fillDefinitions<T>(array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}> $context): array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}>Adds reflected tables that have no materialized shadow rows yet.
Parameters
$context | array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}> |
Returns
array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}>Test cases 2
Called from 1
Calls 1
- method-call TableDefinitionRegistry::getAll() line 161
public function applyPartitions<T>(
array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}> $context,
array<string, array<int, array<string, T>>> $allData,
): array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}>Projects child partitions from their shared storage table and sibling predicates.
Parameters
$context | array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}> | |
$allData | array<string, array<int, array<string, T>>> |
Returns
array<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>, primaryKeys: array<int, string>, candidateKeys: array<string, array<int, string>>, partialUniqueIndexes: array<string, PartialUniqueIndex>, sourceSql?: string, storageTable?: string}>Test cases 1
Called from 1
Calls 7
- method-call TableDefinitionRegistry::getAll() line 193
- new PgSqlIdentifierQuoter line 194
- function-call
strcasecmpline 205 - method-call PgSqlPartitionPredicateRenderer::render() line 211
- method-call StorageTable::storageTable() line 212
- new StorageTable line 212
- method-call PgSqlIdentifierQuoter::quote() line 220
Private surface 4§
Implementation details, listed for orientation only.
private PgSqlPartitionPredicateRenderer $partitionPredicateRendererprivate TableDefinitionRegistry $registryprivate ShadowStore $shadowStoreprivate ViewDefinitionSet $viewsTest cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
TableContextTest::testApplyPartitionsUsesSharedParentRowscallsTableContextTest::testBuildTableContextIncludesShadowTablesAndViewscallsTableContextTest::testDataContextInfersTheUnionOfUnknownRowColumnscallsTableContextTest::testFillDefinitionsRetainsExistingRowsAndAddsUnmaterializedTablescallsTableContextTest::testHasSchemaContextTracksMutableRegistryStatecallsTableContextTest::testTableExistsIncludesRegisteredMaterializedAndViewNamescalls
Other tests reaching this symbol 3
PgSqlSessionFactoryTestcallsPgSqlRewriterTestcallsStatementRewriterTestcalls
Relations§
Instantiated in 3
- new ZtdQuery\Platform\Postgres\Rewrite\StatementRewriter::rewriteStatement() packages/ztd-query-postgres/src/Rewrite/StatementRewriter.php:82
- new ZtdQuery\Platform\Postgres\Rewrite\StatementRewriter::validateReadTables() packages/ztd-query-postgres/src/Rewrite/StatementRewriter.php:101
- new ZtdQuery\Platform\Postgres\Rewrite\StatementRewriter::validateReadTables() packages/ztd-query-postgres/src/Rewrite/StatementRewriter.php:108
Method calls 3
- method-call ZtdQuery\Platform\Postgres\Rewrite\StatementRewriter::rewriteStatement() packages/ztd-query-postgres/src/Rewrite/StatementRewriter.php:82
- method-call ZtdQuery\Platform\Postgres\Rewrite\StatementRewriter::validateReadTables() packages/ztd-query-postgres/src/Rewrite/StatementRewriter.php:101
- method-call ZtdQuery\Platform\Postgres\Rewrite\StatementRewriter::validateReadTables() packages/ztd-query-postgres/src/Rewrite/StatementRewriter.php:108