@@ -309,26 +309,37 @@ static zend_string* mysql_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquo
309
309
{
310
310
pdo_mysql_db_handle * H = (pdo_mysql_db_handle * )dbh -> driver_data ;
311
311
bool use_national_character_set = 0 ;
312
+ bool use_binary = 0 ;
312
313
char * quoted ;
313
314
size_t quotedlen ;
314
315
zend_string * quoted_str ;
315
316
316
- if (H -> assume_national_character_set_strings ) {
317
- use_national_character_set = 1 ;
318
- }
319
- if ((paramtype & PDO_PARAM_STR_NATL ) == PDO_PARAM_STR_NATL ) {
320
- use_national_character_set = 1 ;
321
- }
322
- if ((paramtype & PDO_PARAM_STR_CHAR ) == PDO_PARAM_STR_CHAR ) {
323
- use_national_character_set = 0 ;
317
+ if ((paramtype & PDO_PARAM_LOB ) == PDO_PARAM_LOB ) {
318
+ use_binary = 1 ;
319
+ } else {
320
+ if (H -> assume_national_character_set_strings ) {
321
+ use_national_character_set = 1 ;
322
+ }
323
+ if ((paramtype & PDO_PARAM_STR_NATL ) == PDO_PARAM_STR_NATL ) {
324
+ use_national_character_set = 1 ;
325
+ }
326
+ if ((paramtype & PDO_PARAM_STR_CHAR ) == PDO_PARAM_STR_CHAR ) {
327
+ use_national_character_set = 0 ;
328
+ }
324
329
}
325
330
326
331
PDO_DBG_ENTER ("mysql_handle_quoter" );
327
332
PDO_DBG_INF_FMT ("dbh=%p" , dbh );
328
333
PDO_DBG_INF_FMT ("unquoted=%.*s" , (int )ZSTR_LEN (unquoted ), ZSTR_VAL (unquoted ));
329
- quoted = safe_emalloc (2 , ZSTR_LEN (unquoted ), 3 + (use_national_character_set ? 1 : 0 ));
334
+ quoted = safe_emalloc (2 , ZSTR_LEN (unquoted ), 3 + (use_national_character_set ? 1 : 0 ) +
335
+ (use_binary ? 7 : 0 ));
336
+
337
+ if (use_binary ) {
338
+ quotedlen = mysql_real_escape_string_quote (H -> server , quoted + 8 , ZSTR_VAL (unquoted ), ZSTR_LEN (unquoted ), '\'' );
339
+ memcpy (quoted , "_binary'" , 8 );
330
340
331
- if (use_national_character_set ) {
341
+ quotedlen += 7 ; /* _binary prefix */
342
+ } else if (use_national_character_set ) {
332
343
quotedlen = mysql_real_escape_string_quote (H -> server , quoted + 2 , ZSTR_VAL (unquoted ), ZSTR_LEN (unquoted ), '\'' );
333
344
quoted [0 ] = 'N' ;
334
345
quoted [1 ] = '\'' ;
0 commit comments