Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: idimetrix/mysql-1
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: go-sql-driver/mysql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 20 commits
  • 23 files changed
  • 24 contributors

Commits on Nov 10, 2024

  1. Specify a custom dial function per config (go-sql-driver#1527)

    Specify a custom dial function per config instead of using
    RegisterDialContext.
    aaronjheng authored Nov 10, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    91ad4fb View commit details

Commits on Nov 11, 2024

  1. ci: update Go and staticcheck versions (go-sql-driver#1639)

    - Add Go 1.23 support
    - Remove Go 1.20 support
    - Update staticcheck action
    methane authored Nov 11, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    fc64d3f View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f62f523 View commit details

Commits on Nov 19, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    41a5fa2 View commit details

Commits on Nov 21, 2024

  1. Reduce "busy buffer" logs (go-sql-driver#1641)

    Reduce the use of `errBadConnNoWrite` to improve maintainability.
    
    ResetSession() and IsValid() checks if the buffer is busy. This reduces
    the risk of busy buffer error during connection in use. In principle,
    the risk of this is zero. So I removed errBadConnNoWrite when checking
    the busy buffer.
    
    After this change, only `writePacke()` returns errBadConnNoWrite.
    
    Additionally, I do not send COM_QUIT when readPacket() encounter read error.
    It caused "busy buffer" error too and hide real errors.
    methane authored Nov 21, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9c8d6a5 View commit details

Commits on Nov 27, 2024

  1. stmt.Close() returns nil when double close (go-sql-driver#1642)

    ErrBadConn needs special care to ensure it is safe to retry.
    To improve maintenance, I don't want to use the error where I don't have to.
    
    Additionally, update the old comment about Go's bug that had been fixed long time ago.
    methane authored Nov 27, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2df7a26 View commit details

Commits on Dec 1, 2024

  1. stop double-buffering (go-sql-driver#1643)

    Since we dropped Go 1.20 support, we do not need double buffering.
    
    This pull request stop double buffering and simplify buffer
    implementation a lot.
    
    Fix go-sql-driver#1435
    methane authored Dec 1, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    575e1b2 View commit details

Commits on Dec 15, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c9f41c0 View commit details

Commits on Dec 19, 2024

  1. Implement zlib compression (go-sql-driver#1487)

    Implemented the SQL compression protocol. This new feature is enabled by:
    
    * Adding `compress=true` in DSN.
    * `cfg.Apply(Compress(True))`
    
    Co-authored-by: Brigitte Lamarche <[email protected]>
    Co-authored-by: Julien Schmidt <[email protected]>
    Co-authored-by: Jeffrey Charles <[email protected]>
    Co-authored-by: Jeff Hodges <[email protected]>
    Co-authored-by: Daniel Montoya <[email protected]>
    Co-authored-by: Justin Li <[email protected]>
    Co-authored-by: Dave Stubbs <[email protected]>
    Co-authored-by: Linh Tran Tuan <[email protected]>
    Co-authored-by: Robert R. Russell <[email protected]>
    Co-authored-by: INADA Naoki <[email protected]>
    Co-authored-by: Kieron Woodhouse <[email protected]>
    Co-authored-by: Alexey Palazhchenko <[email protected]>
    Co-authored-by: Reed Allman <[email protected]>
    Co-authored-by: Joe Mann <[email protected]>
    15 people authored Dec 19, 2024

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    3348e57 View commit details

Commits on Dec 20, 2024

  1. use binary.LittleEndian (go-sql-driver#1651)

    Recent Go does inlinine functions well.
    Using `LittleEndian.Put*` would better for readability and minimize bound check.
    
    Additionally, Go 1.19 introduced `LittleEndian.Append*`. It reduce more code.
    methane authored Dec 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b335ed3 View commit details

Commits on Dec 24, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7403860 View commit details

Commits on Jan 22, 2025

  1. better max_allowed_packet parsing (go-sql-driver#1661)

    Remove `stringToInt()` and use `strconv.Atoi` instead.
    methane authored Jan 22, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    255d1ad View commit details

Commits on Jan 23, 2025

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    85c6311 View commit details

Commits on Jan 29, 2025

  1. Fix auth_switch_request packet handling

    auth_data contains last NUL.
    
    Fix go-sql-driver#1666
    
    Signed-off-by: Bes Dollma (bdollma) <[email protected]>
    bdollma-te authored Jan 29, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    341a5a5 View commit details

Commits on Feb 18, 2025

  1. fix flaky test. (go-sql-driver#1663)

    TestIssue1567 fails by max_connections error. This makes our CI unhappy.
    
    https://github.com/go-sql-driver/mysql/actions/runs/12904961433/job/35984402310
    methane authored Feb 18, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5d1bb8a View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    58941dd View commit details

Commits on Mar 10, 2025

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c879816 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    88ff88b View commit details

Commits on Mar 14, 2025

  1. go.mod: fix go version format (go-sql-driver#1682)

    As of Go 1.21, toolchain versions must use the 1.N.P syntax.
    https://go.dev/doc/toolchain#version
    methane authored Mar 14, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b84ac5a View commit details

Commits on Mar 21, 2025

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1fbafa8 View commit details
Showing with 812 additions and 363 deletions.
  1. +4 −6 .github/workflows/test.yml
  2. +8 −0 AUTHORS
  3. +36 −0 CHANGELOG.md
  4. +12 −1 README.md
  5. +12 −12 auth_test.go
  6. +20 −8 benchmark_test.go
  7. +50 −81 buffer.go
  8. +214 −0 compress.go
  9. +119 −0 compress_test.go
  10. +49 −6 connection.go
  11. +7 −7 connection_test.go
  12. +30 −19 connector.go
  13. +2 −0 const.go
  14. +43 −11 driver_test.go
  15. +43 −4 dsn.go
  16. +5 −1 dsn_test.go
  17. +1 −1 go.mod
  18. +6 −5 infile.go
  19. +113 −150 packets.go
  20. +15 −9 packets_test.go
  21. +0 −7 rows.go
  22. +6 −5 statement.go
  23. +17 −30 utils.go
10 changes: 4 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -15,9 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dominikh/staticcheck-action@v1.3.0
with:
version: "2023.1.6"
- uses: dominikh/staticcheck-action@v1.3.1

list:
runs-on: ubuntu-latest
@@ -31,10 +29,10 @@ jobs:
import os
go = [
# Keep the most recent production release at the top
'1.22',
'1.23',
# Older production releases
'1.22',
'1.21',
'1.20',
]
mysql = [
'9.0',
@@ -85,7 +83,7 @@ jobs:
my-cnf: |
innodb_log_file_size=256MB
innodb_buffer_pool_size=512MB
max_allowed_packet=16MB
max_allowed_packet=48MB
; TestConcurrent fails if max_connections is too large
max_connections=50
local_infile=1
8 changes: 8 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ Andrew Reid <andrew.reid at tixtrack.com>
Animesh Ray <mail.rayanimesh at gmail.com>
Arne Hormann <arnehormann at gmail.com>
Ariel Mashraki <ariel at mashraki.co.il>
Artur Melanchyk <artur.melanchyk@gmail.com>
Asta Xie <xiemengjun at gmail.com>
B Lamarche <blam413 at gmail.com>
Bes Dollma <bdollma@thousandeyes.com>
Bogdan Constantinescu <bog.con.bc at gmail.com>
Brian Hendriks <brian at dolthub.com>
Bulat Gaifullin <gaifullinbf at gmail.com>
Caine Jette <jette at alum.mit.edu>
@@ -51,6 +55,7 @@ ICHINOSE Shogo <shogo82148 at gmail.com>
Ilia Cimpoes <ichimpoesh at gmail.com>
INADA Naoki <songofacandy at gmail.com>
Jacek Szwec <szwec.jacek at gmail.com>
Jakub Adamus <kratky at zobak.cz>
James Harr <james.harr at gmail.com>
Janek Vedock <janekvedock at comcast.net>
Jason Ng <oblitorum at gmail.com>
@@ -61,6 +66,7 @@ Jennifer Purevsuren <jennifer at dolthub.com>
Jerome Meyer <jxmeyer at gmail.com>
Jiajia Zhong <zhong2plus at gmail.com>
Jian Zhen <zhenjl at gmail.com>
Joe Mann <contact at joemann.co.uk>
Joshua Prunier <joshua.prunier at gmail.com>
Julien Lefevre <julien.lefevr at gmail.com>
Julien Schmidt <go-sql-driver at julienschmidt.com>
@@ -91,6 +97,7 @@ Paul Bonser <misterpib at gmail.com>
Paulius Lozys <pauliuslozys at gmail.com>
Peter Schultz <peter.schultz at classmarkets.com>
Phil Porada <philporada at gmail.com>
Minh Quang <minhquang4334 at gmail.com>
Rebecca Chin <rchin at pivotal.io>
Reed Allman <rdallman10 at gmail.com>
Richard Wilkes <wilkes at me.com>
@@ -141,4 +148,5 @@ PingCAP Inc.
Pivotal Inc.
Shattered Silicon Ltd.
Stripe Inc.
ThousandEyes
Zendesk Inc.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# Changelog

## v1.9.1 (2025-03-21)

### Major Changes

* Add Charset() option. (#1679)

### Bugfixes

* go.mod: fix go version format (#1682)
* Fix FormatDSN missing ConnectionAttributes (#1619)

## v1.9.0 (2025-02-18)

### Major Changes

- Implement zlib compression. (#1487)
- Supported Go version is updated to Go 1.21+. (#1639)
- Add support for VECTOR type introduced in MySQL 9.0. (#1609)
- Config object can have custom dial function. (#1527)

### Bugfixes

- Fix auth errors when username/password are too long. (#1625)
- Check if MySQL supports CLIENT_CONNECT_ATTRS before sending client attributes. (#1640)
- Fix auth switch request handling. (#1666)

### Other changes

- Add "filename:line" prefix to log in go-mysql. Custom loggers now show it. (#1589)
- Improve error handling. It reduces the "busy buffer" errors. (#1595, #1601, #1641)
- Use `strconv.Atoi` to parse max_allowed_packet. (#1661)
- `rejectReadOnly` option now handles ER_READ_ONLY_MODE (1290) error too. (#1660)


## Version 1.8.1 (2024-03-26)

Bugfixes:
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -38,10 +38,11 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac
* Secure `LOAD DATA LOCAL INFILE` support with file allowlisting and `io.Reader` support
* Optional `time.Time` parsing
* Optional placeholder interpolation
* Supports zlib compression.

## Requirements

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

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

##### `compress`

```
Type: bool
Valid Values: true, false
Default: false
```

Toggles zlib compression. false by default.

##### `interpolateParams`

```
24 changes: 12 additions & 12 deletions auth_test.go
Original file line number Diff line number Diff line change
@@ -734,9 +734,9 @@ func TestAuthSwitchCachingSHA256PasswordCached(t *testing.T) {

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

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

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

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

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

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

// 2. Packet: Cleartext password
7, 0, 0, 5, 115, 101, 99, 114, 101, 116, 0,
28 changes: 20 additions & 8 deletions benchmark_test.go
Original file line number Diff line number Diff line change
@@ -46,9 +46,13 @@ func (tb *TB) checkStmt(stmt *sql.Stmt, err error) *sql.Stmt {
return stmt
}

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

func BenchmarkQuery(b *testing.B) {
benchmarkQueryHelper(b, false)
}

func BenchmarkQueryCompression(b *testing.B) {
benchmarkQueryHelper(b, true)
}

func benchmarkQueryHelper(b *testing.B, compr bool) {
tb := (*TB)(b)
b.StopTimer()
b.ReportAllocs()
db := initDB(b,
db := initDB(b, compr,
"DROP TABLE IF EXISTS foo",
"CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))",
`INSERT INTO foo VALUES (1, "one")`,
@@ -222,7 +234,7 @@ func BenchmarkInterpolation(b *testing.B) {
},
maxAllowedPacket: maxPacketSize,
maxWriteSize: maxPacketSize - 1,
buf: newBuffer(nil),
buf: newBuffer(),
}

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

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

func BenchmarkExecContext(b *testing.B) {
db := initDB(b,
db := initDB(b, false,
"DROP TABLE IF EXISTS foo",
"CREATE TABLE foo (id INT PRIMARY KEY, val CHAR(50))",
`INSERT INTO foo VALUES (1, "one")`,
@@ -323,7 +335,7 @@ func BenchmarkExecContext(b *testing.B) {
// "size=" means size of each blobs.
func BenchmarkQueryRawBytes(b *testing.B) {
var sizes []int = []int{100, 1000, 2000, 4000, 8000, 12000, 16000, 32000, 64000, 256000}
db := initDB(b,
db := initDB(b, false,
"DROP TABLE IF EXISTS bench_rawbytes",
"CREATE TABLE bench_rawbytes (id INT PRIMARY KEY, val LONGBLOB)",
)
@@ -376,7 +388,7 @@ func BenchmarkQueryRawBytes(b *testing.B) {
// BenchmarkReceiveMassiveRows measures performance of receiving large number of rows.
func BenchmarkReceiveMassiveRows(b *testing.B) {
// Setup -- prepare 10000 rows.
db := initDB(b,
db := initDB(b, false,
"DROP TABLE IF EXISTS foo",
"CREATE TABLE foo (id INT PRIMARY KEY, val TEXT)")
defer db.Close()
Loading