This commit is contained in:
兔子 2023-04-25 19:30:24 +08:00
parent 6a7e5fc485
commit d0dad74b18

View File

@ -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
} }
@ -159,6 +161,8 @@ 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()
} }