Skip to content

Commit 4ab9b9b

Browse files
committed
Added support for pgx v5
1 parent dffe906 commit 4ab9b9b

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

driver/driver.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/go-sql-driver/mysql"
1111
"github.com/jackc/pgx/v4/stdlib"
12+
v5 "github.com/jackc/pgx/v5/stdlib"
1213
"github.com/lib/pq"
1314
)
1415

@@ -34,11 +35,15 @@ var (
3435
driverMu sync.RWMutex
3536
driverFactories = make(map[string]factory)
3637
availableDrivers = map[string]factory{
37-
"pgx": pgxDriver,
38+
"pgxv4": pgxDriver,
39+
"pgx": pgxV5Driver,
3840
"mysql": mysqlDriver,
3941
"pq": pqDriver,
4042
}
41-
errInvalidDriverName = fmt.Errorf("invalid Driver name. Must be one of: %s", strings.Join(drivers(), ", "))
43+
errInvalidDriverName = fmt.Errorf(
44+
"invalid Driver name. Must be one of: %s",
45+
strings.Join(drivers(), ", "),
46+
)
4247
)
4348

4449
func init() { //nolint:gochecknoinits
@@ -130,6 +135,14 @@ func pgxDriver() *Driver {
130135
}
131136
}
132137

138+
func pgxV5Driver() *Driver {
139+
return &Driver{
140+
Driver: &v5.Driver{},
141+
Formatter: PgFormatter,
142+
AuthError: PostgreSQLAuthError,
143+
}
144+
}
145+
133146
func pqDriver() *Driver {
134147
return &Driver{
135148
Driver: &pq.Driver{},

go.mod

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
module github.com/davepgreene/go-db-credential-refresh
22

3-
go 1.18
3+
go 1.21
4+
5+
toolchain go1.23.2
46

57
require (
68
github.com/go-sql-driver/mysql v1.8.1
79
github.com/go-test/deep v1.1.1
810
github.com/jackc/pgx/v4 v4.18.3
11+
github.com/jackc/pgx/v5 v5.7.1
912
github.com/lib/pq v1.10.9
1013
)
1114

@@ -19,9 +22,11 @@ require (
1922
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
2023
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
2124
github.com/jackc/pgtype v1.14.4 // indirect
25+
github.com/jackc/puddle/v2 v2.2.2 // indirect
2226
github.com/pkg/errors v0.9.1 // indirect
2327
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
2428
github.com/stretchr/testify v1.9.0 // indirect
2529
golang.org/x/crypto v0.28.0 // indirect
30+
golang.org/x/sync v0.8.0 // indirect
2631
golang.org/x/text v0.19.0 // indirect
2732
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgS
6969
github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
7070
github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA=
7171
github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
72+
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
73+
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
7274
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
7375
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
7476
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
7577
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
78+
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
79+
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
7680
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
7781
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
7882
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@@ -166,6 +170,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
166170
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
167171
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
168172
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
173+
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
174+
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
169175
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
170176
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
171177
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

0 commit comments

Comments
 (0)