final class CopyFacts
Restricted visibility: declared "@visibility SqlSemantics\Platform\PostgreSql". Code outside that scope must not name this declaration.

Derives the facts of COPY.

Rule: PG-COPY-001. The table follows PG-TARGET-TABLE-001; COPY TO reads only a table and COPY FROM writes neither a materialized view nor a sequence (PG-RELATION-KIND-001; cannot copy from view "v"). A column of the column list must be a column of the table, may be listed once and may not be a generated column (column "b" is a generated column, CopyGetAttnums, copy.c); without a list every column but the generated columns is copied. The WHERE condition sees the table and is allowed with COPY FROM only. The query of COPY TO is derived as a nested query; a data-modifying statement without RETURNING and a SELECT INTO are reported. PROGRAM with STDIN or STDOUT is reported. The options follow PG-COPY-OPTIONS-001. COPY returns no rows: the data goes to or comes from the file, the program or the client. Source: https://www.postgresql.org/docs/17/sql-copy.html, https://github.com/postgres/postgres/blob/REL_17_2/src/backend/commands/copy.c. Status: Implemented.

Methods§

public function kind(CopyTable $copy, ?RelationKind $kind, Derivation $derivation): void

Reports a relation of a kind COPY cannot read from or write into.

COPY TO reads only tables: a view, a materialized view, a foreign table or a sequence is refused. COPY FROM refuses a materialized view and a sequence; a view needs an INSTEAD OF INSERT trigger and a foreign table a wrapper that inserts, which the context does not tell.

Parameters

$copyCopyTable
$kind?RelationKind
$derivationDerivation
Called from 1
Calls 14
public function columns(
    list<Name> $columns,
    VisibleRelation $table,
    Derivation $derivation,
): list<Name>|null

Derives the column list and answers the columns copied, or null when they are not known; the columns of a table without a list exclude its generated columns.

Parameters

$columnslist<Name>
$tableVisibleRelation
$derivationDerivation

Returns

list<Name>|null
Called from 1
Calls 5
public function generated(VisibleRelation $table): list<Name>

Answers the names of the generated columns of a table.

Parameters

Returns

list<Name>
Called from 1

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 2
Method calls 2