1
2#
3# Tests for "LOAD XML" - a contributed patch from Erik Wetterberg.
4#
5
6# Running the $MYSQL_DUMP tool against an embedded server does not work.
7--source include/not_embedded.inc
8
9--disable_warnings
10drop table if exists t1, t2;
11--enable_warnings
12
13create table t1 (a int, b varchar(64));
14
15
16--echo -- Load a static XML file
17load xml infile '../../std_data/loadxml.dat' into table t1
18rows identified by '<row>';
19select * from t1 order by a;
20delete from t1;
21
22
23--echo -- Load a static XML file with 'IGNORE num ROWS'
24load xml infile '../../std_data/loadxml.dat' into table t1
25rows identified by '<row>' ignore 4 rows;
26select * from t1 order by a;
27
28
29--echo -- Check 'mysqldump --xml' + 'LOAD XML' round trip
30--exec $MYSQL_DUMP --xml test t1 > "$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml" 2>&1
31delete from t1;
32--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
33--eval load xml infile '$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml' into table t1 rows identified by '<row>';
34select * from t1 order by a;
35
36--echo --Check that default row tag is '<row>
37delete from t1;
38--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
39--eval load xml infile '$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml' into table t1;
40select * from t1 order by a;
41
42--echo -- Check that 'xml' is not a keyword
43select 1 as xml;
44
45
46#
47# Bug #42520    killing load .. infile Assertion failed: ! is_set(), file .\sql_error.cc, line 8
48#
49
50--disable_query_log
51delete from t1;
52insert into t1 values (1, '12345678900987654321'), (2, 'asdfghjkl;asdfghjkl;');
53insert into t1 select * from t1;
54insert into t1 select * from t1;
55insert into t1 select * from t1;
56insert into t1 select * from t1;
57insert into t1 select * from t1;
58insert into t1 select * from t1;
59insert into t1 select * from t1;
60insert into t1 select * from t1;
61insert into t1 select * from t1;
62insert into t1 select * from t1;
63insert into t1 select * from t1;
64insert into t1 select * from t1;
65insert into t1 select * from t1;
66--exec $MYSQL_DUMP --xml test t1 > "$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml" 2>&1
67--enable_query_log
68
69connect (addconroot, localhost, root,,);
70connection addconroot;
71create table t2(fl text);
72--let $PSEUDO_THREAD_ID=`select @@pseudo_thread_id    `
73
74--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
75--send_eval LOAD XML LOCAL INFILE "$MYSQLTEST_VARDIR/tmp/loadxml-dump.xml"  INTO TABLE t2 ROWS IDENTIFIED BY '<person>';
76
77sleep 3;
78
79
80connection default;
81
82--disable_query_log
83--eval kill $PSEUDO_THREAD_ID
84connection addconroot;
85# Read response from connection to avoid packets out-of-order when disconnecting
86# Note, that connection can already be dead due to previously issued kill
87--error 0,2013
88--reap
89disconnect addconroot;
90connection default;
91--enable_query_log
92#
93# Clean up
94#
95remove_file $MYSQLTEST_VARDIR/tmp/loadxml-dump.xml;
96drop table t1;
97drop table t2;
98
99#
100# Bug #36750    LOAD XML doesn't understand new line (feed) characters in multi line text fields
101#
102
103create table t1 (
104  id int(11) not null,
105  text text,
106  primary key (id)
107) default charset=latin1;
108load xml infile '../../std_data/loadxml2.dat' into table t1;
109select * from t1;
110drop table t1;
111
112--echo #
113--echo # Bug#51571 load xml infile causes server crash
114--echo #
115CREATE TABLE t1 (a text, b text);
116LOAD XML INFILE '../../std_data/loadxml.dat' INTO TABLE t1
117ROWS IDENTIFIED BY '<row>' (a,@b) SET b=concat('!',@b);
118SELECT * FROM t1 ORDER BY a;
119DROP TABLE t1;
120
121
122--echo #
123--echo # Bug#16171518 LOAD XML DOES NOT HANDLE EMPTY ELEMENTS
124--echo #
125CREATE TABLE t1 (col1 VARCHAR(3), col2 VARCHAR(3), col3 VARCHAR(3), col4 VARCHAR(4));
126LOAD XML INFILE '../../std_data/bug16171518_1.dat' INTO TABLE t1;
127SELECT * FROM t1 ORDER BY col1, col2, col3, col4;
128DROP TABLE t1;
129
130CREATE TABLE t1 (col1 VARCHAR(3), col2 VARCHAR(3), col3 INTEGER);
131LOAD XML INFILE '../../std_data/bug16171518_2.dat' INTO TABLE t1;
132SELECT * FROM t1 ORDER BY col1, col2, col3;
133DROP TABLE t1;
134