From 72da68eef08cb3f22512cf283e859ae4f2039e84 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 2 Jul 2009 07:03:18 +0000 Subject: [PATCH] Regression test for XML mapping functionality I wrote this one while chasing down some bugs in the closing days of 8.4. It could be useful in the long run. This area of the code had no test coverage at all before. --- src/test/regress/expected/xmlmap.out | 1202 ++++++++++++++++++++++++ src/test/regress/expected/xmlmap_1.out | 109 +++ src/test/regress/parallel_schedule | 4 +- src/test/regress/serial_schedule | 3 +- src/test/regress/sql/xmlmap.sql | 41 + 5 files changed, 1356 insertions(+), 3 deletions(-) create mode 100644 src/test/regress/expected/xmlmap.out create mode 100644 src/test/regress/expected/xmlmap_1.out create mode 100644 src/test/regress/sql/xmlmap.sql diff --git a/src/test/regress/expected/xmlmap.out b/src/test/regress/expected/xmlmap.out new file mode 100644 index 0000000000..c074761b60 --- /dev/null +++ b/src/test/regress/expected/xmlmap.out @@ -0,0 +1,1202 @@ +CREATE SCHEMA testxmlschema; +CREATE TABLE testxmlschema.test1 (a int, b text); +INSERT INTO testxmlschema.test1 VALUES (1, 'one'), (2, 'two'), (-1, null); +CREATE DOMAIN testxmldomain AS varchar; +CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), w numeric(9,2), v smallint, u bigint, t real, s time, r timestamp, q date, p xml, o testxmldomain, n bool, m bytea, aaa text); +ALTER TABLE testxmlschema.test2 DROP COLUMN aaa; +INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def', 98.6, 2, 999, 0, '21:07', '2009-06-08 21:07:30', '2009-06-08', NULL, 'ABC', true, 'XYZ'); +SELECT table_to_xml('testxmlschema.test1', false, false, ''); + table_to_xml +--------------------------------------------------------------- + + + + 1 + one + + + + 2 + two + + + + -1 + + + + +(1 row) + +SELECT table_to_xml('testxmlschema.test1', true, false, 'foo'); + table_to_xml +--------------------------------------------------------------------------- + + + + 1 + one + + + + 2 + two + + + + -1 + + + + + +(1 row) + +SELECT table_to_xml('testxmlschema.test1', false, true, ''); + table_to_xml +--------------------------------------------------------------- + + + 1 + one + + + + + 2 + two + + + + + -1 + + + +(1 row) + +SELECT table_to_xml('testxmlschema.test1', true, true, ''); + table_to_xml +--------------------------------------------------------------- + + + 1 + one + + + + + 2 + two + + + + + -1 + + + + +(1 row) + +SELECT table_to_xml('testxmlschema.test2', false, false, ''); + table_to_xml +--------------------------------------------------------------- + + + + 55 + abc + def + 98.60 + 2 + 999 + 0 + 21:07:00 + 2009-06-08T21:07:30 + 2009-06-08 + ABC + true + WFla + + + + +(1 row) + +SELECT table_to_xmlschema('testxmlschema.test1', false, false, ''); + table_to_xmlschema +----------------------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT table_to_xmlschema('testxmlschema.test1', true, false, ''); + table_to_xmlschema +----------------------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo'); + table_to_xmlschema +---------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT table_to_xmlschema('testxmlschema.test1', true, true, ''); + table_to_xmlschema +------------------------------------------------------------------------------------------------ + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT table_to_xmlschema('testxmlschema.test2', false, false, ''); + table_to_xmlschema +----------------------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, ''); + table_to_xml_and_xmlschema +----------------------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + one + + + + 2 + two + + + + -1 + + + + +(1 row) + +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, ''); + table_to_xml_and_xmlschema +----------------------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + one + + + + 2 + two + + + + -1 + + + + + +(1 row) + +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, ''); + table_to_xml_and_xmlschema +---------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + one + + + + + 2 + two + + + + + -1 + + + +(1 row) + +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo'); + table_to_xml_and_xmlschema +------------------------------------------------------------------------------------------------ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + one + + + + + 2 + two + + + + + -1 + + + + +(1 row) + +SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, ''); + query_to_xml +--------------------------------------------------------------- + + + + 1 + one + + + + 2 + two + + + + -1 + + +
+ +(1 row) + +SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, ''); + query_to_xmlschema +---------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, ''); + query_to_xml_and_xmlschema +------------------------------------------------------------------------------------------------ + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + one + + + + + 2 + two + + + + + -1 + + + + +(1 row) + +DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2; +SELECT cursor_to_xml('xc'::refcursor, 5, false, true, ''); + cursor_to_xml +------------------------------------------------------------- + + + -1 + + + + + 1 + one + + + + + 2 + two + + + +(1 row) + +MOVE FIRST IN xc; +SELECT cursor_to_xml('xc'::refcursor, 5, true, false, ''); + cursor_to_xml +--------------- + + 1 + one + + + + 2 + two + + + +(1 row) + +SELECT cursor_to_xmlschema('xc'::refcursor, true, false, ''); + cursor_to_xmlschema +------------------------------------------------------------------------------------------------ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT schema_to_xml('testxmlschema', false, true, ''); + schema_to_xml +----------------------------------------------------------------------- + + + + + 1 + one + + + + + 2 + two + + + + + -1 + + + + + + 55 + abc + def + 98.60 + 2 + 999 + 0 + 21:07:00 + 2009-06-08T21:07:30 + 2009-06-08 + ABC + true + WFla + + + + + +(1 row) + +SELECT schema_to_xml('testxmlschema', true, false, ''); + schema_to_xml +----------------------------------------------------------------------- + + + + + + 1 + one + + + + 2 + two + + + + -1 + + + + + + + + + 55 + abc + def + 98.60 + 2 + 999 + 0 + 21:07:00 + 2009-06-08T21:07:30 + 2009-06-08 +

