diff options
author | unknown <jimw@rama.(none)> | 2006-07-12 16:33:29 -0700 |
---|---|---|
committer | unknown <jimw@rama.(none)> | 2006-07-12 16:33:29 -0700 |
commit | abbf7ad01461284d8c92fbc385caa4b37fa50765 (patch) | |
tree | 1660ddac7e38126c61edc217faba955e6171301c /sql/field.cc | |
parent | a7dddd3b67e70292c0813e80ad255f1dc2f3a867 (diff) | |
download | mariadb-git-abbf7ad01461284d8c92fbc385caa4b37fa50765.tar.gz |
Bug #17608: String literals lost during INSERT query on FEDERATED table
The Federated storage engine used Field methods that had arbitrary limits on
the amount of data they could process, which caused problems with data
over that limit (4K). By removing those Field methods and just using
features of the String class, we can avoid this problem.
mysql-test/r/federated.result:
Add new results
mysql-test/t/federated.test:
Add new regression test
sql/field.cc:
Remove unnecessary methods
sql/field.h:
Remove unnecessary methods
sql/ha_federated.cc:
Remove use of quote_data, use String::print() to get escaping of strings,
and don't bother with needs_quotes, just always quote values.
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/sql/field.cc b/sql/field.cc index 946351efe36..2cf4a2f83af 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1551,104 +1551,6 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table, } -/* - SYNOPSIS - Field::quote_data() - unquoted_string Pointer pointing to the value of a field - - DESCRIPTION - Simple method that passes the field type to the method "type_quote" - To get a true/false value as to whether the value in string1 needs - to be enclosed with quotes. This ensures that values in the final - sql statement to be passed to the remote server will be quoted properly - - RETURN_VALUE - void Immediately - if string doesn't need quote - void Upon prepending/appending quotes on each side of variable - -*/ - -bool Field::quote_data(String *unquoted_string) -{ - char escaped_string[IO_SIZE]; - DBUG_ENTER("Field::quote_data"); - - 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('\'') || - unquoted_string->append((char *)escaped_string) || - unquoted_string->append('\'')) - DBUG_RETURN(1); - DBUG_RETURN(0); -} - - -/* - Quote a field type if needed - - SYNOPSIS - Field::type_quote - - DESCRIPTION - Simple method to give true/false whether a field should be quoted. - Used when constructing INSERT and UPDATE queries to the remote server - see write_row and update_row - - RETURN VALUE - 0 if value is of type NOT needing quotes - 1 if value is of type needing quotes -*/ - -bool Field::needs_quotes(void) -{ - DBUG_ENTER("Field::type_quote"); - - switch (type()) { - //FIX this when kernel is fixed - case MYSQL_TYPE_VARCHAR : - case FIELD_TYPE_STRING : - case FIELD_TYPE_VAR_STRING : - case FIELD_TYPE_YEAR : - case FIELD_TYPE_NEWDATE : - case FIELD_TYPE_TIME : - case FIELD_TYPE_TIMESTAMP : - case FIELD_TYPE_DATE : - case FIELD_TYPE_DATETIME : - case FIELD_TYPE_TINY_BLOB : - case FIELD_TYPE_BLOB : - case FIELD_TYPE_MEDIUM_BLOB : - case FIELD_TYPE_LONG_BLOB : - case FIELD_TYPE_GEOMETRY : - case FIELD_TYPE_BIT: - DBUG_RETURN(1); - - case FIELD_TYPE_DECIMAL : - case FIELD_TYPE_TINY : - case FIELD_TYPE_SHORT : - case FIELD_TYPE_INT24 : - case FIELD_TYPE_LONG : - case FIELD_TYPE_FLOAT : - case FIELD_TYPE_DOUBLE : - case FIELD_TYPE_LONGLONG : - case FIELD_TYPE_NULL : - case FIELD_TYPE_SET : - case FIELD_TYPE_ENUM : - DBUG_RETURN(0); - default: - DBUG_RETURN(0); - } -} - - /**************************************************************************** Field_null, a field that always return NULL ****************************************************************************/ |