@@ -165,27 +165,6 @@ func (mc *mysqlConn) Prepare(query string) (driver.Stmt, error) {
165165 return stmt , err
166166}
167167
168- // https://github.com/mysql/mysql-server/blob/mysql-5.7.5/libmysql/libmysql.c#L1150-L1156
169- func (mc * mysqlConn ) escapeBytes (buf , v []byte ) []byte {
170- buf = append (buf , '\'' )
171- if mc .status & statusNoBackslashEscapes == 0 {
172- buf = escapeBytesBackslash (buf , v )
173- } else {
174- buf = escapeBytesQuotes (buf , v )
175- }
176- return append (buf , '\'' )
177- }
178-
179- func (mc * mysqlConn ) escapeString (buf []byte , v string ) []byte {
180- buf = append (buf , '\'' )
181- if mc .status & statusNoBackslashEscapes == 0 {
182- buf = escapeStringBackslash (buf , v )
183- } else {
184- buf = escapeStringQuotes (buf , v )
185- }
186- return append (buf , '\'' )
187- }
188-
189168// estimateParamLength calculates upper bound of string length from types.
190169func estimateParamLength (args []driver.Value ) (int , bool ) {
191170 l := 0
@@ -296,10 +275,22 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
296275 if v == nil {
297276 buf = append (buf , "NULL" ... )
298277 } else {
299- buf = mc .escapeBytes (buf , v )
278+ buf = append (buf , '\'' )
279+ if mc .status & statusNoBackslashEscapes == 0 {
280+ buf = escapeBytesBackslash (buf , v )
281+ } else {
282+ buf = escapeBytesQuotes (buf , v )
283+ }
284+ buf = append (buf , '\'' )
300285 }
301286 case string :
302- buf = mc .escapeString (buf , v )
287+ buf = append (buf , '\'' )
288+ if mc .status & statusNoBackslashEscapes == 0 {
289+ buf = escapeStringBackslash (buf , v )
290+ } else {
291+ buf = escapeStringQuotes (buf , v )
292+ }
293+ buf = append (buf , '\'' )
303294 default :
304295 return "" , driver .ErrSkip
305296 }
0 commit comments