- 暴露事务级 last_committed、sequence_number、transaction_length 和 commit timestamp - 在 GTID event 转换时透传 logical clock 元数据 - 新增 ParseOptions、ParseProgress,支持上下文取消和解析进度回调 - 保留 TransactionPayloadEvent 展开后的 tablemap 与压缩类型信息 - 增加 TransactionSummary 辅助结构,便于上层统计事务结果、耗时、表分布和逻辑时钟 - 清理测试对外部大 binlog 样本的依赖,保证独立库测试可运行 - 修正跨平台测试与 GTID 输出格式断言,提升发版稳定性
39 lines
770 B
Go
39 lines
770 B
Go
package binlog
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func ParseBinlogFile(path string, fx func(transaction Transaction) bool) error {
|
|
return ParseBinlogWithOptions(path, ParseOptions{}, fx)
|
|
}
|
|
|
|
func finalizeTx(tx *Transaction, onlyShowGtid bool) {
|
|
idx := 0
|
|
for k, v := range tx.Txs {
|
|
if v.SqlType != "query" && len(tx.sqlOrigin) > idx {
|
|
v.Sql = tx.sqlOrigin[idx]
|
|
idx++
|
|
}
|
|
tx.RowsCount += v.RowCount
|
|
tx.Txs[k] = v
|
|
}
|
|
|
|
if onlyShowGtid {
|
|
tx.Size = 0
|
|
} else {
|
|
tx.Size = tx.EndPos - tx.StartPos
|
|
}
|
|
}
|
|
|
|
func fillTimeLazy(tx *Transaction) {
|
|
if tx.Timestamp != 0 && tx.Time.IsZero() {
|
|
tx.Time = time.Unix(tx.Timestamp, 0)
|
|
}
|
|
for i := range tx.Txs {
|
|
if tx.Txs[i].Timestamp != 0 && tx.Txs[i].Time.IsZero() {
|
|
tx.Txs[i].Time = time.Unix(tx.Txs[i].Timestamp, 0)
|
|
}
|
|
}
|
|
}
|