Commit d383a168 authored by Alexander Barkov's avatar Alexander Barkov

Adding a test for "mysqldump -Tdir dbname tabname" followed by

"LOAD DATA INFILE" with various command line and CHARACTER SET
clause options.
parent 52018344
......@@ -8,6 +8,9 @@ t1 CREATE TABLE `t1` (
`a` text,
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=gbk
#
# Dump using SELECT INTO OUTFILE
#
Locale: zh_CN.gbk
OUTFILE: --default-character-set=auto
......@@ -575,5 +578,197 @@ INFILE: --default-character-set=utf8 CHARACTER SET utf8
file E9A0AB-3F5C5C
a EE5C
b 3F5C BAD-BLOB
#
# Dump using mysqldump -Tdir
#
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=auto
file EE5C-EE5C5C
a EE5C
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=auto CHARACTER SET gbk
file EE5C-EE5C5C
a EE5C
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=auto CHARACTER SET utf8
file EE5C-EE5C5C
a 3F5C BAD-TEXT
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=gbk
file EE5C-EE5C5C
a EE5C
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=gbk CHARACTER SET gbk
file EE5C-EE5C5C
a EE5C
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=gbk CHARACTER SET utf8
file EE5C-EE5C5C
a 3F5C BAD-TEXT
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=utf8
file EE5C-EE5C5C
a EE5C
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=utf8 CHARACTER SET gbk
file EE5C-EE5C5C
a EE5C
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=binary
INFILE: --default-character-set=utf8 CHARACTER SET utf8
file EE5C-EE5C5C
a 3F5C BAD-TEXT
b EE5C0A BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=auto
file EE5C-EE5C
a EE5C
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=auto CHARACTER SET gbk
file EE5C-EE5C
a EE5C
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=auto CHARACTER SET utf8
file EE5C-EE5C
a 3F5C BAD-TEXT
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=gbk
file EE5C-EE5C
a EE5C
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=gbk CHARACTER SET gbk
file EE5C-EE5C
a EE5C
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=gbk CHARACTER SET utf8
file EE5C-EE5C
a 3F5C BAD-TEXT
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=utf8
file EE5C-EE5C
a EE5C
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=utf8 CHARACTER SET gbk
file EE5C-EE5C
a EE5C
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=gbk
INFILE: --default-character-set=utf8 CHARACTER SET utf8
file EE5C-EE5C
a 3F5C BAD-TEXT
b EE5C
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=auto
file E9A0AB-3F5C5C
a E9A03F BAD-TEXT
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=auto CHARACTER SET gbk
file E9A0AB-3F5C5C
a E9A03F BAD-TEXT
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=auto CHARACTER SET utf8
file E9A0AB-3F5C5C
a EE5C
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=gbk
file E9A0AB-3F5C5C
a E9A03F BAD-TEXT
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=gbk CHARACTER SET gbk
file E9A0AB-3F5C5C
a E9A03F BAD-TEXT
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=gbk CHARACTER SET utf8
file E9A0AB-3F5C5C
a EE5C
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=utf8
file E9A0AB-3F5C5C
a E9A03F BAD-TEXT
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=utf8 CHARACTER SET gbk
file E9A0AB-3F5C5C
a E9A03F BAD-TEXT
b 3F5C BAD-BLOB
Locale: zh_CN.gbk
OUTFILE: --default-character-set=utf8
INFILE: --default-character-set=utf8 CHARACTER SET utf8
file E9A0AB-3F5C5C
a EE5C
b 3F5C BAD-BLOB
DROP DATABASE gbk;
USE test;
......@@ -26,10 +26,13 @@ USE gbk;
CREATE TABLE t1 (a TEXT, b BLOB);
SHOW CREATE TABLE t1;
--echo #
--echo # Dump using SELECT INTO OUTFILE
--echo #
--perl
my $dir= $ENV{'MYSQL_TMP_DIR'};
open (my $FILE, '>', "$dir/tmp.inc") or die "open(): $!";
open (my $FILE, '>', "$dir/tmpgbk.inc") or die "open(): $!";
for $LOCALE ("zh_CN.gbk") {
for $DUMP_OPTIONS ("--default-character-set=auto", "--default-character-set=gbk","--default-character-set=utf8") {
for $DUMP_CHARSET_CLAUSE ("", "CHARACTER SET gbk", "CHARACTER SET utf8") {
......@@ -58,8 +61,49 @@ END
}}}}}
close $FILE
EOF
--source $MYSQL_TMP_DIR/tmp.inc
--remove_file $MYSQL_TMP_DIR/tmp.inc
--source $MYSQL_TMP_DIR/tmpgbk.inc
--remove_file $MYSQL_TMP_DIR/tmpgbk.inc
--echo #
--echo # Dump using mysqldump -Tdir
--echo #
--exec mkdir $MYSQLTEST_VARDIR/tmp/tmpgbk
--perl
my $dir= $ENV{'MYSQL_TMP_DIR'};
open (my $FILE, '>', "$dir/tmpgbk.inc") or die "open(): $!";
for $LOCALE ("zh_CN.gbk") {
for $DUMP_OPTIONS ("--default-character-set=binary","--default-character-set=gbk","--default-character-set=utf8") {
for $RESTORE_OPTIONS ("--default-character-set=auto", "--default-character-set=gbk","--default-character-set=utf8") {
for $RESTORE_CHARSET_CLAUSE ("", "CHARACTER SET gbk", "CHARACTER SET utf8") {
print $FILE <<END
--echo
--echo Locale: $LOCALE
--echo OUTFILE: $DUMP_OPTIONS
--echo INFILE: $RESTORE_OPTIONS $RESTORE_CHARSET_CLAUSE
--disable_query_log
INSERT INTO t1 VALUES (0xEE5C, 0xEE5C);
--exec LC_ALL=$LOCALE \$MYSQL_DUMP $DUMP_OPTIONS -Tvar/tmp/tmpgbk gbk t1
--vertical_results
TRUNCATE TABLE t1;
--eval SET \@file=REPLACE(TRIM(TRAILING 0x0A FROM LOAD_FILE('\$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.txt')),'\t','----');
SELECT REPLACE(HEX(\@file), '2D2D2D2D','-') AS file;
--exec LC_ALL=$LOCALE \$MYSQL $RESTORE_OPTIONS gbk -e "LOAD DATA INFILE '\$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.txt' INTO TABLE t1 $RESTORE_CHARSET_CLAUSE"
SELECT CONCAT(HEX(COALESCE(a,'')), IF(a<>0xEE5C,' BAD-TEXT','')) AS a,
CONCAT(HEX(COALESCE(b,'')), IF(b<>0xEE5C,' BAD-BLOB','')) AS b FROM t1;
TRUNCATE TABLE t1;
--horizontal_results
--enable_query_log
--remove_file \$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.txt
--remove_file \$MYSQLTEST_VARDIR/tmp/tmpgbk/t1.sql
END
}}}}
close $FILE
EOF
--source $MYSQL_TMP_DIR/tmpgbk.inc
--remove_file $MYSQL_TMP_DIR/tmpgbk.inc
--rmdir $MYSQLTEST_VARDIR/tmp/tmpgbk
DROP DATABASE gbk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment