Skip to content

Commit

Permalink
PostgreSQL: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Safonov committed Aug 2, 2022
1 parent ffd7c9b commit 96a86e2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 6 additions & 4 deletions format/postgres/flavours/pgproee14/pgheap.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ func DecodePageSpecial(d *decode.D) {
specialPos := int64(page.PagePosBegin*8) + int64(page.PdSpecial*8)
d.SeekAbs(specialPos)

page.PdXidBase = d.FieldU64("pd_xid_base")
page.PdMultiBase = d.FieldU64("pd_multi_base")
page.PdPruneXid = d.FieldU32("pd_prune_xid")
page.PdMagic = d.FieldU32("pd_magic")
d.FieldStruct("HeapPageSpecialData", func(d *decode.D) {
page.PdXidBase = d.FieldU64("pd_xid_base")
page.PdMultiBase = d.FieldU64("pd_multi_base")
page.PdPruneXid = d.FieldU32("pd_prune_xid")
page.PdMagic = d.FieldU32("pd_magic")
})
}
18 changes: 12 additions & 6 deletions format/postgres/flavours/postgres14/common14/pgheap.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const (
//
/* total size (bytes): 12 */
/* } t_choice; //
/* 12 | 6 */// ItemPointerData t_ctid;
/* 12 | 6 */ // ItemPointerData t_ctid;
/* 18 | 2 */ // uint16 t_infomask2;
/* 20 | 2 */ // uint16 t_infomask;
/* 22 | 1 */ // uint8 t_hoff;
Expand Down Expand Up @@ -160,9 +160,9 @@ type itemIdDataD struct {
/* 0: 0 | 4 */ // unsigned int lp_off: 15
/* 1: 7 | 4 */ // unsigned int lp_flags: 2
/* 2: 1 | 4 */ // unsigned int lp_len: 15
lpOff uint32
lpFlags uint32
lpLen uint32
lpOff uint32
lpFlags uint32
lpLen uint32
}

func GetHeapD(d *decode.D) *HeapD {
Expand All @@ -185,6 +185,10 @@ func decodeHeapPages(d *decode.D) {
heap := GetHeapD(d)

for {
if end, _ := d.TryEnd(); end {
return
}

page := &HeapPageD{}
heap.Page = page

Expand Down Expand Up @@ -212,7 +216,9 @@ func decodeHeapPage(d *decode.D) {
// free space
freeSpaceEnd := int64(pagePosBegin*8) + int64(page.PdUpper*8)
freeSpaceNBits := freeSpaceEnd - d.Pos()
d.FieldRawLen("FreeSpace", freeSpaceNBits, scalar.RawHex)
if freeSpaceNBits != 0 {
d.FieldRawLen("FreeSpace", freeSpaceNBits, scalar.RawHex)
}

if uint64(page.PdSpecial) != heap.PageSize && heap.DecodePageSpecialFn != nil {
heap.DecodePageSpecialFn(d)
Expand Down Expand Up @@ -274,7 +280,7 @@ func decodeTuples(d *decode.D) {
// } t_choice;
/* total size (bytes): 12 */
/*
/* 12 | 6 */// ItemPointerData t_ctid;
/* 12 | 6 */ // ItemPointerData t_ctid;
/* 18 | 2 */ // uint16 t_infomask2;
/* 20 | 2 */ // uint16 t_infomask;
/* 22 | 1 */ // uint8 t_hoff;
Expand Down

0 comments on commit 96a86e2

Please sign in to comment.