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: jpeirson/mysql
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.

Commits on Nov 13, 2018

  1. Fix Auth Resnponse packet for cleartext password (go-sql-driver#887)

    Trailing NUL char should be in `string[n] auth-response`.
    But NUL was after auth-response.
    methane authored Nov 13, 2018
    Copy the full SHA
    369b5d6 View commit details

Commits on Nov 16, 2018

  1. Improve buffer handling (go-sql-driver#890)

    * Eliminate redundant size test in takeBuffer.
    * Change buffer takeXXX functions to return an error to make it explicit that they can fail.
    * Add missing error check in handleAuthResult.
    * Add buffer.store(..) method which can be used by external buffer consumers to update the raw buffer.
    * Fix some typos and unnecessary UTF-8 characters in comments.
    * Improve buffer function docs.
    * Add comments to explain some non-obvious behavior around buffer handling.
    stevenh authored and methane committed Nov 16, 2018
    Copy the full SHA
    6be42e0 View commit details

Commits on Dec 2, 2018

  1. Implement support of Optional TLS (go-sql-driver#900)

    Issue: go-sql-driver#899
    
    Add `preferred` config value to the `tls` config variable on the DSN.
    
    This results in a TLS connection when the server advertises this by the flag
    send in the initial packet.
    dveeden authored and julienschmidt committed Dec 2, 2018
    Copy the full SHA
    60d456a View commit details

Commits on Dec 18, 2018

  1. Copy the full SHA
    c45f530 View commit details

Commits on Jan 27, 2019

  1. test: close rows (go-sql-driver#918)

    peergynt authored and methane committed Jan 27, 2019
    Copy the full SHA
    1b9eda2 View commit details

Commits on Feb 17, 2019

  1. Copy the full SHA
    972a708 View commit details

Commits on Mar 8, 2019

  1. README: 'Equivalent' is clearer (go-sql-driver#927)

    * Equivalent is clearer
    
    * Update AUTHORS
    Tim Ruffles authored and julienschmidt committed Mar 8, 2019
    Copy the full SHA
    2c9d54f View commit details

Commits on Mar 15, 2019

  1. drop Go 1.8 support (go-sql-driver#936)

    * drop Go 1.8 support
    
    * travis: add Go 1.12.x
    methane authored and julienschmidt committed Mar 15, 2019
    Copy the full SHA
    1fbca2a View commit details

Commits on Mar 29, 2019

  1. check connection liveness before writing query (go-sql-driver#934)

    This commit contains a potential fix to the issue reported in go-sql-driver#657.
    
    As a summary: when a MySQL server kills a connection on the server-side
    (either because it is actively pruning connections, or because the
    connection has hit the server-side timeout), the Go MySQL client does
    not immediately become aware of the connection being dead.
    
    Because of the way TCP works, the client cannot know that the connection
    has received a RST packet from the server (i.e. the server-side has
    closed) until it actually reads from it. This causes an unfortunate bug
    wherein a MySQL idle connection is pulled from the connection pool, a
    query packet is written to it without error, and then the query fails
    with an "unexpected EOF" error when trying to read the response packet.
    
    Since the initial write to the socket does not fail with an error, it is
    generally not safe to return `driver.ErrBadConn` when the read fails,
    because in theory the write could have arrived to the server and could
    have been committed. Returning `ErrBadConn` could lead to duplicate
    inserts on the database and data corruption because of the way the Go
    SQL package performs retries.
    
    In order to significantly reduce the circumstances where this
    "unexpected EOF" error is returned for stale connections, this commit
    performs a liveness check before writing a new query.
    
    When do we check?
    -----------------
    
    This check is not performed for all writes. Go 1.10 introduced a new
    `sql/driver` interface called `driver.SessionResetter`, which calls the
    `ResetSession` method on any connections _when they are returned to the
    connection pool_. Since performing the liveness check during
    `ResetSession` is not particularly useful (the connection can spend a
    long time in the pool before it's checked out again, and become stale),
    we simply mark the connection with a `reset` flag instead.
    
    This `reset` flag is then checked from `mysqlConn.writePacket` to
    perform the liveness checks. This ensures that the liveness check will
    only be performed for the first query on a connection that has been
    checked out of the connection pool. These are pretty much the semantics
    we want: a fresh connection from the pool is more likely to be stale,
    and it has not performed any previous writes that could cause data
    corruption. If a connection is being consistently used by the client
    (i.e. through an open transaction), we do NOT perform liveness checks.
    If MySQL Server kills such active connection, we want to bubble up the
    error to the user because any silent retrying can and will lead to data
    corruption.
    
    Since the `ResetSession` interface is only available in Go 1.10+, the
    liveness checks will only be performed starting with that Go version.
    
    How do we check?
    ----------------
    
    To perform the actual liveness test on the connection, we use the new
    `syscall.Conn` interface which is available for all `net.Conn`s since Go
    1.9. The `SyscallConn` method returns a `RawConn` that lets us read
    directly from the connection's file descriptor using syscalls, and
    skipping the default read pipeline of the Go runtime.
    
    When reading directly from the file descriptor using `syscall.Read`, we
    pass in a 1-length buffer, as passing a 0-length buffer will always
    result in a 0-length read, and the 1-length buffer will never be filled
    because we're not expecting any reads from MySQL before we have written
    any request packets in a fresh connection.
    
    All sockets created in the Go runtime are set to non-blocking
    (O_NONBLOCK). Consequently, we can detect a socket that has been closed
    on the server-side because the `read` syscall will return a 0-length read
    _and_ no error.
    
    We assume that any other errors returned from the `read` also mean the
    connection is in a bad state, except for `EAGAIN`/`EWOULDBLOCK`, which is
    the expected return for a healthy non-blocking socket in this circumstance.
    
    Because of the dependency on `syscall.Conn`, liveness checks can only be
    performed in Go 1.9+. This restriction however overlaps with the fact
    that we only mark connections as having been reset in Go 1.10+, as
    explained in the previous section.
    Vicent Martí authored and methane committed Mar 29, 2019
    Copy the full SHA
    bc5e6ea View commit details

Commits on Mar 30, 2019

  1. Copy the full SHA
    c0f6b44 View commit details

Commits on Apr 4, 2019

  1. buffer: Use a double-buffering scheme to prevent data races (go-sql-d…

    …river#943)
    
    Fixes go-sql-driver#903
    
    Co-Authored-By: vmg <vicent@github.com>
    Vicent Martí authored and methane committed Apr 4, 2019
    Copy the full SHA
    df597a2 View commit details
  2. Support Go 1.10 Connector interface (go-sql-driver#941)

    Vicent Martí authored and methane committed Apr 4, 2019
    Copy the full SHA
    89ec2a9 View commit details
  3. Copy the full SHA
    8f4b98d View commit details

Commits on Apr 5, 2019

  1. Copy the full SHA
    d3a0b0f View commit details
  2. Copy the full SHA
    93c3765 View commit details

Commits on Apr 10, 2019

  1. Copy the full SHA
    578c4c8 View commit details

Commits on Apr 23, 2019

  1. connection: interpolate uint64 parameters (go-sql-driver#955)

    PR go-sql-driver#838 introduced a fix for the driver's custom Value Converter that
    stopped emitting large uint64 `driver.Value`s as a string. Instead, now
    _all_ uint{8,16,32,64} values passed to the driver are returned as
    uint64, and `packets.c` now explicitly handles `driver.Value` instances
    that are uint64.
    
    However, the update in `packets.c` only applies when sending
    `driver.Value` arguments to the server. When a connection is set up
    using `InterpolateParams = true` and query interpolation happens inside
    of the driver, the `(*mysqlConn) interpolateParams` does **not** handle
    uint64 values (which, again, are now passed by `database/sql` because
    we've updated our value converter to generate them).
    
    Because of this, any `DB.Query` operations which have an uint argument
    (regardless of its size!!) will force the driver to return
    `driver.ErrSkip`, disabling client interpolation for such queries.
    
    We can fix this by updating `interpolateParams` like we previously
    updated `writeExecutePacket`.
    vmg authored and julienschmidt committed Apr 23, 2019
    Copy the full SHA
    d0a5481 View commit details

Commits on May 7, 2019

  1. packets: reset read deadline before conn check (go-sql-driver#964)

    * packets: reset read deadline before conn check
    
    If a MySQL connection has been configured with a short `ReadTimeout`,
    each read from the TCP connection will be preceded by a
    `SetReadDeadline` call, which lingers until the next `SetReadDeadline`.
    
    This can be an issue if the connection becomes stale after staying too
    long in the connection pool, because when we attempt to perform a stale
    connection check, the Go runtime scheduler will return a timedout error
    from the scheduler itself, without letting us get to the kernel to
    perform the non-blocking read.
    
    To fix this, reset the read deadline before we perform the connection
    check.
    
    * packets: set a 0 deadline
    vmg authored and julienschmidt committed May 7, 2019
    Copy the full SHA
    8056f2c View commit details

Commits on May 10, 2019

  1. move tls and pubkey object creation to Config.normalize() (go-sql-dri…

    …ver#958)
    
    This is still less than ideal since we cannot directly pass in
    tls.Config into Config and have it be used, but it is sill backwards
    compatable.  In the future this should be revisited to be able to use a
    custome tls.Config passed directly in without string
    parsing/registering.
    nemith authored and methane committed May 10, 2019
    Copy the full SHA
    877a977 View commit details

Commits on Sep 4, 2019

  1. Copy the full SHA
    7244e50 View commit details
  2. GCP DSN example for flexible environment (go-sql-driver#993)

    * Added GCP connection string example for flexible environment.
    
    * Added one more GCP connection string example for flexible environment.
    
    * Unified GCP connection strings examples for 2nd gen and flexible env.
    cn0047 authored and julienschmidt committed Sep 4, 2019
    Copy the full SHA
    23821f4 View commit details

Commits on Sep 5, 2019

  1. Copy the full SHA
    d9aa6d3 View commit details

Commits on Sep 7, 2019

  1. Copy the full SHA
    b2c03bc View commit details

Commits on Sep 17, 2019

  1. Copy the full SHA
    6c79a37 View commit details

Commits on Oct 1, 2019

  1. Remove Cloud SQL dialer (go-sql-driver#1007)

    CloudSQL is only available up to Go 1.9 on Google AppEngine, which was phased out. Starting from 2019-10-01, no new apps can be deployed to GAE/Go 1.9 anymore. This dialer is thus obsolete.
    
    Fixes go-sql-driver#1002
    julienschmidt authored Oct 1, 2019
    Copy the full SHA
    59de189 View commit details
  2. Copy the full SHA
    14bb9c0 View commit details

Commits on Oct 21, 2019

  1. Add string type to ColumnTypeScanType(). (go-sql-driver#976)

    ColumnTypeScanType() now returns string and sql.NullString.
    j-forster authored and methane committed Oct 21, 2019
    Copy the full SHA
    5ee934f View commit details

Commits on Oct 22, 2019

  1. Copy the full SHA
    6ea7374 View commit details

Commits on Nov 1, 2019

  1. Copy the full SHA
    296987f View commit details

Commits on Nov 8, 2019

  1. connector: don't return ErrBadConn when failing to connect (go-sql-dr…

    …iver#1020)
    
    ErrBadConn should only be returned for an already established
    connection, not when creating a new one.
    bouk authored and methane committed Nov 8, 2019
    Copy the full SHA
    b57978c View commit details

Commits on Nov 14, 2019

  1. Copy the full SHA
    b4242ba View commit details

Commits on Nov 21, 2019

  1. Set timeout for custom dialer. (go-sql-driver#1035)

    zjj authored and methane committed Nov 21, 2019
    Copy the full SHA
    15462c1 View commit details

Commits on Dec 11, 2019

  1. Drop Go 1.9 support (go-sql-driver#1017)

    * Drop Go 1.9 support
    
    * Add test for Go 1.13.
    methane authored and shogo82148 committed Dec 11, 2019
    Copy the full SHA
    94084c9 View commit details

Commits on Dec 12, 2019

  1. Remove "go1.10" build tag (go-sql-driver#1016)

    Some IDEs and editors refuse to acknowledge the "go1.10" build tag when
    autocompleting & compiling. Removing said tag increases usibility of the
    library for those stuck with these editors.
    neetle authored and methane committed Dec 12, 2019
    Copy the full SHA
    b66d043 View commit details

Commits on Jan 5, 2020

  1. fix compile error of connCheck.go (go-sql-driver#1048)

    * fix compile error of connCheck.go
    
    * remove "appengine" build tag
    shogo82148 authored Jan 5, 2020
    Copy the full SHA
    8723940 View commit details

Commits on Jan 7, 2020

  1. Copy the full SHA
    4bdaef4 View commit details
  2. conncheck: allow to disable via config (go-sql-driver#1052)

    * conncheck: allow to disable via config
    
    * dsn: refactor writing of params in FormatDSN
    julienschmidt authored Jan 7, 2020
    Copy the full SHA
    6844171 View commit details
  3. Copy the full SHA
    2898b56 View commit details
  4. Release v1.5.0 (go-sql-driver#1047)

    * CHANGELOG: include v1.4.1
    
    * Release v1.5.0
    julienschmidt authored Jan 7, 2020
    Copy the full SHA
    17ef3dd View commit details

Commits on Feb 9, 2020

  1. connection: interpolate json.RawMessage as string (go-sql-driver#1058)

    json encoded data is represented as bytes however it should be interpolated as a string
    
    Fixes go-sql-driver#819
    alexsn authored Feb 9, 2020
    Copy the full SHA
    c4f1976 View commit details

Commits on Feb 13, 2020

  1. Copy the full SHA
    5a8a207 View commit details

Commits on Feb 18, 2020

  1. stmt: add json.RawMessage for converter and prepared statement (go-sq…

    …l-driver#1059)
    
    Following go-sql-driver#1058, in order for the driver.Value to get as a json.RawMessage,
    the converter should accept it as a valid value, and handle it as bytes in
    case where interpolation is disabled
    a8m authored Feb 18, 2020
    Copy the full SHA
    3d8a029 View commit details

Commits on Feb 25, 2020

  1. Put zero filler into the SSL handshake packet. (go-sql-driver#1066)

    According to the linked documentation at
    http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest
    SSLRequest packet should have zero filler similar to the regular handshake request,
    but now the driver puts zeros only in the regular request. Luckily vanilla MySQL
    doesn't rely on this zero filler and doesn't verify its presence, thus the driver worked
    fine so far. But MySQL can change to rely on zeros at any point.
    
    The problem was discovered while testing against a customized MySQL.
    pivanof authored Feb 25, 2020
    Copy the full SHA
    dd9d356 View commit details

Commits on Mar 11, 2020

  1. travis: Add compile check for all supported platforms (go-sql-driver#…

    …1070)
    
    Implements a Travis CI task that checks if the driver compiles on all platforms supported by Go.
    
    Fixes go-sql-driver#1050
    rayanimesh authored Mar 11, 2020
    Copy the full SHA
    681ffa8 View commit details

Commits on May 8, 2020

  1. Travis allow Go master to fail (go-sql-driver#1092)

    * travis: allow master branch to fail
    
    * travis: matrix is an alias for jobs
    
    * travis: remove obsolete sudo key
    
    * travis: remove obsolete sudo keys in jobs matrix
    julienschmidt authored May 8, 2020
    Copy the full SHA
    f070e56 View commit details

Commits on May 9, 2020

  1. mysqlStmt Implements CheckNamedValue (go-sql-driver#1090)

    * Add CheckNamedValue for mysqlStmt
    
    * Update AUTHORS
    
    Co-authored-by: Zhixin Wen <zwen@nuro.ai>
    zhixinwen and Zhixin Wen authored May 9, 2020
    Copy the full SHA
    343c803 View commit details

Commits on May 12, 2020

  1. Fix checking cancelled connections back into the connection pool (go-…

    …sql-driver#1095)
    
    If
        * BeginTx is called with a non-default isolation level,
        * The context is canceled before SET TRANSACTION ISOLATION LEVEL
        completes,
    then the connection:
        * has the cancelled property set to "context cancelled",
        * has the closed property set to true,
    and,
        * BeginTx returns "context canceled"
    
    Because of this, the connection gets put back into the connection pool.
    When it is checked out again, if BeginTx is called on it again _without_
    an isolation level,
        * then we fall into the mc.closed.IsSet() check in begin(),
        * so we return ErrBadConn,
        * so the driver kicks the broken connection out of the pool
        * (and transparently retries to get a new connection that isn't
        broken too).
    
    However, if BeginTx is called on the connection _with_ an isolation
    level, then we return a context canceled error from the SET TRANSACTION
    ISOLATION LEVEL call.
    
    That means the broken connection will stick around in the pool forever
    (or until it's checked out for some other operation that correctly
    returns ErrBadConn).
    
    The fix is to check for the connection being closed before executing SET
    TRANSACTION ISOLATION LEVEL.
    Konstantinos Tsanaktsidis authored May 12, 2020
    Copy the full SHA
    6313f20 View commit details

Commits on May 13, 2020

  1. Update travis: use Go 1.14 for testing (go-sql-driver#1100)

    * Travis-CI: reverse order of Go version
    
    Reverse order of Go versions so the recent ones are tested first.
    
    * Travis-CI: add Go 1.14
    
    * Travis-CI: move 'tip' just below the latest Go release
    
    * Travis-CI: upgrade Go to 1.14 to run tests
    dolmen authored May 13, 2020
    Copy the full SHA
    f378f59 View commit details

Commits on May 17, 2020

  1. Copy the full SHA
    096feaa View commit details

Commits on May 19, 2020

  1. On connect, set all variables in a single SET statement (go-sql-drive…

    …r#1099)
    
    When opening a connection, instead of iterating on all variables and
    calling "SET <variable>=<value>" for each, we now use a single SET statement
    with all pairs using a comma as separator:
      SET <variable1>=<value1>,<variable2>=<value2>,...
    dolmen authored May 19, 2020
    Copy the full SHA
    3f51e4e View commit details
Showing with 5,122 additions and 2,106 deletions.
  1. 0 { → .github}/CONTRIBUTING.md
  2. +41 −0 .github/workflows/codeql.yml
  3. +114 −0 .github/workflows/test.yml
  4. +0 −107 .travis.yml
  5. +0 −5 .travis/docker.cnf
  6. +0 −7 .travis/gofmt.sh
  7. +0 −8 .travis/wait_mysql.sh
  8. +60 −0 AUTHORS
  9. +180 −3 CHANGELOG.md
  10. +145 −40 README.md
  11. +0 −19 appengine.go
  12. +117 −53 auth.go
  13. +107 −55 auth_test.go
  14. +134 −11 benchmark_test.go
  15. +78 −74 buffer.go
  16. +198 −183 collations.go
  17. +214 −0 compress.go
  18. +119 −0 compress_test.go
  19. +55 −0 conncheck.go
  20. +18 −0 conncheck_dummy.go
  21. +39 −0 conncheck_test.go
  22. +202 −124 connection.go
  23. +65 −16 connection_test.go
  24. +227 −0 connector.go
  25. +30 −0 connector_test.go
  26. +20 −2 const.go
  27. +59 −110 driver.go
  28. +1,100 −364 driver_test.go
  29. +274 −184 dsn.go
  30. +47 −0 dsn_fuzz_test.go
  31. +175 −64 dsn_test.go
  32. +27 −9 errors.go
  33. +22 −3 errors_test.go
  34. +57 −27 fields.go
  35. +5 −0 go.mod
  36. +2 −0 go.sum
  37. +33 −31 infile.go
  38. +71 −0 nulltime.go
  39. +62 −0 nulltime_test.go
  40. +341 −264 packets.go
  41. +47 −34 packets_test.go
  42. +32 −4 result.go
  43. +11 −2 rows.go
  44. +42 −37 statement.go
  45. +31 −6 statement_test.go
  46. +2 −2 transaction.go
  47. +235 −160 utils.go
  48. +284 −98 utils_test.go
File renamed without changes.
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: "18 19 * * 1"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ go ]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
114 changes: 114 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: test
on:
pull_request:
push:
workflow_dispatch:

env:
MYSQL_TEST_USER: gotest
MYSQL_TEST_PASS: secret
MYSQL_TEST_ADDR: 127.0.0.1:3306
MYSQL_TEST_CONCURRENT: 1

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dominikh/staticcheck-action@v1.3.1

list:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: list
id: set-matrix
run: |
import json
import os
go = [
# Keep the most recent production release at the top
'1.23',
# Older production releases
'1.22',
'1.21',
]
mysql = [
'9.0',
'8.4', # LTS
'8.0',
'5.7',
'mariadb-11.4', # LTS
'mariadb-11.2',
'mariadb-11.1',
'mariadb-10.11', # LTS
'mariadb-10.6', # LTS
'mariadb-10.5', # LTS
]
includes = []
# Go versions compatibility check
for v in go[1:]:
includes.append({'os': 'ubuntu-latest', 'go': v, 'mysql': mysql[0]})
matrix = {
# OS vs MySQL versions
'os': [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ],
'go': [ go[0] ],
'mysql': mysql,
'include': includes
}
output = json.dumps(matrix, separators=(',', ':'))
with open(os.environ["GITHUB_OUTPUT"], 'a', encoding="utf-8") as f:
print(f"matrix={output}", file=f)
shell: python
test:
needs: list
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.list.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: ${{ matrix.mysql }}
user: ${{ env.MYSQL_TEST_USER }}
password: ${{ env.MYSQL_TEST_PASS }}
my-cnf: |
innodb_log_file_size=256MB
innodb_buffer_pool_size=512MB
max_allowed_packet=48MB
; TestConcurrent fails if max_connections is too large
max_connections=50
local_infile=1
performance_schema=on
- name: setup database
run: |
mysql --user 'root' --host '127.0.0.1' -e 'create database gotest;'
- name: test
run: |
go test -v '-race' '-covermode=atomic' '-coverprofile=coverage.out' -parallel 10
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
flag-name: ${{ runner.os }}-Go-${{ matrix.go }}-DB-${{ matrix.mysql }}
parallel: true

# notifies that all test jobs are finished.
finish:
needs: test
if: always()
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true
107 changes: 0 additions & 107 deletions .travis.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .travis/docker.cnf

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/gofmt.sh

This file was deleted.

8 changes: 0 additions & 8 deletions .travis/wait_mysql.sh

This file was deleted.

Loading