+ ABC + true + WFla + + + + + + +(1 row) + +SELECT schema_to_xmlschema('testxmlschema', false, true, ''); + schema_to_xmlschema +------------------------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT schema_to_xmlschema('testxmlschema', true, false, ''); + schema_to_xmlschema +--------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +(1 row) + +SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo'); + schema_to_xml_and_xmlschema +------------------------------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + one + + + + + 2 + two + + + + + -1 + + + + + + + 55 + abc + def + 98.60 + 2 + 999 + 0 + 21:07:00 + 2009-06-08T21:07:30 + 2009-06-08 +

+ ABC + true + WFla + + + + + +(1 row) + diff --git a/src/test/regress/expected/xmlmap_1.out b/src/test/regress/expected/xmlmap_1.out new file mode 100644 index 0000000000..932122f6be --- /dev/null +++ b/src/test/regress/expected/xmlmap_1.out @@ -0,0 +1,109 @@ +CREATE SCHEMA testxmlschema; +CREATE TABLE testxmlschema.test1 (a int, b text); +INSERT INTO testxmlschema.test1 VALUES (1, 'one'), (2, 'two'), (-1, null); +CREATE DOMAIN testxmldomain AS varchar; +CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), w numeric(9,2), v smallint, u bigint, t real, s time, r timestamp, q date, p xml, o testxmldomain, n bool, m bytea, aaa text); +ALTER TABLE testxmlschema.test2 DROP COLUMN aaa; +INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def', 98.6, 2, 999, 0, '21:07', '2009-06-08 21:07:30', '2009-06-08', NULL, 'ABC', true, 'XYZ'); +SELECT table_to_xml('testxmlschema.test1', false, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml('testxmlschema.test1', true, false, 'foo'); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml('testxmlschema.test1', false, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml('testxmlschema.test1', true, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml('testxmlschema.test2', false, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xmlschema('testxmlschema.test1', false, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xmlschema('testxmlschema.test1', true, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo'); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xmlschema('testxmlschema.test1', true, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xmlschema('testxmlschema.test2', false, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo'); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2; +SELECT cursor_to_xml('xc'::refcursor, 5, false, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +MOVE FIRST IN xc; +SELECT cursor_to_xml('xc'::refcursor, 5, true, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT cursor_to_xmlschema('xc'::refcursor, true, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT schema_to_xml('testxmlschema', false, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT schema_to_xml('testxmlschema', true, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT schema_to_xmlschema('testxmlschema', false, true, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT schema_to_xmlschema('testxmlschema', true, false, ''); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. +SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo'); +ERROR: unsupported XML feature +DETAIL: This functionality requires the server to be built with libxml support. +HINT: You need to rebuild PostgreSQL using --with-libxml. diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index 7b4425b940..82a73e319c 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -1,5 +1,5 @@ # ---------- -# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.55 2009/01/27 12:40:15 petere Exp $ +# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.56 2009/07/02 07:03:18 petere Exp $ # # By convention, we put no more than twenty tests in any one parallel group; # this limits the number of connections needed to run the tests. @@ -77,7 +77,7 @@ test: misc # ---------- # Another group of parallel tests # ---------- -test: select_views portals_p2 rules foreign_key cluster dependency guc bitmapops combocid tsearch tsdicts foreign_data window +test: select_views portals_p2 rules foreign_key cluster dependency guc bitmapops combocid tsearch tsdicts foreign_data window xmlmap # ---------- # Another group of parallel tests diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule index ba93ea8520..46731986e2 100644 --- a/src/test/regress/serial_schedule +++ b/src/test/regress/serial_schedule @@ -1,4 +1,4 @@ -# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.52 2009/01/27 12:40:15 petere Exp $ +# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.53 2009/07/02 07:03:18 petere Exp $ # This should probably be in an order similar to parallel_schedule. test: boolean test: char @@ -100,6 +100,7 @@ test: tsearch test: tsdicts test: foreign_data test: window +test: xmlmap test: plancache test: limit test: plpgsql diff --git a/src/test/regress/sql/xmlmap.sql b/src/test/regress/sql/xmlmap.sql new file mode 100644 index 0000000000..df1f98046d --- /dev/null +++ b/src/test/regress/sql/xmlmap.sql @@ -0,0 +1,41 @@ +CREATE SCHEMA testxmlschema; + +CREATE TABLE testxmlschema.test1 (a int, b text); +INSERT INTO testxmlschema.test1 VALUES (1, 'one'), (2, 'two'), (-1, null); +CREATE DOMAIN testxmldomain AS varchar; +CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), w numeric(9,2), v smallint, u bigint, t real, s time, r timestamp, q date, p xml, o testxmldomain, n bool, m bytea, aaa text); +ALTER TABLE testxmlschema.test2 DROP COLUMN aaa; +INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def', 98.6, 2, 999, 0, '21:07', '2009-06-08 21:07:30', '2009-06-08', NULL, 'ABC', true, 'XYZ'); + +SELECT table_to_xml('testxmlschema.test1', false, false, ''); +SELECT table_to_xml('testxmlschema.test1', true, false, 'foo'); +SELECT table_to_xml('testxmlschema.test1', false, true, ''); +SELECT table_to_xml('testxmlschema.test1', true, true, ''); +SELECT table_to_xml('testxmlschema.test2', false, false, ''); + +SELECT table_to_xmlschema('testxmlschema.test1', false, false, ''); +SELECT table_to_xmlschema('testxmlschema.test1', true, false, ''); +SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo'); +SELECT table_to_xmlschema('testxmlschema.test1', true, true, ''); +SELECT table_to_xmlschema('testxmlschema.test2', false, false, ''); + +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, ''); +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, ''); +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, ''); +SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo'); + +SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, ''); +SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, ''); +SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, ''); + +DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2; +SELECT cursor_to_xml('xc'::refcursor, 5, false, true, ''); +MOVE FIRST IN xc; +SELECT cursor_to_xml('xc'::refcursor, 5, true, false, ''); +SELECT cursor_to_xmlschema('xc'::refcursor, true, false, ''); + +SELECT schema_to_xml('testxmlschema', false, true, ''); +SELECT schema_to_xml('testxmlschema', true, false, ''); +SELECT schema_to_xmlschema('testxmlschema', false, true, ''); +SELECT schema_to_xmlschema('testxmlschema', true, false, ''); +SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo'); -- 2.40.0