@@ -627,6 +627,25 @@ static char **fill_out_embedded_options(char *options,
627627 return options_list ;
628628}
629629
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+
630649/*
631650 constructs an SQL statement previously prepared with
632651 actual values replacing placeholders
@@ -838,9 +857,8 @@ static char *parse_params(
838857#if MYSQL_VERSION_ID < 50001
839858 if (sock -> server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES )
840859 {
841- * ptr ++ = 'X' ;
842860 * ptr ++ = '\'' ;
843- ptr += mysql_hex_string (ptr , ph -> value , ph -> len );
861+ ptr += string_escape_quotes (ptr , ph -> value , ph -> len );
844862 * ptr ++ = '\'' ;
845863 }
846864 else
@@ -6411,9 +6429,8 @@ SV* mariadb_db_quote(SV *dbh, SV *str, SV *type)
64116429#if MYSQL_VERSION_ID < 50001
64126430 if (imp_dbh -> pmysql -> server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES )
64136431 {
6414- * sptr ++ = 'X' ;
64156432 * sptr ++ = '\'' ;
6416- sptr += mysql_hex_string (sptr , ptr , len );
6433+ sptr += string_escape_quotes (sptr , ptr , len );
64176434 * sptr ++ = '\'' ;
64186435 }
64196436 else
0 commit comments