From 934e845e5996d0b9dabc8a59f7e5c16358361f93 Mon Sep 17 00:00:00 2001 From: ymmt2005 Date: Tue, 10 Nov 2015 08:59:32 +0900 Subject: [PATCH] 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 --- AUTHORS | 1 + connection.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 6fc4c6f7b..d4b321788 100644 --- a/AUTHORS +++ b/AUTHORS @@ -20,6 +20,7 @@ Frederick Mayle Gustavo Kristic Hanno Braun Henri Yandell +Hirotaka Yamamoto INADA Naoki James Harr Jian Zhen diff --git a/connection.go b/connection.go index caaae013f..72ed09d69 100644 --- a/connection.go +++ b/connection.go @@ -253,7 +253,7 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin if v == nil { buf = append(buf, "NULL"...) } else { - buf = append(buf, '\'') + buf = append(buf, "_binary'"...) if mc.status&statusNoBackslashEscapes == 0 { buf = escapeBytesBackslash(buf, v) } else {