diff options
author | unknown <serg@serg.mylan> | 2005-03-17 12:27:45 +0100 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2005-03-17 12:27:45 +0100 |
commit | b6e29d09b0c22037f7c1d54c55c76045a01b03ac (patch) | |
tree | 6647c711e18c396c34022d37fca3cc74234620f2 /sql/field.cc | |
parent | 278e691ba885480cb1ab0879d1464ecbd8d3803f (diff) | |
download | mariadb-git-b6e29d09b0c22037f7c1d54c55c76045a01b03ac.tar.gz |
Field::quote_data():
don't call escape_string_for_mysql() unnecesary
don't overwrite local buffer
escape_string_for_mysql():
take a length of the destination buffer as an argument
include/my_sys.h:
prototype changed
libmysql/libmysql.c:
prototype changed
mysys/charset.c:
escape_string_for_mysql():
take a length of the destination buffer as an argument
sql/field.cc:
Field::quote_data():
don't call escape_string_for_mysql() unnecesary
don't overwrite local buffer
sql/item.cc:
prototype changed
sql/sql_prepare.cc:
prototype changed
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/sql/field.cc b/sql/field.cc index b6dd00d62a7..ae9b76e2dc4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -752,25 +752,22 @@ bool Field::quote_data(String *unquoted_string) { char escaped_string[IO_SIZE]; char *unquoted_string_buffer= (char *)(unquoted_string->ptr()); - uint need_quotes; DBUG_ENTER("Field::quote_data"); - // this is the same call that mysql_real_escape_string() calls - escape_string_for_mysql(&my_charset_bin, (char *)escaped_string, - unquoted_string->ptr(), unquoted_string->length()); - - need_quotes= needs_quotes(); - - if (need_quotes == 0) + if (!needs_quotes()) DBUG_RETURN(0); + // this is the same call that mysql_real_escape_string() calls + if (escape_string_for_mysql(&my_charset_bin, (char *)escaped_string, + sizeof(escaped_string), unquoted_string->ptr(), + unquoted_string->length()) == (ulong)~0) + DBUG_RETURN(1); + // reset string, then re-append with quotes and escaped values unquoted_string->length(0); - if (unquoted_string->append('\'')) - DBUG_RETURN(1); - if (unquoted_string->append((char *)escaped_string)) - DBUG_RETURN(1); - if (unquoted_string->append('\'')) + if (unquoted_string->append('\'') || + unquoted_string->append((char *)escaped_string) || + unquoted_string->append('\'')) DBUG_RETURN(1); DBUG_RETURN(0); } |