classQueryTables
final class QueryTables
Derives the declaration of a relation defined by a query: CREATE TABLE AS, CREATE VIEW, CREATE MATERIALIZED VIEW.
Rule: PG-QUERY-TABLE-001. The relation has one column per output column of the query, in order; the written column names rename the first columns, and more names than columns is an error. A column of type unknown (an untyped string constant) is text. The columns of a table made by CREATE TABLE AS have no constraints and can be NULL; the columns of a view or a materialized view hold exactly the rows of the query and keep its NULL facts. A column whose type depends on declarations the context does not hold is declared with the type those inputs settle (PG-DECLARED-TYPE-001); the declaration is complete only up to the first output whose name or position the context cannot know (an open row) or whose type is invalid. A temporary relation with an unqualified name belongs to pg_temp. Tables and materialized views have the system columns; views do not. The declaration states the kind of the relation (PG-RELATION-KIND-001). Two columns of one name are an error. Source: https://www.postgresql.org/docs/17/sql-createtableas.html, https://www.postgresql.org/docs/17/sql-createview.html, https://www.postgresql.org/docs/17/sql-creatematerializedview.html. Termination: one pass over the output columns. Status: Implemented.
Methods§
public function name(
QualifiedName $written,
Persistence $persistence,
?Name $schema,
): QualifiedNameAnswers the name a relation is declared under; $schema is the schema of an enclosing CREATE SCHEMA.
Parameters
$written | QualifiedName | |
$persistence | Persistence | |
$schema | ?Name |
Returns
Test cases 1
Called from 5
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Sequences::create() packages/sql-semantics-postgres/src/Rules/Table/Definition/Sequences.php:49
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Views::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Views.php:50
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAs::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAs.php:66
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAsExecute::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAsExecute.php:58
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\View\CreateMaterializedView::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/View/CreateMaterializedView.php:88
Calls 3
- method-call Persistence::temporary() line 55
- new QualifiedName line 56
- new Name line 56
public function table(
Derivation $derivation,
QualifiedName $name,
QueryFact $fact,
list<Name> $names,
RelationKind $kind,
DefinitionRule $tooMany = DefinitionRule::TableColumnCount,
): TableBuilds the declaration of the relation a query defines and reports the problems of its column names.
Parameters
$derivation | Derivation | |
$name | QualifiedName | |
$fact | QueryFact | |
$names | list<Name> | The written column names |
$kind | RelationKind | A base table, whose columns can all be NULL, a view, which has no system columns, or a materialized view |
$tooMany | DefinitionRule |
Returns
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Views::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Views.php:50
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAs::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAs.php:66
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\View\CreateMaterializedView::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/View/CreateMaterializedView.php:88
Calls 14
- class-const DefinitionRule::TableColumnCount() line 68
- class-const RelationKind::BaseTable() line 70
- new DeclaredTyping line 74
- method-call DeclaredTyping::defined() line 77
- method-call Derivation::report() line 83
- new DefinitionProblem line 83
- class-const DefinitionRule::DuplicateColumn() line 83
- new Column line 86
- class-const Nullability::Nullable() line 86
- function-call
countline 88 - new Table line 92
- class-const RelationKind::View() line 92
- method-call SystemColumns::implicit() line 92
- new SystemColumns line 92
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 5
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Sequences::create() packages/sql-semantics-postgres/src/Rules/Table/Definition/Sequences.php:49
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Views::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Views.php:49
- new SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAs::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAs.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAsExecute::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAsExecute.php:58
- new SqlSemantics\Platform\PostgreSql\Statement\Table\View\CreateMaterializedView::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/View/CreateMaterializedView.php:86
Method calls 8
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Sequences::create() packages/sql-semantics-postgres/src/Rules/Table/Definition/Sequences.php:49
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Views::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Views.php:50
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Views::derive() packages/sql-semantics-postgres/src/Rules/Table/Definition/Views.php:50
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAs::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAs.php:66
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAs::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAs.php:66
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\CreateTableAsExecute::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/CreateTableAsExecute.php:58
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\View\CreateMaterializedView::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/View/CreateMaterializedView.php:88
- method-call SqlSemantics\Platform\PostgreSql\Statement\Table\View\CreateMaterializedView::deriveStatement() packages/sql-semantics-postgres/src/Statement/Table/View/CreateMaterializedView.php:88