-
Notifications
You must be signed in to change notification settings - Fork 216
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
96a86e2
commit 2d3884a
Showing
6 changed files
with
232 additions
and
53 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,76 @@ | ||
package pgproee11 | ||
|
||
// type = struct ControlFileData { | ||
/* 0 | 8 */ // uint64 system_identifier; | ||
/* 8 | 4 */ // uint32 pg_control_version; | ||
/* 12 | 4 */ // uint32 catalog_version_no; | ||
/* 16 | 4 */ // DBState state; | ||
/* XXX 4-byte hole */ | ||
/* 24 | 8 */ // pg_time_t time; | ||
/* 32 | 8 */ // XLogRecPtr checkPoint; | ||
/* 40 | 120 */ // CheckPoint checkPointCopy; | ||
/* 160 | 8 */ // XLogRecPtr unloggedLSN; | ||
/* 168 | 8 */ // XLogRecPtr minRecoveryPoint; | ||
/* 176 | 4 */ // TimeLineID minRecoveryPointTLI; | ||
/* XXX 4-byte hole */ | ||
/* 184 | 8 */ // XLogRecPtr backupStartPoint; | ||
/* 192 | 8 */ // XLogRecPtr backupEndPoint; | ||
/* 200 | 1 */ // _Bool backupEndRequired; | ||
/* XXX 3-byte hole */ | ||
/* 204 | 4 */ // int wal_level; | ||
/* 208 | 1 */ // _Bool wal_log_hints; | ||
/* XXX 3-byte hole */ | ||
/* 212 | 4 */ // int MaxConnections; | ||
/* 216 | 4 */ // int max_worker_processes; | ||
/* 220 | 4 */ // int max_prepared_xacts; | ||
/* 224 | 4 */ // int max_locks_per_xact; | ||
/* 228 | 1 */ // _Bool track_commit_timestamp; | ||
/* XXX 3-byte hole */ | ||
/* 232 | 4 */ // uint32 maxAlign; | ||
/* XXX 4-byte hole */ | ||
/* 240 | 8 */ // double floatFormat; | ||
/* 248 | 4 */ // uint32 blcksz; | ||
/* 252 | 4 */ // uint32 relseg_size; | ||
/* 256 | 4 */ // uint32 xlog_blcksz; | ||
/* 260 | 4 */ // uint32 xlog_seg_size; | ||
/* 264 | 4 */ // uint32 nameDataLen; | ||
/* 268 | 4 */ // uint32 indexMaxKeys; | ||
/* 272 | 4 */ // uint32 toast_max_chunk_size; | ||
/* 276 | 4 */ // uint32 loblksize; | ||
/* 280 | 1 */ // _Bool float4ByVal; | ||
/* 281 | 1 */ // _Bool float8ByVal; | ||
/* XXX 2-byte hole */ | ||
/* 284 | 4 */ // uint32 data_checksum_version; | ||
/* 288 | 32 */ // char mock_authentication_nonce[32]; | ||
/* 320 | 4 */ // pg_icu_version icu_version; | ||
/* 324 | 4 */ // uint32 pg_old_version; | ||
/* 328 | 4 */ // SnapshotId oldest_snapshot; | ||
/* 332 | 4 */ // SnapshotId recent_snapshot; | ||
/* 336 | 4 */ // SnapshotId active_snapshot; | ||
/* 340 | 4 */ // pg_crc32c crc; | ||
// | ||
/* total size (bytes): 344 */ | ||
|
||
// type = struct CheckPoint { | ||
/* 0 | 8 */ // XLogRecPtr redo; | ||
/* 8 | 4 */ // TimeLineID ThisTimeLineID; | ||
/* 12 | 4 */ // TimeLineID PrevTimeLineID; | ||
/* 16 | 1 */ // _Bool fullPageWrites; | ||
/* XXX 7-byte hole */ | ||
/* 24 | 8 */ // TransactionId nextXid; | ||
/* 32 | 4 */ // Oid nextOid; | ||
/* XXX 4-byte hole */ | ||
/* 40 | 8 */ // MultiXactId nextMulti; | ||
/* 48 | 8 */ // MultiXactOffset nextMultiOffset; | ||
/* 56 | 8 */ // TransactionId oldestXid; | ||
/* 64 | 4 */ // Oid oldestXidDB; | ||
/* XXX 4-byte hole */ | ||
/* 72 | 8 */ // MultiXactId oldestMulti; | ||
/* 80 | 4 */ // Oid oldestMultiDB; | ||
/* XXX 4-byte hole */ | ||
/* 88 | 8 */ // pg_time_t time; | ||
/* 96 | 8 */ // TransactionId oldestCommitTsXid; | ||
/* 104 | 8 */ // TransactionId newestCommitTsXid; | ||
/* 112 | 8 */ // TransactionId oldestActiveXid; | ||
// | ||
/* total size (bytes): 120 */ |
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,83 @@ | ||
package pgproee11 | ||
|
||
import ( | ||
"github.com/wader/fq/format/postgres/common" | ||
"github.com/wader/fq/format/postgres/flavours/pgproee14/ee14" | ||
"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 PageXLogRecPtr { | ||
/* 0 | 4 */ // uint32 xlogid; | ||
/* 4 | 4 */ // uint32 xrecoff; | ||
// | ||
/* total size (bytes): 8 */ | ||
|
||
// 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; | ||
// } t_field3; | ||
/* total size (bytes): 4 */ | ||
// | ||
/* 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 */ | ||
|
||
// 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 DecodeHeap(d *decode.D) any { | ||
heap := &common14.HeapD{ | ||
PageSize: common.HeapPageSize, | ||
DecodePageHeaderDataFn: ee14.DecodePageHeaderData, | ||
DecodePageSpecialFn: ee14.DecodePageSpecial, | ||
} | ||
return common14.DecodeHeap(d, heap) | ||
} |
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,60 @@ | ||
package ee14 | ||
|
||
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[]; | ||
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) | ||
|
||
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") | ||
}) | ||
} |
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
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
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