classCopyOptions
final class CopyOptions
Checks the options of COPY.
Rule: PG-COPY-OPTIONS-001. Every option of the old syntax, BINARY after COPY and DELIMITERS set a generic option (format, freeze, delimiter, null, header, quote, escape, encoding, force_quote, force_not_null, force_null). A parenthesized option must be one PostgreSQL knows: those, default and convert_selectively, and from PostgreSQL 17 on_error and log_verbosity; the names compare exactly, as written after folding. An option set twice, by any spelling, is reported. A column a FORCE option names, in the old syntax or as the list argument of force_quote, force_not_null or force_null, that is a generated column is reported (column "b" is a generated column, CopyGetAttnums, copy.c); a column a FORCE option of the old syntax names that is not copied is reported when the copied columns are known. Termination: one pass over the options. Source: https://www.postgresql.org/docs/17/sql-copy.html, https://www.postgresql.org/docs/16/sql-copy.html. Status: Implemented.
Methods§
public function check(
bool $binary,
bool $delimiters,
list<CopyFlag|CopyText|CopyForce> $legacy,
list<CopyOption> $options,
list<Name>|null $copied,
Derivation $derivation,
list<Name> $generated = [],
): voidChecks the options of a COPY statement.
Parameters
$binary | bool | |
$delimiters | bool | |
$legacy | list<CopyFlag|CopyText|CopyForce> | |
$options | list<CopyOption> | |
$copied | list<Name>|null | The columns copied, or null when they are not known |
$derivation | Derivation | |
$generated | list<Name> | The generated columns of the table |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::table() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:65
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:117
Calls 12
- method-call CopyOptions::copied() line 72
- function-call
strtoupperline 72 - function-call
in_arrayline 76 - method-call CopyOptions::listed() line 76
- class-const GrammarRelease::PostgreSql166() line 79
- class-const CopyOptions::KNOWN() line 79
- class-const CopyOptions::ADDED() line 79
- method-call Derivation::report() line 82
- new ManipulationMisuse line 82
- class-const ManipulationMisuseRule::CopyUnknownOption() line 82
- function-call
array_count_valuesline 87 - class-const ManipulationMisuseRule::CopyRedundantOption() line 89
public function listed(CopyOption $option): list<Name>Answers the column names the list argument of an option holds, or none when its argument is not a list.
Parameters
$option | CopyOption |
Returns
list<Name>Test cases 1
Called from 1
public function copied(
string $option,
list<Name> $columns,
list<Name>|null $copied,
list<Name> $generated,
Derivation $derivation,
): voidReports the columns of a FORCE option that are generated columns or, when the copied columns are known, are not copied.
Parameters
$option | string | The option name as the server spells it in its messages |
$columns | list<Name> | The columns the option names |
$copied | list<Name>|null | The columns copied, or null when they are not known |
$generated | list<Name> | The generated columns of the table |
$derivation | Derivation |
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyOptions::check() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyOptions.php:72
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyOptions::check() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyOptions.php:77
Calls 5
- function-call
array_filterline 126 - method-call Derivation::report() line 127
- new ManipulationMisuse line 127
- class-const ManipulationMisuseRule::CopyGeneratedColumn() line 127
- class-const ManipulationMisuseRule::CopyColumnNotCopied() line 129
Private surface 2§
Implementation details, listed for orientation only.
private const KNOWN = ['format', 'freeze', 'delimiter', 'null', 'default', 'header', 'quote', 'escape…private const ADDED = ['on_error', 'log_verbosity']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
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::table() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:65
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\CopyFacts::query() packages/sql-semantics-postgres/src/Rules/Manipulation/CopyFacts.php:117