mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
4e95179af9
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.
256 lines
9.2 KiB
Text
256 lines
9.2 KiB
Text
--disable_warnings
|
|
DROP TABLE IF EXISTS t1, t2;
|
|
--enable_warnings
|
|
|
|
--echo #
|
|
--echo # Bug#31663 FIELDS TERMINATED BY special character
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (i1 int, i2 int, c1 VARCHAR(256), c2 VARCHAR(256));
|
|
INSERT INTO t1 VALUES (101, 202, '-r-', '=raker=');
|
|
|
|
--let $fields=*
|
|
--let $clauses=FIELDS TERMINATED BY 'raker'
|
|
--echo # $clauses, warning:
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt')
|
|
--eval CREATE TABLE t2 SELECT $fields FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses
|
|
--eval SELECT $fields FROM t2
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
|
|
DROP TABLE t2;
|
|
|
|
--let $fields=i1, i2
|
|
--let $clauses=FIELDS TERMINATED BY 'r'
|
|
--echo # Only numeric fields, $clauses, no warnings:
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt')
|
|
--eval CREATE TABLE t2 SELECT $fields FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses
|
|
--eval SELECT $fields FROM t2
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
|
|
DROP TABLE t2;
|
|
|
|
--let $fields=*
|
|
--let $clauses=FIELDS TERMINATED BY '0'
|
|
--echo # $clauses, warning:
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt')
|
|
--eval CREATE TABLE t2 SELECT $fields FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses
|
|
--eval SELECT $fields FROM t2
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
|
|
DROP TABLE t2;
|
|
|
|
--let $fields=*
|
|
--let $clauses=FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0'
|
|
--echo # $clauses, warning:
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt')
|
|
--eval CREATE TABLE t2 SELECT $fields FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses
|
|
--eval SELECT $fields FROM t2
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
|
|
DROP TABLE t2;
|
|
|
|
--let $fields=c1, c2
|
|
--let $clauses=FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY '0'
|
|
--echo # Only string fields, $clauses, no warnings:
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt')
|
|
--eval CREATE TABLE t2 SELECT $fields FROM t1
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' INTO TABLE t2 $clauses
|
|
--eval SELECT $fields FROM t2
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/bug31663.txt
|
|
DROP TABLE t2;
|
|
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # Bug#32533: SELECT INTO OUTFILE never escapes multibyte character
|
|
--echo #
|
|
|
|
CREATE TABLE t1 (c1 VARCHAR(256));
|
|
INSERT INTO t1 VALUES (0xC3);
|
|
SELECT HEX(c1) FROM t1;
|
|
|
|
--let $file=$MYSQLTEST_VARDIR/tmp/bug32533.txt
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * INTO OUTFILE '$file' FIELDS ENCLOSED BY 0xC3 FROM t1
|
|
TRUNCATE t1;
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT HEX(LOAD_FILE('$file'))
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t1 FIELDS ENCLOSED BY 0xC3
|
|
SELECT HEX(c1) FROM t1;
|
|
|
|
--remove_file $file
|
|
DROP TABLE t1;
|
|
|
|
--echo # End of 5.0 tests.
|
|
|
|
###########################################################################
|
|
|
|
--echo #
|
|
--echo # Bug #30946: mysqldump silently ignores --default-character-set
|
|
--echo # when used with --tab
|
|
--echo #
|
|
--echo # Also see mysqldump.test
|
|
--echo #
|
|
|
|
SET NAMES utf8;
|
|
CREATE TABLE t1 (a INT, b CHAR(10) CHARSET koi8r, c CHAR(10) CHARSET latin1);
|
|
CREATE TABLE t2 LIKE t1;
|
|
INSERT INTO t1 VALUES (1, 'ABC-АБВ', 'DEF-ÂÃÄ'), (2, NULL, NULL);
|
|
|
|
--let $file=$MYSQLTEST_VARDIR/tmp/t1.txt
|
|
|
|
|
|
--echo # Error on multi-character ENCLOSED/ESCAPED BY
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--error 1083
|
|
--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ENCLOSED BY '12345'
|
|
--remove_file $file
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--error 1083
|
|
--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ESCAPED BY '12345'
|
|
--remove_file $file
|
|
|
|
|
|
--echo # "Not implemented" warning on multibyte ENCLOSED/ESCAPED BY character,
|
|
--echo # LOAD DATA rises error or has unpredictable result -- to be fixed later
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ENCLOSED BY 'ъ'
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--error 1083 # backward compatibility
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS ENCLOSED BY 'ъ'
|
|
--remove_file $file
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ESCAPED BY 'ъ'
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--error 1083 # backward compatibility
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS ESCAPED BY 'ъ'
|
|
--remove_file $file
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS TERMINATED BY 'ъ'
|
|
--echo ##################################################
|
|
--cat_file $file
|
|
--echo ##################################################
|
|
TRUNCATE t2;
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS TERMINATED BY 'ъ'
|
|
--remove_file $file
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * FROM t1 INTO OUTFILE '$file' LINES STARTING BY 'ъ'
|
|
--echo ##################################################
|
|
--cat_file $file
|
|
--echo ##################################################
|
|
TRUNCATE t2;
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary LINES STARTING BY 'ъ'
|
|
--remove_file $file
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * FROM t1 INTO OUTFILE '$file' LINES TERMINATED BY 'ъ'
|
|
--echo ##################################################
|
|
--cat_file $file
|
|
--echo ##################################################
|
|
TRUNCATE t2;
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary LINES TERMINATED BY 'ъ'
|
|
--remove_file $file
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
|
|
|
|
--echo # Default (binary) charset:
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * INTO OUTFILE '$file' FROM t1
|
|
--echo ##################################################
|
|
--cat_file $file
|
|
--echo ##################################################
|
|
TRUNCATE t2;
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary
|
|
--remove_file $file
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
|
|
|
|
|
|
--echo # latin1 charset (INTO OUTFILE warning is expected):
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * INTO OUTFILE '$file' CHARACTER SET latin1 FROM t1
|
|
--echo ##################################################
|
|
--cat_file $file
|
|
--echo ##################################################
|
|
TRUNCATE t2;
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET latin1
|
|
--remove_file $file
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
|
|
|
|
|
|
--echo # KOI8-R charset (INTO OUTFILE warning is expected):
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * INTO OUTFILE '$file' CHARACTER SET koi8r FROM t1
|
|
--echo ##################################################
|
|
--cat_file $file
|
|
--echo ##################################################
|
|
TRUNCATE t2;
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET koi8r
|
|
--remove_file $file
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
|
|
|
|
|
|
--echo # UTF-8 charset:
|
|
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval SELECT * INTO OUTFILE '$file' CHARACTER SET utf8 FROM t1
|
|
--echo ##################################################
|
|
--cat_file $file
|
|
--echo ##################################################
|
|
TRUNCATE t2;
|
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
--eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET utf8
|
|
--remove_file $file
|
|
SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c;
|
|
|
|
|
|
SET NAMES default;
|
|
|
|
DROP TABLE t1, t2;
|
|
|
|
###########################################################################
|
|
--echo # End of 5.1 tests.
|