Browse Source

upgrade mysql driver

tags/v2.7.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
57c5030e91

+ 1
- 1
go.mod View File

@@ -7,7 +7,7 @@ require (
7 7
 	github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962
8 8
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
9 9
 	github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
10
-	github.com/go-sql-driver/mysql v1.5.0
10
+	github.com/go-sql-driver/mysql v1.6.0
11 11
 	github.com/go-test/deep v1.0.6 // indirect
12 12
 	github.com/gorilla/websocket v1.4.2
13 13
 	github.com/goshuirc/irc-go v0.0.0-20210318074529-bdc2c2cd2fef

+ 2
- 0
go.sum View File

@@ -13,6 +13,8 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
13 13
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
14 14
 github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
15 15
 github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
16
+github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
17
+github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
16 18
 github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
17 19
 github.com/go-test/deep v1.0.6/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
18 20
 github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=

+ 0
- 129
vendor/github.com/go-sql-driver/mysql/.travis.yml View File

@@ -1,129 +0,0 @@
1
-sudo: false
2
-language: go
3
-go:
4
-  - 1.10.x
5
-  - 1.11.x
6
-  - 1.12.x
7
-  - 1.13.x
8
-  - master
9
-
10
-before_install:
11
-  - go get golang.org/x/tools/cmd/cover
12
-  - go get github.com/mattn/goveralls
13
-
14
-before_script:
15
-  - echo -e "[server]\ninnodb_log_file_size=256MB\ninnodb_buffer_pool_size=512MB\nmax_allowed_packet=16MB" | sudo tee -a /etc/mysql/my.cnf
16
-  - sudo service mysql restart
17
-  - .travis/wait_mysql.sh
18
-  - mysql -e 'create database gotest;'
19
-
20
-matrix:
21
-  include:
22
-    - env: DB=MYSQL8
23
-      sudo: required
24
-      dist: trusty
25
-      go: 1.10.x
26
-      services:
27
-        - docker
28
-      before_install:
29
-        - go get golang.org/x/tools/cmd/cover
30
-        - go get github.com/mattn/goveralls
31
-        - docker pull mysql:8.0
32
-        - docker run -d -p 127.0.0.1:3307:3306 --name mysqld -e MYSQL_DATABASE=gotest -e MYSQL_USER=gotest -e MYSQL_PASSWORD=secret -e MYSQL_ROOT_PASSWORD=verysecret
33
-          mysql:8.0 --innodb_log_file_size=256MB --innodb_buffer_pool_size=512MB --max_allowed_packet=16MB --local-infile=1
34
-        - cp .travis/docker.cnf ~/.my.cnf
35
-        - .travis/wait_mysql.sh
36
-      before_script:
37
-        - export MYSQL_TEST_USER=gotest
38
-        - export MYSQL_TEST_PASS=secret
39
-        - export MYSQL_TEST_ADDR=127.0.0.1:3307
40
-        - export MYSQL_TEST_CONCURRENT=1
41
-
42
-    - env: DB=MYSQL57
43
-      sudo: required
44
-      dist: trusty
45
-      go: 1.10.x
46
-      services:
47
-        - docker
48
-      before_install:
49
-        - go get golang.org/x/tools/cmd/cover
50
-        - go get github.com/mattn/goveralls
51
-        - docker pull mysql:5.7
52
-        - docker run -d -p 127.0.0.1:3307:3306 --name mysqld -e MYSQL_DATABASE=gotest -e MYSQL_USER=gotest -e MYSQL_PASSWORD=secret -e MYSQL_ROOT_PASSWORD=verysecret
53
-          mysql:5.7 --innodb_log_file_size=256MB --innodb_buffer_pool_size=512MB --max_allowed_packet=16MB --local-infile=1
54
-        - cp .travis/docker.cnf ~/.my.cnf
55
-        - .travis/wait_mysql.sh
56
-      before_script:
57
-        - export MYSQL_TEST_USER=gotest
58
-        - export MYSQL_TEST_PASS=secret
59
-        - export MYSQL_TEST_ADDR=127.0.0.1:3307
60
-        - export MYSQL_TEST_CONCURRENT=1
61
-
62
-    - env: DB=MARIA55
63
-      sudo: required
64
-      dist: trusty
65
-      go: 1.10.x
66
-      services:
67
-        - docker
68
-      before_install:
69
-        - go get golang.org/x/tools/cmd/cover
70
-        - go get github.com/mattn/goveralls
71
-        - docker pull mariadb:5.5
72
-        - docker run -d -p 127.0.0.1:3307:3306 --name mysqld -e MYSQL_DATABASE=gotest -e MYSQL_USER=gotest -e MYSQL_PASSWORD=secret -e MYSQL_ROOT_PASSWORD=verysecret
73
-          mariadb:5.5 --innodb_log_file_size=256MB --innodb_buffer_pool_size=512MB --max_allowed_packet=16MB --local-infile=1
74
-        - cp .travis/docker.cnf ~/.my.cnf
75
-        - .travis/wait_mysql.sh
76
-      before_script:
77
-        - export MYSQL_TEST_USER=gotest
78
-        - export MYSQL_TEST_PASS=secret
79
-        - export MYSQL_TEST_ADDR=127.0.0.1:3307
80
-        - export MYSQL_TEST_CONCURRENT=1
81
-
82
-    - env: DB=MARIA10_1
83
-      sudo: required
84
-      dist: trusty
85
-      go: 1.10.x
86
-      services:
87
-        - docker
88
-      before_install:
89
-        - go get golang.org/x/tools/cmd/cover
90
-        - go get github.com/mattn/goveralls
91
-        - docker pull mariadb:10.1
92
-        - docker run -d -p 127.0.0.1:3307:3306 --name mysqld -e MYSQL_DATABASE=gotest -e MYSQL_USER=gotest -e MYSQL_PASSWORD=secret -e MYSQL_ROOT_PASSWORD=verysecret
93
-          mariadb:10.1 --innodb_log_file_size=256MB --innodb_buffer_pool_size=512MB --max_allowed_packet=16MB --local-infile=1
94
-        - cp .travis/docker.cnf ~/.my.cnf
95
-        - .travis/wait_mysql.sh
96
-      before_script:
97
-        - export MYSQL_TEST_USER=gotest
98
-        - export MYSQL_TEST_PASS=secret
99
-        - export MYSQL_TEST_ADDR=127.0.0.1:3307
100
-        - export MYSQL_TEST_CONCURRENT=1
101
-
102
-    - os: osx
103
-      osx_image: xcode10.1
104
-      addons:
105
-        homebrew:
106
-          packages:
107
-            - mysql
108
-          update: true
109
-      go: 1.12.x
110
-      before_install:
111
-        - go get golang.org/x/tools/cmd/cover
112
-        - go get github.com/mattn/goveralls
113
-      before_script:
114
-        - echo -e "[server]\ninnodb_log_file_size=256MB\ninnodb_buffer_pool_size=512MB\nmax_allowed_packet=16MB\nlocal_infile=1" >> /usr/local/etc/my.cnf
115
-        - mysql.server start
116
-        - mysql -uroot -e 'CREATE USER gotest IDENTIFIED BY "secret"'
117
-        - mysql -uroot -e 'GRANT ALL ON *.* TO gotest'
118
-        - mysql -uroot -e 'create database gotest;'
119
-        - export MYSQL_TEST_USER=gotest
120
-        - export MYSQL_TEST_PASS=secret
121
-        - export MYSQL_TEST_ADDR=127.0.0.1:3306
122
-        - export MYSQL_TEST_CONCURRENT=1
123
-
124
-script:
125
-  - go test -v -covermode=count -coverprofile=coverage.out
126
-  - go vet ./...
127
-  - .travis/gofmt.sh
128
-after_script:
129
-  - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci

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

@@ -13,11 +13,15 @@
13 13
 
14 14
 Aaron Hopkins <go-sql-driver at die.net>
15 15
 Achille Roussel <achille.roussel at gmail.com>
16
+Alex Snast <alexsn at fb.com>
16 17
 Alexey Palazhchenko <alexey.palazhchenko at gmail.com>
17 18
 Andrew Reid <andrew.reid at tixtrack.com>
19
+Animesh Ray <mail.rayanimesh at gmail.com>
18 20
 Arne Hormann <arnehormann at gmail.com>
21
+Ariel Mashraki <ariel at mashraki.co.il>
19 22
 Asta Xie <xiemengjun at gmail.com>
20 23
 Bulat Gaifullin <gaifullinbf at gmail.com>
24
+Caine Jette <jette at alum.mit.edu>
21 25
 Carlos Nieto <jose.carlos at menteslibres.net>
22 26
 Chris Moos <chris at tech9computers.com>
23 27
 Craig Wilson <craiggwilson at gmail.com>
@@ -52,6 +56,7 @@ Julien Schmidt <go-sql-driver at julienschmidt.com>
52 56
 Justin Li <jli at j-li.net>
53 57
 Justin Nuß <nuss.justin at gmail.com>
54 58
 Kamil Dziedzic <kamil at klecza.pl>
59
+Kei Kamikawa <x00.x7f.x86 at gmail.com>
55 60
 Kevin Malachowski <kevin at chowski.com>
56 61
 Kieron Woodhouse <kieron.woodhouse at infosum.com>
57 62
 Lennart Rudolph <lrudolph at hmc.edu>
@@ -74,20 +79,26 @@ Reed Allman <rdallman10 at gmail.com>
74 79
 Richard Wilkes <wilkes at me.com>
75 80
 Robert Russell <robert at rrbrussell.com>
76 81
 Runrioter Wung <runrioter at gmail.com>
82
+Sho Iizuka <sho.i518 at gmail.com>
83
+Sho Ikeda <suicaicoca at gmail.com>
77 84
 Shuode Li <elemount at qq.com>
78 85
 Simon J Mudd <sjmudd at pobox.com>
79 86
 Soroush Pour <me at soroushjp.com>
80 87
 Stan Putrya <root.vagner at gmail.com>
81 88
 Stanley Gunawan <gunawan.stanley at gmail.com>
82 89
 Steven Hartland <steven.hartland at multiplay.co.uk>
90
+Tan Jinhua <312841925 at qq.com>
83 91
 Thomas Wodarek <wodarekwebpage at gmail.com>
84 92
 Tim Ruffles <timruffles at gmail.com>
85 93
 Tom Jenkinson <tom at tjenkinson.me>
86 94
 Vladimir Kovpak <cn007b at gmail.com>
95
+Vladyslav Zhelezniak <zhvladi at gmail.com>
87 96
 Xiangyu Hu <xiangyu.hu at outlook.com>
88 97
 Xiaobing Jiang <s7v7nislands at gmail.com>
89 98
 Xiuming Chen <cc at cxm.cc>
99
+Xuehong Chan <chanxuehong at gmail.com>
90 100
 Zhenye Xie <xiezhenye at gmail.com>
101
+Zhixin Wen <john.wenzhixin at gmail.com>
91 102
 
92 103
 # Organizations
93 104
 
@@ -103,3 +114,4 @@ Multiplay Ltd.
103 114
 Percona LLC
104 115
 Pivotal Inc.
105 116
 Stripe Inc.
117
+Zendesk Inc.

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

@@ -1,3 +1,29 @@
1
+## Version 1.6 (2021-04-01)
2
+
3
+Changes:
4
+
5
+  - Migrate the CI service from travis-ci to GitHub Actions (#1176, #1183, #1190)
6
+  - `NullTime` is deprecated (#960, #1144)
7
+  - Reduce allocations when building SET command (#1111)
8
+  - Performance improvement for time formatting (#1118)
9
+  - Performance improvement for time parsing (#1098, #1113)
10
+
11
+New Features:
12
+
13
+  - Implement `driver.Validator` interface (#1106, #1174)
14
+  - Support returning `uint64` from `Valuer` in `ConvertValue` (#1143)
15
+  - Add `json.RawMessage` for converter and prepared statement (#1059)
16
+  - Interpolate `json.RawMessage` as `string` (#1058)
17
+  - Implements `CheckNamedValue` (#1090)
18
+
19
+Bugfixes:
20
+
21
+  - Stop rounding times (#1121, #1172)
22
+  - Put zero filler into the SSL handshake packet (#1066)
23
+  - Fix checking cancelled connections back into the connection pool (#1095)
24
+  - Fix remove last 0 byte for mysql_old_password when password is empty (#1133)
25
+
26
+
1 27
 ## Version 1.5 (2020-01-07)
2 28
 
3 29
 Changes:

+ 31
- 12
vendor/github.com/go-sql-driver/mysql/README.md View File

@@ -35,7 +35,7 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac
35 35
   * Supports queries larger than 16MB
36 36
   * Full [`sql.RawBytes`](https://golang.org/pkg/database/sql/#RawBytes) support.
37 37
   * Intelligent `LONG DATA` handling in prepared statements
38
-  * Secure `LOAD DATA LOCAL INFILE` support with file Whitelisting and `io.Reader` support
38
+  * Secure `LOAD DATA LOCAL INFILE` support with file allowlisting and `io.Reader` support
39 39
   * Optional `time.Time` parsing
40 40
   * Optional placeholder interpolation
41 41
 
@@ -56,15 +56,37 @@ Make sure [Git is installed](https://git-scm.com/downloads) on your machine and
56 56
 _Go MySQL Driver_ is an implementation of Go's `database/sql/driver` interface. You only need to import the driver and can use the full [`database/sql`](https://golang.org/pkg/database/sql/) API then.
57 57
 
58 58
 Use `mysql` as `driverName` and a valid [DSN](#dsn-data-source-name)  as `dataSourceName`:
59
+
59 60
 ```go
60
-import "database/sql"
61
-import _ "github.com/go-sql-driver/mysql"
61
+import (
62
+	"database/sql"
63
+	"time"
64
+
65
+	_ "github.com/go-sql-driver/mysql"
66
+)
67
+
68
+// ...
62 69
 
63 70
 db, err := sql.Open("mysql", "user:password@/dbname")
71
+if err != nil {
72
+	panic(err)
73
+}
74
+// See "Important settings" section.
75
+db.SetConnMaxLifetime(time.Minute * 3)
76
+db.SetMaxOpenConns(10)
77
+db.SetMaxIdleConns(10)
64 78
 ```
65 79
 
66 80
 [Examples are available in our Wiki](https://github.com/go-sql-driver/mysql/wiki/Examples "Go-MySQL-Driver Examples").
67 81
 
82
+### Important settings
83
+
84
+`db.SetConnMaxLifetime()` is required to ensure connections are closed by the driver safely before connection is closed by MySQL server, OS, or other middlewares. Since some middlewares close idle connections by 5 minutes, we recommend timeout shorter than 5 minutes. This setting helps load balancing and changing system variables too.
85
+
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
+
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.
89
+
68 90
 
69 91
 ### DSN (Data Source Name)
70 92
 
@@ -122,7 +144,7 @@ Valid Values:   true, false
122 144
 Default:        false
123 145
 ```
124 146
 
125
-`allowAllFiles=true` disables the file Whitelist for `LOAD DATA LOCAL INFILE` and allows *all* files.
147
+`allowAllFiles=true` disables the file allowlist for `LOAD DATA LOCAL INFILE` and allows *all* files.
126 148
 [*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)
127 149
 
128 150
 ##### `allowCleartextPasswords`
@@ -133,7 +155,7 @@ Valid Values:   true, false
133 155
 Default:        false
134 156
 ```
135 157
 
136
-`allowCleartextPasswords=true` allows using the [cleartext client side plugin](http://dev.mysql.com/doc/en/cleartext-authentication-plugin.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.
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.
137 159
 
138 160
 ##### `allowNativePasswords`
139 161
 
@@ -230,7 +252,7 @@ Default:        false
230 252
 
231 253
 If `interpolateParams` is true, placeholders (`?`) in calls to `db.Query()` and `db.Exec()` are interpolated into a single query string with given parameters. This reduces the number of roundtrips, since the driver has to prepare a statement, execute it with given parameters and close the statement again with `interpolateParams=false`.
232 254
 
233
-*This can not be used together with the multibyte encodings BIG5, CP932, GB2312, GBK or SJIS. These are blacklisted as they may [introduce a SQL injection vulnerability](http://stackoverflow.com/a/12118602/3430118)!*
255
+*This can not be used together with the multibyte encodings BIG5, CP932, GB2312, GBK or SJIS. These are rejected as they may [introduce a SQL injection vulnerability](http://stackoverflow.com/a/12118602/3430118)!*
234 256
 
235 257
 ##### `loc`
236 258
 
@@ -376,7 +398,7 @@ Rules:
376 398
 Examples:
377 399
   * `autocommit=1`: `SET autocommit=1`
378 400
   * [`time_zone=%27Europe%2FParis%27`](https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html): `SET time_zone='Europe/Paris'`
379
-  * [`tx_isolation=%27REPEATABLE-READ%27`](https://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_tx_isolation): `SET tx_isolation='REPEATABLE-READ'`
401
+  * [`transaction_isolation=%27REPEATABLE-READ%27`](https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_transaction_isolation): `SET transaction_isolation='REPEATABLE-READ'`
380 402
 
381 403
 
382 404
 #### Examples
@@ -445,7 +467,7 @@ For this feature you need direct access to the package. Therefore you must chang
445 467
 import "github.com/go-sql-driver/mysql"
446 468
 ```
447 469
 
448
-Files must be whitelisted by registering them with `mysql.RegisterLocalFile(filepath)` (recommended) or the Whitelist check must be deactivated by using the DSN parameter `allowAllFiles=true` ([*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)).
470
+Files must be explicitly allowed by registering them with `mysql.RegisterLocalFile(filepath)` (recommended) or the allowlist check must be deactivated by using the DSN parameter `allowAllFiles=true` ([*Might be insecure!*](http://dev.mysql.com/doc/refman/5.7/en/load-data-local.html)).
449 471
 
450 472
 To use a `io.Reader` a handler function must be registered with `mysql.RegisterReaderHandler(name, handler)` which returns a `io.Reader` or `io.ReadCloser`. The Reader is available with the filepath `Reader::<name>` then. Choose different names for different handlers and `DeregisterReaderHandler` when you don't need it anymore.
451 473
 
@@ -459,8 +481,6 @@ However, many want to scan MySQL `DATE` and `DATETIME` values into `time.Time` v
459 481
 
460 482
 **Caution:** As of Go 1.1, this makes `time.Time` the only variable type you can scan `DATE` and `DATETIME` values into. This breaks for example [`sql.RawBytes` support](https://github.com/go-sql-driver/mysql/wiki/Examples#rawbytes).
461 483
 
462
-Alternatively you can use the [`NullTime`](https://godoc.org/github.com/go-sql-driver/mysql#NullTime) type as the scan destination, which works with both `time.Time` and `string` / `[]byte`.
463
-
464 484
 
465 485
 ### Unicode support
466 486
 Since version 1.5 Go-MySQL-Driver automatically uses the collation ` utf8mb4_general_ci` by default.
@@ -477,7 +497,7 @@ To run the driver tests you may need to adjust the configuration. See the [Testi
477 497
 Go-MySQL-Driver is not feature-complete yet. Your help is very appreciated.
478 498
 If you want to contribute, you can work on an [open issue](https://github.com/go-sql-driver/mysql/issues?state=open) or review a [pull request](https://github.com/go-sql-driver/mysql/pulls).
479 499
 
480
-See the [Contribution Guidelines](https://github.com/go-sql-driver/mysql/blob/master/CONTRIBUTING.md) for details.
500
+See the [Contribution Guidelines](https://github.com/go-sql-driver/mysql/blob/master/.github/CONTRIBUTING.md) for details.
481 501
 
482 502
 ---------------------------------------
483 503
 
@@ -498,4 +518,3 @@ Please read the [MPL 2.0 FAQ](https://www.mozilla.org/en-US/MPL/2.0/FAQ/) if you
498 518
 You can read the full terms here: [LICENSE](https://raw.github.com/go-sql-driver/mysql/master/LICENSE).
499 519
 
500 520
 ![Go Gopher and MySQL Dolphin](https://raw.github.com/wiki/go-sql-driver/mysql/go-mysql-driver_m.jpg "Golang Gopher transporting the MySQL Dolphin in a wheelbarrow")
501
-

+ 8
- 5
vendor/github.com/go-sql-driver/mysql/auth.go View File

@@ -15,6 +15,7 @@ import (
15 15
 	"crypto/sha256"
16 16
 	"crypto/x509"
17 17
 	"encoding/pem"
18
+	"fmt"
18 19
 	"sync"
19 20
 )
20 21
 
@@ -136,10 +137,6 @@ func pwHash(password []byte) (result [2]uint32) {
136 137
 
137 138
 // Hash password using insecure pre 4.1 method
138 139
 func scrambleOldPassword(scramble []byte, password string) []byte {
139
-	if len(password) == 0 {
140
-		return nil
141
-	}
142
-
143 140
 	scramble = scramble[:8]
144 141
 
145 142
 	hashPw := pwHash([]byte(password))
@@ -247,6 +244,9 @@ func (mc *mysqlConn) auth(authData []byte, plugin string) ([]byte, error) {
247 244
 		if !mc.cfg.AllowOldPasswords {
248 245
 			return nil, ErrOldPassword
249 246
 		}
247
+		if len(mc.cfg.Passwd) == 0 {
248
+			return nil, nil
249
+		}
250 250
 		// Note: there are edge cases where this should work but doesn't;
251 251
 		// this is currently "wontfix":
252 252
 		// https://github.com/go-sql-driver/mysql/issues/184
@@ -372,7 +372,10 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
372 372
 							return err
373 373
 						}
374 374
 
375
-						block, _ := pem.Decode(data[1:])
375
+						block, rest := pem.Decode(data[1:])
376
+						if block == nil {
377
+							return fmt.Errorf("No Pem data found, data: %s", rest)
378
+						}
376 379
 						pkix, err := x509.ParsePKIXPublicKey(block.Bytes)
377 380
 						if err != nil {
378 381
 							return err

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

@@ -247,7 +247,7 @@ var collations = map[string]byte{
247 247
 	"utf8mb4_0900_ai_ci":       255,
248 248
 }
249 249
 
250
-// A blacklist of collations which is unsafe to interpolate parameters.
250
+// A denylist of collations which is unsafe to interpolate parameters.
251 251
 // These multibyte encodings may contains 0x5c (`\`) in their trailing bytes.
252 252
 var unsafeCollations = map[string]bool{
253 253
 	"big5_chinese_ci":        true,

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

@@ -12,6 +12,7 @@ import (
12 12
 	"context"
13 13
 	"database/sql"
14 14
 	"database/sql/driver"
15
+	"encoding/json"
15 16
 	"io"
16 17
 	"net"
17 18
 	"strconv"
@@ -46,9 +47,10 @@ type mysqlConn struct {
46 47
 
47 48
 // Handles parameters set in DSN after the connection is established
48 49
 func (mc *mysqlConn) handleParams() (err error) {
50
+	var cmdSet strings.Builder
49 51
 	for param, val := range mc.cfg.Params {
50 52
 		switch param {
51
-		// Charset
53
+		// Charset: character_set_connection, character_set_client, character_set_results
52 54
 		case "charset":
53 55
 			charsets := strings.Split(val, ",")
54 56
 			for i := range charsets {
@@ -62,12 +64,25 @@ func (mc *mysqlConn) handleParams() (err error) {
62 64
 				return
63 65
 			}
64 66
 
65
-		// System Vars
67
+		// Other system vars accumulated in a single SET command
66 68
 		default:
67
-			err = mc.exec("SET " + param + "=" + val + "")
68
-			if err != nil {
69
-				return
69
+			if cmdSet.Len() == 0 {
70
+				// Heuristic: 29 chars for each other key=value to reduce reallocations
71
+				cmdSet.Grow(4 + len(param) + 1 + len(val) + 30*(len(mc.cfg.Params)-1))
72
+				cmdSet.WriteString("SET ")
73
+			} else {
74
+				cmdSet.WriteByte(',')
70 75
 			}
76
+			cmdSet.WriteString(param)
77
+			cmdSet.WriteByte('=')
78
+			cmdSet.WriteString(val)
79
+		}
80
+	}
81
+
82
+	if cmdSet.Len() > 0 {
83
+		err = mc.exec(cmdSet.String())
84
+		if err != nil {
85
+			return
71 86
 		}
72 87
 	}
73 88
 
@@ -230,47 +245,21 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
230 245
 			if v.IsZero() {
231 246
 				buf = append(buf, "'0000-00-00'"...)
232 247
 			} else {
233
-				v := v.In(mc.cfg.Loc)
234
-				v = v.Add(time.Nanosecond * 500) // To round under microsecond
235
-				year := v.Year()
236
-				year100 := year / 100
237
-				year1 := year % 100
238
-				month := v.Month()
239
-				day := v.Day()
240
-				hour := v.Hour()
241
-				minute := v.Minute()
242
-				second := v.Second()
243
-				micro := v.Nanosecond() / 1000
244
-
245
-				buf = append(buf, []byte{
246
-					'\'',
247
-					digits10[year100], digits01[year100],
248
-					digits10[year1], digits01[year1],
249
-					'-',
250
-					digits10[month], digits01[month],
251
-					'-',
252
-					digits10[day], digits01[day],
253
-					' ',
254
-					digits10[hour], digits01[hour],
255
-					':',
256
-					digits10[minute], digits01[minute],
257
-					':',
258
-					digits10[second], digits01[second],
259
-				}...)
260
-
261
-				if micro != 0 {
262
-					micro10000 := micro / 10000
263
-					micro100 := micro / 100 % 100
264
-					micro1 := micro % 100
265
-					buf = append(buf, []byte{
266
-						'.',
267
-						digits10[micro10000], digits01[micro10000],
268
-						digits10[micro100], digits01[micro100],
269
-						digits10[micro1], digits01[micro1],
270
-					}...)
248
+				buf = append(buf, '\'')
249
+				buf, err = appendDateTime(buf, v.In(mc.cfg.Loc))
250
+				if err != nil {
251
+					return "", err
271 252
 				}
272 253
 				buf = append(buf, '\'')
273 254
 			}
255
+		case json.RawMessage:
256
+			buf = append(buf, '\'')
257
+			if mc.status&statusNoBackslashEscapes == 0 {
258
+				buf = escapeBytesBackslash(buf, v)
259
+			} else {
260
+				buf = escapeBytesQuotes(buf, v)
261
+			}
262
+			buf = append(buf, '\'')
274 263
 		case []byte:
275 264
 			if v == nil {
276 265
 				buf = append(buf, "NULL"...)
@@ -480,6 +469,10 @@ func (mc *mysqlConn) Ping(ctx context.Context) (err error) {
480 469
 
481 470
 // BeginTx implements driver.ConnBeginTx interface
482 471
 func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
472
+	if mc.closed.IsSet() {
473
+		return nil, driver.ErrBadConn
474
+	}
475
+
483 476
 	if err := mc.watchCancel(ctx); err != nil {
484 477
 		return nil, err
485 478
 	}
@@ -649,3 +642,9 @@ func (mc *mysqlConn) ResetSession(ctx context.Context) error {
649 642
 	mc.reset = true
650 643
 	return nil
651 644
 }
645
+
646
+// IsValid implements driver.Validator interface
647
+// (From Go 1.15)
648
+func (mc *mysqlConn) IsValid() bool {
649
+	return !mc.closed.IsSet()
650
+}

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

@@ -375,7 +375,7 @@ func parseDSNParams(cfg *Config, params string) (err error) {
375 375
 
376 376
 		// cfg params
377 377
 		switch value := param[1]; param[0] {
378
-		// Disable INFILE whitelist / enable all files
378
+		// Disable INFILE allowlist / enable all files
379 379
 		case "allowAllFiles":
380 380
 			var isBool bool
381 381
 			cfg.AllowAllFiles, isBool = readBool(value)

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

@@ -106,7 +106,7 @@ var (
106 106
 	scanTypeInt64     = reflect.TypeOf(int64(0))
107 107
 	scanTypeNullFloat = reflect.TypeOf(sql.NullFloat64{})
108 108
 	scanTypeNullInt   = reflect.TypeOf(sql.NullInt64{})
109
-	scanTypeNullTime  = reflect.TypeOf(NullTime{})
109
+	scanTypeNullTime  = reflect.TypeOf(nullTime{})
110 110
 	scanTypeUint8     = reflect.TypeOf(uint8(0))
111 111
 	scanTypeUint16    = reflect.TypeOf(uint16(0))
112 112
 	scanTypeUint32    = reflect.TypeOf(uint32(0))

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

@@ -0,0 +1,24 @@
1
+// Go MySQL Driver - A MySQL-Driver for Go's database/sql package.
2
+//
3
+// Copyright 2020 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 gofuzz
10
+
11
+package mysql
12
+
13
+import (
14
+	"database/sql"
15
+)
16
+
17
+func Fuzz(data []byte) int {
18
+	db, err := sql.Open("mysql", string(data))
19
+	if err != nil {
20
+		return 0
21
+	}
22
+	db.Close()
23
+	return 1
24
+}

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

@@ -23,7 +23,7 @@ var (
23 23
 	readerRegisterLock sync.RWMutex
24 24
 )
25 25
 
26
-// RegisterLocalFile adds the given file to the file whitelist,
26
+// RegisterLocalFile adds the given file to the file allowlist,
27 27
 // so that it can be used by "LOAD DATA LOCAL INFILE <filepath>".
28 28
 // Alternatively you can allow the use of all local files with
29 29
 // the DSN parameter 'allowAllFiles=true'
@@ -45,7 +45,7 @@ func RegisterLocalFile(filePath string) {
45 45
 	fileRegisterLock.Unlock()
46 46
 }
47 47
 
48
-// DeregisterLocalFile removes the given filepath from the whitelist.
48
+// DeregisterLocalFile removes the given filepath from the allowlist.
49 49
 func DeregisterLocalFile(filePath string) {
50 50
 	fileRegisterLock.Lock()
51 51
 	delete(fileRegister, strings.Trim(filePath, `"`))

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

@@ -28,11 +28,11 @@ func (nt *NullTime) Scan(value interface{}) (err error) {
28 28
 		nt.Time, nt.Valid = v, true
29 29
 		return
30 30
 	case []byte:
31
-		nt.Time, err = parseDateTime(string(v), time.UTC)
31
+		nt.Time, err = parseDateTime(v, time.UTC)
32 32
 		nt.Valid = (err == nil)
33 33
 		return
34 34
 	case string:
35
-		nt.Time, err = parseDateTime(v, time.UTC)
35
+		nt.Time, err = parseDateTime([]byte(v), time.UTC)
36 36
 		nt.Valid = (err == nil)
37 37
 		return
38 38
 	}

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

@@ -28,4 +28,13 @@ import (
28 28
 //  }
29 29
 //
30 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.
31 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

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

@@ -32,3 +32,8 @@ type NullTime struct {
32 32
 	Time  time.Time
33 33
 	Valid bool // Valid is true if Time is not NULL
34 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

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

@@ -13,6 +13,7 @@ import (
13 13
 	"crypto/tls"
14 14
 	"database/sql/driver"
15 15
 	"encoding/binary"
16
+	"encoding/json"
16 17
 	"errors"
17 18
 	"fmt"
18 19
 	"io"
@@ -348,6 +349,12 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
348 349
 		return errors.New("unknown collation")
349 350
 	}
350 351
 
352
+	// Filler [23 bytes] (all 0x00)
353
+	pos := 13
354
+	for ; pos < 13+23; pos++ {
355
+		data[pos] = 0
356
+	}
357
+
351 358
 	// SSL Connection Request Packet
352 359
 	// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest
353 360
 	if mc.cfg.tls != nil {
@@ -366,12 +373,6 @@ func (mc *mysqlConn) writeHandshakeResponsePacket(authResp []byte, plugin string
366 373
 		mc.buf.nc = tlsConn
367 374
 	}
368 375
 
369
-	// Filler [23 bytes] (all 0x00)
370
-	pos := 13
371
-	for ; pos < 13+23; pos++ {
372
-		data[pos] = 0
373
-	}
374
-
375 376
 	// User [null terminated string]
376 377
 	if len(mc.cfg.User) > 0 {
377 378
 		pos += copy(data[pos:], mc.cfg.User)
@@ -777,7 +778,7 @@ func (rows *textRows) readRow(dest []driver.Value) error {
777 778
 					case fieldTypeTimestamp, fieldTypeDateTime,
778 779
 						fieldTypeDate, fieldTypeNewDate:
779 780
 						dest[i], err = parseDateTime(
780
-							string(dest[i].([]byte)),
781
+							dest[i].([]byte),
781 782
 							mc.cfg.Loc,
782 783
 						)
783 784
 						if err == nil {
@@ -1003,6 +1004,9 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
1003 1004
 				continue
1004 1005
 			}
1005 1006
 
1007
+			if v, ok := arg.(json.RawMessage); ok {
1008
+				arg = []byte(v)
1009
+			}
1006 1010
 			// cache types and values
1007 1011
 			switch v := arg.(type) {
1008 1012
 			case int64:
@@ -1112,7 +1116,10 @@ func (stmt *mysqlStmt) writeExecutePacket(args []driver.Value) error {
1112 1116
 				if v.IsZero() {
1113 1117
 					b = append(b, "0000-00-00"...)
1114 1118
 				} else {
1115
-					b = v.In(mc.cfg.Loc).AppendFormat(b, timeFormat)
1119
+					b, err = appendDateTime(b, v.In(mc.cfg.Loc))
1120
+					if err != nil {
1121
+						return err
1122
+					}
1116 1123
 				}
1117 1124
 
1118 1125
 				paramValues = appendLengthEncodedInteger(paramValues,

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

@@ -10,6 +10,7 @@ package mysql
10 10
 
11 11
 import (
12 12
 	"database/sql/driver"
13
+	"encoding/json"
13 14
 	"fmt"
14 15
 	"io"
15 16
 	"reflect"
@@ -43,6 +44,11 @@ func (stmt *mysqlStmt) ColumnConverter(idx int) driver.ValueConverter {
43 44
 	return converter{}
44 45
 }
45 46
 
47
+func (stmt *mysqlStmt) CheckNamedValue(nv *driver.NamedValue) (err error) {
48
+	nv.Value, err = converter{}.ConvertValue(nv.Value)
49
+	return
50
+}
51
+
46 52
 func (stmt *mysqlStmt) Exec(args []driver.Value) (driver.Result, error) {
47 53
 	if stmt.mc.closed.IsSet() {
48 54
 		errLog.Print(ErrInvalidConn)
@@ -129,6 +135,8 @@ func (stmt *mysqlStmt) query(args []driver.Value) (*binaryRows, error) {
129 135
 	return rows, err
130 136
 }
131 137
 
138
+var jsonType = reflect.TypeOf(json.RawMessage{})
139
+
132 140
 type converter struct{}
133 141
 
134 142
 // ConvertValue mirrors the reference/default converter in database/sql/driver
@@ -146,12 +154,17 @@ func (c converter) ConvertValue(v interface{}) (driver.Value, error) {
146 154
 		if err != nil {
147 155
 			return nil, err
148 156
 		}
149
-		if !driver.IsValue(sv) {
150
-			return nil, fmt.Errorf("non-Value type %T returned from Value", sv)
157
+		if driver.IsValue(sv) {
158
+			return sv, nil
151 159
 		}
152
-		return sv, nil
160
+		// A value returend from the Valuer interface can be "a type handled by
161
+		// a database driver's NamedValueChecker interface" so we should accept
162
+		// uint64 here as well.
163
+		if u, ok := sv.(uint64); ok {
164
+			return u, nil
165
+		}
166
+		return nil, fmt.Errorf("non-Value type %T returned from Value", sv)
153 167
 	}
154
-
155 168
 	rv := reflect.ValueOf(v)
156 169
 	switch rv.Kind() {
157 170
 	case reflect.Ptr:
@@ -170,11 +183,14 @@ func (c converter) ConvertValue(v interface{}) (driver.Value, error) {
170 183
 	case reflect.Bool:
171 184
 		return rv.Bool(), nil
172 185
 	case reflect.Slice:
173
-		ek := rv.Type().Elem().Kind()
174
-		if ek == reflect.Uint8 {
186
+		switch t := rv.Type(); {
187
+		case t == jsonType:
188
+			return v, nil
189
+		case t.Elem().Kind() == reflect.Uint8:
175 190
 			return rv.Bytes(), nil
191
+		default:
192
+			return nil, fmt.Errorf("unsupported type %T, a slice of %s", v, t.Elem().Kind())
176 193
 		}
177
-		return nil, fmt.Errorf("unsupported type %T, a slice of %s", v, ek)
178 194
 	case reflect.String:
179 195
 		return rv.String(), nil
180 196
 	}

+ 181
- 14
vendor/github.com/go-sql-driver/mysql/utils.go View File

@@ -106,27 +106,136 @@ func readBool(input string) (value bool, valid bool) {
106 106
 *                           Time related utils                                *
107 107
 ******************************************************************************/
108 108
 
109
-func parseDateTime(str string, loc *time.Location) (t time.Time, err error) {
110
-	base := "0000-00-00 00:00:00.0000000"
111
-	switch len(str) {
109
+func parseDateTime(b []byte, loc *time.Location) (time.Time, error) {
110
+	const base = "0000-00-00 00:00:00.000000"
111
+	switch len(b) {
112 112
 	case 10, 19, 21, 22, 23, 24, 25, 26: // up to "YYYY-MM-DD HH:MM:SS.MMMMMM"
113
-		if str == base[:len(str)] {
114
-			return
113
+		if string(b) == base[:len(b)] {
114
+			return time.Time{}, nil
115 115
 		}
116
-		t, err = time.Parse(timeFormat[:len(str)], str)
116
+
117
+		year, err := parseByteYear(b)
118
+		if err != nil {
119
+			return time.Time{}, err
120
+		}
121
+		if year <= 0 {
122
+			year = 1
123
+		}
124
+
125
+		if b[4] != '-' {
126
+			return time.Time{}, fmt.Errorf("bad value for field: `%c`", b[4])
127
+		}
128
+
129
+		m, err := parseByte2Digits(b[5], b[6])
130
+		if err != nil {
131
+			return time.Time{}, err
132
+		}
133
+		if m <= 0 {
134
+			m = 1
135
+		}
136
+		month := time.Month(m)
137
+
138
+		if b[7] != '-' {
139
+			return time.Time{}, fmt.Errorf("bad value for field: `%c`", b[7])
140
+		}
141
+
142
+		day, err := parseByte2Digits(b[8], b[9])
143
+		if err != nil {
144
+			return time.Time{}, err
145
+		}
146
+		if day <= 0 {
147
+			day = 1
148
+		}
149
+		if len(b) == 10 {
150
+			return time.Date(year, month, day, 0, 0, 0, 0, loc), nil
151
+		}
152
+
153
+		if b[10] != ' ' {
154
+			return time.Time{}, fmt.Errorf("bad value for field: `%c`", b[10])
155
+		}
156
+
157
+		hour, err := parseByte2Digits(b[11], b[12])
158
+		if err != nil {
159
+			return time.Time{}, err
160
+		}
161
+		if b[13] != ':' {
162
+			return time.Time{}, fmt.Errorf("bad value for field: `%c`", b[13])
163
+		}
164
+
165
+		min, err := parseByte2Digits(b[14], b[15])
166
+		if err != nil {
167
+			return time.Time{}, err
168
+		}
169
+		if b[16] != ':' {
170
+			return time.Time{}, fmt.Errorf("bad value for field: `%c`", b[16])
171
+		}
172
+
173
+		sec, err := parseByte2Digits(b[17], b[18])
174
+		if err != nil {
175
+			return time.Time{}, err
176
+		}
177
+		if len(b) == 19 {
178
+			return time.Date(year, month, day, hour, min, sec, 0, loc), nil
179
+		}
180
+
181
+		if b[19] != '.' {
182
+			return time.Time{}, fmt.Errorf("bad value for field: `%c`", b[19])
183
+		}
184
+		nsec, err := parseByteNanoSec(b[20:])
185
+		if err != nil {
186
+			return time.Time{}, err
187
+		}
188
+		return time.Date(year, month, day, hour, min, sec, nsec, loc), nil
117 189
 	default:
118
-		err = fmt.Errorf("invalid time string: %s", str)
119
-		return
190
+		return time.Time{}, fmt.Errorf("invalid time bytes: %s", b)
120 191
 	}
192
+}
121 193
 
122
-	// Adjust location
123
-	if err == nil && loc != time.UTC {
124
-		y, mo, d := t.Date()
125
-		h, mi, s := t.Clock()
126
-		t, err = time.Date(y, mo, d, h, mi, s, t.Nanosecond(), loc), nil
194
+func parseByteYear(b []byte) (int, error) {
195
+	year, n := 0, 1000
196
+	for i := 0; i < 4; i++ {
197
+		v, err := bToi(b[i])
198
+		if err != nil {
199
+			return 0, err
200
+		}
201
+		year += v * n
202
+		n = n / 10
127 203
 	}
204
+	return year, nil
205
+}
128 206
 
129
-	return
207
+func parseByte2Digits(b1, b2 byte) (int, error) {
208
+	d1, err := bToi(b1)
209
+	if err != nil {
210
+		return 0, err
211
+	}
212
+	d2, err := bToi(b2)
213
+	if err != nil {
214
+		return 0, err
215
+	}
216
+	return d1*10 + d2, nil
217
+}
218
+
219
+func parseByteNanoSec(b []byte) (int, error) {
220
+	ns, digit := 0, 100000 // max is 6-digits
221
+	for i := 0; i < len(b); i++ {
222
+		v, err := bToi(b[i])
223
+		if err != nil {
224
+			return 0, err
225
+		}
226
+		ns += v * digit
227
+		digit /= 10
228
+	}
229
+	// nanoseconds has 10-digits. (needs to scale digits)
230
+	// 10 - 6 = 4, so we have to multiple 1000.
231
+	return ns * 1000, nil
232
+}
233
+
234
+func bToi(b byte) (int, error) {
235
+	if b < '0' || b > '9' {
236
+		return 0, errors.New("not [0-9]")
237
+	}
238
+	return int(b - '0'), nil
130 239
 }
131 240
 
132 241
 func parseBinaryDateTime(num uint64, data []byte, loc *time.Location) (driver.Value, error) {
@@ -167,6 +276,64 @@ func parseBinaryDateTime(num uint64, data []byte, loc *time.Location) (driver.Va
167 276
 	return nil, fmt.Errorf("invalid DATETIME packet length %d", num)
168 277
 }
169 278
 
279
+func appendDateTime(buf []byte, t time.Time) ([]byte, error) {
280
+	year, month, day := t.Date()
281
+	hour, min, sec := t.Clock()
282
+	nsec := t.Nanosecond()
283
+
284
+	if year < 1 || year > 9999 {
285
+		return buf, errors.New("year is not in the range [1, 9999]: " + strconv.Itoa(year)) // use errors.New instead of fmt.Errorf to avoid year escape to heap
286
+	}
287
+	year100 := year / 100
288
+	year1 := year % 100
289
+
290
+	var localBuf [len("2006-01-02T15:04:05.999999999")]byte // does not escape
291
+	localBuf[0], localBuf[1], localBuf[2], localBuf[3] = digits10[year100], digits01[year100], digits10[year1], digits01[year1]
292
+	localBuf[4] = '-'
293
+	localBuf[5], localBuf[6] = digits10[month], digits01[month]
294
+	localBuf[7] = '-'
295
+	localBuf[8], localBuf[9] = digits10[day], digits01[day]
296
+
297
+	if hour == 0 && min == 0 && sec == 0 && nsec == 0 {
298
+		return append(buf, localBuf[:10]...), nil
299
+	}
300
+
301
+	localBuf[10] = ' '
302
+	localBuf[11], localBuf[12] = digits10[hour], digits01[hour]
303
+	localBuf[13] = ':'
304
+	localBuf[14], localBuf[15] = digits10[min], digits01[min]
305
+	localBuf[16] = ':'
306
+	localBuf[17], localBuf[18] = digits10[sec], digits01[sec]
307
+
308
+	if nsec == 0 {
309
+		return append(buf, localBuf[:19]...), nil
310
+	}
311
+	nsec100000000 := nsec / 100000000
312
+	nsec1000000 := (nsec / 1000000) % 100
313
+	nsec10000 := (nsec / 10000) % 100
314
+	nsec100 := (nsec / 100) % 100
315
+	nsec1 := nsec % 100
316
+	localBuf[19] = '.'
317
+
318
+	// milli second
319
+	localBuf[20], localBuf[21], localBuf[22] =
320
+		digits01[nsec100000000], digits10[nsec1000000], digits01[nsec1000000]
321
+	// micro second
322
+	localBuf[23], localBuf[24], localBuf[25] =
323
+		digits10[nsec10000], digits01[nsec10000], digits10[nsec100]
324
+	// nano second
325
+	localBuf[26], localBuf[27], localBuf[28] =
326
+		digits01[nsec100], digits10[nsec1], digits01[nsec1]
327
+
328
+	// trim trailing zeros
329
+	n := len(localBuf)
330
+	for n > 0 && localBuf[n-1] == '0' {
331
+		n--
332
+	}
333
+
334
+	return append(buf, localBuf[:n]...), nil
335
+}
336
+
170 337
 // zeroDateTime is used in formatBinaryDateTime to avoid an allocation
171 338
 // if the DATE or DATETIME has the zero value.
172 339
 // It must never be changed.

+ 1
- 1
vendor/modules.txt View File

@@ -13,7 +13,7 @@ github.com/dgrijalva/jwt-go
13 13
 # github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
14 14
 ## explicit
15 15
 github.com/docopt/docopt-go
16
-# github.com/go-sql-driver/mysql v1.5.0
16
+# github.com/go-sql-driver/mysql v1.6.0
17 17
 ## explicit
18 18
 github.com/go-sql-driver/mysql
19 19
 # github.com/go-test/deep v1.0.6

Loading…
Cancel
Save