Special Handling of DM DDLs
When TiDB Data Migration (DM) migrates data, it parses the DDL statements and handles them according to the statement type and the current migration stage.
Skip DDL statements
The following statements are not supported by DM, so DM skips them directly after parsing.
Description | SQL |
---|---|
transaction | ^SAVEPOINT |
skip all flush sqls | ^FLUSH |
table maintenance | ^OPTIMIZE\s+TABLE |
^ANALYZE\s+TABLE | |
^REPAIR\s+TABLE | |
temporary table | ^DROP\s+(\/\\!40005\s+)?TEMPORARY\s+(\\/\s+)?TABLE |
trigger | ^CREATE\s+(DEFINER\s?=.+?)?TRIGGER |
^DROP\s+TRIGGER | |
procedure | ^DROP\s+PROCEDURE |
^CREATE\s+(DEFINER\s?=.+?)?PROCEDURE | |
^ALTER\s+PROCEDURE | |
view | ^CREATE\s(OR REPLACE)?\s+(ALGORITHM\s?=.+?)?(DEFINER\s?=.+?)?\s+(SQL SECURITY DEFINER)?VIEW |
^DROP\s+VIEW | |
^ALTER\s+(ALGORITHM\s?=.+?)?(DEFINER\s?=.+?)?(SQL SECURITY DEFINER)?VIEW | |
function | ^CREATE\s+(AGGREGATE)?\s?FUNCTION |
^CREATE\s+(DEFINER\s?=.+?)?FUNCTION | |
^ALTER\s+FUNCTION | |
^DROP\s+FUNCTION | |
tableSpace | ^CREATE\s+TABLESPACE |
^ALTER\s+TABLESPACE | |
^DROP\s+TABLESPACE | |
event | ^CREATE\s+(DEFINER\s?=.+?)?EVENT |
^ALTER\s+(DEFINER\s?=.+?)?EVENT | |
^DROP\s+EVENT | |
account management | ^GRANT |
^REVOKE | |
^CREATE\s+USER | |
^ALTER\s+USER | |
^RENAME\s+USER | |
^DROP\s+USER | |
^DROP\s+USER |
Rewrite DDL statements
The following statements are rewritten before being replicated to the downstream.
Original statement | Rewritten statement |
---|---|
^CREATE DATABASE… | ^CREATE DATABASE…IF NOT EXISTS |
^CREATE TABLE… | ^CREATE TABLE..IF NOT EXISTS |
^DROP DATABASE… | ^DROP DATABASE…IF EXISTS |
^DROP TABLE… | ^DROP TABLE…IF EXISTS |
^DROP INDEX… | ^DROP INDEX…IF EXISTS |
Shard merge migration tasks
When DM merges and migrates tables in pessimistic or optimistic mode, the behavior of DDL replication is different from that in other scenarios. For details, refer to Pessimistic Mode and Optimistic Mode.
Online DDL
The Online DDL feature also handles DDL events in a special way. For details, refer to Migrate from Databases that Use GH-ost/PT-osc.