@@ -165,27 +165,6 @@ func (mc *mysqlConn) Prepare(query string) (driver.Stmt, error) {
165
165
return stmt , err
166
166
}
167
167
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
-
189
168
// estimateParamLength calculates upper bound of string length from types.
190
169
func estimateParamLength (args []driver.Value ) (int , bool ) {
191
170
l := 0
@@ -296,10 +275,22 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
296
275
if v == nil {
297
276
buf = append (buf , "NULL" ... )
298
277
} 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 , '\'' )
300
285
}
301
286
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 , '\'' )
303
294
default :
304
295
return "" , driver .ErrSkip
305
296
}
0 commit comments