classLoadTable
final class LoadTable
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.LOAD DATA and LOAD XML: reads rows from a file into a table.
Mirrors the server's PT_load_table with its sql_exchange. The facts follow MYSQL-LOAD-001. A clause written twice in the field or line options is kept twice. Source: https://dev.mysql.com/doc/refman/8.4/en/load-data.html, https://dev.mysql.com/doc/refman/8.4/en/load-xml.html.
$load = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("LOAD DATA INFILE 'f' REPLACE INTO TABLE t FIELDS TERMINATED BY ',' IGNORE 1 LINES (a, @b) SET c = @b * 2");
[$load->statement->duplicates, count($load->statement->columns), $load->toString()] // => [\SqlSemantics\Platform\MySql\Statement\Dml\DuplicateHandling::Replace, 2, "LOAD DATA INFILE 'f' REPLACE INTO TABLE t COLUMNS TERMINATED BY ',' IGNORE 1 LINES (a, @b) SET c = @b * 2"]Properties§
public list<FieldOption> $fieldspublic list<LineOption> $linespublic list<ColumnUse|UserVariable> $columnspublic list<Assignment> $assignmentspublic LoadFormat $formatpublic LoadLock|null $lockpublic LoadInput $inputpublic DuplicateHandling|null $duplicatespublic WriteTarget $tablepublic CharsetName|null $charset = nullpublic Text|null $compression = nullpublic Text|null $rowTag = nullpublic Numeral|null $ignored = nullpublic BulkOptions|null $bulk = nullMethods§
public function __construct(
public LoadFormat $format,
public LoadLock|null $lock,
public LoadInput $input,
public DuplicateHandling|null $duplicates,
public WriteTarget $table,
public CharsetName|null $charset = null,
public Text|null $compression = null,
public Text|null $rowTag = null,
list<FieldOption> $fields = [],
list<LineOption> $lines = [],
public Numeral|null $ignored = null,
list<ColumnUse|UserVariable> $columns = [],
list<Assignment> $assignments = [],
public BulkOptions|null $bulk = null,
)Parameters
$format | LoadFormat | DATA or XML |
$lock | LoadLock|null | The scheduling modifier |
$input | LoadInput | What is read |
$duplicates | DuplicateHandling|null | What a row that duplicates a unique key does |
$table | WriteTarget | The table the rows are written to; it has no correlation name |
$charset | CharsetName|null | The character set of the file |
$compression | Text|null | The compression algorithm of the files (9.x bulk load) |
$rowTag | Text|null | The XML element of a row, `ROWS IDENTIFIED BY` |
$fields | list<FieldOption> | The FIELDS options |
$lines | list<LineOption> | The LINES options |
$ignored | Numeral|null | The number of lines or rows skipped at the start |
$columns | list<ColumnUse|UserVariable> | The columns and user variables the fields are read into |
$assignments | list<Assignment> | The SET assignments |
$bulk | BulkOptions|null | The options of a bulk load |
Throws
InvalidConstruction When the table has a correlation name or a member of a list is of the wrong classCalls 6
- static-call Check::input() line 94
- static-call Check::listOf() line 95
- class-const FieldOption::class() line 95
- class-const LineOption::class() line 96
- class-const Node::class() line 98
- class-const Assignment::class() line 103
public function deriveStatement(Derivation $derivation): voidDerives the table, the columns and the assignments; the statement returns no rows.
Parameters
$derivation | Derivation |
Calls 2
- method-call LoadFacts::derive() line 111
- new LoadFacts line 111
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 119
- method-call Output::node() line 123
- method-call Output::symbol() line 153
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.