|
@@ -240,6 +240,9 @@ type HdrInfo struct {
|
|
|
WALLast uint32 `json:"wal1"`
|
|
WALLast uint32 `json:"wal1"`
|
|
|
TxnID uint64 `json:"txn"`
|
|
TxnID uint64 `json:"txn"`
|
|
|
Comment string `json:"cm"`
|
|
Comment string `json:"cm"`
|
|
|
|
|
+ HeaderCrc uint32 `json:"crc"` // 头页声明的整页 XXH32 (旧库为 0)
|
|
|
|
|
+ CrcVerdict string `json:"cv"` // 校验结论: OK / CRC 不符 / 跳过
|
|
|
|
|
+ CrcDetail string `json:"cd"` // 校验说明
|
|
|
|
|
|
|
|
// 实算值 (与上面的声明值互校)
|
|
// 实算值 (与上面的声明值互校)
|
|
|
FreeWalked int `json:"fw"` // 实走空闲链长度
|
|
FreeWalked int `json:"fw"` // 实走空闲链长度
|
|
@@ -1078,7 +1081,8 @@ func rHdrInfo() *HdrInfo {
|
|
|
// 16 CreateTime | 24 ModifyTime | 32 NextTxnID | 40 GlobalFlags
|
|
// 16 CreateTime | 24 ModifyTime | 32 NextTxnID | 40 GlobalFlags
|
|
|
// 48 TablePage | 52 TableCount | 56 FreePageStart | 60 FreePageEnd
|
|
// 48 TablePage | 52 TableCount | 56 FreePageStart | 60 FreePageEnd
|
|
|
// 64 FreePageCount | 68 FirstWALPage | 72 LastWALPage
|
|
// 64 FreePageCount | 68 FirstWALPage | 72 LastWALPage
|
|
|
- // 76 ExtConfig[256] | 332 Comment[3764] (占满整页余下空间)
|
|
|
|
|
|
|
+ // 76 ExtConfigHdr[8] | 84 HeaderCrc | 88 ExtConfig[244]
|
|
|
|
|
+ // 332 Comment[3764] (占满整页余下空间)
|
|
|
magic := string(b[:4])
|
|
magic := string(b[:4])
|
|
|
ver := binary.LittleEndian.Uint32(b[4:8])
|
|
ver := binary.LittleEndian.Uint32(b[4:8])
|
|
|
pgsz := binary.LittleEndian.Uint32(b[8:12])
|
|
pgsz := binary.LittleEndian.Uint32(b[8:12])
|
|
@@ -1094,7 +1098,9 @@ func rHdrInfo() *HdrInfo {
|
|
|
fc := binary.LittleEndian.Uint32(b[64:68])
|
|
fc := binary.LittleEndian.Uint32(b[64:68])
|
|
|
wal0 := binary.LittleEndian.Uint32(b[68:72])
|
|
wal0 := binary.LittleEndian.Uint32(b[68:72])
|
|
|
wal1 := binary.LittleEndian.Uint32(b[72:76])
|
|
wal1 := binary.LittleEndian.Uint32(b[72:76])
|
|
|
- cm := strings.TrimRight(string(b[332:844]), "\x00")
|
|
|
|
|
|
|
+ cm := strings.TrimRight(string(b[332:4096]), "\x00")
|
|
|
|
|
+ crc := le32(b[HDR_CRC : HDR_CRC+4])
|
|
|
|
|
+ crcV, crcD := checkHeaderCrc(b, ver)
|
|
|
fcW := rFreeChain()
|
|
fcW := rFreeChain()
|
|
|
total := totalPages()
|
|
total := totalPages()
|
|
|
h := &HdrInfo{
|
|
h := &HdrInfo{
|
|
@@ -1103,7 +1109,8 @@ func rHdrInfo() *HdrInfo {
|
|
|
CreateTime: time.Unix(0, ct).Format("2006-01-02 15:04:05"),
|
|
CreateTime: time.Unix(0, ct).Format("2006-01-02 15:04:05"),
|
|
|
ModifyTime: time.Unix(0, mt).Format("2006-01-02 15:04:05"),
|
|
ModifyTime: time.Unix(0, mt).Format("2006-01-02 15:04:05"),
|
|
|
FreeStart: fs, FreeEnd: fe, FreeCount: fc,
|
|
FreeStart: fs, FreeEnd: fe, FreeCount: fc,
|
|
|
- GlobalFlags: gf, WALFirst: wal0, WALLast: wal1, TxnID: txn, Comment: cm,
|
|
|
|
|
|
|
+ GlobalFlags: gf, WALFirst: wal0, WALLast: wal1, TxnID: txn, Comment: cm,
|
|
|
|
|
+ HeaderCrc: crc, CrcVerdict: crcV, CrcDetail: crcD,
|
|
|
FreeWalked: fcW.Total, Pages: total,
|
|
FreeWalked: fcW.Total, Pages: total,
|
|
|
FreeVerdict: fcW.Verdict, FreeDetail: fcW.Detail,
|
|
FreeVerdict: fcW.Verdict, FreeDetail: fcW.Detail,
|
|
|
}
|
|
}
|