Skip to content

Commit ef0bcc9

Browse files
authored
Merge branch 'master' into fix_formatdsn_connectionattributes
2 parents 32a54ed + 58941dd commit ef0bcc9

25 files changed

+830
-412
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: dominikh/[email protected]
19-
with:
20-
version: "2023.1.6"
18+
- uses: dominikh/[email protected]
2119

2220
list:
2321
runs-on: ubuntu-latest
@@ -31,10 +29,10 @@ jobs:
3129
import os
3230
go = [
3331
# Keep the most recent production release at the top
34-
'1.22',
32+
'1.23',
3533
# Older production releases
34+
'1.22',
3635
'1.21',
37-
'1.20',
3836
]
3937
mysql = [
4038
'9.0',
@@ -85,7 +83,7 @@ jobs:
8583
my-cnf: |
8684
innodb_log_file_size=256MB
8785
innodb_buffer_pool_size=512MB
88-
max_allowed_packet=16MB
86+
max_allowed_packet=48MB
8987
; TestConcurrent fails if max_connections is too large
9088
max_connections=50
9189
local_infile=1

AUTHORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ Andrew Reid <andrew.reid at tixtrack.com>
2020
Animesh Ray <mail.rayanimesh at gmail.com>
2121
Arne Hormann <arnehormann at gmail.com>
2222
Ariel Mashraki <ariel at mashraki.co.il>
23+
Artur Melanchyk <[email protected]>
2324
Asta Xie <xiemengjun at gmail.com>
25+
B Lamarche <blam413 at gmail.com>
26+
Bes Dollma <[email protected]>
2427
Bogdan Constantinescu <bog.con.bc at gmail.com>
2528
Brian Hendriks <brian at dolthub.com>
2629
Bulat Gaifullin <gaifullinbf at gmail.com>
@@ -52,6 +55,7 @@ ICHINOSE Shogo <shogo82148 at gmail.com>
5255
Ilia Cimpoes <ichimpoesh at gmail.com>
5356
INADA Naoki <songofacandy at gmail.com>
5457
Jacek Szwec <szwec.jacek at gmail.com>
58+
Jakub Adamus <kratky at zobak.cz>
5559
James Harr <james.harr at gmail.com>
5660
Janek Vedock <janekvedock at comcast.net>
5761
Jason Ng <oblitorum at gmail.com>
@@ -62,6 +66,7 @@ Jennifer Purevsuren <jennifer at dolthub.com>
6266
Jerome Meyer <jxmeyer at gmail.com>
6367
Jiajia Zhong <zhong2plus at gmail.com>
6468
Jian Zhen <zhenjl at gmail.com>
69+
Joe Mann <contact at joemann.co.uk>
6570
Joshua Prunier <joshua.prunier at gmail.com>
6671
Julien Lefevre <julien.lefevr at gmail.com>
6772
Julien Schmidt <go-sql-driver at julienschmidt.com>
@@ -82,6 +87,7 @@ Lunny Xiao <xiaolunwen at gmail.com>
8287
Luke Scott <luke at webconnex.com>
8388
Maciej Zimnoch <maciej.zimnoch at codilime.com>
8489
Michael Woolnough <michael.woolnough at gmail.com>
90+
Nao Yokotsuka <yokotukanao at gmail.com>
8591
Nathanial Murphy <nathanial.murphy at gmail.com>
8692
Nicola Peduzzi <thenikso at gmail.com>
8793
Oliver Bone <owbone at github.com>
@@ -91,6 +97,7 @@ Paul Bonser <misterpib at gmail.com>
9197
Paulius Lozys <pauliuslozys at gmail.com>
9298
Peter Schultz <peter.schultz at classmarkets.com>
9399
Phil Porada <philporada at gmail.com>
100+
Minh Quang <minhquang4334 at gmail.com>
94101
Rebecca Chin <rchin at pivotal.io>
95102
Reed Allman <rdallman10 at gmail.com>
96103
Richard Wilkes <wilkes at me.com>
@@ -141,4 +148,5 @@ PingCAP Inc.
141148
Pivotal Inc.
142149
Shattered Silicon Ltd.
143150
Stripe Inc.
151+
ThousandEyes
144152
Zendesk Inc.

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# Changelog
2+
3+
## v1.9.0 (2025-02-18)
4+
5+
### Major Changes
6+
7+
- Implement zlib compression. (#1487)
8+
- Supported Go version is updated to Go 1.21+. (#1639)
9+
- Add support for VECTOR type introduced in MySQL 9.0. (#1609)
10+
- Config object can have custom dial function. (#1527)
11+
12+
### Bugfixes
13+
14+
- Fix auth errors when username/password are too long. (#1625)
15+
- Check if MySQL supports CLIENT_CONNECT_ATTRS before sending client attributes. (#1640)
16+
- Fix auth switch request handling. (#1666)
17+
18+
### Other changes
19+
20+
- Add "filename:line" prefix to log in go-mysql. Custom loggers now show it. (#1589)
21+
- Improve error handling. It reduces the "busy buffer" errors. (#1595, #1601, #1641)
22+
- Use `strconv.Atoi` to parse max_allowed_packet. (#1661)
23+
- `rejectReadOnly` option now handles ER_READ_ONLY_MODE (1290) error too. (#1660)
24+
25+
126
## Version 1.8.1 (2024-03-26)
227

328
Bugfixes:

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac
3838
* Secure `LOAD DATA LOCAL INFILE` support with file allowlisting and `io.Reader` support
3939
* Optional `time.Time` parsing
4040
* Optional placeholder interpolation
41+
* Supports zlib compression.
4142

4243
## Requirements
4344

44-
* Go 1.20 or higher. We aim to support the 3 latest versions of Go.
45+
* Go 1.21 or higher. We aim to support the 3 latest versions of Go.
4546
* MySQL (5.7+) and MariaDB (10.5+) are supported.
4647
* [TiDB](https://github.com/pingcap/tidb) is supported by PingCAP.
4748
* Do not ask questions about TiDB in our issue tracker or forum.
@@ -267,6 +268,16 @@ SELECT u.id FROM users as u
267268

268269
will return `u.id` instead of just `id` if `columnsWithAlias=true`.
269270

271+
##### `compress`
272+
273+
```
274+
Type: bool
275+
Valid Values: true, false
276+
Default: false
277+
```
278+
279+
Toggles zlib compression. false by default.
280+
270281
##### `interpolateParams`
271282

272283
```

auth_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ func TestAuthSwitchCachingSHA256PasswordCached(t *testing.T) {
734734

735735
expectedReply := []byte{
736736
// 1. Packet: Hash
737-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
738-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
739-
153, 9, 130,
737+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
738+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
739+
118, 211, 69,
740740
}
741741
if !bytes.Equal(conn.written, expectedReply) {
742742
t.Errorf("got unexpected data: %v", conn.written)
@@ -803,9 +803,9 @@ func TestAuthSwitchCachingSHA256PasswordFullRSA(t *testing.T) {
803803

804804
expectedReplyPrefix := []byte{
805805
// 1. Packet: Hash
806-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
807-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
808-
153, 9, 130,
806+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
807+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
808+
118, 211, 69,
809809

810810
// 2. Packet: Pub Key Request
811811
1, 0, 0, 5, 2,
@@ -848,9 +848,9 @@ func TestAuthSwitchCachingSHA256PasswordFullRSAWithKey(t *testing.T) {
848848

849849
expectedReplyPrefix := []byte{
850850
// 1. Packet: Hash
851-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
852-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
853-
153, 9, 130,
851+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
852+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
853+
118, 211, 69,
854854

855855
// 2. Packet: Encrypted Password
856856
0, 1, 0, 5, // [changing bytes]
@@ -891,9 +891,9 @@ func TestAuthSwitchCachingSHA256PasswordFullSecure(t *testing.T) {
891891

892892
expectedReply := []byte{
893893
// 1. Packet: Hash
894-
32, 0, 0, 3, 129, 93, 132, 95, 114, 48, 79, 215, 128, 62, 193, 118, 128,
895-
54, 75, 208, 159, 252, 227, 215, 129, 15, 242, 97, 19, 159, 31, 20, 58,
896-
153, 9, 130,
894+
32, 0, 0, 3, 219, 72, 64, 97, 56, 197, 167, 203, 64, 236, 168, 80, 223,
895+
56, 103, 217, 196, 176, 124, 60, 253, 41, 195, 10, 205, 190, 177, 206, 63,
896+
118, 211, 69,
897897

898898
// 2. Packet: Cleartext password
899899
7, 0, 0, 5, 115, 101, 99, 114, 101, 116, 0,

benchmark_test.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ func (tb *TB) checkStmt(stmt *sql.Stmt, err error) *sql.Stmt {
4646
return stmt
4747
}
4848

49-
func initDB(b *testing.B, queries ...string) *sql.DB {
49+
func initDB(b *testing.B, useCompression bool, queries ...string) *sql.DB {
5050
tb := (*TB)(b)
51-
db := tb.checkDB(sql.Open(driverNameTest, dsn))
51+
comprStr := ""
52+
if useCompression {
53+
comprStr = "&compress=1"
54+
}
55+
db := tb.checkDB(sql.Open(driverNameTest, dsn+comprStr))
5256
for _, query := range queries {
5357
if _, err := db.Exec(query); err != nil {
5458
b.Fatalf("error on %q: %v", query, err)
@@ -60,10 +64,18 @@ func initDB(b *testing.B, queries ...string) *sql.DB {
6064
const concurrencyLevel = 10
6165

6266
func BenchmarkQuery(b *testing.B) {
67+
benchmarkQueryHelper(b, false)
68+
}
69+
70+
func BenchmarkQueryCompression(b *testing.B) {
71+
benchmarkQueryHelper(b, true)
72+
}
73+
74+
func benchmarkQueryHelper(b *testing.B, compr bool) {
6375
tb := (*TB)(b)
6476
b.StopTimer()
6577
b.ReportAllocs()
66-
db := initDB(b,
78+
db := initDB(b, compr,
6779
"DROP TABLE IF EXISTS foo",
6880
"CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))",
6981
`INSERT INTO foo VALUES (1, "one")`,
@@ -222,7 +234,7 @@ func BenchmarkInterpolation(b *testing.B) {
222234
},
223235
maxAllowedPacket: maxPacketSize,
224236
maxWriteSize: maxPacketSize - 1,
225-
buf: newBuffer(nil),
237+
buf: newBuffer(),
226238
}
227239

228240
args := []driver.Value{
@@ -269,7 +281,7 @@ func benchmarkQueryContext(b *testing.B, db *sql.DB, p int) {
269281
}
270282

271283
func BenchmarkQueryContext(b *testing.B) {
272-
db := initDB(b,
284+
db := initDB(b, false,
273285
"DROP TABLE IF EXISTS foo",
274286
"CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))",
275287
`INSERT INTO foo VALUES (1, "one")`,
@@ -305,7 +317,7 @@ func benchmarkExecContext(b *testing.B, db *sql.DB, p int) {
305317
}
306318

307319
func BenchmarkExecContext(b *testing.B) {
308-
db := initDB(b,
320+
db := initDB(b, false,
309321
"DROP TABLE IF EXISTS foo",
310322
"CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))",
311323
`INSERT INTO foo VALUES (1, "one")`,
@@ -323,7 +335,7 @@ func BenchmarkExecContext(b *testing.B) {
323335
// "size=" means size of each blobs.
324336
func BenchmarkQueryRawBytes(b *testing.B) {
325337
var sizes []int = []int{100, 1000, 2000, 4000, 8000, 12000, 16000, 32000, 64000, 256000}
326-
db := initDB(b,
338+
db := initDB(b, false,
327339
"DROP TABLE IF EXISTS bench_rawbytes",
328340
"CREATE TABLE bench_rawbytes (id INT PRIMARY KEY, val LONGBLOB)",
329341
)
@@ -376,7 +388,7 @@ func BenchmarkQueryRawBytes(b *testing.B) {
376388
// BenchmarkReceiveMassiveRows measures performance of receiving large number of rows.
377389
func BenchmarkReceiveMassiveRows(b *testing.B) {
378390
// Setup -- prepare 10000 rows.
379-
db := initDB(b,
391+
db := initDB(b, false,
380392
"DROP TABLE IF EXISTS foo",
381393
"CREATE TABLE foo (id INT PRIMARY KEY, val TEXT)")
382394
defer db.Close()

0 commit comments

Comments
 (0)