Skip to content

Commit

Permalink
PostgreSQL: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Safonov committed Aug 4, 2022
1 parent 96a96a5 commit d9de2d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion format/postgres/common/pgheap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import (
)

const (
HeapPageSize = 8192
HeapPageSize = 8192
FirstNormalTransactionId = 3

LP_UNUSED = 0 /* unused (should always have lp_len=0) */
LP_NORMAL = 1 /* used (should always have lp_len>0) */
LP_REDIRECT = 2 /* HOT redirect (should have lp_len=0) */
LP_DEAD = 3
)

func TransactionIdIsNormal(xid uint64) bool {
return xid >= FirstNormalTransactionId
}

type lpOffMapper struct{}

func (m lpOffMapper) MapScalar(s scalar.S) (scalar.S, error) {
Expand Down
4 changes: 2 additions & 2 deletions format/postgres/flavours/postgres14/common14/pgheap.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,12 @@ type TransactionMapper struct {
func (m TransactionMapper) MapScalar(s scalar.S) (scalar.S, error) {
xid := s.ActualU()

if m.Page.PdXidBase != 0 && m.Tuple.IsMulti == 0 {
if m.Page.PdXidBase != 0 && m.Tuple.IsMulti == 0 && common.TransactionIdIsNormal(xid) {
xid64 := xid + m.Page.PdXidBase
s.Sym = fmt.Sprintf("%d", xid64)
}

if m.Page.PdMultiBase != 0 && m.Tuple.IsMulti != 0 {
if m.Page.PdMultiBase != 0 && m.Tuple.IsMulti != 0 && common.TransactionIdIsNormal(xid) {
xid64 := xid + m.Page.PdMultiBase
s.Sym = fmt.Sprintf("%d", xid64)
}
Expand Down

0 comments on commit d9de2d4

Please sign in to comment.