protected void parseRenameTable(Marker start) { TableId from = parseQualifiedTableName(start); tokens.consume("TO"); TableId to = parseQualifiedTableName(start); databaseTables.renameTable(from, to); // Signal a separate statement for this table rename action, even though multiple renames might be // performed by a single DDL statement on the token stream ... signalAlterTable(from, to, "RENAME TABLE " + from + " TO " + to); }
@Override public void enterRenameTableClause(MySqlParser.RenameTableClauseContext ctx) { TableId oldTable = parser.parseQualifiedTableId(ctx.tableName(0).fullId()); TableId newTable = parser.parseQualifiedTableId(ctx.tableName(1).fullId()); parser.databaseTables().renameTable(oldTable, newTable); parser.signalAlterTable(newTable, oldTable, ctx); super.enterRenameTableClause(ctx); } }
@Override public void enterAlterByRename(MySqlParser.AlterByRenameContext ctx) { parser.runIfNotNull(() -> { final TableId newTableId = ctx.uid() != null ? parser.resolveTableId(parser.currentSchema(), parser.parseName(ctx.uid())) : parser.parseQualifiedTableId(ctx.fullId()); parser.databaseTables().renameTable(tableEditor.tableId(), newTableId); // databaseTables are updated clear table editor so exitAlterTable will not update a table by table editor tableEditor = null; }, tableEditor); super.enterAlterByRename(ctx); }
if (newTableName.get() != null) { Table renamed = databaseTables.renameTable(tableId, newTableName.get()); if (renamed != null) { oldTableId = tableId;