Skip to content

Commit

Permalink
use tableInfo in rowChangeEvent to gennerate dmls
Browse files Browse the repository at this point in the history
  • Loading branch information
asddongmen committed Sep 26, 2023
1 parent 43848f2 commit 7ea72b9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cdc/sink/dmlsink/txn/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,15 @@ func (s *mysqlBackend) prepareDMLs() *preparedDMLs {
}
// only use batch dml when the table has a handle key
if hasHandleKey(tableColumns) {
// TODO(dongmen): find a better way to get table info.
tableInfo := model.BuildTiDBTableInfo(tableColumns, firstRow.IndexColumns)
var tableInfo *timodel.TableInfo
if firstRow.TableInfo != nil && firstRow.TableInfo.TableInfo != nil {
tableInfo = firstRow.TableInfo.TableInfo
} else {
// firstRow.TableInfo is nil only when the row change event was generated by
// mounter, which only occurs when mysql sink was used in redo consumer or
// in the other consumers.
tableInfo = model.BuildTiDBTableInfo(tableColumns, firstRow.IndexColumns)
}
sql, value := s.batchSingleTxnDmls(event, tableInfo, translateToInsert)
sqls = append(sqls, sql...)
values = append(values, value...)
Expand Down

0 comments on commit 7ea72b9

Please sign in to comment.