@@ -627,6 +627,25 @@ static char **fill_out_embedded_options(char *options,
627
627
return options_list ;
628
628
}
629
629
630
+ #if MYSQL_VERSION_ID < 50001
631
+ /* MySQL client prior to version 5.0.1 does not implement mysql_real_escape_string() for SERVER_STATUS_NO_BACKSLASH_ESCAPES */
632
+ static unsigned long string_escape_quotes (char * to , const char * from , unsigned long len )
633
+ {
634
+ const char * to_start = to ;
635
+ const char * end = from + len ;
636
+
637
+ while (from < end )
638
+ {
639
+ if (* from == '\'' )
640
+ * to ++ = '\'' ;
641
+ * to ++ = * from ++ ;
642
+ }
643
+
644
+ * to = '\0' ;
645
+ return to - to_start ;
646
+ }
647
+ #endif
648
+
630
649
/*
631
650
constructs an SQL statement previously prepared with
632
651
actual values replacing placeholders
@@ -838,9 +857,8 @@ static char *parse_params(
838
857
#if MYSQL_VERSION_ID < 50001
839
858
if (sock -> server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES )
840
859
{
841
- * ptr ++ = 'X' ;
842
860
* ptr ++ = '\'' ;
843
- ptr += mysql_hex_string (ptr , ph -> value , ph -> len );
861
+ ptr += string_escape_quotes (ptr , ph -> value , ph -> len );
844
862
* ptr ++ = '\'' ;
845
863
}
846
864
else
@@ -6411,9 +6429,8 @@ SV* mariadb_db_quote(SV *dbh, SV *str, SV *type)
6411
6429
#if MYSQL_VERSION_ID < 50001
6412
6430
if (imp_dbh -> pmysql -> server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES )
6413
6431
{
6414
- * sptr ++ = 'X' ;
6415
6432
* sptr ++ = '\'' ;
6416
- sptr += mysql_hex_string (sptr , ptr , len );
6433
+ sptr += string_escape_quotes (sptr , ptr , len );
6417
6434
* sptr ++ = '\'' ;
6418
6435
}
6419
6436
else
0 commit comments