aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-05-03 21:25:01 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-05-04 21:17:46 -0400
commit071d13395cc2ea0b87aa5f135c87808d6dd60cd5 (patch)
tree0b2cd46593fbe22bfb5e5d657ee6a45af4e9251e /src/test
parent855f0e9247a160bfad00c117ba7d97148cd2a0ec (diff)
downloadpostgresql-071d13395cc2ea0b87aa5f135c87808d6dd60cd5.tar.gz
postgresql-071d13395cc2ea0b87aa5f135c87808d6dd60cd5.zip
Fix cursor_to_xml in tableforest false mode
It only produced <row> elements but no wrapping <table> element. By contrast, cursor_to_xmlschema produced a schema that is now correct but did not previously match the XML data produced by cursor_to_xml. In passing, also fix a minor misunderstanding about moving cursors in the tests related to this. Reported-by: filip@jirsak.org Based-on-patch-by: Thomas Munro <thomas.munro@enterprisedb.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/xmlmap.out64
-rw-r--r--src/test/regress/expected/xmlmap_1.out6
-rw-r--r--src/test/regress/sql/xmlmap.sql3
3 files changed, 58 insertions, 15 deletions
diff --git a/src/test/regress/expected/xmlmap.out b/src/test/regress/expected/xmlmap.out
index b50396face9..c08f8a0d9c1 100644
--- a/src/test/regress/expected/xmlmap.out
+++ b/src/test/regress/expected/xmlmap.out
@@ -696,20 +696,58 @@ SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '');
(1 row)
-MOVE FIRST IN xc;
+SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '');
+ cursor_to_xmlschema
+----------------------------------------------------------------------------------------------
+ <xsd:schema +
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
+ +
+ <xsd:simpleType name="INTEGER"> +
+ <xsd:restriction base="xsd:int"> +
+ <xsd:maxInclusive value="2147483647"/> +
+ <xsd:minInclusive value="-2147483648"/> +
+ </xsd:restriction> +
+ </xsd:simpleType> +
+ +
+ <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
+ <xsd:restriction base="xsd:string"> +
+ </xsd:restriction> +
+ </xsd:simpleType> +
+ +
+ <xsd:complexType name="RowType"> +
+ <xsd:sequence> +
+ <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
+ <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
+ </xsd:sequence> +
+ </xsd:complexType> +
+ +
+ <xsd:element name="row" type="RowType"/> +
+ +
+ </xsd:schema>
+(1 row)
+
+MOVE BACKWARD ALL IN xc;
SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '');
- cursor_to_xml
----------------
- <row> +
- <a>1</a> +
- <b>one</b> +
- </row> +
- +
- <row> +
- <a>2</a> +
- <b>two</b> +
- </row> +
- +
+ cursor_to_xml
+---------------------------------------------------------------
+ <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+ +
+ <row> +
+ <a>-1</a> +
+ <b xsi:nil="true"/> +
+ </row> +
+ +
+ <row> +
+ <a>1</a> +
+ <b>one</b> +
+ </row> +
+ +
+ <row> +
+ <a>2</a> +
+ <b>two</b> +
+ </row> +
+ +
+ </table> +
(1 row)
diff --git a/src/test/regress/expected/xmlmap_1.out b/src/test/regress/expected/xmlmap_1.out
index d67ef6d3e24..f6dbf81666a 100644
--- a/src/test/regress/expected/xmlmap_1.out
+++ b/src/test/regress/expected/xmlmap_1.out
@@ -78,7 +78,11 @@ 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_xmlschema('xc'::refcursor, 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 BACKWARD ALL 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.
diff --git a/src/test/regress/sql/xmlmap.sql b/src/test/regress/sql/xmlmap.sql
index 8f8d6808139..fde1b9eb597 100644
--- a/src/test/regress/sql/xmlmap.sql
+++ b/src/test/regress/sql/xmlmap.sql
@@ -30,7 +30,8 @@ SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, tru
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_xmlschema('xc'::refcursor, false, true, '');
+MOVE BACKWARD ALL IN xc;
SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '');
SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '');