go-mysql-org / go-mysql

a powerful mysql toolset with Go
MIT License
4.62k stars 987 forks source link

canal能否支持存储过程,trigger,索引等DDL的Query传递 #641

Open chj733 opened 3 years ago

chj733 commented 3 years ago

image sync.go里面 1.目前对于存储过程,触发器等对象的DDL,因为parser无法解析,是直接忽略的,能否至少继续传递event? 我下游收到这个DDL query还是有用的 2.能否针对DDL,带上schema信息?

afghanistanyn commented 11 months ago
    for _, stmt := range stmts {
        nodes := parseStmt(stmt)
        for _, node := range nodes {
            if node.db == "" {
                node.db = string(e.Schema)
            }
            if err = c.updateTable(ev.Header, node.db, node.table); err != nil {
                return errors.Trace(err)
            }
        }
                // if len(nodes) > 0
        if len(nodes) >= 0 {
            savePos = true
            force = true
            // Now we only handle Table Changed DDL, maybe we will support more later.
            if err = c.eventHandler.OnDDL(ev.Header, pos, e); err != nil {
                return errors.Trace(err)
            }
        }
    }

change the len(nodes) >= 0 will always receive the ddl, or you can update parseStmt() to add the ddl type you want