classCreateTableAsExecute
final class CreateTableAsExecute
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.A request to create a table from the rows of a prepared statement: CREATE TABLE ... AS EXECUTE.
Mirrors PostgreSQL's CreateTableAsStmt whose query is an ExecuteStmt. The columns are those of the prepared statement, which a context does not declare: the statement provides a declaration of the table with its system columns and no known column (PG-QUERY-TABLE-001). Source: https://www.postgresql.org/docs/17/sql-createtableas.html.
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t AS EXECUTE q (1) WITH DATA');
[$create->declarations()[0]->complete, $create->toString()] // => [false, 'CREATE TABLE t AS EXECUTE q (1) WITH DATA']Properties§
public CreateTarget $targetpublic Statement $executepublic Persistence $persistence = Persistence::Permanentpublic bool $ifNotExists = falsepublic bool|null $withData = nullMethods§
public function __construct(
public CreateTarget $target,
public Statement $execute,
public Persistence $persistence = Persistence::Permanent,
public bool $ifNotExists = false,
public bool|null $withData = null,
)Parameters
$target | CreateTarget | The new table |
$execute | Statement | The EXECUTE statement |
$persistence | Persistence | The persistence |
$ifNotExists | bool | Whether IF NOT EXISTS is written |
$withData | bool|null | True for WITH DATA, false for WITH NO DATA, null when not written |
Calls 1
- class-const Persistence::Permanent() line 45
public function deriveStatement(Derivation $derivation): voidDerives the EXECUTE statement and provides the declaration of the table.
Parameters
$derivation | Derivation |
Calls 9
- method-call Derivation::member() line 56
- method-call CreationSchemas::check() line 57
- new CreationSchemas line 57
- method-call QueryTables::name() line 58
- new QueryTables line 58
- method-call Derivation::declare() line 59
- new Table line 59
- method-call SystemColumns::implicit() line 59
- new SystemColumns line 59
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 67
- method-call Output::node() line 71
- method-call Writing::withData() line 72
- new Writing line 72
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
CreateTableAsExecuteTestcalls