|
|
|
@ -8,7 +8,6 @@ import ( |
|
|
|
|
|
|
|
"github.com/go-mysql-org/go-mysql/canal" |
|
|
|
"github.com/go-mysql-org/go-mysql/mysql" |
|
|
|
"github.com/go-mysql-org/go-mysql/replication" |
|
|
|
) |
|
|
|
|
|
|
|
// 自定义事件处理结构体
|
|
|
|
@ -79,13 +78,13 @@ func (h *MyEventHandler) OnRow(e *canal.RowsEvent) error { |
|
|
|
} |
|
|
|
|
|
|
|
// 处理DDL事件
|
|
|
|
func (h *MyEventHandler) OnDDL(nextPos mysql.Position, queryEvent *replication.QueryEvent) error { |
|
|
|
sql := string(queryEvent.Query) |
|
|
|
if sql != "" { |
|
|
|
fmt.Println(sql + ";") |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
// func (h *MyEventHandler) OnDDL(nextPos mysql.Position, queryEvent *replication.QueryEvent) error {
|
|
|
|
// sql := string(queryEvent.Query)
|
|
|
|
// if sql != "" {
|
|
|
|
// fmt.Println(sql + ";")
|
|
|
|
// }
|
|
|
|
// return nil
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 格式化值为SQL表示形式
|
|
|
|
func formatValue(value interface{}) string { |
|
|
|
|