Browse Source

upgrade mysql

tags/v2.12.0-rc1
Shivaram Lingamneni 1 year ago
parent
commit
7a82554f9d

+ 1
- 1
go.mod View File

@@ -9,7 +9,7 @@ require (
9 9
 	github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1
10 10
 	github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775
11 11
 	github.com/ergochat/irc-go v0.1.0
12
-	github.com/go-sql-driver/mysql v1.6.0
12
+	github.com/go-sql-driver/mysql v1.7.0
13 13
 	github.com/go-test/deep v1.0.6 // indirect
14 14
 	github.com/golang-jwt/jwt v3.2.2+incompatible
15 15
 	github.com/gorilla/websocket v1.4.2

+ 2
- 0
go.sum View File

@@ -21,6 +21,8 @@ github.com/ergochat/websocket v1.4.2-oragono1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh
21 21
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
22 22
 github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
23 23
 github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
24
+github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
25
+github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
24 26
 github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
25 27
 github.com/go-test/deep v1.0.6/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
26 28
 github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=

+ 7
- 0
vendor/github.com/go-sql-driver/mysql/AUTHORS View File

@@ -23,6 +23,7 @@ Asta Xie <xiemengjun at gmail.com>
23 23
 Bulat Gaifullin <gaifullinbf at gmail.com>
24 24
 Caine Jette <jette at alum.mit.edu>
25 25
 Carlos Nieto <jose.carlos at menteslibres.net>
26
+Chris Kirkland <chriskirkland at github.com>
26 27
 Chris Moos <chris at tech9computers.com>
27 28
 Craig Wilson <craiggwilson at gmail.com>
28 29
 Daniel Montoya <dsmontoyam at gmail.com>
@@ -45,6 +46,7 @@ Ilia Cimpoes <ichimpoesh at gmail.com>
45 46
 INADA Naoki <songofacandy at gmail.com>
46 47
 Jacek Szwec <szwec.jacek at gmail.com>
47 48
 James Harr <james.harr at gmail.com>
49
+Janek Vedock <janekvedock at comcast.net>
48 50
 Jeff Hodges <jeff at somethingsimilar.com>
49 51
 Jeffrey Charles <jeffreycharles at gmail.com>
50 52
 Jerome Meyer <jxmeyer at gmail.com>
@@ -59,12 +61,14 @@ Kamil Dziedzic <kamil at klecza.pl>
59 61
 Kei Kamikawa <x00.x7f.x86 at gmail.com>
60 62
 Kevin Malachowski <kevin at chowski.com>
61 63
 Kieron Woodhouse <kieron.woodhouse at infosum.com>
64
+Lance Tian <lance6716 at gmail.com>
62 65
 Lennart Rudolph <lrudolph at hmc.edu>
63 66
 Leonardo YongUk Kim <dalinaum at gmail.com>
64 67
 Linh Tran Tuan <linhduonggnu at gmail.com>
65 68
 Lion Yang <lion at aosc.xyz>
66 69
 Luca Looz <luca.looz92 at gmail.com>
67 70
 Lucas Liu <extrafliu at gmail.com>
71
+Lunny Xiao <xiaolunwen at gmail.com>
68 72
 Luke Scott <luke at webconnex.com>
69 73
 Maciej Zimnoch <maciej.zimnoch at codilime.com>
70 74
 Michael Woolnough <michael.woolnough at gmail.com>
@@ -79,6 +83,7 @@ Reed Allman <rdallman10 at gmail.com>
79 83
 Richard Wilkes <wilkes at me.com>
80 84
 Robert Russell <robert at rrbrussell.com>
81 85
 Runrioter Wung <runrioter at gmail.com>
86
+Santhosh Kumar Tekuri <santhosh.tekuri at gmail.com>
82 87
 Sho Iizuka <sho.i518 at gmail.com>
83 88
 Sho Ikeda <suicaicoca at gmail.com>
84 89
 Shuode Li <elemount at qq.com>
@@ -99,12 +104,14 @@ Xiuming Chen <cc at cxm.cc>
99 104
 Xuehong Chan <chanxuehong at gmail.com>
100 105
 Zhenye Xie <xiezhenye at gmail.com>
101 106
 Zhixin Wen <john.wenzhixin at gmail.com>
107
+Ziheng Lyu <zihenglv at gmail.com>
102 108
 
103 109
 # Organizations
104 110
 
105 111
 Barracuda Networks, Inc.
106 112
 Counting Ltd.
107 113
 DigitalOcean Inc.
114
+dyves labs AG
108 115
 Facebook Inc.
109 116
 GitHub Inc.
110 117
 Google Inc.

+ 21
- 0
vendor/github.com/go-sql-driver/mysql/CHANGELOG.md View File

@@ -1,3 +1,24 @@
1
+## Version 1.7 (2022-11-29)
2
+
3
+Changes:
4
+
5
+  - Drop support of Go 1.12 (#1211)
6
+  - Refactoring `(*textRows).readRow` in a more clear way (#1230)
7
+  - util: Reduce boundary check in escape functions. (#1316)
8
+  - enhancement for mysqlConn handleAuthResult (#1250)
9
+
10
+New Features:
11
+
12
+  - support Is comparison on MySQLError (#1210)
13
+  - return unsigned in database type name when necessary (#1238)
14
+  - Add API to express like a --ssl-mode=PREFERRED MySQL client (#1370)
15
+  - Add SQLState to MySQLError (#1321)
16
+
17
+Bugfixes:
18
+
19
+  -  Fix parsing 0 year. (#1257)
20
+
21
+
1 22
 ## Version 1.6 (2021-04-01)
2 23
 
3 24
 Changes:

+ 14
- 3
vendor/github.com/go-sql-driver/mysql/README.md View File

@@ -40,7 +40,7 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac
40 40
   * Optional placeholder interpolation
41 41
 
42 42
 ## Requirements
43
-  * Go 1.10 or higher. We aim to support the 3 latest versions of Go.
43
+  * Go 1.13 or higher. We aim to support the 3 latest versions of Go.
44 44
   * MySQL (4.1+), MariaDB, Percona Server, Google CloudSQL or Sphinx (2.2.3+)
45 45
 
46 46
 ---------------------------------------
@@ -85,7 +85,7 @@ db.SetMaxIdleConns(10)
85 85
 
86 86
 `db.SetMaxOpenConns()` is highly recommended to limit the number of connection used by the application. There is no recommended limit number because it depends on application and MySQL server.
87 87
 
88
-`db.SetMaxIdleConns()` is recommended to be set same to (or greater than) `db.SetMaxOpenConns()`. When it is smaller than `SetMaxOpenConns()`, connections can be opened and closed very frequently than you expect. Idle connections can be closed by the `db.SetConnMaxLifetime()`. If you want to close idle connections more rapidly, you can use `db.SetConnMaxIdleTime()` since Go 1.15.
88
+`db.SetMaxIdleConns()` is recommended to be set same to `db.SetMaxOpenConns()`. When it is smaller than `SetMaxOpenConns()`, connections can be opened and closed much more frequently than you expect. Idle connections can be closed by the `db.SetConnMaxLifetime()`. If you want to close idle connections more rapidly, you can use `db.SetConnMaxIdleTime()` since Go 1.15.
89 89
 
90 90
 
91 91
 ### DSN (Data Source Name)
@@ -157,6 +157,17 @@ Default:        false
157 157
 
158 158
 `allowCleartextPasswords=true` allows using the [cleartext client side plugin](https://dev.mysql.com/doc/en/cleartext-pluggable-authentication.html) if required by an account, such as one defined with the [PAM authentication plugin](http://dev.mysql.com/doc/en/pam-authentication-plugin.html). Sending passwords in clear text may be a security problem in some configurations. To avoid problems if there is any possibility that the password would be intercepted, clients should connect to MySQL Server using a method that protects the password. Possibilities include [TLS / SSL](#tls), IPsec, or a private network.
159 159
 
160
+
161
+##### `allowFallbackToPlaintext`
162
+
163
+```
164
+Type:           bool
165
+Valid Values:   true, false
166
+Default:        false
167
+```
168
+
169
+`allowFallbackToPlaintext=true` acts like a `--ssl-mode=PREFERRED` MySQL client as described in [Command Options for Connecting to the Server](https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode)
170
+
160 171
 ##### `allowNativePasswords`
161 172
 
162 173
 ```
@@ -454,7 +465,7 @@ user:password@/
454 465
 The connection pool is managed by Go's database/sql package. For details on how to configure the size of the pool and how long connections stay in the pool see `*DB.SetMaxOpenConns`, `*DB.SetMaxIdleConns`, and `*DB.SetConnMaxLifetime` in the [database/sql documentation](https://golang.org/pkg/database/sql/). The read, write, and dial timeouts for each individual connection are configured with the DSN parameters [`readTimeout`](#readtimeout), [`writeTimeout`](#writetimeout), and [`timeout`](#timeout), respectively.
455 466
 
456 467
 ## `ColumnType` Support
457
-This driver supports the [`ColumnType` interface](https://golang.org/pkg/database/sql/#ColumnType) introduced in Go 1.8, with the exception of [`ColumnType.Length()`](https://golang.org/pkg/database/sql/#ColumnType.Length), which is currently not supported.
468
+This driver supports the [`ColumnType` interface](https://golang.org/pkg/database/sql/#ColumnType) introduced in Go 1.8, with the exception of [`ColumnType.Length()`](https://golang.org/pkg/database/sql/#ColumnType.Length), which is currently not supported. All Unsigned database type names will be returned `UNSIGNED ` with `INT`, `TINYINT`, `SMALLINT`, `BIGINT`.
458 469
 
459 470
 ## `context.Context` Support
460 471
 Go 1.8 added `database/sql` support for `context.Context`. This driver supports query timeouts and cancellation via contexts.

+ 19
- 0
vendor/github.com/go-sql-driver/mysql/atomic_bool.go View File

@@ -0,0 +1,19 @@
1
+// Go MySQL Driver - A MySQL-Driver for Go's database/sql package.
2
+//
3
+// Copyright 2022 The Go-MySQL-Driver Authors. All rights reserved.
4
+//
5
+// This Source Code Form is subject to the terms of the Mozilla Public
6
+// License, v. 2.0. If a copy of the MPL was not distributed with this file,
7
+// You can obtain one at http://mozilla.org/MPL/2.0/.
8
+//go:build go1.19
9
+// +build go1.19
10
+
11
+package mysql
12
+
13
+import "sync/atomic"
14
+
15
+/******************************************************************************
16
+*                               Sync utils                                    *
17
+******************************************************************************/
18
+
19
+type atomicBool = atomic.Bool

+ 47
- 0
vendor/github.com/go-sql-driver/mysql/atomic_bool_go118.go View File

@@ -0,0 +1,47 @@
1
+// Go MySQL Driver - A MySQL-Driver for Go's database/sql package.
2
+//
3
+// Copyright 2022 The Go-MySQL-Driver Authors. All rights reserved.
4
+//
5
+// This Source Code Form is subject to the terms of the Mozilla Public
6
+// License, v. 2.0. If a copy of the MPL was not distributed with this file,
7
+// You can obtain one at http://mozilla.org/MPL/2.0/.
8
+//go:build !go1.19
9
+// +build !go1.19
10
+
11
+package mysql
12
+
13
+import "sync/atomic"
14
+
15
+/******************************************************************************
16
+*                               Sync utils                                    *
17
+******************************************************************************/
18
+
19
+// atomicBool is an implementation of atomic.Bool for older version of Go.
20
+// it is a wrapper around uint32 for usage as a boolean value with
21
+// atomic access.
22
+type atomicBool struct {
23
+	_     noCopy
24
+	value uint32
25
+}
26
+
27
+// Load returns whether the current boolean value is true
28
+func (ab *atomicBool) Load() bool {
29
+	return atomic.LoadUint32(&ab.value) > 0
30
+}
31
+
32
+// Store sets the value of the bool regardless of the previous value
33
+func (ab *atomicBool) Store(value bool) {
34
+	if value {
35
+		atomic.StoreUint32(&ab.value, 1)
36
+	} else {
37
+		atomic.StoreUint32(&ab.value, 0)
38
+	}
39
+}
40
+
41
+// Swap sets the value of the bool and returns the old value.
42
+func (ab *atomicBool) Swap(value bool) bool {
43
+	if value {
44
+		return atomic.SwapUint32(&ab.value, 1) > 0
45
+	}
46
+	return atomic.SwapUint32(&ab.value, 0) > 0
47
+}

+ 34
- 22
vendor/github.com/go-sql-driver/mysql/auth.go View File

@@ -33,27 +33,26 @@ var (
33 33
 // Note: The provided rsa.PublicKey instance is exclusively owned by the driver
34 34
 // after registering it and may not be modified.
35 35
 //
36
-//  data, err := ioutil.ReadFile("mykey.pem")
37
-//  if err != nil {
38
-//  	log.Fatal(err)
39
-//  }
36
+//	data, err := ioutil.ReadFile("mykey.pem")
37
+//	if err != nil {
38
+//		log.Fatal(err)
39
+//	}
40 40
 //
41
-//  block, _ := pem.Decode(data)
42
-//  if block == nil || block.Type != "PUBLIC KEY" {
43
-//  	log.Fatal("failed to decode PEM block containing public key")
44
-//  }
41
+//	block, _ := pem.Decode(data)
42
+//	if block == nil || block.Type != "PUBLIC KEY" {
43
+//		log.Fatal("failed to decode PEM block containing public key")
44
+//	}
45 45
 //
46
-//  pub, err := x509.ParsePKIXPublicKey(block.Bytes)
47
-//  if err != nil {
48
-//  	log.Fatal(err)
49
-//  }
50
-//
51
-//  if rsaPubKey, ok := pub.(*rsa.PublicKey); ok {
52
-//  	mysql.RegisterServerPubKey("mykey", rsaPubKey)
53
-//  } else {
54
-//  	log.Fatal("not a RSA public key")
55
-//  }
46
+//	pub, err := x509.ParsePKIXPublicKey(block.Bytes)
47
+//	if err != nil {
48
+//		log.Fatal(err)
49
+//	}
56 50
 //
51
+//	if rsaPubKey, ok := pub.(*rsa.PublicKey); ok {
52
+//		mysql.RegisterServerPubKey("mykey", rsaPubKey)
53
+//	} else {
54
+//		log.Fatal("not a RSA public key")
55
+//	}
57 56
 func RegisterServerPubKey(name string, pubKey *rsa.PublicKey) {
58 57
 	serverPubKeyLock.Lock()
59 58
 	if serverPubKeyRegistry == nil {
@@ -274,7 +273,9 @@ func (mc *mysqlConn) auth(authData []byte, plugin string) ([]byte, error) {
274 273
 		if len(mc.cfg.Passwd) == 0 {
275 274
 			return []byte{0}, nil
276 275
 		}
277
-		if mc.cfg.tls != nil || mc.cfg.Net == "unix" {
276
+		// unlike caching_sha2_password, sha256_password does not accept
277
+		// cleartext password on unix transport.
278
+		if mc.cfg.TLS != nil {
278 279
 			// write cleartext auth packet
279 280
 			return append([]byte(mc.cfg.Passwd), 0), nil
280 281
 		}
@@ -350,7 +351,7 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
350 351
 				}
351 352
 
352 353
 			case cachingSha2PasswordPerformFullAuthentication:
353
-				if mc.cfg.tls != nil || mc.cfg.Net == "unix" {
354
+				if mc.cfg.TLS != nil || mc.cfg.Net == "unix" {
354 355
 					// write cleartext auth packet
355 356
 					err = mc.writeAuthSwitchPacket(append([]byte(mc.cfg.Passwd), 0))
356 357
 					if err != nil {
@@ -365,13 +366,20 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
365 366
 							return err
366 367
 						}
367 368
 						data[4] = cachingSha2PasswordRequestPublicKey
368
-						mc.writePacket(data)
369
+						err = mc.writePacket(data)
370
+						if err != nil {
371
+							return err
372
+						}
369 373
 
370
-						// parse public key
371 374
 						if data, err = mc.readPacket(); err != nil {
372 375
 							return err
373 376
 						}
374 377
 
378
+						if data[0] != iAuthMoreData {
379
+							return fmt.Errorf("unexpect resp from server for caching_sha2_password perform full authentication")
380
+						}
381
+
382
+						// parse public key
375 383
 						block, rest := pem.Decode(data[1:])
376 384
 						if block == nil {
377 385
 							return fmt.Errorf("No Pem data found, data: %s", rest)
@@ -404,6 +412,10 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
404 412
 			return nil // auth successful
405 413
 		default:
406 414
 			block, _ := pem.Decode(authData)
415
+			if block == nil {
416
+				return fmt.Errorf("no Pem data found, data: %s", authData)
417
+			}
418
+
407 419
 			pub, err := x509.ParsePKIXPublicKey(block.Bytes)
408 420
 			if err != nil {
409 421
 				return err

+ 2
- 1
vendor/github.com/go-sql-driver/mysql/collations.go View File

@@ -13,7 +13,8 @@ const binaryCollation = "binary"
13 13
 
14 14
 // A list of available collations mapped to the internal ID.
15 15
 // To update this map use the following MySQL query:
16
-//     SELECT COLLATION_NAME, ID FROM information_schema.COLLATIONS WHERE ID<256 ORDER BY ID
16
+//
17
+//	SELECT COLLATION_NAME, ID FROM information_schema.COLLATIONS WHERE ID<256 ORDER BY ID
17 18
 //
18 19
 // Handshake packet have only 1 byte for collation_id.  So we can't use collations with ID > 255.
19 20
 //

+ 1
- 0
vendor/github.com/go-sql-driver/mysql/conncheck.go View File

@@ -6,6 +6,7 @@
6 6
 // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 7
 // You can obtain one at http://mozilla.org/MPL/2.0/.
8 8
 
9
+//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
9 10
 // +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
10 11
 
11 12
 package mysql

+ 1
- 0
vendor/github.com/go-sql-driver/mysql/conncheck_dummy.go View File

@@ -6,6 +6,7 @@
6 6
 // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 7
 // You can obtain one at http://mozilla.org/MPL/2.0/.
8 8
 
9
+//go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos
9 10
 // +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos
10 11
 
11 12
 package mysql

+ 11
- 11
vendor/github.com/go-sql-driver/mysql/connection.go View File

@@ -104,7 +104,7 @@ func (mc *mysqlConn) Begin() (driver.Tx, error) {
104 104
 }
105 105
 
106 106
 func (mc *mysqlConn) begin(readOnly bool) (driver.Tx, error) {
107
-	if mc.closed.IsSet() {
107
+	if mc.closed.Load() {
108 108
 		errLog.Print(ErrInvalidConn)
109 109
 		return nil, driver.ErrBadConn
110 110
 	}
@@ -123,7 +123,7 @@ func (mc *mysqlConn) begin(readOnly bool) (driver.Tx, error) {
123 123
 
124 124
 func (mc *mysqlConn) Close() (err error) {
125 125
 	// Makes Close idempotent
126
-	if !mc.closed.IsSet() {
126
+	if !mc.closed.Load() {
127 127
 		err = mc.writeCommandPacket(comQuit)
128 128
 	}
129 129
 
@@ -137,7 +137,7 @@ func (mc *mysqlConn) Close() (err error) {
137 137
 // is called before auth or on auth failure because MySQL will have already
138 138
 // closed the network connection.
139 139
 func (mc *mysqlConn) cleanup() {
140
-	if !mc.closed.TrySet(true) {
140
+	if mc.closed.Swap(true) {
141 141
 		return
142 142
 	}
143 143
 
@@ -152,7 +152,7 @@ func (mc *mysqlConn) cleanup() {
152 152
 }
153 153
 
154 154
 func (mc *mysqlConn) error() error {
155
-	if mc.closed.IsSet() {
155
+	if mc.closed.Load() {
156 156
 		if err := mc.canceled.Value(); err != nil {
157 157
 			return err
158 158
 		}
@@ -162,7 +162,7 @@ func (mc *mysqlConn) error() error {
162 162
 }
163 163
 
164 164
 func (mc *mysqlConn) Prepare(query string) (driver.Stmt, error) {
165
-	if mc.closed.IsSet() {
165
+	if mc.closed.Load() {
166 166
 		errLog.Print(ErrInvalidConn)
167 167
 		return nil, driver.ErrBadConn
168 168
 	}
@@ -295,7 +295,7 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
295 295
 }
296 296
 
297 297
 func (mc *mysqlConn) Exec(query string, args []driver.Value) (driver.Result, error) {
298
-	if mc.closed.IsSet() {
298
+	if mc.closed.Load() {
299 299
 		errLog.Print(ErrInvalidConn)
300 300
 		return nil, driver.ErrBadConn
301 301
 	}
@@ -356,7 +356,7 @@ func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, erro
356 356
 }
357 357
 
358 358
 func (mc *mysqlConn) query(query string, args []driver.Value) (*textRows, error) {
359
-	if mc.closed.IsSet() {
359
+	if mc.closed.Load() {
360 360
 		errLog.Print(ErrInvalidConn)
361 361
 		return nil, driver.ErrBadConn
362 362
 	}
@@ -450,7 +450,7 @@ func (mc *mysqlConn) finish() {
450 450
 
451 451
 // Ping implements driver.Pinger interface
452 452
 func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
453
-	if mc.closed.IsSet() {
453
+	if mc.closed.Load() {
454 454
 		errLog.Print(ErrInvalidConn)
455 455
 		return driver.ErrBadConn
456 456
 	}
@@ -469,7 +469,7 @@ func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
469 469
 
470 470
 // BeginTx implements driver.ConnBeginTx interface
471 471
 func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
472
-	if mc.closed.IsSet() {
472
+	if mc.closed.Load() {
473 473
 		return nil, driver.ErrBadConn
474 474
 	}
475 475
 
@@ -636,7 +636,7 @@ func (mc *mysqlConn) CheckNamedValue(nv *driver.NamedValue) (err error) {
636 636
 // ResetSession implements driver.SessionResetter.
637 637
 // (From Go 1.10)
638 638
 func (mc *mysqlConn) ResetSession(ctx context.Context) error {
639
-	if mc.closed.IsSet() {
639
+	if mc.closed.Load() {
640 640
 		return driver.ErrBadConn
641 641
 	}
642 642
 	mc.reset = true
@@ -646,5 +646,5 @@ func (mc *mysqlConn) ResetSession(ctx context.Context) error {
646 646
 // IsValid implements driver.Validator interface
647 647
 // (From Go 1.15)
648 648
 func (mc *mysqlConn) IsValid() bool {
649
-	return !mc.closed.IsSet()
649
+	return !mc.closed.Load()
650 650
 }

+ 3
- 3
vendor/github.com/go-sql-driver/mysql/driver.go View File

@@ -8,10 +8,10 @@
8 8
 //
9 9
 // The driver should be used via the database/sql package:
10 10
 //
11
-//  import "database/sql"
12
-//  import _ "github.com/go-sql-driver/mysql"
11
+//	import "database/sql"
12
+//	import _ "github.com/go-sql-driver/mysql"
13 13
 //
14
-//  db, err := sql.Open("mysql", "user:password@/dbname")
14
+//	db, err := sql.Open("mysql", "user:password@/dbname")
15 15
 //
16 16
 // See https://github.com/go-sql-driver/mysql#usage for details
17 17
 package mysql

+ 45
- 28
vendor/github.com/go-sql-driver/mysql/dsn.go View File

@@ -46,22 +46,23 @@ type Config struct {
46 46
 	ServerPubKey     string            // Server public key name
47 47
 	pubKey           *rsa.PublicKey    // Server public key
48 48
 	TLSConfig        string            // TLS configuration name
49
-	tls              *tls.Config       // TLS configuration
49
+	TLS              *tls.Config       // TLS configuration, its priority is higher than TLSConfig
50 50
 	Timeout          time.Duration     // Dial timeout
51 51
 	ReadTimeout      time.Duration     // I/O read timeout
52 52
 	WriteTimeout     time.Duration     // I/O write timeout
53 53
 
54
-	AllowAllFiles           bool // Allow all files to be used with LOAD DATA LOCAL INFILE
55
-	AllowCleartextPasswords bool // Allows the cleartext client side plugin
56
-	AllowNativePasswords    bool // Allows the native password authentication method
57
-	AllowOldPasswords       bool // Allows the old insecure password method
58
-	CheckConnLiveness       bool // Check connections for liveness before using them
59
-	ClientFoundRows         bool // Return number of matching rows instead of rows changed
60
-	ColumnsWithAlias        bool // Prepend table alias to column names
61
-	InterpolateParams       bool // Interpolate placeholders into query string
62
-	MultiStatements         bool // Allow multiple statements in one query
63
-	ParseTime               bool // Parse time values to time.Time
64
-	RejectReadOnly          bool // Reject read-only connections
54
+	AllowAllFiles            bool // Allow all files to be used with LOAD DATA LOCAL INFILE
55
+	AllowCleartextPasswords  bool // Allows the cleartext client side plugin
56
+	AllowFallbackToPlaintext bool // Allows fallback to unencrypted connection if server does not support TLS
57
+	AllowNativePasswords     bool // Allows the native password authentication method
58
+	AllowOldPasswords        bool // Allows the old insecure password method
59
+	CheckConnLiveness        bool // Check connections for liveness before using them
60
+	ClientFoundRows          bool // Return number of matching rows instead of rows changed
61
+	ColumnsWithAlias         bool // Prepend table alias to column names
62
+	InterpolateParams        bool // Interpolate placeholders into query string
63
+	MultiStatements          bool // Allow multiple statements in one query
64
+	ParseTime                bool // Parse time values to time.Time
65
+	RejectReadOnly           bool // Reject read-only connections
65 66
 }
66 67
 
67 68
 // NewConfig creates a new Config and sets default values.
@@ -77,8 +78,8 @@ func NewConfig() *Config {
77 78
 
78 79
 func (cfg *Config) Clone() *Config {
79 80
 	cp := *cfg
80
-	if cp.tls != nil {
81
-		cp.tls = cfg.tls.Clone()
81
+	if cp.TLS != nil {
82
+		cp.TLS = cfg.TLS.Clone()
82 83
 	}
83 84
 	if len(cp.Params) > 0 {
84 85
 		cp.Params = make(map[string]string, len(cfg.Params))
@@ -119,24 +120,29 @@ func (cfg *Config) normalize() error {
119 120
 		cfg.Addr = ensureHavePort(cfg.Addr)
120 121
 	}
121 122
 
122
-	switch cfg.TLSConfig {
123
-	case "false", "":
124
-		// don't set anything
125
-	case "true":
126
-		cfg.tls = &tls.Config{}
127
-	case "skip-verify", "preferred":
128
-		cfg.tls = &tls.Config{InsecureSkipVerify: true}
129
-	default:
130
-		cfg.tls = getTLSConfigClone(cfg.TLSConfig)
131
-		if cfg.tls == nil {
132
-			return errors.New("invalid value / unknown config name: " + cfg.TLSConfig)
123
+	if cfg.TLS == nil {
124
+		switch cfg.TLSConfig {
125
+		case "false", "":
126
+			// don't set anything
127
+		case "true":
128
+			cfg.TLS = &tls.Config{}
129
+		case "skip-verify":
130
+			cfg.TLS = &tls.Config{InsecureSkipVerify: true}
131
+		case "preferred":
132
+			cfg.TLS = &tls.Config{InsecureSkipVerify: true}
133
+			cfg.AllowFallbackToPlaintext = true
134
+		default:
135
+			cfg.TLS = getTLSConfigClone(cfg.TLSConfig)
136
+			if cfg.TLS == nil {
137
+				return errors.New("invalid value / unknown config name: " + cfg.TLSConfig)
138
+			}
133 139
 		}
134 140
 	}
135 141
 
136
-	if cfg.tls != nil && cfg.tls.ServerName == "" && !cfg.tls.InsecureSkipVerify {
142
+	if cfg.TLS != nil && cfg.TLS.ServerName == "" && !cfg.TLS.InsecureSkipVerify {
137 143
 		host, _, err := net.SplitHostPort(cfg.Addr)
138 144
 		if err == nil {
139
-			cfg.tls.ServerName = host
145
+			cfg.TLS.ServerName = host
140 146
 		}
141 147
 	}
142 148
 
@@ -204,6 +210,10 @@ func (cfg *Config) FormatDSN() string {
204 210
 		writeDSNParam(&buf, &hasParam, "allowCleartextPasswords", "true")
205 211
 	}
206 212
 
213
+	if cfg.AllowFallbackToPlaintext {
214
+		writeDSNParam(&buf, &hasParam, "allowFallbackToPlaintext", "true")
215
+	}
216
+
207 217
 	if !cfg.AllowNativePasswords {
208 218
 		writeDSNParam(&buf, &hasParam, "allowNativePasswords", "false")
209 219
 	}
@@ -391,6 +401,14 @@ func parseDSNParams(cfg *Config, params string) (err error) {
391 401
 				return errors.New("invalid bool value: " + value)
392 402
 			}
393 403
 
404
+		// Allow fallback to unencrypted connection if server does not support TLS
405
+		case "allowFallbackToPlaintext":
406
+			var isBool bool
407
+			cfg.AllowFallbackToPlaintext, isBool = readBool(value)
408
+			if !isBool {
409
+				return errors.New("invalid bool value: " + value)
410
+			}
411
+
394 412
 		// Use native password authentication
395 413
 		case "allowNativePasswords":
396 414
 			var isBool bool
@@ -426,7 +444,6 @@ func parseDSNParams(cfg *Config, params string) (err error) {
426 444
 		// Collation
427 445
 		case "collation":
428 446
 			cfg.Collation = value
429
-			break
430 447
 
431 448
 		case "columnsWithAlias":
432 449
 			var isBool bool

+ 14
- 2
vendor/github.com/go-sql-driver/mysql/errors.go View File

@@ -56,10 +56,22 @@ func SetLogger(logger Logger) error {
56 56
 
57 57
 // MySQLError is an error type which represents a single MySQL error
58 58
 type MySQLError struct {
59
-	Number  uint16
60
-	Message string
59
+	Number   uint16
60
+	SQLState [5]byte
61
+	Message  string
61 62
 }
62 63
 
63 64
 func (me *MySQLError) Error() string {
65
+	if me.SQLState != [5]byte{} {
66
+		return fmt.Sprintf("Error %d (%s): %s", me.Number, me.SQLState, me.Message)
67
+	}
68
+
64 69
 	return fmt.Sprintf("Error %d: %s", me.Number, me.Message)
65 70
 }
71
+
72
+func (me *MySQLError) Is(err error) bool {
73
+	if merr, ok := err.(*MySQLError); ok {
74
+		return merr.Number == me.Number
75
+	}
76
+	return false
77
+}

+ 13
- 1
vendor/github.com/go-sql-driver/mysql/fields.go View File

@@ -41,6 +41,9 @@ func (mf *mysqlField) typeDatabaseName() string {
41 41
 	case fieldTypeJSON:
42 42
 		return "JSON"
43 43
 	case fieldTypeLong:
44
+		if mf.flags&flagUnsigned != 0 {
45
+			return "UNSIGNED INT"
46
+		}
44 47
 		return "INT"
45 48
 	case fieldTypeLongBLOB:
46 49
 		if mf.charSet != collations[binaryCollation] {
@@ -48,6 +51,9 @@ func (mf *mysqlField) typeDatabaseName() string {
48 51
 		}
49 52
 		return "LONGBLOB"
50 53
 	case fieldTypeLongLong:
54
+		if mf.flags&flagUnsigned != 0 {
55
+			return "UNSIGNED BIGINT"
56
+		}
51 57
 		return "BIGINT"
52 58
 	case fieldTypeMediumBLOB:
53 59
 		if mf.charSet != collations[binaryCollation] {
@@ -63,6 +69,9 @@ func (mf *mysqlField) typeDatabaseName() string {
63 69
 	case fieldTypeSet:
64 70
 		return "SET"
65 71
 	case fieldTypeShort:
72
+		if mf.flags&flagUnsigned != 0 {
73
+			return "UNSIGNED SMALLINT"
74
+		}
66 75
 		return "SMALLINT"
67 76
 	case fieldTypeString:
68 77
 		if mf.charSet == collations[binaryCollation] {
@@ -74,6 +83,9 @@ func (mf *mysqlField) typeDatabaseName() string {
74 83
 	case fieldTypeTimestamp:
75 84
 		return "TIMESTAMP"
76 85
 	case fieldTypeTiny:
86
+		if mf.flags&flagUnsigned != 0 {
87
+			return "UNSIGNED TINYINT"
88
+		}
77 89
 		return "TINYINT"
78 90
 	case fieldTypeTinyBLOB:
79 91
 		if mf.charSet != collations[binaryCollation] {
@@ -106,7 +118,7 @@ var (
106 118
 	scanTypeInt64     = reflect.TypeOf(int64(0))
107 119
 	scanTypeNullFloat = reflect.TypeOf(sql.NullFloat64{})
108 120
 	scanTypeNullInt   = reflect.TypeOf(sql.NullInt64{})
109
-	scanTypeNullTime  = reflect.TypeOf(nullTime{})
121
+	scanTypeNullTime  = reflect.TypeOf(sql.NullTime{})
110 122
 	scanTypeUint8     = reflect.TypeOf(uint8(0))
111 123
 	scanTypeUint16    = reflect.TypeOf(uint16(0))
112 124
 	scanTypeUint32    = reflect.TypeOf(uint32(0))

+ 1
- 0
vendor/github.com/go-sql-driver/mysql/fuzz.go View File

@@ -6,6 +6,7 @@
6 6
 // License, v. 2.0. If a copy of the MPL was not distributed with this file,
7 7
 // You can obtain one at http://mozilla.org/MPL/2.0/.
8 8
 
9
+//go:build gofuzz
9 10
 // +build gofuzz
10 11
 
11 12
 package mysql

+ 16
- 16
vendor/github.com/go-sql-driver/mysql/infile.go View File

@@ -28,12 +28,11 @@ var (
28 28
 // Alternatively you can allow the use of all local files with
29 29
 // the DSN parameter 'allowAllFiles=true'
30 30
 //
31
-//  filePath := "/home/gopher/data.csv"
32
-//  mysql.RegisterLocalFile(filePath)
33
-//  err := db.Exec("LOAD DATA LOCAL INFILE '" + filePath + "' INTO TABLE foo")
34
-//  if err != nil {
35
-//  ...
36
-//
31
+//	filePath := "/home/gopher/data.csv"
32
+//	mysql.RegisterLocalFile(filePath)
33
+//	err := db.Exec("LOAD DATA LOCAL INFILE '" + filePath + "' INTO TABLE foo")
34
+//	if err != nil {
35
+//	...
37 36
 func RegisterLocalFile(filePath string) {
38 37
 	fileRegisterLock.Lock()
39 38
 	// lazy map init
@@ -58,15 +57,14 @@ func DeregisterLocalFile(filePath string) {
58 57
 // If the handler returns a io.ReadCloser Close() is called when the
59 58
 // request is finished.
60 59
 //
61
-//  mysql.RegisterReaderHandler("data", func() io.Reader {
62
-//  	var csvReader io.Reader // Some Reader that returns CSV data
63
-//  	... // Open Reader here
64
-//  	return csvReader
65
-//  })
66
-//  err := db.Exec("LOAD DATA LOCAL INFILE 'Reader::data' INTO TABLE foo")
67
-//  if err != nil {
68
-//  ...
69
-//
60
+//	mysql.RegisterReaderHandler("data", func() io.Reader {
61
+//		var csvReader io.Reader // Some Reader that returns CSV data
62
+//		... // Open Reader here
63
+//		return csvReader
64
+//	})
65
+//	err := db.Exec("LOAD DATA LOCAL INFILE 'Reader::data' INTO TABLE foo")
66
+//	if err != nil {
67
+//	...
70 68
 func RegisterReaderHandler(name string, handler func() io.Reader) {
71 69
 	readerRegisterLock.Lock()
72 70
 	// lazy map init
@@ -93,10 +91,12 @@ func deferredClose(err *error, closer io.Closer) {
93 91
 	}
94 92
 }
95 93
 
94
+const defaultPacketSize = 16 * 1024 // 16KB is small enough for disk readahead and large enough for TCP
95
+
96 96
 func (mc *mysqlConn) handleInFileRequest(name string) (err error) {
97 97
 	var rdr io.Reader
98 98
 	var data []byte
99
-	packetSize := 16 * 1024 // 16KB is small enough for disk readahead and large enough for TCP
99
+	packetSize := defaultPacketSize
100 100
 	if mc.maxWriteSize < packetSize {
101 101
 		packetSize = mc.maxWriteSize
102 102
 	}

+ 21
- 0
vendor/github.com/go-sql-driver/mysql/nulltime.go View File

@@ -9,11 +9,32 @@
9 9
 package mysql
10 10
 
11 11
 import (
12
+	"database/sql"
12 13
 	"database/sql/driver"
13 14
 	"fmt"
14 15
 	"time"
15 16
 )
16 17
 
18
+// NullTime represents a time.Time that may be NULL.
19
+// NullTime implements the Scanner interface so
20
+// it can be used as a scan destination:
21
+//
22
+//	var nt NullTime
23
+//	err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt)
24
+//	...
25
+//	if nt.Valid {
26
+//	   // use nt.Time
27
+//	} else {
28
+//	   // NULL value
29
+//	}
30
+//
31
+// # This NullTime implementation is not driver-specific
32
+//
33
+// Deprecated: NullTime doesn't honor the loc DSN parameter.
34
+// NullTime.Scan interprets a time as UTC, not the loc DSN parameter.
35
+// Use sql.NullTime instead.
36
+type NullTime sql.NullTime
37
+
17 38
 // Scan implements the Scanner interface.
18 39
 // The value type must be time.Time or string / []byte (formatted time-string),
19 40
 // otherwise Scan fails.

+ 0
- 40
vendor/github.com/go-sql-driver/mysql/nulltime_go113.go View File

@@ -1,40 +0,0 @@
1
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2
-//
3
-// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
4
-//
5
-// This Source Code Form is subject to the terms of the Mozilla Public
6
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
7
-// You can obtain one at http://mozilla.org/MPL/2.0/.
8
-
9
-// +build go1.13
10
-
11
-package mysql
12
-
13
-import (
14
-	"database/sql"
15
-)
16
-
17
-// NullTime represents a time.Time that may be NULL.
18
-// NullTime implements the Scanner interface so
19
-// it can be used as a scan destination:
20
-//
21
-//  var nt NullTime
22
-//  err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt)
23
-//  ...
24
-//  if nt.Valid {
25
-//     // use nt.Time
26
-//  } else {
27
-//     // NULL value
28
-//  }
29
-//
30
-// This NullTime implementation is not driver-specific
31
-//
32
-// Deprecated: NullTime doesn't honor the loc DSN parameter.
33
-// NullTime.Scan interprets a time as UTC, not the loc DSN parameter.
34
-// Use sql.NullTime instead.
35
-type NullTime sql.NullTime
36
-
37
-// for internal use.
38
-// the mysql package uses sql.NullTime if it is available.
39
-// if not, the package uses mysql.NullTime.
40
-type nullTime = sql.NullTime // sql.NullTime is available

+ 0
- 39
vendor/github.com/go-sql-driver/mysql/nulltime_legacy.go View File

@@ -1,39 +0,0 @@
1
-// Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2
-//
3
-// Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved.
4
-//
5
-// This Source Code Form is subject to the terms of the Mozilla Public
6
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
7
-// You can obtain one at http://mozilla.org/MPL/2.0/.
8
-
9
-// +build !go1.13
10
-
11
-package mysql
12
-
13
-import (
14
-	"time"
15
-)
16
-
17
-// NullTime represents a time.Time that may be NULL.
18
-// NullTime implements the Scanner interface so
19
-// it can be used as a scan destination:
20
-//
21
-//  var nt NullTime
22
-//  err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt)
23
-//  ...
24
-//  if nt.Valid {
25
-//     // use nt.Time
26
-//  } else {
27
-//     // NULL value
28
-//  }
29
-//
30
-// This NullTime implementation is not driver-specific
31
-type NullTime struct {
32
-	Time  time.Time
33
-	Valid bool // Valid is true if Time is not NULL
34
-}
35
-
36
-// for internal use.
37
-// the mysql package uses sql.NullTime if it is available.
38
-// if not, the package uses mysql.NullTime.
39
-type nullTime = NullTime // sql.NullTime is not available

+ 45
- 45
vendor/github.com/go-sql-driver/mysql/packets.go View File

@@ -110,14 +110,13 @@ func (mc *mysqlConn) writePacket(data []byte) error {
110 110
 			conn = mc.rawConn
111 111
 		}
112 112
 		var err error
113
-		// If this connection has a ReadTimeout which we've been setting on
114
-		// reads, reset it to its default value before we attempt a non-blocking
115
-		// read, otherwise the scheduler will just time us out before we can read
116
-		if mc.cfg.ReadTimeout != 0 {
117
-			err = conn.SetReadDeadline(time.Time{})
118
-		}
119
-		if err == nil && mc.cfg.CheckConnLiveness {
120
-			err = connCheck(conn)
113
+		if mc.cfg.CheckConnLiveness {
114
+			if mc.cfg.ReadTimeout != 0 {
115
+				err = conn.SetReadDeadline(time.Now().Add(mc.cfg.ReadTimeout))
116
+			}
117
+			if err == nil {
118
+				err = connCheck(conn)
119
+			}
121 120
 		}
122 121
 		if err != nil {
123 122
 			errLog.Print("closing bad idle connection: ", err)
@@ -223,9 +222,9 @@ func (mc *mysqlConn) readHandshakePacket() (data []byte, plugin string, err erro
223 222
 	if mc.flags&clientProtocol41 == 0 {
224 223
 		return nil, "", ErrOldProtocol
225 224
 	}
226
-	if mc.flags&clientSSL == 0 && mc.cfg.tls != nil {
227
-		if mc.cfg.TLSConfig == "preferred" {
228
-			mc.cfg.tls = nil
225
+	if mc.flags&clientSSL == 0 && mc.cfg.TLS != nil {
226
+		if mc.cfg.AllowFallbackToPlaintext {
227
+			mc.cfg.TLS = nil
229 228
 		} else {
230 229
 			return nil, "", ErrNoTLS
231 230
 		}
@@ -293,7 +292,7 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
293 292
 	}
294 293
 
295 294
 	// To enable TLS / SSL
296
-	if mc.cfg.tls != nil {
295
+	if mc.cfg.TLS != nil {
297 296
 		clientFlags |= clientSSL
298 297
 	}
299 298
 
@@ -357,14 +356,14 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
357 356
 
358 357
 	// SSL Connection Request Packet
359 358
 	// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest
360
-	if mc.cfg.tls != nil {
359
+	if mc.cfg.TLS != nil {
361 360
 		// Send TLS / SSL request packet
362 361
 		if err := mc.writePacket(data[:(4+4+1+23)+4]); err != nil {
363 362
 			return err
364 363
 		}
365 364
 
366 365
 		// Switch to TLS
367
-		tlsConn := tls.Client(mc.netConn, mc.cfg.tls)
366
+		tlsConn := tls.Client(mc.netConn, mc.cfg.TLS)
368 367
 		if err := tlsConn.Handshake(); err != nil {
369 368
 			return err
370 369
 		}
@@ -588,19 +587,20 @@ func (mc *mysqlConn) handleErrorPacket(data []byte) error {
588 587
 		return driver.ErrBadConn
589 588
 	}
590 589
 
590
+	me := &MySQLError{Number: errno}
591
+
591 592
 	pos := 3
592 593
 
593 594
 	// SQL State [optional: # + 5bytes string]
594 595
 	if data[3] == 0x23 {
595
-		//sqlstate := string(data[4 : 4+5])
596
+		copy(me.SQLState[:], data[4:4+5])
596 597
 		pos = 9
597 598
 	}
598 599
 
599 600
 	// Error Message [string]
600
-	return &MySQLError{
601
-		Number:  errno,
602
-		Message: string(data[pos:]),
603
-	}
601
+	me.Message = string(data[pos:])
602
+
603
+	return me
604 604
 }
605 605
 
606 606
 func readStatus(b []byte) statusFlag {
@@ -761,40 +761,40 @@ func (rows *textRows) readRow(dest []driver.Value) error {
761 761
 	}
762 762
 
763 763
 	// RowSet Packet
764
-	var n int
765
-	var isNull bool
766
-	pos := 0
764
+	var (
765
+		n      int
766
+		isNull bool
767
+		pos    int = 0
768
+	)
767 769
 
768 770
 	for i := range dest {
769 771
 		// Read bytes and convert to string
770 772
 		dest[i], isNull, n, err = readLengthEncodedString(data[pos:])
771 773
 		pos += n
772
-		if err == nil {
773
-			if !isNull {
774
-				if !mc.parseTime {
775
-					continue
776
-				} else {
777
-					switch rows.rs.columns[i].fieldType {
778
-					case fieldTypeTimestamp, fieldTypeDateTime,
779
-						fieldTypeDate, fieldTypeNewDate:
780
-						dest[i], err = parseDateTime(
781
-							dest[i].([]byte),
782
-							mc.cfg.Loc,
783
-						)
784
-						if err == nil {
785
-							continue
786
-						}
787
-					default:
788
-						continue
789
-					}
790
-				}
791 774
 
792
-			} else {
793
-				dest[i] = nil
794
-				continue
775
+		if err != nil {
776
+			return err
777
+		}
778
+
779
+		if isNull {
780
+			dest[i] = nil
781
+			continue
782
+		}
783
+
784
+		if !mc.parseTime {
785
+			continue
786
+		}
787
+
788
+		// Parse time field
789
+		switch rows.rs.columns[i].fieldType {
790
+		case fieldTypeTimestamp,
791
+			fieldTypeDateTime,
792
+			fieldTypeDate,
793
+			fieldTypeNewDate:
794
+			if dest[i], err = parseDateTime(dest[i].([]byte), mc.cfg.Loc); err != nil {
795
+				return err
795 796
 			}
796 797
 		}
797
-		return err // err != nil
798 798
 	}
799 799
 
800 800
 	return nil

+ 4
- 4
vendor/github.com/go-sql-driver/mysql/statement.go View File

@@ -23,7 +23,7 @@ type mysqlStmt struct {
23 23
 }
24 24
 
25 25
 func (stmt *mysqlStmt) Close() error {
26
-	if stmt.mc == nil || stmt.mc.closed.IsSet() {
26
+	if stmt.mc == nil || stmt.mc.closed.Load() {
27 27
 		// driver.Stmt.Close can be called more than once, thus this function
28 28
 		// has to be idempotent.
29 29
 		// See also Issue #450 and golang/go#16019.
@@ -50,7 +50,7 @@ func (stmt *mysqlStmt) CheckNamedValue(nv *driver.NamedValue) (err error) {
50 50
 }
51 51
 
52 52
 func (stmt *mysqlStmt) Exec(args []driver.Value) (driver.Result, error) {
53
-	if stmt.mc.closed.IsSet() {
53
+	if stmt.mc.closed.Load() {
54 54
 		errLog.Print(ErrInvalidConn)
55 55
 		return nil, driver.ErrBadConn
56 56
 	}
@@ -98,7 +98,7 @@ func (stmt *mysqlStmt) Query(args []driver.Value) (driver.Rows, error) {
98 98
 }
99 99
 
100 100
 func (stmt *mysqlStmt) query(args []driver.Value) (*binaryRows, error) {
101
-	if stmt.mc.closed.IsSet() {
101
+	if stmt.mc.closed.Load() {
102 102
 		errLog.Print(ErrInvalidConn)
103 103
 		return nil, driver.ErrBadConn
104 104
 	}
@@ -157,7 +157,7 @@ func (c converter) ConvertValue(v interface{}) (driver.Value, error) {
157 157
 		if driver.IsValue(sv) {
158 158
 			return sv, nil
159 159
 		}
160
-		// A value returend from the Valuer interface can be "a type handled by
160
+		// A value returned from the Valuer interface can be "a type handled by
161 161
 		// a database driver's NamedValueChecker interface" so we should accept
162 162
 		// uint64 here as well.
163 163
 		if u, ok := sv.(uint64); ok {

+ 2
- 2
vendor/github.com/go-sql-driver/mysql/transaction.go View File

@@ -13,7 +13,7 @@ type mysqlTx struct {
13 13
 }
14 14
 
15 15
 func (tx *mysqlTx) Commit() (err error) {
16
-	if tx.mc == nil || tx.mc.closed.IsSet() {
16
+	if tx.mc == nil || tx.mc.closed.Load() {
17 17
 		return ErrInvalidConn
18 18
 	}
19 19
 	err = tx.mc.exec("COMMIT")
@@ -22,7 +22,7 @@ func (tx *mysqlTx) Commit() (err error) {
22 22
 }
23 23
 
24 24
 func (tx *mysqlTx) Rollback() (err error) {
25
-	if tx.mc == nil || tx.mc.closed.IsSet() {
25
+	if tx.mc == nil || tx.mc.closed.Load() {
26 26
 		return ErrInvalidConn
27 27
 	}
28 28
 	err = tx.mc.exec("ROLLBACK")

+ 44
- 78
vendor/github.com/go-sql-driver/mysql/utils.go View File

@@ -35,26 +35,25 @@ var (
35 35
 // Note: The provided tls.Config is exclusively owned by the driver after
36 36
 // registering it.
37 37
 //
38
-//  rootCertPool := x509.NewCertPool()
39
-//  pem, err := ioutil.ReadFile("/path/ca-cert.pem")
40
-//  if err != nil {
41
-//      log.Fatal(err)
42
-//  }
43
-//  if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
44
-//      log.Fatal("Failed to append PEM.")
45
-//  }
46
-//  clientCert := make([]tls.Certificate, 0, 1)
47
-//  certs, err := tls.LoadX509KeyPair("/path/client-cert.pem", "/path/client-key.pem")
48
-//  if err != nil {
49
-//      log.Fatal(err)
50
-//  }
51
-//  clientCert = append(clientCert, certs)
52
-//  mysql.RegisterTLSConfig("custom", &tls.Config{
53
-//      RootCAs: rootCertPool,
54
-//      Certificates: clientCert,
55
-//  })
56
-//  db, err := sql.Open("mysql", "user@tcp(localhost:3306)/test?tls=custom")
57
-//
38
+//	rootCertPool := x509.NewCertPool()
39
+//	pem, err := ioutil.ReadFile("/path/ca-cert.pem")
40
+//	if err != nil {
41
+//	    log.Fatal(err)
42
+//	}
43
+//	if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
44
+//	    log.Fatal("Failed to append PEM.")
45
+//	}
46
+//	clientCert := make([]tls.Certificate, 0, 1)
47
+//	certs, err := tls.LoadX509KeyPair("/path/client-cert.pem", "/path/client-key.pem")
48
+//	if err != nil {
49
+//	    log.Fatal(err)
50
+//	}
51
+//	clientCert = append(clientCert, certs)
52
+//	mysql.RegisterTLSConfig("custom", &tls.Config{
53
+//	    RootCAs: rootCertPool,
54
+//	    Certificates: clientCert,
55
+//	})
56
+//	db, err := sql.Open("mysql", "user@tcp(localhost:3306)/test?tls=custom")
58 57
 func RegisterTLSConfig(key string, config *tls.Config) error {
59 58
 	if _, isBool := readBool(key); isBool || strings.ToLower(key) == "skip-verify" || strings.ToLower(key) == "preferred" {
60 59
 		return fmt.Errorf("key '%s' is reserved", key)
@@ -118,10 +117,6 @@ func parseDateTime(b []byte, loc *time.Location) (time.Time, error) {
118 117
 		if err != nil {
119 118
 			return time.Time{}, err
120 119
 		}
121
-		if year <= 0 {
122
-			year = 1
123
-		}
124
-
125 120
 		if b[4] != '-' {
126 121
 			return time.Time{}, fmt.Errorf("bad value for field: `%c`", b[4])
127 122
 		}
@@ -130,9 +125,6 @@ func parseDateTime(b []byte, loc *time.Location) (time.Time, error) {
130 125
 		if err != nil {
131 126
 			return time.Time{}, err
132 127
 		}
133
-		if m <= 0 {
134
-			m = 1
135
-		}
136 128
 		month := time.Month(m)
137 129
 
138 130
 		if b[7] != '-' {
@@ -143,9 +135,6 @@ func parseDateTime(b []byte, loc *time.Location) (time.Time, error) {
143 135
 		if err != nil {
144 136
 			return time.Time{}, err
145 137
 		}
146
-		if day <= 0 {
147
-			day = 1
148
-		}
149 138
 		if len(b) == 10 {
150 139
 			return time.Date(year, month, day, 0, 0, 0, 0, loc), nil
151 140
 		}
@@ -199,7 +188,7 @@ func parseByteYear(b []byte) (int, error) {
199 188
 			return 0, err
200 189
 		}
201 190
 		year += v * n
202
-		n = n / 10
191
+		n /= 10
203 192
 	}
204 193
 	return year, nil
205 194
 }
@@ -542,7 +531,7 @@ func stringToInt(b []byte) int {
542 531
 	return val
543 532
 }
544 533
 
545
-// returns the string read as a bytes slice, wheter the value is NULL,
534
+// returns the string read as a bytes slice, whether the value is NULL,
546 535
 // the number of bytes read and an error, in case the string is longer than
547 536
 // the input slice
548 537
 func readLengthEncodedString(b []byte) ([]byte, bool, int, error) {
@@ -652,32 +641,32 @@ func escapeBytesBackslash(buf, v []byte) []byte {
652 641
 	for _, c := range v {
653 642
 		switch c {
654 643
 		case '\x00':
655
-			buf[pos] = '\\'
656 644
 			buf[pos+1] = '0'
645
+			buf[pos] = '\\'
657 646
 			pos += 2
658 647
 		case '\n':
659
-			buf[pos] = '\\'
660 648
 			buf[pos+1] = 'n'
649
+			buf[pos] = '\\'
661 650
 			pos += 2
662 651
 		case '\r':
663
-			buf[pos] = '\\'
664 652
 			buf[pos+1] = 'r'
653
+			buf[pos] = '\\'
665 654
 			pos += 2
666 655
 		case '\x1a':
667
-			buf[pos] = '\\'
668 656
 			buf[pos+1] = 'Z'
657
+			buf[pos] = '\\'
669 658
 			pos += 2
670 659
 		case '\'':
671
-			buf[pos] = '\\'
672 660
 			buf[pos+1] = '\''
661
+			buf[pos] = '\\'
673 662
 			pos += 2
674 663
 		case '"':
675
-			buf[pos] = '\\'
676 664
 			buf[pos+1] = '"'
665
+			buf[pos] = '\\'
677 666
 			pos += 2
678 667
 		case '\\':
679
-			buf[pos] = '\\'
680 668
 			buf[pos+1] = '\\'
669
+			buf[pos] = '\\'
681 670
 			pos += 2
682 671
 		default:
683 672
 			buf[pos] = c
@@ -697,32 +686,32 @@ func escapeStringBackslash(buf []byte, v string) []byte {
697 686
 		c := v[i]
698 687
 		switch c {
699 688
 		case '\x00':
700
-			buf[pos] = '\\'
701 689
 			buf[pos+1] = '0'
690
+			buf[pos] = '\\'
702 691
 			pos += 2
703 692
 		case '\n':
704
-			buf[pos] = '\\'
705 693
 			buf[pos+1] = 'n'
694
+			buf[pos] = '\\'
706 695
 			pos += 2
707 696
 		case '\r':
708
-			buf[pos] = '\\'
709 697
 			buf[pos+1] = 'r'
698
+			buf[pos] = '\\'
710 699
 			pos += 2
711 700
 		case '\x1a':
712
-			buf[pos] = '\\'
713 701
 			buf[pos+1] = 'Z'
702
+			buf[pos] = '\\'
714 703
 			pos += 2
715 704
 		case '\'':
716
-			buf[pos] = '\\'
717 705
 			buf[pos+1] = '\''
706
+			buf[pos] = '\\'
718 707
 			pos += 2
719 708
 		case '"':
720
-			buf[pos] = '\\'
721 709
 			buf[pos+1] = '"'
710
+			buf[pos] = '\\'
722 711
 			pos += 2
723 712
 		case '\\':
724
-			buf[pos] = '\\'
725 713
 			buf[pos+1] = '\\'
714
+			buf[pos] = '\\'
726 715
 			pos += 2
727 716
 		default:
728 717
 			buf[pos] = c
@@ -744,8 +733,8 @@ func escapeBytesQuotes(buf, v []byte) []byte {
744 733
 
745 734
 	for _, c := range v {
746 735
 		if c == '\'' {
747
-			buf[pos] = '\''
748 736
 			buf[pos+1] = '\''
737
+			buf[pos] = '\''
749 738
 			pos += 2
750 739
 		} else {
751 740
 			buf[pos] = c
@@ -764,8 +753,8 @@ func escapeStringQuotes(buf []byte, v string) []byte {
764 753
 	for i := 0; i < len(v); i++ {
765 754
 		c := v[i]
766 755
 		if c == '\'' {
767
-			buf[pos] = '\''
768 756
 			buf[pos+1] = '\''
757
+			buf[pos] = '\''
769 758
 			pos += 2
770 759
 		} else {
771 760
 			buf[pos] = c
@@ -790,39 +779,16 @@ type noCopy struct{}
790 779
 // Lock is a no-op used by -copylocks checker from `go vet`.
791 780
 func (*noCopy) Lock() {}
792 781
 
793
-// atomicBool is a wrapper around uint32 for usage as a boolean value with
794
-// atomic access.
795
-type atomicBool struct {
796
-	_noCopy noCopy
797
-	value   uint32
798
-}
799
-
800
-// IsSet returns whether the current boolean value is true
801
-func (ab *atomicBool) IsSet() bool {
802
-	return atomic.LoadUint32(&ab.value) > 0
803
-}
804
-
805
-// Set sets the value of the bool regardless of the previous value
806
-func (ab *atomicBool) Set(value bool) {
807
-	if value {
808
-		atomic.StoreUint32(&ab.value, 1)
809
-	} else {
810
-		atomic.StoreUint32(&ab.value, 0)
811
-	}
812
-}
813
-
814
-// TrySet sets the value of the bool and returns whether the value changed
815
-func (ab *atomicBool) TrySet(value bool) bool {
816
-	if value {
817
-		return atomic.SwapUint32(&ab.value, 1) == 0
818
-	}
819
-	return atomic.SwapUint32(&ab.value, 0) > 0
820
-}
782
+// Unlock is a no-op used by -copylocks checker from `go vet`.
783
+// noCopy should implement sync.Locker from Go 1.11
784
+// https://github.com/golang/go/commit/c2eba53e7f80df21d51285879d51ab81bcfbf6bc
785
+// https://github.com/golang/go/issues/26165
786
+func (*noCopy) Unlock() {}
821 787
 
822 788
 // atomicError is a wrapper for atomically accessed error values
823 789
 type atomicError struct {
824
-	_noCopy noCopy
825
-	value   atomic.Value
790
+	_     noCopy
791
+	value atomic.Value
826 792
 }
827 793
 
828 794
 // Set sets the error value regardless of the previous value.

+ 2
- 2
vendor/modules.txt View File

@@ -22,8 +22,8 @@ github.com/ergochat/irc-go/ircfmt
22 22
 github.com/ergochat/irc-go/ircmsg
23 23
 github.com/ergochat/irc-go/ircreader
24 24
 github.com/ergochat/irc-go/ircutils
25
-# github.com/go-sql-driver/mysql v1.6.0
26
-## explicit; go 1.10
25
+# github.com/go-sql-driver/mysql v1.7.0
26
+## explicit; go 1.13
27 27
 github.com/go-sql-driver/mysql
28 28
 # github.com/go-test/deep v1.0.6
29 29
 ## explicit; go 1.13

Loading…
Cancel
Save