classCreateForeignTable
final class CreateForeignTable
implements Relation, Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.A request to create a foreign table: a table whose rows a foreign server provides.
Mirrors PostgreSQL's CreateForeignTableStmt (a CreateStmt with servername and options). Like CREATE TABLE it provides a declaration (PG-TABLE-DECLARATION-001); its relation fact resolves to it. Source: https://www.postgresql.org/docs/17/sql-createforeigntable.html.
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("CREATE FOREIGN TABLE f (a int OPTIONS (column_name 'x') NOT NULL) SERVER s OPTIONS (table_name 'y')");
[$create->declarations()[0]->columns[0]->nullability, $create->toString()] // => [\SqlSemantics\Platform\PostgreSql\Model\Statement\Type\Nullability::NotNull, "CREATE FOREIGN TABLE f (a INT OPTIONS (column_name 'x') NOT NULL) SERVER s OPTIONS (table_name 'y')"]Properties§
public list<GenericOption> $optionspublic QualifiedName $namepublic ListedColumns|PartitionOf $definitionpublic Name $serverpublic bool $ifNotExists = falseMethods§
public function __construct(
public QualifiedName $name,
public ListedColumns|PartitionOf $definition,
public Name $server,
list<GenericOption> $options = [],
public bool $ifNotExists = false,
)Parameters
$name | QualifiedName | The table name |
$definition | ListedColumns|PartitionOf | The columns: a column list or a parent partitioned table |
$server | Name | The foreign server |
$options | list<GenericOption> | The options of the foreign table |
$ifNotExists | bool | Whether IF NOT EXISTS is written |
Calls 2
- static-call Check::listOf() line 58
- class-const GenericOption::class() line 58
public function deriveStatement(Derivation $derivation): voidProvides the declaration and derives the definition against it.
Parameters
$derivation | Derivation |
Calls 2
- method-call Definitions::derive() line 66
- new Definitions line 66
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactAnswers the facts of the new table: its row shape and the declaration, without providing it.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call Definitions::fact() line 74
- new Definitions line 74
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 82
- method-call Spelling::qualified() line 86
- new Spelling line 86
- method-call Output::node() line 87
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 1
Type checks 1
Type declarations 5
- type SqlSemantics\Platform\PostgreSql\Lowering\Table\CreateTableRule packages/sql-semantics-postgres/src/Lowering/Table/CreateTableRule.php:107
- type SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:59
- type SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:86
- type SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:96
- type SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:104