Commit 1e3610dd authored by Alexander Barkov's avatar Alexander Barkov

Adding basic XML tests. More XML tests coming soon.

added:
  mysql-test/suite/connect/r/xml.result
  mysql-test/suite/connect/std_data/
  mysql-test/suite/connect/std_data/cp1251.xml
  mysql-test/suite/connect/std_data/latin1.xml
  mysql-test/suite/connect/std_data/nocs.xml
  mysql-test/suite/connect/std_data/xsample.xml
  mysql-test/suite/connect/t/xml.test
parent 8eccf8dd
SET NAMES utf8;
#
# Testing tag values
#
CREATE TABLE t1
(
AUTHOR CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml';
#
# Testing that tag names are case sensitive
#
SELECT * FROM t1;
AUTHOR
Jean-Christophe
Bernadac
TITLE Construire une application XML
TRANSLATOR
PUBLISHER
Eyrolles
Paris
DATEPUB 1999
AUTHOR
William J.
Pardi
TITLE XML en Action
TRANSLATOR
James
Guerin
PUBLISHER
Microsoft Press
Paris
DATEPUB 1999
DROP TABLE t1;
CREATE TABLE t1
(
author CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml';
SELECT * FROM t1;
author
TITLE Construire une application XML
TRANSLATOR
PUBLISHER
Eyrolles
Paris
DATEPUB 1999
author
TITLE XML en Action
TRANSLATOR
James
Guerin
PUBLISHER
Microsoft Press
Paris
DATEPUB 1999
DROP TABLE t1;
#
# Testing attribute values
#
CREATE TABLE t1 (
ISBN CHAR(15),
LANG CHAR(2),
SUBJECT CHAR(32)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml' OPTION_LIST='Coltype=@';
SELECT * FROM t1;
ISBN 9782212090819
LANG fr
SUBJECT applications
ISBN 9782840825685
LANG fr
SUBJECT applications
DROP TABLE t1;
#
# Testing that attribute names are case sensitive
#
CREATE TABLE t1 (
isbn CHAR(15),
LANG CHAR(2),
SUBJECT CHAR(32)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml' OPTION_LIST='Coltype=@';
SELECT * FROM t1;
isbn
LANG fr
SUBJECT applications
isbn
LANG fr
SUBJECT applications
DROP TABLE t1;
#
# Testing mixed tag and attribute values
#
CREATE TABLE t1 (
ISBN CHAR(15) FIELD_FORMAT='@',
LANG CHAR(2) FIELD_FORMAT='@',
SUBJECT CHAR(32) FIELD_FORMAT='@',
AUTHOR CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK';
SELECT * FROM t1;
ISBN 9782212090819
LANG fr
SUBJECT applications
AUTHOR
Jean-Christophe
Bernadac
TITLE Construire une application XML
TRANSLATOR
PUBLISHER
Eyrolles
Paris
DATEPUB 1999
ISBN 9782840825685
LANG fr
SUBJECT applications
AUTHOR
William J.
Pardi
TITLE XML en Action
TRANSLATOR
James
Guerin
PUBLISHER
Microsoft Press
Paris
DATEPUB 1999
DROP TABLE t1;
#
# Testing INSERT on mixed tag and attribute values
#
CREATE TABLE t1 (
ISBN CHAR(15) FIELD_FORMAT='@',
LANG CHAR(2) FIELD_FORMAT='@',
SUBJECT CHAR(32) FIELD_FORMAT='@',
AUTHOR CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample2.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK';
INSERT INTO t1 (ISBN, LANG, SUBJECT, AUTHOR, TITLE, PUBLISHEr, DATEPUB)
VALUES('9782212090529','fr','général','Alain Michard',
'XML, Langage et Applications','Eyrolles Paris',1998);
SELECT * FROM t1;
ISBN 9782212090819
LANG fr
SUBJECT applications
AUTHOR
Jean-Christophe
Bernadac
TITLE Construire une application XML
TRANSLATOR
PUBLISHER
Eyrolles
Paris
DATEPUB 1999
ISBN 9782840825685
LANG fr
SUBJECT applications
AUTHOR
William J.
Pardi
TITLE XML en Action
TRANSLATOR
James
Guerin
PUBLISHER
Microsoft Press
Paris
DATEPUB 1999
ISBN 9782212090529
LANG fr
SUBJECT général
AUTHOR Alain Michard
TITLE XML, Langage et Applications
TRANSLATOR
PUBLISHER Eyrolles Paris
DATEPUB 1998
SELECT LOAD_FILE('test/xsample2.xml');
LOAD_FILE('test/xsample2.xml') <?xml version="1.0" encoding="UTF-8"?>
<BIBLIO SUBJECT="XML">
<BOOK ISBN="9782212090819" LANG="fr" SUBJECT="applications">
<AUTHOR>
<FIRSTNAME>Jean-Christophe</FIRSTNAME>
<LASTNAME>Bernadac</LASTNAME>
</AUTHOR>
<AUTHOR>
<FIRSTNAME>François</FIRSTNAME>
<LASTNAME>Knab</LASTNAME>
</AUTHOR>
<TITLE>Construire une application XML</TITLE>
<PUBLISHER>
<NAME>Eyrolles</NAME>
<PLACE>Paris</PLACE>
</PUBLISHER>
<DATEPUB>1999</DATEPUB>
</BOOK>
<BOOK ISBN="9782840825685" LANG="fr" SUBJECT="applications">
<AUTHOR>
<FIRSTNAME>William J.</FIRSTNAME>
<LASTNAME>Pardi</LASTNAME>
</AUTHOR>
<TRANSLATOR PREFIX="adapté de l'anglais par">
<FIRSTNAME>James</FIRSTNAME>
<LASTNAME>Guerin</LASTNAME>
</TRANSLATOR>
<TITLE>XML en Action</TITLE>
<PUBLISHER>
<NAME>Microsoft Press</NAME>
<PLACE>Paris</PLACE>
</PUBLISHER>
<DATEPUB>1999</DATEPUB>
</BOOK>
<BOOK ISBN="9782212090529" LANG="fr" SUBJECT="général">
<AUTHOR>Alain Michard</AUTHOR>
<TITLE>XML, Langage et Applications</TITLE>
<PUBLISHER>Eyrolles Paris</PUBLISHER>
<DATEPUB>1998</DATEPUB>
</BOOK>
</BIBLIO>
DROP TABLE t1;
#
# Testing XPath
#
CREATE TABLE t1 (
isbn CHAR(15) FIELD_FORMAT='@ISBN',
language CHAR(2) FIELD_FORMAT='@LANG',
subject CHAR(32) FIELD_FORMAT='@SUBJECT',
authorfn CHAR(20) FIELD_FORMAT='AUTHOR/FIRSTNAME',
authorln CHAR(20) FIELD_FORMAT='AUTHOR/LASTNAME',
title CHAR(32) FIELD_FORMAT='TITLE',
translated CHAR(32) FIELD_FORMAT='TRANSLATOR/@PREFIX',
tranfn CHAR(20) FIELD_FORMAT='TRANSLATOR/FIRSTNAME',
tranln CHAR(20) FIELD_FORMAT='TRANSLATOR/LASTNAME',
publisher CHAR(20) FIELD_FORMAT='PUBLISHER/NAME',
location CHAR(20) FIELD_FORMAT='PUBLISHER/PLACE',
year INT(4) FIELD_FORMAT='DATEPUB'
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK,skipnull=1';
SELECT * FROM t1;
isbn 9782212090819
language fr
subject applications
authorfn Jean-Christophe
authorln Bernadac
title Construire une application XML
translated
tranfn
tranln
publisher Eyrolles
location Paris
year 1999
isbn 9782840825685
language fr
subject applications
authorfn William J.
authorln Pardi
title XML en Action
translated adapté de l'anglais par
tranfn James
tranln Guerin
publisher Microsoft Press
location Paris
year 1999
SELECT isbn, title, translated, tranfn, tranln, location FROM t1
WHERE translated <> '';
isbn 9782840825685
title XML en Action
translated adapté de l'anglais par
tranfn James
tranln Guerin
location Paris
DROP TABLE t1;
#
# Testing that XPath is case sensitive
#
CREATE TABLE t1
(
isbn CHAR(15) FIELD_FORMAT='@isbn'
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK,skipnull=1';
SELECT * FROM t1;
isbn
isbn
DROP TABLE t1;
#
# Testing character sets
#
CREATE TABLE t1
(
c CHAR(16)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='latin1.xml';
SELECT c, HEX(c) FROM t1;
c ÁÂÃÄÅÆÇ
HEX(c) C1C2C3C4C5C6C7
DROP TABLE t1;
CREATE TABLE t1
(
c CHAR(16) CHARACTER SET utf8
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='latin1.xml';
SELECT c, HEX(c) FROM t1;
c ÁÂÃÄÅÆÇ
HEX(c) C381C382C383C384C385C386C387
DROP TABLE t1;
#
# Conversion from latin1 to cp1251 produces a warning.
# Question marks are returned.
#
CREATE TABLE t1
(
c CHAR(16) CHARACTER SET cp1251
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='latin1.xml';
SELECT c, HEX(c) FROM t1;
c ???????
HEX(c) 3F3F3F3F3F3F3F
Warnings:
Level Warning
Code 1366
Message Incorrect string value: '\xC1\xC2\xC3\xC4\xC5\xC6...' for column 'c' at row 1
DROP TABLE t1;
<?xml version="1.0" encoding="utf-8"?>
<a><b><c></c></b></a>
<?xml version="1.0" encoding="ISO-8859-1"?>
<a><b><c></c></b></a>
<?xml version="1.0"?>
<a><b><c></c></b></a>
<?xml version="1.0" encoding="UTF-8"?>
<BIBLIO SUBJECT="XML">
<BOOK ISBN="9782212090819" LANG="fr" SUBJECT="applications">
<AUTHOR>
<FIRSTNAME>Jean-Christophe</FIRSTNAME>
<LASTNAME>Bernadac</LASTNAME>
</AUTHOR>
<AUTHOR>
<FIRSTNAME>François</FIRSTNAME>
<LASTNAME>Knab</LASTNAME>
</AUTHOR>
<TITLE>Construire une application XML</TITLE>
<PUBLISHER>
<NAME>Eyrolles</NAME>
<PLACE>Paris</PLACE>
</PUBLISHER>
<DATEPUB>1999</DATEPUB>
</BOOK>
<BOOK ISBN="9782840825685" LANG="fr" SUBJECT="applications">
<AUTHOR>
<FIRSTNAME>William J.</FIRSTNAME>
<LASTNAME>Pardi</LASTNAME>
</AUTHOR>
<TRANSLATOR PREFIX="adapté de l'anglais par">
<FIRSTNAME>James</FIRSTNAME>
<LASTNAME>Guerin</LASTNAME>
</TRANSLATOR>
<TITLE>XML en Action</TITLE>
<PUBLISHER>
<NAME>Microsoft Press</NAME>
<PLACE>Paris</PLACE>
</PUBLISHER>
<DATEPUB>1999</DATEPUB>
</BOOK>
</BIBLIO>
let $MYSQLD_DATADIR= `select @@datadir`;
SET NAMES utf8;
--vertical_results
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/xsample.xml $MYSQLD_DATADIR/test/xsample.xml
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/latin1.xml $MYSQLD_DATADIR/test/latin1.xml
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/cp1251.xml $MYSQLD_DATADIR/test/cp1251.xml
#--echo $MYSQL_TEST_DIR
#--exec pwd
#SELECT LOAD_FILE('test/xsample.xml');
--echo #
--echo # Testing tag values
--echo #
CREATE TABLE t1
(
AUTHOR CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml';
--echo #
--echo # Testing that tag names are case sensitive
--echo #
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1
(
author CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml';
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Testing attribute values
--echo #
CREATE TABLE t1 (
ISBN CHAR(15),
LANG CHAR(2),
SUBJECT CHAR(32)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml' OPTION_LIST='Coltype=@';
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Testing that attribute names are case sensitive
--echo #
CREATE TABLE t1 (
isbn CHAR(15),
LANG CHAR(2),
SUBJECT CHAR(32)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml' OPTION_LIST='Coltype=@';
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Testing mixed tag and attribute values
--echo #
CREATE TABLE t1 (
ISBN CHAR(15) FIELD_FORMAT='@',
LANG CHAR(2) FIELD_FORMAT='@',
SUBJECT CHAR(32) FIELD_FORMAT='@',
AUTHOR CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK';
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Testing INSERT on mixed tag and attribute values
--echo #
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/xsample.xml $MYSQLD_DATADIR/test/xsample2.xml
CREATE TABLE t1 (
ISBN CHAR(15) FIELD_FORMAT='@',
LANG CHAR(2) FIELD_FORMAT='@',
SUBJECT CHAR(32) FIELD_FORMAT='@',
AUTHOR CHAR(50),
TITLE CHAR(32),
TRANSLATOR CHAR(40),
PUBLISHER CHAR(40),
DATEPUB INT(4)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample2.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK';
INSERT INTO t1 (ISBN, LANG, SUBJECT, AUTHOR, TITLE, PUBLISHEr, DATEPUB)
VALUES('9782212090529','fr','général','Alain Michard',
'XML, Langage et Applications','Eyrolles Paris',1998);
SELECT * FROM t1;
SELECT LOAD_FILE('test/xsample2.xml');
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/xsample2.xml
--echo #
--echo # Testing XPath
--echo #
CREATE TABLE t1 (
isbn CHAR(15) FIELD_FORMAT='@ISBN',
language CHAR(2) FIELD_FORMAT='@LANG',
subject CHAR(32) FIELD_FORMAT='@SUBJECT',
authorfn CHAR(20) FIELD_FORMAT='AUTHOR/FIRSTNAME',
authorln CHAR(20) FIELD_FORMAT='AUTHOR/LASTNAME',
title CHAR(32) FIELD_FORMAT='TITLE',
translated CHAR(32) FIELD_FORMAT='TRANSLATOR/@PREFIX',
tranfn CHAR(20) FIELD_FORMAT='TRANSLATOR/FIRSTNAME',
tranln CHAR(20) FIELD_FORMAT='TRANSLATOR/LASTNAME',
publisher CHAR(20) FIELD_FORMAT='PUBLISHER/NAME',
location CHAR(20) FIELD_FORMAT='PUBLISHER/PLACE',
year INT(4) FIELD_FORMAT='DATEPUB'
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK,skipnull=1';
SELECT * FROM t1;
SELECT isbn, title, translated, tranfn, tranln, location FROM t1
WHERE translated <> '';
DROP TABLE t1;
#
# TODO: Connect.pdf says nodes with variable depth are not supported
#
#--echo #
#--echo # Relative paths are not supported
#--echo #
#CREATE TABLE t1 (
# authorfn CHAR(20) FIELD_FORMAT='//FIRSTNAME',
# authorln CHAR(20) FIELD_FORMAT='//LASTNAME'
#) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
# TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK,skipnull=1';
#SELECT * FROM t1;
#DROP TABLE t1;
#
# TODO: Connect.pdf says absolute paths are not supported
#
#--echo #
#--echo # Absolute path is not supported
#--echo #
#CREATE TABLE t1 (
# authorfn CHAR(20) FIELD_FORMAT='/BIBLIO/BOOK/AUTHOR/FIRSTNAME',
# authorln CHAR(20) FIELD_FORMAT='/BIBLIO/BOOK/AUTHOR/LASTNAME'
#) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
# TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK,skipnull=1';
#SELECT * FROM t1;
#DROP TABLE t1;
--echo #
--echo # Testing that XPath is case sensitive
--echo #
CREATE TABLE t1
(
isbn CHAR(15) FIELD_FORMAT='@isbn'
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample.xml'
TABNAME='BIBLIO' OPTION_LIST='rownode=BOOK,skipnull=1';
SELECT * FROM t1;
DROP TABLE t1;
--echo #
--echo # Testing character sets
--echo #
CREATE TABLE t1
(
c CHAR(16)
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='latin1.xml';
SELECT c, HEX(c) FROM t1;
DROP TABLE t1;
CREATE TABLE t1
(
c CHAR(16) CHARACTER SET utf8
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='latin1.xml';
SELECT c, HEX(c) FROM t1;
DROP TABLE t1;
--echo #
--echo # Conversion from latin1 to cp1251 produces a warning.
--echo # Question marks are returned.
--echo #
CREATE TABLE t1
(
c CHAR(16) CHARACTER SET cp1251
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='latin1.xml';
SELECT c, HEX(c) FROM t1;
DROP TABLE t1;
#
# TODO: Cyrillic does not work
#
#CREATE TABLE t1
#(
# c CHAR(16) CHARACTER SET utf8
#) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='cp1251.xml';
#SELECT c, HEX(c) FROM t1;
#DROP TABLE t1;
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/xsample.xml
--remove_file $MYSQLD_DATADIR/test/latin1.xml
--remove_file $MYSQLD_DATADIR/test/cp1251.xml
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