-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pavel Safonov
committed
Aug 2, 2022
1 parent
6ed0263
commit ffd7c9b
Showing
4 changed files
with
604 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package pgproee14 | ||
|
||
import ( | ||
"github.com/wader/fq/format/postgres/common" | ||
"github.com/wader/fq/format/postgres/flavours/postgres14/common14" | ||
"github.com/wader/fq/pkg/decode" | ||
) | ||
|
||
// type = struct PageHeaderData { | ||
/* 0 | 8 */ // PageXLogRecPtr pd_lsn; | ||
/* 8 | 2 */ // uint16 pd_checksum; | ||
/* 10 | 2 */ // uint16 pd_flags; | ||
/* 12 | 2 */ // LocationIndex pd_lower; | ||
/* 14 | 2 */ // LocationIndex pd_upper; | ||
/* 16 | 2 */ // LocationIndex pd_special; | ||
/* 18 | 2 */ // uint16 pd_pagesize_version; | ||
/* 20 | 0 */ // ItemIdData pd_linp[]; | ||
// | ||
/* total size (bytes): 20 */ | ||
|
||
// type = struct { | ||
/* 0 | 4 */ // uint32 xlogid; | ||
/* 4 | 4 */ // uint32 xrecoff; | ||
// | ||
/* total size (bytes): 8 */ | ||
|
||
// type = struct ItemIdData { | ||
/* 0: 0 | 4 */ // unsigned int lp_off : 15; | ||
/* 1: 7 | 4 */ // unsigned int lp_flags : 2; | ||
/* 2: 1 | 4 */ // unsigned int lp_len : 15; | ||
// | ||
/* total size (bytes): 4 */ | ||
|
||
// type = struct HeapTupleHeaderData { | ||
/* 0 | 12 */ // union { | ||
/* 12 */ // HeapTupleFields t_heap; | ||
/* 12 */ // DatumTupleFields t_datum; | ||
// } t_choice; | ||
/* total size (bytes): 12 */ | ||
// | ||
/* 12 | 6 */ // ItemPointerData t_ctid | ||
/* 18 | 2 */ // uint16 t_infomask2 | ||
/* 20 | 2 */ // uint16 t_infomask | ||
/* 22 | 1 */ // uint8 t_hoff | ||
/* 23 | 0 */ // bits8 t_bits[] | ||
/* XXX 1-byte padding */ | ||
// | ||
/* total size (bytes): 24 */ | ||
|
||
// type = struct HeapTupleFields { | ||
/* 0 | 4 */ // ShortTransactionId t_xmin; | ||
/* 4 | 4 */ // ShortTransactionId t_xmax; | ||
/* 8 | 4 */ // union { | ||
/* 4 */ // CommandId t_cid; | ||
/* 4 */ // ShortTransactionId t_xvac; | ||
// | ||
/* total size (bytes): 4 */ | ||
// } t_field3; | ||
// | ||
/* total size (bytes): 12 */ | ||
|
||
// type = struct DatumTupleFields { | ||
/* 0 | 4 */ // int32 datum_len_; | ||
/* 4 | 4 */ // int32 datum_typmod; | ||
/* 8 | 4 */ // Oid datum_typeid; | ||
// | ||
/* total size (bytes): 12 */ | ||
|
||
// type = struct ItemPointerData { | ||
/* 0 | 4 */ // BlockIdData ip_blkid; | ||
/* 4 | 2 */ // OffsetNumber ip_posid; | ||
// | ||
/* total size (bytes): 6 */ | ||
|
||
func DecodeHeap(d *decode.D) any { | ||
heap := &common14.HeapD{ | ||
PageSize: common.HeapPageSize, | ||
DecodePageHeaderDataFn: DecodePageHeaderData, | ||
DecodePageSpecialFn: DecodePageSpecial, | ||
} | ||
return common14.DecodeHeap(d, heap) | ||
} | ||
|
||
// type = struct PageHeaderData { | ||
/* 0 | 8 */ // PageXLogRecPtr pd_lsn; | ||
/* 8 | 2 */ // uint16 pd_checksum; | ||
/* 10 | 2 */ // uint16 pd_flags; | ||
/* 12 | 2 */ // LocationIndex pd_lower; | ||
/* 14 | 2 */ // LocationIndex pd_upper; | ||
/* 16 | 2 */ // LocationIndex pd_special; | ||
/* 18 | 2 */ // uint16 pd_pagesize_version; | ||
/* 20 | 0 */ // ItemIdData pd_linp[]; | ||
func DecodePageHeaderData(d *decode.D) { | ||
heap := common14.GetHeapD(d) | ||
page := heap.Page | ||
|
||
d.FieldStruct("pd_lsn", func(d *decode.D) { | ||
/* 0 | 4 */ // uint32 xlogid; | ||
/* 4 | 4 */ // uint32 xrecoff; | ||
d.FieldU32("xlogid", common.HexMapper) | ||
d.FieldU32("xrecoff", common.HexMapper) | ||
}) | ||
d.FieldU16("pd_checksum") | ||
d.FieldU16("pd_flags") | ||
page.PdLower = uint16(d.FieldU16("pd_lower")) | ||
page.PdUpper = uint16(d.FieldU16("pd_upper")) | ||
page.PdSpecial = uint16(d.FieldU16("pd_special")) | ||
page.PdPagesizeVersion = uint16(d.FieldU16("pd_pagesize_version")) | ||
|
||
// ItemIdData pd_linp[]; | ||
page.ItemsEnd = int64(page.PagePosBegin*8) + int64(page.PdLower*8) | ||
d.FieldArray("pd_linp", common14.DecodeItemIds) | ||
} | ||
|
||
// type = struct HeapPageSpecialData { | ||
/* 0 | 8 */ // TransactionId pd_xid_base; | ||
/* 8 | 8 */ // TransactionId pd_multi_base; | ||
/* 16 | 4 */ // ShortTransactionId pd_prune_xid; | ||
/* 20 | 4 */ // uint32 pd_magic; | ||
// | ||
/* total size (bytes): 24 */ | ||
func DecodePageSpecial(d *decode.D) { | ||
heap := common14.GetHeapD(d) | ||
page := heap.Page | ||
|
||
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") | ||
} |
Oops, something went wrong.