|
|
@ -13,16 +13,16 @@ import (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type TxDetail struct {
|
|
|
|
type TxDetail struct {
|
|
|
|
StartPos int
|
|
|
|
StartPos int `json:"startPos"`
|
|
|
|
EndPos int
|
|
|
|
EndPos int `json:"endPos"`
|
|
|
|
RowCount int
|
|
|
|
RowCount int `json:"rowCount"`
|
|
|
|
Timestamp int64
|
|
|
|
Timestamp int64 `json:"timestamp"`
|
|
|
|
Time time.Time
|
|
|
|
Time time.Time `json:"time"`
|
|
|
|
Sql string
|
|
|
|
Sql string `json:"sql"`
|
|
|
|
Db string
|
|
|
|
Db string `json:"db"`
|
|
|
|
Table string
|
|
|
|
Table string `json:"table"`
|
|
|
|
SqlType string
|
|
|
|
SqlType string `json:"sqlType"`
|
|
|
|
CompressionType string
|
|
|
|
CompressionType string `json:"compressionType"`
|
|
|
|
Rows [][]interface{}
|
|
|
|
Rows [][]interface{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -34,16 +34,17 @@ const (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Transaction struct {
|
|
|
|
type Transaction struct {
|
|
|
|
GTID string
|
|
|
|
GTID string `json:"gtid"`
|
|
|
|
Timestamp int64
|
|
|
|
Timestamp int64 `json:"timestamp"`
|
|
|
|
Time time.Time
|
|
|
|
Time time.Time `json:"time"`
|
|
|
|
StartPos int
|
|
|
|
StartPos int `json:"startPos"`
|
|
|
|
EndPos int
|
|
|
|
EndPos int `json:"endPos"`
|
|
|
|
Size int
|
|
|
|
Size int `json:"size"`
|
|
|
|
RowsCount int
|
|
|
|
RowsCount int `json:"rowsCount"`
|
|
|
|
Status uint8
|
|
|
|
Status uint8 `json:"status"`
|
|
|
|
sqlOrigin []string
|
|
|
|
sqlOrigin []string `json:"sqlOrigin"`
|
|
|
|
Txs []TxDetail
|
|
|
|
Txs []TxDetail `json:"txs"`
|
|
|
|
|
|
|
|
matchFilterSchema bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (t Transaction) GetSqlOrigin() []string {
|
|
|
|
func (t Transaction) GetSqlOrigin() []string {
|
|
|
@ -367,8 +368,39 @@ func parseBinlogWithFilter(r io.Reader, parse *replication.BinlogParser, filter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
excludeMap[v] = true
|
|
|
|
excludeMap[v] = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
excludeMap["*.*"] = true
|
|
|
|
matchTbs := func(db, tb string) bool {
|
|
|
|
|
|
|
|
if len(filter.ExcludeTables) == 0 && len(filter.ExcludeTables) == 0 {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := includeMap["*.*"]; ok {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := excludeMap["*.*"]; ok {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := includeMap[db+"."+tb]; ok {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := excludeMap[db+"."+tb]; ok {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := includeMap[db+".*"]; ok {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := excludeMap[db+".*"]; ok {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := includeMap["*."+tb]; ok {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, ok := excludeMap["*."+tb]; ok {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(includeMap) != 0 {
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if filter.IncludeGtid != "" {
|
|
|
|
if filter.IncludeGtid != "" {
|
|
|
|
inGtid, err = gtid.Parse(filter.IncludeGtid)
|
|
|
|
inGtid, err = gtid.Parse(filter.IncludeGtid)
|
|
|
@ -414,6 +446,9 @@ func parseBinlogWithFilter(r io.Reader, parse *replication.BinlogParser, filter
|
|
|
|
if filter.SmallThan != 0 && filter.SmallThan < tx.Size {
|
|
|
|
if filter.SmallThan != 0 && filter.SmallThan < tx.Size {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(tx.Txs) == 0 && tx.matchFilterSchema {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
return fn(tx)
|
|
|
|
return fn(tx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for {
|
|
|
|
for {
|
|
|
@ -583,6 +618,10 @@ func parseBinlogWithFilter(r io.Reader, parse *replication.BinlogParser, filter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tx.Status = status
|
|
|
|
tx.Status = status
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !matchTbs(ev.DB, ev.TB) {
|
|
|
|
|
|
|
|
tx.matchFilterSchema = true
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
tx.Txs = append(tx.Txs, TxDetail{
|
|
|
|
tx.Txs = append(tx.Txs, TxDetail{
|
|
|
|
StartPos: startPos,
|
|
|
|
StartPos: startPos,
|
|
|
|
EndPos: int(h.LogPos),
|
|
|
|
EndPos: int(h.LogPos),
|
|
|
|