summaryrefslogtreecommitdiff
path: root/sql/sql_string.h
diff options
context:
space:
mode:
authorGleb Shchepa <gshchepa@mysql.com>2009-07-31 22:14:52 +0500
committerGleb Shchepa <gshchepa@mysql.com>2009-07-31 22:14:52 +0500
commit4e95179af9c2f2589093ea9f94472d8d047892c7 (patch)
treed3022917ee0647bbcdfe1a41e7b73aa60a6ebd7f /sql/sql_string.h
parent7d8b967a86f077754ad74cee6aff0543984beba4 (diff)
downloadmariadb-git-4e95179af9c2f2589093ea9f94472d8d047892c7.tar.gz
Bug# 30946: mysqldump silently ignores --default-character-set
when used with --tab 1) New syntax: added CHARACTER SET clause to the SELECT ... INTO OUTFILE (to complement the same clause in LOAD DATA INFILE). mysqldump is updated to use this in --tab mode. 2) ESCAPED BY/ENCLOSED BY field parameters are documented as accepting CHAR argument, however SELECT .. INTO OUTFILE silently ignored rests of multisymbol arguments. For the symmetrical behavior with LOAD DATA INFILE the server has been modified to fail with the same error: ERROR 42000: Field separator argument is not what is expected; check the manual 3) Current LOAD DATA INFILE recognizes field/line separators "as is" without converting from client charset to data file charset. So, it is supposed, that input file of LOAD DATA INFILE consists of data in one charset and separators in other charset. For the compatibility with that [buggy] behaviour SELECT INTO OUTFILE implementation has been saved "as is" too, but the new warning message has been added: Non-ASCII separator arguments are not fully supported This message warns on field/line separators that contain non-ASCII symbols. client/mysqldump.c: mysqldump has been updated to call SELECT ... INTO OUTFILE statement with a charset from the --default-charset command line parameter. mysql-test/r/mysqldump.result: Added test case for bug #30946. mysql-test/r/outfile_loaddata.result: Added test case for bug #30946. mysql-test/t/mysqldump.test: Added test case for bug #30946. mysql-test/t/outfile_loaddata.test: Added test case for bug #30946. sql/field.cc: String conversion code has been moved from check_string_copy_error() to convert_to_printable() for reuse. sql/share/errmsg.txt: New WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED message has been added. sql/sql_class.cc: The select_export::prepare() method has been modified to: 1) raise the ER_WRONG_FIELD_TERMINATORS error on multisymbol ENCLOSED BY/ESCAPED BY field arguments like LOAD DATA INFILE; 2) warn with a new WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED message on non-ASCII field or line separators. The select_export::send_data() merhod has been modified to convert item data to output charset (see new SELECT INTO OUTFILE syntax). By default the BINARY charset is used for backward compatibility. sql/sql_class.h: The select_export::write_cs field added to keep output charset. sql/sql_load.cc: mysql_load has been modified to warn on non-ASCII field or line separators with a new WARN_NON_ASCII_SEPARATOR_NOT_IMPLEMENTED message. sql/sql_string.cc: New global function has been added: convert_to_printable() (common code has been moved from check_string_copy_error()). sql/sql_string.h: New String::is_ascii() method and new global convert_to_printable() function have been added. sql/sql_yacc.yy: New syntax: added CHARACTER SET clause to the SELECT ... INTO OUTFILE (to complement the same clause in LOAD DATA INFILE). By default the BINARY charset is used for backward compatibility.
Diffstat (limited to 'sql/sql_string.h')
-rw-r--r--sql/sql_string.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/sql_string.h b/sql/sql_string.h
index be11fea70dc..d62908e5d66 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -40,6 +40,9 @@ uint32 well_formed_copy_nchars(CHARSET_INFO *to_cs,
size_t my_copy_with_hex_escaping(CHARSET_INFO *cs,
char *dst, size_t dstlen,
const char *src, size_t srclen);
+uint convert_to_printable(char *to, size_t to_len,
+ const char *from, size_t from_len,
+ CHARSET_INFO *from_cs, size_t nbytes= 0);
class String
{
@@ -366,6 +369,19 @@ public:
{
return (s->alloced && Ptr >= s->Ptr && Ptr < s->Ptr + s->str_length);
}
+ bool is_ascii() const
+ {
+ if (length() == 0)
+ return TRUE;
+ if (charset()->mbminlen > 1)
+ return FALSE;
+ for (const char *c= ptr(), *end= c + length(); c < end; c++)
+ {
+ if (!my_isascii(*c))
+ return FALSE;
+ }
+ return TRUE;
+ }
};
static inline bool check_if_only_end_space(CHARSET_INFO *cs, char *str,