-
Notifications
You must be signed in to change notification settings - Fork 307
redo(ticdc): add column info for redo ddl event #12602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -286,9 +286,18 @@ type RedoRowChangedEvent struct { | |
|
|
||
| // RedoDDLEvent represents DDL event used in redo log persistent | ||
| type RedoDDLEvent struct { | ||
| DDL *DDLEvent `msg:"ddl"` | ||
| Type byte `msg:"type"` | ||
| TableName TableName `msg:"table-name"` | ||
| DDL *DDLEvent `msg:"ddl"` | ||
| Type byte `msg:"type"` | ||
| TableName TableName `msg:"table-name"` | ||
| Columns []*ColumnInfo `msg:"columns"` | ||
| } | ||
|
|
||
| // ColumnInfo is for column meta in DDL event | ||
| type ColumnInfo struct { | ||
| Name string `msg:"name"` | ||
| OriginDefaultValue any `msg:"origin_default"` | ||
| Type byte `msg:"type"` | ||
| Version uint64 `msg:"version"` | ||
| } | ||
|
|
||
| // ToRedoLog converts row changed event to redo log | ||
|
|
@@ -314,8 +323,20 @@ func (r *RowChangedEvent) ToRedoLog() *RedoLog { | |
|
|
||
| // ToRedoLog converts ddl event to redo log | ||
| func (d *DDLEvent) ToRedoLog() *RedoLog { | ||
| var columns []*ColumnInfo | ||
| if d.TableInfo != nil && d.TableInfo.TableInfo != nil { | ||
| columns = make([]*ColumnInfo, 0, len(d.TableInfo.Columns)) | ||
| for _, col := range d.TableInfo.Columns { | ||
| columns = append(columns, &ColumnInfo{ | ||
| Name: col.Name.String(), | ||
| OriginDefaultValue: col.GetOriginDefaultValue(), | ||
| Type: col.GetType(), | ||
| Version: col.Version, | ||
| }) | ||
|
Comment on lines
+330
to
+335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| } | ||
| return &RedoLog{ | ||
| RedoDDL: RedoDDLEvent{DDL: d}, | ||
| RedoDDL: RedoDDLEvent{DDL: d, Columns: columns}, | ||
| Type: RedoLogTypeDDL, | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ColumnInfostruct is missing the columnID. Sincetimodel.ColumnInforequires a unique ID for various internal operations and schema tracking, it is recommended to persist the original ID from the upstream table info to ensure accurate reconstruction during redo log playback.