mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Add missing deparsing of [NO] IDENT to XMLSERIALIZE()
NO INDENT is the default, and is added if no explicit indentation
flag was provided with XMLSERIALIZE().
Oversight in 483bdb2afe.
Author: Jim Jones <jim.jones@uni-muenster.de>
Discussion: https://postgr.es/m/bebd457e-5b43-46b3-8fc6-f6a6509483ba@uni-muenster.de
Backpatch-through: 16
			
			
This commit is contained in:
		@@ -9898,9 +9898,16 @@ get_rule_expr(Node *node, deparse_context *context,
 | 
				
			|||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if (xexpr->op == IS_XMLSERIALIZE)
 | 
									if (xexpr->op == IS_XMLSERIALIZE)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
					appendStringInfo(buf, " AS %s",
 | 
										appendStringInfo(buf, " AS %s",
 | 
				
			||||||
									 format_type_with_typemod(xexpr->type,
 | 
														 format_type_with_typemod(xexpr->type,
 | 
				
			||||||
															  xexpr->typmod));
 | 
																				  xexpr->typmod));
 | 
				
			||||||
 | 
										if (xexpr->indent)
 | 
				
			||||||
 | 
											appendStringInfoString(buf, " INDENT");
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
											appendStringInfoString(buf, " NO INDENT");
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (xexpr->op == IS_DOCUMENT)
 | 
									if (xexpr->op == IS_DOCUMENT)
 | 
				
			||||||
					appendStringInfoString(buf, " IS DOCUMENT");
 | 
										appendStringInfoString(buf, " IS DOCUMENT");
 | 
				
			||||||
				else
 | 
									else
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -822,11 +822,15 @@ CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar');
 | 
				
			|||||||
CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
 | 
					CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
 | 
				
			||||||
CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
 | 
					CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
 | 
				
			||||||
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
 | 
					CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
 | 
				
			||||||
 | 
					CREATE VIEW xmlview10 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS text indent);
 | 
				
			||||||
 | 
					CREATE VIEW xmlview11 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS character varying no indent);
 | 
				
			||||||
SELECT table_name, view_definition FROM information_schema.views
 | 
					SELECT table_name, view_definition FROM information_schema.views
 | 
				
			||||||
  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
					  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
				
			||||||
 table_name |                                                            view_definition                                                            
 | 
					 table_name |                                                            view_definition                                                            
 | 
				
			||||||
------------+------------------------------------------------------------------------------------------------------------
 | 
					------------+---------------------------------------------------------------------------------------------------------------------------------------
 | 
				
			||||||
 xmlview1   |  SELECT xmlcomment('test'::text) AS xmlcomment;
 | 
					 xmlview1   |  SELECT xmlcomment('test'::text) AS xmlcomment;
 | 
				
			||||||
 | 
					 xmlview10  |  SELECT XMLSERIALIZE(DOCUMENT '<foo><bar>42</bar></foo>'::xml AS text INDENT) AS "xmlserialize";
 | 
				
			||||||
 | 
					 xmlview11  |  SELECT (XMLSERIALIZE(DOCUMENT '<foo><bar>42</bar></foo>'::xml AS character varying NO INDENT))::character varying AS "xmlserialize";
 | 
				
			||||||
 xmlview2   |  SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
 | 
					 xmlview2   |  SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
 | 
				
			||||||
 xmlview3   |  SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
 | 
					 xmlview3   |  SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
 | 
				
			||||||
 xmlview4   |  SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement"                                +
 | 
					 xmlview4   |  SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement"                                +
 | 
				
			||||||
@@ -834,9 +838,9 @@ SELECT table_name, view_definition FROM information_schema.views
 | 
				
			|||||||
 xmlview5   |  SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
 | 
					 xmlview5   |  SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
 | 
				
			||||||
 xmlview6   |  SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
 | 
					 xmlview6   |  SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
 | 
				
			||||||
 xmlview7   |  SELECT XMLROOT('<foo/>'::xml, VERSION NO VALUE, STANDALONE YES) AS "xmlroot";
 | 
					 xmlview7   |  SELECT XMLROOT('<foo/>'::xml, VERSION NO VALUE, STANDALONE YES) AS "xmlroot";
 | 
				
			||||||
 xmlview8   |  SELECT (XMLSERIALIZE(CONTENT 'good'::xml AS character(10)))::character(10) AS "xmlserialize";
 | 
					 xmlview8   |  SELECT (XMLSERIALIZE(CONTENT 'good'::xml AS character(10) NO INDENT))::character(10) AS "xmlserialize";
 | 
				
			||||||
 xmlview9   |  SELECT XMLSERIALIZE(CONTENT 'good'::xml AS text) AS "xmlserialize";
 | 
					 xmlview9   |  SELECT XMLSERIALIZE(CONTENT 'good'::xml AS text NO INDENT) AS "xmlserialize";
 | 
				
			||||||
(9 rows)
 | 
					(11 rows)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Text XPath expressions evaluation
 | 
					-- Text XPath expressions evaluation
 | 
				
			||||||
SELECT xpath('/value', data) FROM xmltest;
 | 
					SELECT xpath('/value', data) FROM xmltest;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -583,6 +583,16 @@ ERROR:  unsupported XML feature
 | 
				
			|||||||
LINE 1: ...EATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as ...
 | 
					LINE 1: ...EATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as ...
 | 
				
			||||||
                                                             ^
 | 
					                                                             ^
 | 
				
			||||||
