classCopyQuery
final class CopyQuery
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.COPY of the rows of a query to a file, a program or the client.
Mirrors PostgreSQL's CopyStmt with a query. The query is a query statement or a data-modifying statement with RETURNING. The facts follow PG-COPY-001. Source: https://www.postgresql.org/docs/17/sql-copy.html. Status: Implemented.
$copy = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("COPY (SELECT 1) TO '/tmp/x' CSV");
[$copy->statement->query instanceof \SqlSemantics\Platform\PostgreSql\Statement\Query\Select, $copy->toString()] // => [true, "COPY (SELECT 1) TO '/tmp/x' CSV"]Properties§
public list<CopyOption> $optionspublic Query $querypublic bool $programpublic StringConstant|CopyStream $fileMethods§
public function __construct(
public Query $query,
public bool $program,
public StringConstant|CopyStream $file,
list<CopyFlag|CopyText|CopyForce> $legacy = [],
list<CopyOption> $options = [],
)Parameters
$query | Query | The query: a query statement or a data-modifying statement |
$program | bool | Whether the file is a program |
$file | StringConstant|CopyStream | The file name or command, or the client |
$legacy | list<CopyFlag|CopyText|CopyForce> | The options of the old syntax |
$options | list<CopyOption> | The parenthesized options |
Throws
InvalidConstruction When the query is no statement, both kinds of options are written, or a list holds a foreign itemCalls 10
- static-call Check::input() line 58
- method-call Sources::statement() line 58
- new Sources line 58
- method-call ClosedList::of() line 59
- new ClosedList line 59
- class-const CopyFlag::class() line 59
- class-const CopyText::class() line 59
- class-const CopyForce::class() line 59
- static-call Check::listOf() line 60
- class-const CopyOption::class() line 60
public function deriveStatement(Derivation $derivation): voidDerives the query and the options.
Parameters
$derivation | Derivation |
Calls 2
- method-call CopyFacts::query() line 69
- new CopyFacts line 69
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 77
- method-call Output::node() line 81
- method-call Output::symbol() line 86
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
CopyQueryTestcalls