@@ -309,23 +309,29 @@ static zend_string* mysql_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquo
309309{
310310	pdo_mysql_db_handle  * H  =  (pdo_mysql_db_handle  * )dbh -> driver_data ;
311311	bool  use_national_character_set  =  0 ;
312+ 	bool  use_binary  =  0 ;
312313	size_t  quotedlen ;
313314
314- 	if  (H -> assume_national_character_set_strings ) {
315- 		use_national_character_set  =  1 ;
316- 	}
317- 	if  ((paramtype  &  PDO_PARAM_STR_NATL ) ==  PDO_PARAM_STR_NATL ) {
318- 		use_national_character_set  =  1 ;
319- 	}
320- 	if  ((paramtype  &  PDO_PARAM_STR_CHAR ) ==  PDO_PARAM_STR_CHAR ) {
321- 		use_national_character_set  =  0 ;
315+ 	if  ((paramtype  &  PDO_PARAM_LOB ) ==  PDO_PARAM_LOB ) {
316+ 		use_binary  =  1 ;
317+ 	} else  {
318+ 		if  (H -> assume_national_character_set_strings ) {
319+ 			use_national_character_set  =  1 ;
320+ 		}
321+ 		if  ((paramtype  &  PDO_PARAM_STR_NATL ) ==  PDO_PARAM_STR_NATL ) {
322+ 			use_national_character_set  =  1 ;
323+ 		}
324+ 		if  ((paramtype  &  PDO_PARAM_STR_CHAR ) ==  PDO_PARAM_STR_CHAR ) {
325+ 			use_national_character_set  =  0 ;
326+ 		}
322327	}
323328
324329	PDO_DBG_ENTER ("mysql_handle_quoter" );
325330	PDO_DBG_INF_FMT ("dbh=%p" , dbh );
326331	PDO_DBG_INF_FMT ("unquoted=%.*s" , (int )ZSTR_LEN (unquoted ), ZSTR_VAL (unquoted ));
327332
328- 	zend_string  * quoted_str  =  zend_string_safe_alloc (2 , ZSTR_LEN (unquoted ), 3  +  (use_national_character_set  ? 1  : 0 ), false);
333+ 	zend_string  * quoted_str  =  zend_string_safe_alloc (2 , ZSTR_LEN (unquoted ),
334+ 		3  +  (use_national_character_set  ? 1  : 0 ) +  (use_binary  ? 7  : 0 ), false);
329335	char  * quoted  =  ZSTR_VAL (quoted_str );
330336
331337	if  (use_national_character_set ) {
@@ -334,6 +340,11 @@ static zend_string* mysql_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquo
334340		quoted [1 ] =  '\'' ;
335341
336342		++ quotedlen ; /* N prefix */ 
343+ 	} else  if  (use_binary ) {
344+ 		quotedlen  =  mysql_real_escape_string_quote (H -> server , quoted  +  8 , ZSTR_VAL (unquoted ), ZSTR_LEN (unquoted ), '\'' );
345+ 		memcpy (quoted , "_binary'" , 8 );
346+ 
347+ 		quotedlen  +=  7 ; /* _binary prefix */ 
337348	} else  {
338349		quotedlen  =  mysql_real_escape_string_quote (H -> server , quoted  +  1 , ZSTR_VAL (unquoted ), ZSTR_LEN (unquoted ), '\'' );
339350		quoted [0 ] =  '\'' ;
0 commit comments