• Gleb Shchepa's avatar
    Bug# 30946: mysqldump silently ignores --default-character-set · 4e95179a
    Gleb Shchepa authored
                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.
    4e95179a
sql_string.h 11.6 KB