Skip to content

Commit

Permalink
feat:add undo log manager-flush undo log func #269 (#307)
Browse files Browse the repository at this point in the history
add undo log manager-flush undo log func #269
  • Loading branch information
betterwinsone committed Oct 29, 2022
1 parent dd81e03 commit 401dc36
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
21 changes: 19 additions & 2 deletions pkg/datasource/sql/undo/base/undo.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,26 @@ func (m *BaseUndoLogManager) BatchDeleteUndoLog(xid []string, branchID []int64,
return nil
}

// FlushUndoLog
// FlushUndoLog flush undo log
func (m *BaseUndoLogManager) FlushUndoLog(txCtx *types.TransactionContext, tx driver.Conn) error {
return nil
if !txCtx.HasUndoLog() {
return nil
}
logs := []undo.SQLUndoLog{
{
SQLType: types.SQLTypeInsert,
TableName: constant.UndoLogTableName,
Images: *txCtx.RoundImages,
},
}
branchUndoLogs := []undo.BranchUndoLog{
{
Xid: txCtx.XaID,
BranchID: strconv.FormatUint(txCtx.BranchID, 10),
Logs: logs,
},
}
return m.InsertUndoLog(branchUndoLogs, tx)
}

// RunUndo
Expand Down
12 changes: 6 additions & 6 deletions pkg/datasource/sql/undo/undo.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ func GetUndoLogManager(d types.DBType) (UndoLogManager, error) {
// BranchUndoLog
type BranchUndoLog struct {
// Xid
Xid string
Xid string `json:"xid"`
// BranchID
BranchID string
BranchID string `json:"branchId"`
// Logs
Logs []SQLUndoLog
Logs []SQLUndoLog `json:"sqlUndoLogs"`
}

// Marshal
Expand All @@ -113,9 +113,9 @@ func (b *BranchUndoLog) Marshal() []byte {

// SQLUndoLog
type SQLUndoLog struct {
SQLType types.SQLType
TableName string
Images types.RoundRecordImage
SQLType types.SQLType `json:"sqlType"`
TableName string `json:"tableName"`
Images types.RoundRecordImage `json:"images"`
}

// UndoLogParser
Expand Down

0 comments on commit 401dc36

Please sign in to comment.