Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection: interpolate uint64 parameters #955

Merged
merged 1 commit into from Apr 23, 2019

Conversation

vmg
Copy link
Contributor

@vmg vmg commented Apr 23, 2019

Hiii @methane!!

Here's a bug fix for you. #838 introduced a regression that causes InterpolateParams to fail when queries pass unsigned arguments. This is a problem! It caused a serious performance regression at GitHub! 馃槄

Commit message inline:

PR #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.go` now explicitly handles `driver.Value` instances
that are uint64.

However, the update in `packets.go` 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`.

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary
  • Added myself / the copyright holder to the AUTHORS file

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`.
@julienschmidt julienschmidt added this to the v1.5.0 milestone Apr 23, 2019
Copy link
Member

@julienschmidt julienschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks good 馃憤

Waiting for the CI (Travis)

@julienschmidt julienschmidt merged commit d0a5481 into go-sql-driver:master Apr 23, 2019
@vmg
Copy link
Contributor Author

vmg commented Apr 23, 2019

Thanks @julienschmidt!

@shlomi-noach
Copy link

@vmg you are awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants