From 6c9e60376cf740d8fb7efc996e74e7cc2d46f2e1 Mon Sep 17 00:00:00 2001 From: Leon Yang Date: Wed, 17 Jan 2024 20:17:51 +0800 Subject: [PATCH] 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 https://github.com/go-sql-driver/mysql/pull/1370. --- cmd/go-tpc/main.go | 2 +- go.mod | 2 +- go.sum | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/go-tpc/main.go b/cmd/go-tpc/main.go index 1b87447..4b4134b 100644 --- a/cmd/go-tpc/main.go +++ b/cmd/go-tpc/main.go @@ -98,7 +98,7 @@ func newDB(targets []string, driver string, user string, password string, dbName switch driver { case mysqlDriver: // allow multiple statements in one query to allow q15 on the TPC-H - dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?multiStatements=true", user, password, addr, dbName) + dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?multiStatements=true&tls=preferred", user, password, addr, dbName) if len(connParams) > 0 { dsn = dsn + "&" + connParams } diff --git a/go.mod b/go.mod index d74391f..423b87f 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/HdrHistogram/hdrhistogram-go v1.0.0 - github.com/go-sql-driver/mysql v1.5.0 + github.com/go-sql-driver/mysql v1.7.1 github.com/jedib0t/go-pretty v4.3.0+incompatible github.com/lib/pq v1.10.6 github.com/olekukonko/tablewriter v0.0.5 diff --git a/go.sum b/go.sum index 38bcc8f..913d530 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,9 @@ github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpX github.com/go-openapi/strfmt v0.19.11 h1:0+YvbNh05rmBkgztd6zHp4OCFn7Mtu30bn46NQo2ZRw= github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= +github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4=