Skip to content

Conversation

@ymmt2005
Copy link
Contributor

This PR is a revise of #381.

Since 5.6.27, mysql server produces a warning if string literals cannot
be interpreted in a given character set (see Bug #20238729).
As a consequence, the driver may fail to insert []byte data into
BLOB columns when interpolateParams is true in strict SQL mode.

This commit adds "_binary" encoding prefix when interpolating []byte data
to avoid that warning.

http://dev.mysql.com/doc/refman/5.7/en/charset-literal.html

Since 5.6.27, mysql server produces a warning if string literals cannot
be interpreted in a given character set (see Bug #20238729).
As a consequence, the driver may fail to insert []byte data into
BLOB columns when interpolateParams is true.

This commit adds "_binary" encoding prefix when interpolating []byte data
to avoid that warning.

http://dev.mysql.com/doc/refman/5.7/en/charset-literal.html
@ymmt2005
Copy link
Contributor Author

@arnehormann @julienschmidt
Could you please take a look?

@arnehormann
Copy link
Member

@ymmt2005 thank you for the PR; I was unsure if this is supported in 4.1 - apparently it is (page 654).

Thanks also to @methane!

LGTM

Congrats for your first merged PR!

arnehormann added a commit that referenced this pull request Nov 12, 2015
Add _binary prefix when interpolating []byte data.
@arnehormann arnehormann merged commit f368b3b into go-sql-driver:master Nov 12, 2015
methane added a commit to methane/PyMySQL that referenced this pull request Jan 8, 2016
@wooparadog
Copy link

Hi, if I'm using an older version of mysql, can this change introduce compatibility issues?

We've encountered a problems very likely related to this, but I'm not entirely sure. Could you provide more infos regarding compatibility with older mysql please?

@ymmt2005
Copy link
Contributor Author

From the old reference, it seems that MySQL 4.1 supports _binary prefix.

Run the following commands in your shell to see if your MySQL supports _binary:

printf 'SELECT _binary "\x80\xb0\xa8";' | mysql --show-warnings -u root -p

nicolestandifer3 added a commit to nicolestandifer3/MySQL-test-repos that referenced this pull request Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants