Skip to content

Commit

Permalink
add icu version mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Safonov committed Jul 20, 2022
1 parent deaf5ef commit 2b1bdfb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion format/postgres/common/common.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package common

import "github.com/wader/fq/pkg/scalar"
import (
"fmt"
"github.com/wader/fq/pkg/scalar"
)

//typedef enum DBState
//{
Expand Down Expand Up @@ -33,3 +36,17 @@ var WalLevel = scalar.SToScalar{
1: {Sym: "WAL_LEVEL_REPLICA"},
2: {Sym: "WAL_LEVEL_LOGICAL"},
}

type icuVersionMapper struct{}

func (m icuVersionMapper) MapScalar(s scalar.S) (scalar.S, error) {
a := s.ActualU()
major := a & 0xff
minor := (a >> 8) & 0xff
v1 := (a >> 16) & 0xff
v2 := (a >> 24) & 0xff
s.Sym = fmt.Sprintf("%d.%d.%d.%d", major, minor, v1, v2)
return s, nil
}

var IcuVersionMapper = icuVersionMapper{}
2 changes: 1 addition & 1 deletion format/postgres/flavours/pgproee14/pg_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func DecodePgControl(d *decode.D, in any) any {
/* XXX 4-byte padding */
d.FieldU32("data_checksum_version")
d.FieldRawLen("mock_authentication_nonce", 32*8, scalar.RawHex)
d.FieldU32("icu_version")
d.FieldU32("icu_version", common.IcuVersionMapper)
d.FieldU32("pg_old_version")
d.FieldU32("crc")
d.U32()
Expand Down

0 comments on commit 2b1bdfb

Please sign in to comment.