Skip to content

Commit 2b1bdfb

Browse files
author
Pavel Safonov
committed
add icu version mapper
1 parent deaf5ef commit 2b1bdfb

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

format/postgres/common/common.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package common
22

3-
import "github.com/wader/fq/pkg/scalar"
3+
import (
4+
"fmt"
5+
"github.com/wader/fq/pkg/scalar"
6+
)
47

58
//typedef enum DBState
69
//{
@@ -33,3 +36,17 @@ var WalLevel = scalar.SToScalar{
3336
1: {Sym: "WAL_LEVEL_REPLICA"},
3437
2: {Sym: "WAL_LEVEL_LOGICAL"},
3538
}
39+
40+
type icuVersionMapper struct{}
41+
42+
func (m icuVersionMapper) MapScalar(s scalar.S) (scalar.S, error) {
43+
a := s.ActualU()
44+
major := a & 0xff
45+
minor := (a >> 8) & 0xff
46+
v1 := (a >> 16) & 0xff
47+
v2 := (a >> 24) & 0xff
48+
s.Sym = fmt.Sprintf("%d.%d.%d.%d", major, minor, v1, v2)
49+
return s, nil
50+
}
51+
52+
var IcuVersionMapper = icuVersionMapper{}

format/postgres/flavours/pgproee14/pg_control.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func DecodePgControl(d *decode.D, in any) any {
216216
/* XXX 4-byte padding */
217217
d.FieldU32("data_checksum_version")
218218
d.FieldRawLen("mock_authentication_nonce", 32*8, scalar.RawHex)
219-
d.FieldU32("icu_version")
219+
d.FieldU32("icu_version", common.IcuVersionMapper)
220220
d.FieldU32("pg_old_version")
221221
d.FieldU32("crc")
222222
d.U32()

0 commit comments

Comments
 (0)