Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a84bf49

Browse files
committed
Avoid extra newlines in XML mapping in table forest mode
found by P. Broennimann
1 parent a36088b commit a84bf49

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

src/backend/utils/adt/xml.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,7 @@ xmldata_root_element_start(StringInfo result, const char *eltname,
23832383
else
23842384
appendStringInfo(result, " xsi:noNamespaceSchemaLocation=\"#\"");
23852385
}
2386-
appendStringInfo(result, ">\n\n");
2386+
appendStringInfo(result, ">\n");
23872387
}
23882388

23892389

@@ -2417,8 +2417,11 @@ query_to_xml_internal(const char *query, char *tablename,
24172417
errmsg("invalid query")));
24182418

24192419
if (!tableforest)
2420+
{
24202421
xmldata_root_element_start(result, xmltn, xmlschema,
24212422
targetns, top_level);
2423+
appendStringInfoString(result, "\n");
2424+
}
24222425

24232426
if (xmlschema)
24242427
appendStringInfo(result, "%s\n\n", xmlschema);
@@ -2581,6 +2584,7 @@ schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls,
25812584
result = makeStringInfo();
25822585

25832586
xmldata_root_element_start(result, xmlsn, xmlschema, targetns, top_level);
2587+
appendStringInfoString(result, "\n");
25842588

25852589
if (xmlschema)
25862590
appendStringInfo(result, "%s\n\n", xmlschema);
@@ -2758,6 +2762,7 @@ database_to_xml_internal(const char *xmlschema, bool nulls,
27582762
result = makeStringInfo();
27592763

27602764
xmldata_root_element_start(result, xmlcn, xmlschema, targetns, true);
2765+
appendStringInfoString(result, "\n");
27612766

27622767
if (xmlschema)
27632768
appendStringInfo(result, "%s\n\n", xmlschema);

src/test/regress/expected/xmlmap.out

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,16 @@ SELECT table_to_xml('testxmlschema.test1', false, true, '');
5656
table_to_xml
5757
---------------------------------------------------------------
5858
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
59-
+
6059
<a>1</a> +
6160
<b>one</b> +
6261
</test1> +
6362
+
6463
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
65-
+
6664
<a>2</a> +
6765
<b>two</b> +
6866
</test1> +
6967
+
7068
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
71-
+
7269
<a>-1</a> +
7370
</test1> +
7471
+
@@ -79,19 +76,16 @@ SELECT table_to_xml('testxmlschema.test1', true, true, '');
7976
table_to_xml
8077
---------------------------------------------------------------
8178
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
82-
+
8379
<a>1</a> +
8480
<b>one</b> +
8581
</test1> +
8682
+
8783
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
88-
+
8984
<a>2</a> +
9085
<b>two</b> +
9186
</test1> +
9287
+
9388
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
94-
+
9589
<a>-1</a> +
9690
<b xsi:nil="true"/> +
9791
</test1> +
@@ -510,19 +504,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '');
510504
</xsd:schema> +
511505
+
512506
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
513-
+
514507
<a>1</a> +
515508
<b>one</b> +
516509
</test1> +
517510
+
518511
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
519-
+
520512
<a>2</a> +
521513
<b>two</b> +
522514
</test1> +
523515
+
524516
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
525-
+
526517
<a>-1</a> +
527518
</test1> +
528519
+
@@ -561,19 +552,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo');
561552
</xsd:schema> +
562553
+
563554
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
564-
+
565555
<a>1</a> +
566556
<b>one</b> +
567557
</test1> +
568558
+
569559
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
570-
+
571560
<a>2</a> +
572561
<b>two</b> +
573562
</test1> +
574563
+
575564
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
576-
+
577565
<a>-1</a> +
578566
<b xsi:nil="true"/> +
579567
</test1> +
@@ -670,19 +658,16 @@ SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, tru
670658
</xsd:schema> +
671659
+
672660
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
673-
+
674661
<a>1</a> +
675662
<b>one</b> +
676663
</row> +
677664
+
678665
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
679-
+
680666
<a>2</a> +
681667
<b>two</b> +
682668
</row> +
683669
+
684670
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
685-
+
686671
<a>-1</a> +
687672
<b xsi:nil="true"/> +
688673
</row> +
@@ -695,18 +680,15 @@ SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '');
695680
cursor_to_xml
696681
-------------------------------------------------------------
697682
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
698-
+
699683
<a>-1</a> +
700684
</row> +
701685
+
702686
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
703-
+
704687
<a>1</a> +
705688
<b>one</b> +
706689
</row> +
707690
+
708691
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
709-
+
710692
<a>2</a> +
711693
<b>two</b> +
712694
</row> +
@@ -773,25 +755,21 @@ SELECT schema_to_xml('testxmlschema', false, true, '');
773755
<testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
774756
+
775757
<test1> +
776-
+
777758
<a>1</a> +
778759
<b>one</b> +
779760
</test1> +
780761
+
781762
<test1> +
782-
+
783763
<a>2</a> +
784764
<b>two</b> +
785765
</test1> +
786766
+
787767
<test1> +
788-
+
789768
<a>-1</a> +
790769
</test1> +
791770
+
792771
+
793772
<test2> +
794-
+
795773
<z>55</z> +
796774
<y>abc</y> +
797775
<x>def </x> +
@@ -1159,26 +1137,22 @@ SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
11591137
</xsd:schema> +
11601138
+
11611139
<test1> +
1162-
+
11631140
<a>1</a> +
11641141
<b>one</b> +
11651142
</test1> +
11661143
+
11671144
<test1> +
1168-
+
11691145
<a>2</a> +
11701146
<b>two</b> +
11711147
</test1> +
11721148
+
11731149
<test1> +
1174-
+
11751150
<a>-1</a> +
11761151
<b xsi:nil="true"/> +
11771152
</test1> +
11781153
+
11791154
+
11801155
<test2> +
1181-
+
11821156
<z>55</z> +
11831157
<y>abc</y> +
11841158
<x>def </x> +

0 commit comments

Comments
 (0)