Re: [PATCH] Add pretty-printed XML output option
Peter Smith <smithpb2250@gmail.com>
From: Peter Smith <smithpb2250@gmail.com>
To: Jim Jones <jim.jones@uni-muenster.de>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Nikolay Samokhvalov <samokhvalov@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Andrey Borodin <amborodin86@gmail.com>
Date: 2023-02-22T07:20:04Z
Lists: pgsql-hackers
Here are some review comments for patch v15-0001
FYI, the patch applies clean and tests OK for me.
======
doc/src/sgml/datatype.sgml
1.
XMLSERIALIZE ( { DOCUMENT | CONTENT } <replaceable>value</replaceable>
AS <replaceable>type</replaceable> [ { NO INDENT | INDENT } ] )
~
Another/shorter way to write that syntax is like below. For me, it is
easier to read. YMMV.
XMLSERIALIZE ( { DOCUMENT | CONTENT } <replaceable>value</replaceable>
AS <replaceable>type</replaceable> [ [NO] INDENT ] )
======
src/backend/executor/execExprInterp.c
2. ExecEvalXmlExpr
@@ -3829,7 +3829,8 @@ ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op)
{
Datum *argvalue = op->d.xmlexpr.argvalue;
bool *argnull = op->d.xmlexpr.argnull;
-
+ bool indent = op->d.xmlexpr.xexpr->indent;
+ text *data;
/* argument type is known to be xml */
Assert(list_length(xexpr->args) == 1);
Missing whitespace after the variable declarations
~~~
3.
+
+ data = xmltotext_with_xmloption(DatumGetXmlP(value),
+ xexpr->xmloption);
+ if(indent)
+ *op->resvalue = PointerGetDatum(xmlformat(data));
+ else
+ *op->resvalue = PointerGetDatum(data);
+
}
Unnecessary blank line at the end.
======
src/backend/utils/adt/xml.
4. xmlformat
+#else
+ NO_XML_SUPPORT();
+return 0;
+#endif
Wrong indentation (return 0) in the indentation function? ;-)
------
Kind Regards,
Peter Smith.
Fujitsu Australia
Commits
-
Fix memory leak in XMLSERIALIZE(... INDENT).
- f24605e2dc16 18.0 landed
- ee58de10084b 16.10 landed
- 20bae0690322 17.6 landed
-
doc: Move documentation of md5_password_warnings to a better place
- f3622b64762b 18.0 cited
-
Support [NO] INDENT option in XMLSERIALIZE().
- 483bdb2afec9 16.0 landed
-
Add an expected-file to match behavior of latest libxml2.
- 085423e3e326 9.6.0 cited