Skip to content

Commit 45247fe

Browse files
fix: add storage to pinned versions check and fix pgx v5.9 macaddr array decoding
- Add cloud.google.com/go/storage v1.59.2 to pinnedVersions in check_pinned_versions/main.go (the go.mod already had the PINNED comment but the checker map was missing the entry) - Fix convertToStringArray to handle pgx v5.9 binary-encoded array elements: pgx v5.9 may decode macaddr[] columns as pgtype.Array[string] where each element is the 6-byte binary wire format instead of "XX:XX:XX:XX:XX:XX". Use ArrayCodec.ElementType to find the element OID, then attempt a binary→text re-scan; fall back to net.HardwareAddr for macaddr specifically. Co-authored-by: Ilia Demianenko <ilidemi@users.noreply.github.com>
1 parent f9b09fe commit 45247fe

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

flow/cmd/check_pinned_versions/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
var pinnedVersions = map[string]string{
2020
"cloud.google.com/go/bigquery": "v1.72.0",
2121
"cloud.google.com/go/pubsub/v2": "v2.3.0",
22+
"cloud.google.com/go/storage": "v1.59.2",
2223
"github.com/aws/aws-sdk-go-v2/feature/s3/manager": "v1.21.0",
2324
"google.golang.org/api": "v0.257.0",
2425
"github.com/tikv/pd/client": "v0.0.0-20251229071808-6173d50c004c",

flow/connectors/postgres/qvalue_convert.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,30 @@ func (c *PostgresConnector) convertToStringArray(kind types.QValueKind, oid uint
339339
switch v := value.(type) {
340340
case pgtype.Array[string]:
341341
if v.Valid {
342+
// pgx v5.9+ may return binary-encoded elements (e.g. macaddr as 6 raw bytes).
343+
// Detect this by checking if the array type has a known element codec and
344+
// attempting a binary→text re-scan for each non-empty element.
345+
if t, ok := c.typeMap.TypeForOID(oid); ok {
346+
if ac, ok := t.Codec.(*pgtype.ArrayCodec); ok && ac.ElementType != nil {
347+
elemOID := ac.ElementType.OID
348+
result := make([]string, len(v.Elements))
349+
for i, elem := range v.Elements {
350+
if elem == "" {
351+
continue
352+
}
353+
var s string
354+
if err := c.typeMap.Scan(elemOID, pgtype.BinaryFormatCode, []byte(elem), &s); err == nil {
355+
result[i] = s
356+
} else if elemOID == pgtype.MacaddrOID && len(elem) == 6 {
357+
// Explicit fallback: decode macaddr binary (6 bytes) to "XX:XX:XX:XX:XX:XX"
358+
result[i] = net.HardwareAddr([]byte(elem)).String()
359+
} else {
360+
result[i] = elem
361+
}
362+
}
363+
return result, nil
364+
}
365+
}
342366
return v.Elements, nil
343367
}
344368
case []string:

0 commit comments

Comments
 (0)