1--source have_libxml2.inc
2
3--echo #
4--echo # Testing changing table type (not in-place)
5--echo #
6CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV HEADER=1 QUOTED=1;
7INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
8SELECT * FROM t1;
9
10--echo # This would fail if the top node name is not specified.
11--echo # This is because the XML top node name defaults to the table name.
12--echo # Sure enough the temporary table name begins with '#' and is rejected by XML.
13--echo # Therefore the top node name must be specified (along with the row nodes name).
14ALTER TABLE t1 TABLE_TYPE=XML TABNAME=t1 OPTION_LIST='xmlsup=libxml2,rownode=row';
15SELECT * FROM t1;
16SHOW CREATE TABLE t1;
17
18--echo # Let us see the XML file
19CREATE TABLE t2 (line VARCHAR(100) NOT NULL) ENGINE=CONNECT FILE_NAME='t1.xml';
20SELECT * FROM t2;
21--echo # NOTE: The first (ignored) row is due to the remaining HEADER=1 option.
22
23--echo # Testing field option modification
24ALTER TABLE t1 MODIFY d CHAR(10) NOT NULL XPATH='@', HEADER=0;
25SELECT * FROM t1;
26SHOW CREATE TABLE t1;
27SELECT * FROM t2;
28
29DROP TABLE t1, t2;
30