Skip to content

Commit 93773a9

Browse files
authored
Explicitly specify PG client protocol (#4467)
With this, it's safe to unpin `jackc/pgx` dependency and bump its version which is also done in the same PR. The selected protocol version is `3.0` which is he one we were selecting by default values with the pinned version: https://github.com/jackc/pgx/blob/4e4eaedb47b7b3cfba0a1b0a9e6a3f015764f046/pgconn/config.go#L472-L474 With the dependency update, the way of decoding macaddr fields is updated to more recent client library versions, concretely after: jackc/pgx@08c9bb1 According to that change, it was a bug to rely on Stringer representation for composite types as macaddr. The changes in this PR do precisely that, move back to using the stringer interface in the type conversion: e4b97ab
1 parent 2019f86 commit 93773a9

8 files changed

Lines changed: 16 additions & 15 deletions

File tree

flow/cmd/check_pinned_versions/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
var pinnedVersions = map[string]string{
2020
"github.com/aws/aws-sdk-go-v2/feature/s3/manager": "v1.21.0",
2121
"github.com/tikv/pd/client": "v0.0.0-20251229071808-6173d50c004c",
22-
"github.com/jackc/pgx/v5": "v5.9.1",
2322
}
2423

2524
func main() {

flow/connectors/postgres/postgres.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ func ParseConfig(connectionString string, pgConfig *protos.PostgresConfig) (*pgx
176176
return nil, fmt.Errorf("failed to parse connection string: %w", err)
177177
}
178178

179+
// Explicitly set the max protocol version. This removes the risk of inadvertedly
180+
// changing the protocol, for example, through a dependency update.
181+
// The version currently set is the default defined but the previsously pinned
182+
// PG client library jackc/pgx/v5 v5.9.1 -> 3.0
183+
// Reference: https://github.com/jackc/pgx/blob/4e4eaedb47b7b3cfba0a1b0a9e6a3f015764f046/pgconn/config.go#L472-L474
184+
connConfig.Config.MaxProtocolVersion = "3.0"
185+
179186
shouldUseTls := internal.PGMustUseTlsConnection(pgConfig)
180187

181188
if shouldUseTls || pgConfig.RootCa != nil {

flow/connectors/postgres/qvalue_convert.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ func (c *PostgresConnector) convertToString(oid uint32, value any) string {
255255
if value == nil {
256256
return ""
257257
}
258+
if hwAddr, ok := value.(net.HardwareAddr); ok {
259+
return hwAddr.String()
260+
}
258261
if buf, err := c.typeMap.Encode(oid, pgtype.TextFormatCode, value, nil); err == nil {
259262
return shared.UnsafeFastReadOnlyBytesToString(buf)
260263
}

flow/go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ require (
3636
github.com/hamba/avro/v2 v2.31.0
3737
github.com/jackc/pgerrcode v0.0.0-20250907135507-afb5586c32a6
3838
github.com/jackc/pglogrepl v0.0.0-20260401131349-e37c41485510
39-
github.com/jackc/pgx/v5 v5.9.1 // PINNED: v5.9.2 enables Postgres wire protocol v3.2 by default which changes macaddr[] decoding
39+
github.com/jackc/pgx/v5 v5.10.0
4040
github.com/joho/godotenv v1.5.1
4141
github.com/json-iterator/go v1.1.12
4242
github.com/lestrrat-go/httprc/v3 v3.0.5
@@ -333,5 +333,4 @@ exclude (
333333
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.15
334334
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.16
335335
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.17
336-
github.com/jackc/pgx/v5 v5.9.2
337336
)

flow/go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,6 @@ github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
289289
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
290290
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
291291
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
292-
github.com/go-mysql-org/go-mysql v1.15.0 h1:bZeRUc9yNVbFEyote79Q4j8SV+q8Ls32AYXRl2QjUoc=
293-
github.com/go-mysql-org/go-mysql v1.15.0/go.mod h1:VjBTZTTDKL8OMXUAhNbg3VHaVVq9HOXJEBLpAKBFIfE=
294292
github.com/go-mysql-org/go-mysql v1.15.1-0.20260615132323-06b4fb6b476d h1:Kl+pOPwscRCgRjhN76nQkJEiXk49q10BxwHCdSrzyOE=
295293
github.com/go-mysql-org/go-mysql v1.15.1-0.20260615132323-06b4fb6b476d/go.mod h1:VjBTZTTDKL8OMXUAhNbg3VHaVVq9HOXJEBLpAKBFIfE=
296294
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
@@ -433,8 +431,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
433431
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
434432
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
435433
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
436-
github.com/jackc/pgx/v5 v5.9.1 h1:uwrxJXBnx76nyISkhr33kQLlUqjv7et7b9FjCen/tdc=
437-
github.com/jackc/pgx/v5 v5.9.1/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
434+
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
435+
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
438436
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
439437
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
440438
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=

flow/pkg/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/aws/aws-sdk-go-v2/service/s3 v1.101.0
1212
github.com/go-mysql-org/go-mysql v1.15.0
1313
github.com/google/uuid v1.6.0
14-
github.com/jackc/pgx/v5 v5.9.1
14+
github.com/jackc/pgx/v5 v5.10.0
1515
github.com/stretchr/testify v1.11.1
1616
go.mongodb.org/mongo-driver/v2 v2.6.0
1717
go.temporal.io/sdk v1.44.0

flow/pkg/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
125125
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
126126
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
127127
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
128-
github.com/jackc/pgx/v5 v5.9.1 h1:uwrxJXBnx76nyISkhr33kQLlUqjv7et7b9FjCen/tdc=
129-
github.com/jackc/pgx/v5 v5.9.1/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
128+
github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
129+
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
130130
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
131131
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
132132
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

renovate.json5

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@
8888
"matchPackageNames": ["github.com/tikv/pd/client"],
8989
"allowedVersions": "v0.0.0-20251229071808-6173d50c004c"
9090
},
91-
{
92-
"matchManagers": ["gomod"],
93-
"matchPackageNames": ["github.com/jackc/pgx/v5"],
94-
"allowedVersions": "v5.9.1"
95-
},
9691
// This package rule instruct renovate to require approval from
9792
// the dependency dashboard before proposing major upgrades.
9893
// This sets a default is approval mindset for automatic proposals.

0 commit comments

Comments
 (0)