classRenameTable
final class RenameTable
implements Statement
uses Snapshot
@visibility public.RENAME TABLE old TO new, …: a request to rename tables, one rename after the other.
Mirrors PT_rename_table_stmt (LEX of 5.x). Rule: MYSQL-RENAME-TABLE-001. The renames run left to right, so a later rename sees the names the earlier ones produced (RENAME TABLE a TO tmp, b TO a, tmp TO b swaps two tables). The relation fact of each TableRenaming is the resolution of its old name at that time (MYSQL-RENAMINGS-001): a name an earlier rename produced resolves to that table, a name an earlier rename moved away is missing. A new name that exists at that time is the diagnostic TableExists. The statement changes no declaration and provides none. TABLE and TABLES are synonyms. Source: https://dev.mysql.com/doc/refman/8.4/en/rename-table.html. Status: Implemented.
$rename = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('RENAME TABLES a TO tmp, b TO a, tmp TO b');
[count($rename->statement->renamings), $rename->toString()] // => [3, 'RENAME TABLE a TO tmp, b TO a, tmp TO b']Properties§
public list<TableRenaming> $renamingsMethods§
public function __construct(list<TableRenaming> $renamings)Parameters
$renamings | list<TableRenaming> | The renames in order; at least one |
Calls 3
- static-call Check::input() line 48
- static-call Check::listOf() line 49
- class-const TableRenaming::class() line 49
public function deriveStatement(Derivation $derivation): voidRecords the resolution of each old name in order and reports new names that already exist.
Parameters
$derivation | Derivation |
Calls 2
- method-call Renamings::derive() line 57
- new Renamings line 57
public function render(Output $out): voidTest cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.