Skip to content

Commit 6c9e603

Browse files
authored
Support connect to both tls and non-tls server (#174)
- Using tls=preferred, the server accepts a TLS connection from the client but is also okay if the client does not switch to encryption. - upgrade go-sql-driver > 1.7.0 to use this feature for older version MySQL server go-sql-driver/mysql#1370.
1 parent fb33a1f commit 6c9e603

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

cmd/go-tpc/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func newDB(targets []string, driver string, user string, password string, dbName
9898
switch driver {
9999
case mysqlDriver:
100100
// allow multiple statements in one query to allow q15 on the TPC-H
101-
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?multiStatements=true", user, password, addr, dbName)
101+
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?multiStatements=true&tls=preferred", user, password, addr, dbName)
102102
if len(connParams) > 0 {
103103
dsn = dsn + "&" + connParams
104104
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
github.com/HdrHistogram/hdrhistogram-go v1.0.0
7-
github.com/go-sql-driver/mysql v1.5.0
7+
github.com/go-sql-driver/mysql v1.7.1
88
github.com/jedib0t/go-pretty v4.3.0+incompatible
99
github.com/lib/pq v1.10.6
1010
github.com/olekukonko/tablewriter v0.0.5

go.sum

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpX
7373
github.com/go-openapi/strfmt v0.19.11 h1:0+YvbNh05rmBkgztd6zHp4OCFn7Mtu30bn46NQo2ZRw=
7474
github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc=
7575
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
76-
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
7776
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
77+
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
78+
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
7879
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
7980
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
8081
github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4=

0 commit comments

Comments
 (0)