master
兔子 2 years ago
parent 6a7e5fc485
commit d0dad74b18

@ -8,6 +8,7 @@ import (
"github.com/starainrt/go-mysql/replication" "github.com/starainrt/go-mysql/replication"
"io" "io"
"os" "os"
"time"
) )
type TxDetail struct { type TxDetail struct {
@ -21,11 +22,12 @@ type TxDetail struct {
type Transaction struct { type Transaction struct {
GTID string GTID string
Timestamp int64
Time time.Time
StartPos int StartPos int
EndPos int EndPos int
Size int Size int
SQLOrigin string SQLOrigin string
Timestamp int64
RowsCount int RowsCount int
Txs []TxDetail Txs []TxDetail
} }
@ -157,8 +159,10 @@ func parseBinlogDetail(r io.Reader, f func(Transaction)) error {
} }
} }
tx = Transaction{ tx = Transaction{
GTID: sql, GTID: sql,
StartPos: startPos, StartPos: startPos,
Timestamp: int64(h.Timestamp),
Time: time.Unix(int64(h.Timestamp), 0),
} }
case "": case "":
tx.EndPos = int(h.LogPos) tx.EndPos = int(h.LogPos)
@ -242,7 +246,7 @@ func GetDbTbAndQueryAndRowCntFromBinevent(ev *replication.BinlogEvent) (string,
sqlType = "query" sqlType = "query"
case replication.GTID_EVENT: case replication.GTID_EVENT:
ge := ev.Event.(*replication.GTIDEvent) ge := ev.Event.(*replication.GTIDEvent)
gid, err := gtid.Parse(fmt.Sprintf("%s:%d", bytesToUuid(ge.SID), ge.SequenceNumber)) gid, err := gtid.Parse(fmt.Sprintf("%s:%d", bytesToUuid(ge.SID), ge.GNO))
if err == nil { if err == nil {
sql = gid.String() sql = gid.String()
} }

Loading…
Cancel
Save