Skip to content

Commit 934e845

Browse files
committed
Add _binary prefix when interpolating []byte data.
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
1 parent 69e3ed7 commit 934e845

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Frederick Mayle <frederickmayle at gmail.com>
2020
Gustavo Kristic <gkristic at gmail.com>
2121
Hanno Braun <mail at hannobraun.com>
2222
Henri Yandell <flamefew at gmail.com>
23+
Hirotaka Yamamoto <ymmt2005 at gmail.com>
2324
INADA Naoki <songofacandy at gmail.com>
2425
James Harr <james.harr at gmail.com>
2526
Jian Zhen <zhenjl at gmail.com>

connection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
253253
if v == nil {
254254
buf = append(buf, "NULL"...)
255255
} else {
256-
buf = append(buf, '\'')
256+
buf = append(buf, "_binary'"...)
257257
if mc.status&statusNoBackslashEscapes == 0 {
258258
buf = escapeBytesBackslash(buf, v)
259259
} else {

0 commit comments

Comments
 (0)