Skip to content

Commit

Permalink
Merge branch 'master' into avro-design
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored May 18, 2022
2 parents 9033520 + 02b0dfb commit a6c9702
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 58 deletions.
11 changes: 11 additions & 0 deletions cdc/entry/mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,14 @@ func datum2Column(tableInfo *model.TableInfo, datums map[int64]types.Datum, fill
if warn != "" {
log.Warn(warn, zap.String("table", tableInfo.TableName.String()), zap.String("column", colInfo.Name.String()))
}
defaultValue := getDDLDefaultDefinition(colInfo)
colSize += size
cols[tableInfo.RowColumnsOffset[colInfo.ID]] = &model.Column{
Name: colName,
Type: colInfo.Tp,
Charset: colInfo.Charset,
Value: colValue,
Default: defaultValue,
Flag: tableInfo.ColumnsFlag[colInfo.ID],
// ApproximateBytes = column data size + column struct size
ApproximateBytes: colSize + sizeOfEmptyColumn,
Expand Down Expand Up @@ -489,6 +491,15 @@ func getDefaultOrZeroValue(col *timodel.ColumnInfo) (interface{}, int, string, e
return formatColVal(d, col)
}

func getDDLDefaultDefinition(col *timodel.ColumnInfo) interface{} {
defaultValue := col.GetDefaultValue()
if defaultValue == nil {
defaultValue = col.GetOriginDefaultValue()
}
defaultDatum := types.NewDatum(defaultValue)
return defaultDatum.GetValue()
}

// DecodeTableID decodes the raw key to a table ID
func DecodeTableID(key []byte) (model.TableID, error) {
_, physicalTableID, err := decodeTableID(key)
Expand Down
Loading

0 comments on commit a6c9702

Please sign in to comment.