DETAIL:  This functionality requires the server to be built with libxml support.
 | 
					DETAIL:  This functionality requires the server to be built with libxml support.
 | 
				
			||||||
 | 
					CREATE VIEW xmlview10 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS text indent);
 | 
				
			||||||
 | 
					ERROR:  unsupported XML feature
 | 
				
			||||||
 | 
					LINE 1: ...TE VIEW xmlview10 AS SELECT xmlserialize(document '<foo><bar...
 | 
				
			||||||
 | 
					                                                             ^
 | 
				
			||||||
 | 
					DETAIL:  This functionality requires the server to be built with libxml support.
 | 
				
			||||||
 | 
					CREATE VIEW xmlview11 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS character varying no indent);
 | 
				
			||||||
 | 
					ERROR:  unsupported XML feature
 | 
				
			||||||
 | 
					LINE 1: ...TE VIEW xmlview11 AS SELECT xmlserialize(document '<foo><bar...
 | 
				
			||||||
 | 
					                                                             ^
 | 
				
			||||||
 | 
					DETAIL:  This functionality requires the server to be built with libxml support.
 | 
				
			||||||
SELECT table_name, view_definition FROM information_schema.views
 | 
					SELECT table_name, view_definition FROM information_schema.views
 | 
				
			||||||
  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
					  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
				
			||||||
 table_name |                                view_definition                                 
 | 
					 table_name |                                view_definition                                 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -808,11 +808,15 @@ CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar');
 | 
				
			|||||||
CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
 | 
					CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
 | 
				
			||||||
CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
 | 
					CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
 | 
				
			||||||
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
 | 
					CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
 | 
				
			||||||
 | 
					CREATE VIEW xmlview10 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS text indent);
 | 
				
			||||||
 | 
					CREATE VIEW xmlview11 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS character varying no indent);
 | 
				
			||||||
SELECT table_name, view_definition FROM information_schema.views
 | 
					SELECT table_name, view_definition FROM information_schema.views
 | 
				
			||||||
  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
					  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
				
			||||||
 table_name |                                                            view_definition                                                            
 | 
					 table_name |                                                            view_definition                                                            
 | 
				
			||||||
------------+------------------------------------------------------------------------------------------------------------
 | 
					------------+---------------------------------------------------------------------------------------------------------------------------------------
 | 
				
			||||||
 xmlview1   |  SELECT xmlcomment('test'::text) AS xmlcomment;
 | 
					 xmlview1   |  SELECT xmlcomment('test'::text) AS xmlcomment;
 | 
				
			||||||
 | 
					 xmlview10  |  SELECT XMLSERIALIZE(DOCUMENT '<foo><bar>42</bar></foo>'::xml AS text INDENT) AS "xmlserialize";
 | 
				
			||||||
 | 
					 xmlview11  |  SELECT (XMLSERIALIZE(DOCUMENT '<foo><bar>42</bar></foo>'::xml AS character varying NO INDENT))::character varying AS "xmlserialize";
 | 
				
			||||||
 xmlview2   |  SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
 | 
					 xmlview2   |  SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat";
 | 
				
			||||||
 xmlview3   |  SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
 | 
					 xmlview3   |  SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement";
 | 
				
			||||||
 xmlview4   |  SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement"                                +
 | 
					 xmlview4   |  SELECT XMLELEMENT(NAME employee, XMLFOREST(name AS name, age AS age, salary AS pay)) AS "xmlelement"                                +
 | 
				
			||||||
@@ -820,9 +824,9 @@ SELECT table_name, view_definition FROM information_schema.views
 | 
				
			|||||||
 xmlview5   |  SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
 | 
					 xmlview5   |  SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse";
 | 
				
			||||||
 xmlview6   |  SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
 | 
					 xmlview6   |  SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi";
 | 
				
			||||||
 xmlview7   |  SELECT XMLROOT('<foo/>'::xml, VERSION NO VALUE, STANDALONE YES) AS "xmlroot";
 | 
					 xmlview7   |  SELECT XMLROOT('<foo/>'::xml, VERSION NO VALUE, STANDALONE YES) AS "xmlroot";
 | 
				
			||||||
 xmlview8   |  SELECT (XMLSERIALIZE(CONTENT 'good'::xml AS character(10)))::character(10) AS "xmlserialize";
 | 
					 xmlview8   |  SELECT (XMLSERIALIZE(CONTENT 'good'::xml AS character(10) NO INDENT))::character(10) AS "xmlserialize";
 | 
				
			||||||
 xmlview9   |  SELECT XMLSERIALIZE(CONTENT 'good'::xml AS text) AS "xmlserialize";
 | 
					 xmlview9   |  SELECT XMLSERIALIZE(CONTENT 'good'::xml AS text NO INDENT) AS "xmlserialize";
 | 
				
			||||||
(9 rows)
 | 
					(11 rows)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Text XPath expressions evaluation
 | 
					-- Text XPath expressions evaluation
 | 
				
			||||||
SELECT xpath('/value', data) FROM xmltest;
 | 
					SELECT xpath('/value', data) FROM xmltest;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -219,6 +219,8 @@ CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar');
 | 
				
			|||||||
CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
 | 
					CREATE VIEW xmlview7 AS SELECT xmlroot(xml '<foo/>', version no value, standalone yes);
 | 
				
			||||||
CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
 | 
					CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10));
 | 
				
			||||||
CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
 | 
					CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text);
 | 
				
			||||||
 | 
					CREATE VIEW xmlview10 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS text indent);
 | 
				
			||||||
 | 
					CREATE VIEW xmlview11 AS SELECT xmlserialize(document '<foo><bar>42</bar></foo>' AS character varying no indent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SELECT table_name, view_definition FROM information_schema.views
 | 
					SELECT table_name, view_definition FROM information_schema.views
 | 
				
			||||||
  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
					  WHERE table_name LIKE 'xmlview%' ORDER BY 1;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user