Skip to content

Commit

Permalink
lsn mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Safonov committed Jul 20, 2022
1 parent 2b1bdfb commit 8d317dd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions format/postgres/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@ func (m icuVersionMapper) MapScalar(s scalar.S) (scalar.S, error) {
}

var IcuVersionMapper = icuVersionMapper{}

type xLogRecPtrMapper struct{}

func (m xLogRecPtrMapper) MapScalar(s scalar.S) (scalar.S, error) {
lsn := s.ActualU()
s.Sym = fmt.Sprintf("%X/%X", lsn>>32, uint32(lsn))
return s, nil
}

var XLogRecPtrMapper = xLogRecPtrMapper{}
4 changes: 2 additions & 2 deletions format/postgres/flavours/pgproee14/pg_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ func DecodePgControl(d *decode.D, in any) any {
/* 32 | 8 */ // XLogRecPtr checkPoint;
/* 40 | 120 */ // CheckPoint checkPointCopy;
d.FieldS64("time")
d.FieldU64("checkPoint")
d.FieldU64("checkPoint", common.XLogRecPtrMapper)
d.FieldStruct("checkPointCopy", func(d *decode.D) {
/* 0 | 8 */ // XLogRecPtr redo;
/* 8 | 4 */ // TimeLineID ThisTimeLineID;
/* 12 | 4 */ // TimeLineID PrevTimeLineID;
/* 16 | 1 */ // _Bool fullPageWrites;
/* XXX 7-byte hole */
d.FieldU64("redo")
d.FieldU64("redo", common.XLogRecPtrMapper)
d.FieldU32("ThisTimeLineID")
d.FieldU32("PrevTimeLineID")
d.FieldU8("fullPageWrites")
Expand Down
4 changes: 2 additions & 2 deletions format/postgres/flavours/postgres11/pg_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ func DecodePgControl(d *decode.D, in any) any {
/* 32 | 8 */ // XLogRecPtr checkPoint;
/* 40 | 80 */ // CheckPoint checkPointCopy;
d.FieldS64("time")
d.FieldU64("checkPoint")
d.FieldU64("checkPoint", common.XLogRecPtrMapper)
d.FieldStruct("checkPointCopy", func(d *decode.D) {
/* 0 | 8 */ // XLogRecPtr redo;
/* 8 | 4 */ // TimeLineID ThisTimeLineID;
/* 12 | 4 */ // TimeLineID PrevTimeLineID;
/* 16 | 1 */ // _Bool fullPageWrites;
/* XXX 3-byte hole */
d.FieldU64("redo")
d.FieldU64("redo", common.XLogRecPtrMapper)
d.FieldU32("ThisTimeLineID")
d.FieldU32("PrevTimeLineID")
d.FieldU8("fullPageWrites")
Expand Down
4 changes: 2 additions & 2 deletions format/postgres/flavours/postgres14/pg_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ func DecodePgControl(d *decode.D, in any) any {
/* 32 | 8 */ // XLogRecPtr checkPoint;
/* 40 | 88 */ // CheckPoint checkPointCopy;
d.FieldS64("time")
d.FieldU64("checkPoint")
d.FieldU64("checkPoint", common.XLogRecPtrMapper)
d.FieldStruct("checkPointCopy", func(d *decode.D) {
/* 0 | 8 */ // XLogRecPtr redo;
/* 8 | 4 */ // TimeLineID ThisTimeLineID;
/* 12 | 4 */ // TimeLineID PrevTimeLineID;
/* 16 | 1 */ // _Bool fullPageWrites;
/* XXX 7-byte hole */
d.FieldU64("redo")
d.FieldU64("redo", common.XLogRecPtrMapper)
d.FieldU32("ThisTimeLineID")
d.FieldU32("PrevTimeLineID")
d.FieldU8("fullPageWrites")
Expand Down

0 comments on commit 8d317dd

Please sign in to comment.