forked from edwardhey/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathundo_log.go
37 lines (32 loc) · 792 Bytes
/
undo_log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package mysql
import (
"github.com/virteman/mysql/schema"
)
type sqlUndoLog struct {
SqlType SQLType
TableName string
BeforeImage *schema.TableRecords
AfterImage *schema.TableRecords
}
func (undoLog *sqlUndoLog) SetTableMeta(tableMeta schema.TableMeta) {
if undoLog.BeforeImage != nil {
undoLog.BeforeImage.TableMeta = tableMeta
}
if undoLog.AfterImage != nil {
undoLog.AfterImage.TableMeta = tableMeta
}
}
func (undoLog *sqlUndoLog) GetUndoRows() *schema.TableRecords {
if undoLog.SqlType == SQLType_UPDATE ||
undoLog.SqlType == SQLType_DELETE {
return undoLog.BeforeImage
} else if undoLog.SqlType == SQLType_INSERT {
return undoLog.AfterImage
}
return nil
}
type branchUndoLog struct {
Xid string
BranchID int64
SqlUndoLogs []*sqlUndoLog
}