Deprecation warnings on Rocky 10.2 with current dev branch

Started by Daniel Westermann (DWE)4 months ago14 messageshackers
Jump to latest
#1Daniel Westermann (DWE)
daniel.westermann@dbi-services.com

Hi,

I've just noticed this while building from the dev branch on Rocky 10.2 x64:

[1086/2136] Compiling C object src/backend/postgres_lib.a.p/utils_adt_xml.c.o
../postgresql/src/backend/utils/adt/xml.c: In function ‘xml_parse’:
../postgresql/src/backend/utils/adt/xml.c:1924:25: warning: ‘xmlKeepBlanksDefault’ is deprecated [-Wdeprecated-declarations]
1924 | save_keep_blanks = xmlKeepBlanksDefault(preserve_whitespace ? 1 : 0);
| ^~~~~~~~~~~~~~~~
In file included from ../postgresql/src/backend/utils/adt/xml.c:51:
/usr/include/libxml2/libxml/parser.h:957:17: note: declared here
957 | xmlKeepBlanksDefault (int val);
| ^~~~~~~~~~~~~~~~~~~~
../postgresql/src/backend/utils/adt/xml.c:1948:25: warning: ‘xmlKeepBlanksDefault’ is deprecated [-Wdeprecated-declarations]
1948 | xmlKeepBlanksDefault(save_keep_blanks);
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/libxml2/libxml/parser.h:957:17: note: declared here
957 | xmlKeepBlanksDefault (int val);
| ^~~~~~~~~~~~~~~~~~~~
../postgresql/src/backend/utils/adt/xml.c:1961:17: warning: ‘xmlKeepBlanksDefault’ is deprecated [-Wdeprecated-declarations]
1961 | xmlKeepBlanksDefault(save_keep_blanks);
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/libxml2/libxml/parser.h:957:17: note: declared here
957 | xmlKeepBlanksDefault (int val);
| ^~~~~~~~~~~~~~~~~~~~

Is this known already?

Regards
Daniel

#2Daniel Gustafsson
daniel@yesql.se
In reply to: Daniel Westermann (DWE) (#1)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

On 17 Jul 2026, at 14:47, Daniel Westermann (DWE) <daniel.westermann@dbi-services.com> wrote:

[1086/2136] Compiling C object src/backend/postgres_lib.a.p/utils_adt_xml.c.o
../postgresql/src/backend/utils/adt/xml.c: In function ‘xml_parse’:
../postgresql/src/backend/utils/adt/xml.c:1924:25: warning: ‘xmlKeepBlanksDefault’ is deprecated [-Wdeprecated-declarations]
1924 | save_keep_blanks = xmlKeepBlanksDefault(preserve_whitespace ? 1 : 0);
| ^~~~~~~~~~~~~~~~
In file included from ../postgresql/src/backend/utils/adt/xml.c:51:

Which version of libxml2 do you have installed?

--
Daniel Gustafsson

#3Daniel Westermann (DWE)
daniel.westermann@dbi-services.com
In reply to: Daniel Gustafsson (#2)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

On 17 Jul 2026, at 14:47, Daniel Westermann (DWE) <daniel.westermann@dbi-services.com> wrote:

[1086/2136] Compiling C object src/backend/postgres_lib.a.p/utils_adt_xml.c.o
../postgresql/src/backend/utils/adt/xml.c: In function ‘xml_parse’:
../postgresql/src/backend/utils/adt/xml.c:1924:25: warning: ‘xmlKeepBlanksDefault’ is deprecated [-Wdeprecated-declarations]
1924 |                         save_keep_blanks = xmlKeepBlanksDefault(preserve_whitespace ? 1 : 0);
      |                         ^~~~~~~~~~~~~~~~
In file included from ../postgresql/src/backend/utils/adt/xml.c:51:

Which version of libxml2 do you have installed?

The standard on Rocky 10:

postgres@rocky10-pgbox:/home/postgres/ [pg20] rpm -qa | grep libxml2
libxml2-2.12.5-10.el10_2.2.x86_64
libxml2-devel-2.12.5-10.el10_2.2.x86_64

Regards
Daniel

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Daniel Westermann (DWE) (#1)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

"Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com> writes:

I've just noticed this while building from the dev branch on Rocky 10.2 x64:
../postgresql/src/backend/utils/adt/xml.c:1961:17: warning: ‘xmlKeepBlanksDefault’ is deprecated [-Wdeprecated-declarations]
1961 | xmlKeepBlanksDefault(save_keep_blanks);
| ^~~~~~~~~~~~~~~~~~~~

Is this known already?

Yeah. It's annoying as heck, because they deprecated that without
providing an adequate replacement. The replacement is claimed to
be "Use the modern options API with XML_PARSE_NOBLANKS", but there
is no direct equivalent to xmlParseBalancedChunkMemory that takes
an options argument.

So to get rid of this, we're looking at a probably-nontrivial
rewrite of xml_parse(), with possibly some user-visible behavioral
changes, and who-knows-what effects for compatibility across
different libxml2 versions.

If you feel like researching that, have at it.

regards, tom lane

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#4)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

On 2026-07-17 Fr 10:38 AM, Tom Lane wrote:

"Daniel Westermann (DWE)" <daniel.westermann@dbi-services.com> writes:

I've just noticed this while building from the dev branch on Rocky 10.2 x64:
../postgresql/src/backend/utils/adt/xml.c:1961:17: warning: ‘xmlKeepBlanksDefault’ is deprecated [-Wdeprecated-declarations]
1961 | xmlKeepBlanksDefault(save_keep_blanks);
| ^~~~~~~~~~~~~~~~~~~~
Is this known already?

Yeah. It's annoying as heck, because they deprecated that without
providing an adequate replacement. The replacement is claimed to
be "Use the modern options API with XML_PARSE_NOBLANKS", but there
is no direct equivalent to xmlParseBalancedChunkMemory that takes
an options argument.

So to get rid of this, we're looking at a probably-nontrivial
rewrite of xml_parse(), with possibly some user-visible behavioral
changes, and who-knows-what effects for compatibility across
different libxml2 versions.

If you feel like researching that, have at it.

I think we can probably use xmlParseInNodeContext(), which does take an
options argument. Did you look at that?

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#5)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

Andrew Dunstan <andrew@dunslane.net> writes:

On 2026-07-17 Fr 10:38 AM, Tom Lane wrote:

Yeah. It's annoying as heck, because they deprecated that without
providing an adequate replacement. The replacement is claimed to
be "Use the modern options API with XML_PARSE_NOBLANKS", but there
is no direct equivalent to xmlParseBalancedChunkMemory that takes
an options argument.

I think we can probably use xmlParseInNodeContext(), which does take an
options argument. Did you look at that?

Hmm ... I think I was confused by the fact that it takes "const char
*data" not "const xmlChar *string". On further research, those are
more equivalent than I'd thought. So maybe it'll work.

regards, tom lane

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#6)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

I wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

I think we can probably use xmlParseInNodeContext(), which does take an
options argument. Did you look at that?

Hmm ... I think I was confused by the fact that it takes "const char
*data" not "const xmlChar *string". On further research, those are
more equivalent than I'd thought. So maybe it'll work.

Here's a quick draft that passes check-world, which is enough to give
me no faith whatsoever. Maybe somebody who knows XML better than me
can break it. One thing I'm pretty unsure about is having to cons up
a dummy root node, which is necessary because xmlParseInNodeContext
takes a parent node not a parent doc. Is that correct? In the case
where we don't call xmlParseInNodeContext because the string is empty,
should we still make that node or just leave the document root-less?

regards, tom lane

Attachments:

0001-avoid-xmlKeepBlanksDefault.patchtext/x-diff; charset=us-ascii; name=0001-avoid-xmlKeepBlanksDefault.patchDownload+44-29
#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#7)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

I wrote:

Here's a quick draft that passes check-world, which is enough to give
me no faith whatsoever. Maybe somebody who knows XML better than me
can break it. One thing I'm pretty unsure about is having to cons up
a dummy root node, which is necessary because xmlParseInNodeContext
takes a parent node not a parent doc. Is that correct? In the case
where we don't call xmlParseInNodeContext because the string is empty,
should we still make that node or just leave the document root-less?

After studying the libxml2 source code I realized that
xmlParseInNodeContext doesn't automatically attach anything at all to
the passed-in node or its document; those are used only as context.
So I think we can clean this up noticeably by attaching the content
node list to that root node instead of returning it separately.
Essentially, this is moving the data structure hacking that
xmltotext_with_options did into xml_parse. Here's a slightly less
hasty version.

regards, tom lane

Attachments:

t253104_8
v2-0001-Modernize-our-parsing-of-XML-data-in-CONTENT-mode.patchtext/x-diff; charset=us-ascii; name*0=v2-0001-Modernize-our-parsing-of-XML-data-in-CONTENT-mode.p; name*1=atchDownload+66-68
#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#8)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

I wrote:

After studying the libxml2 source code I realized that
xmlParseInNodeContext doesn't automatically attach anything at all to
the passed-in node or its document; those are used only as context.
So I think we can clean this up noticeably by attaching the content
node list to that root node instead of returning it separately.
Essentially, this is moving the data structure hacking that
xmltotext_with_options did into xml_parse. Here's a slightly less
hasty version.

The cfbot pointed out that this patch is drawing warnings since
3ee0edb91 added -Wshadow=local. Here's a less shadow-y version;
no substantive change.

regards, tom lane

Attachments:

t253104_9
v3-0001-Modernize-our-parsing-of-XML-data-in-CONTENT-mode.patchtext/x-diff; charset=us-ascii; name*0=v3-0001-Modernize-our-parsing-of-XML-data-in-CONTENT-mode.p; name*1=atchDownload+66-68
#10Rui Zhao
zhaorui126@gmail.com
In reply to: Tom Lane (#9)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

Hi Tom,

Thanks for updating the XML content parser. I compared v3 with master
at 412848dac37 and found two changes in XMLSERIALIZE ... INDENT output
with older libxml2 versions.

I tested with libxml2 2.9.7 from my system, an upstream build of 2.12.5
to match the version reported in this thread, and the latest upstream
release, 2.15.4.

1. With libxml2 2.9.7, v3 drops U+FEFF after the XML declaration.
The attached 0001 fixes this and adds a regression test.

In a UTF8 database:

SELECT xmlserialize(CONTENT xmlparse(CONTENT
'<?xml version="1.0"?>' || chr(65279) || 'abc') AS text INDENT);

master: &#xFEFF;abc
v3: abc
v3 + 0001: &#xFEFF;abc

chr(65279) is U+FEFF, the character used as a byte-order mark (BOM).
Here it follows the XML declaration and is part of the content.
xml_parse() skips the declaration
<?xml version="1.0"?> before calling xmlParseInNodeContext(), leaving
U+FEFF at the start of its input.
With doc->encoding set to UTF-8, libxml2 2.9.7 calls
xmlSwitchToEncoding() and removes the character as a BOM.

0001 moves the doc->encoding assignment after xmlParseInNodeContext().
The input is already UTF-8, so the parser can read it with doc->encoding
unset.

To check whether setting doc->encoding to UTF-8 later could cause
other problems, I read the libxml2 source. I checked all functions
called between the old and new assignment locations in versions
2.9.7, 2.12.5 and 2.15.4.

xmlDocSetRootElement(), xmlAddChildList() and their helpers do not use
doc->encoding. xmlParseInNodeContext() reads it to set the input
encoding in all three versions. xml_parse() has already converted the
input to UTF-8, which this parser also uses with doc->encoding unset.
Only 2.9.7 strips U+FEFF during explicit encoding setup.
0001 sets doc->encoding to UTF-8 after xmlParseInNodeContext(),
before xml_parse() returns. The XML output still uses the same encoding.
I found no other side effects in these functions.

Master and v3 already retain U+FEFF with libxml2 2.12.5 and 2.15.4.
With libxml2 2.9.7, the new test fails on v3 and passes on v3 + 0001.
It also passes on v3 + 0001 with 2.12.5 and 2.15.4.

2. With libxml2 2.9.7 and 2.12.5, v3 removes the space between <a/>
and <b/> in this mixed-content input:

SELECT replace(xmlserialize(CONTENT 'abc<a/> <b/>' AS text INDENT),
E'\n', E'\\n');

master: abc\n<a/> \n<b/>
v3: abc\n<a/>\n<b/>
v3 + 0001 + 0002: abc\n<a/> \n<b/>

I traced this to areBlanks() in libxml2 2.12.5. One of the checks in
its source keeps whitespace when the parent's first child is a text
node. With the old API, that child is the text node "abc", so the
space between <a/> and <b/> is kept. xmlParseInNodeContext() inserts
a temporary comment before "abc". The first child is then a comment,
so that check no longer preserves the space, and the parser removes it.

With libxml2 2.15.4, both master and v3 retain the space, but PG users
can still use old versions.

0002 fixes this in xml_parse() by adding an empty text child to the
dummy root before xmlParseInNodeContext(), then removing it after
parsing. This gives areBlanks() a text node as the first child again.
It does this when whitespace removal is enabled and the content starts
with nonblank text or a character reference. Leading literal whitespace
is left alone.

0001 applies on top of v3, and 0002 applies on top of 0001. With both
patches, all 239 core regression tests passed on each of the three
libxml2 versions.

3. I also tried keeping xmlParseBalancedChunkMemory() and passing an
xmlSAXHandler to control whitespace instead of calling
xmlKeepBlanksDefault(). In xml_parse(), the key change was:

xmlSAXHandler sax;

memset(&sax, 0, sizeof(sax));
xmlSAXVersion(&sax, 2);
if (!preserve_whitespace)
sax.ignorableWhitespace = xmlSAX2IgnorableWhitespace;

res_code = xmlParseBalancedChunkMemory(doc, &sax, NULL, 0,
utf8string + count,
parsed_nodes);

This is a small change. Both examples above and all 239 core
regression tests passed with all three libxml2 versions.
However, on 2.9.7 and 2.12.5, forcing the parser's internal xmlNewDoc()
to fail aborted the PostgreSQL backend. In libxml2 2.12.5,
xmlParseBalancedChunkMemory() calls
xmlParseBalancedChunkMemoryRecover(), which has these two error paths:

/* This return does not free the caller's sax. */
ctxt = xmlCreateDocParserCtxt(string);
if (ctxt == NULL) return(-1);

/* This later failure frees it through xmlFreeParserCtxt(). */
oldsax = ctxt->sax;
ctxt->sax = sax;
newDoc = xmlNewDoc(BAD_CAST "1.0");
if (newDoc == NULL) {
xmlFreeParserCtxt(ctxt);
return(-1);
}

xmlFreeParserCtxt() frees our xmlSAXHandler with:

xmlFree(ctxt->sax);

This is an invalid free for a stack handler. Normal cleanup restores
oldsax first, but the xmlNewDoc() failure path does not.

Allocating sax on the heap does not solve this: both errors return -1,
but only the second frees sax. PG cannot tell which error occurred.
Calling xmlFree(sax) on every error would double-free it after the
xmlNewDoc() failure. Skipping cleanup would leak it after the
xmlCreateDocParserCtxt() failure.

Since libxml2 2.13.0, the parser makes its own copy of the caller's
xmlSAXHandler, avoiding this error path [1]https://gitlab.gnome.org/GNOME/libxml2/-/commit/ecfbcc8a. But PostgreSQL still
supports the affected older libraries, so I dropped the SAX alternative.

The warning comes from the deprecated xmlKeepBlanksDefault(). Its
documentation recommends parser options with XML_PARSE_NOBLANKS [2]https://gnome.pages.gitlab.gnome.org/libxml2/html/parser_8h.html.
xmlParseBalancedChunkMemory() has no options parameter, while
xmlParseInNodeContext() does, as Andrew pointed out. Your change thus
removes the deprecated calls while still controlling whitespace.

The docs also suggest xmlCtxtParseContent() as an alternative to
xmlParseInNodeContext(), but it is only available since 2.14. Given
the older versions PostgreSQL supports and the results above, I think
your approach is the best fit for this change, with these two fixes.

[1]: https://gitlab.gnome.org/GNOME/libxml2/-/commit/ecfbcc8a
[2]: https://gnome.pages.gitlab.gnome.org/libxml2/html/parser_8h.html

Regards,
Rui

Attachments:

nocfbot-0001-Fix-loss-of-leading-U-FEFF-in-XML-content-parsing.patchapplication/octet-stream; name=nocfbot-0001-Fix-loss-of-leading-U-FEFF-in-XML-content-parsing.patchDownload+44-6
nocfbot-0002-Preserve-spaces-after-leading-text-in-XML-content.patchapplication/octet-stream; name=nocfbot-0002-Preserve-spaces-after-leading-text-in-XML-content.patchDownload+58-1
#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rui Zhao (#10)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

Rui Zhao <zhaorui126@gmail.com> writes:

Thanks for updating the XML content parser. I compared v3 with master
at 412848dac37 and found two changes in XMLSERIALIZE ... INDENT output
with older libxml2 versions.

Thanks for looking at it!

1. With libxml2 2.9.7, v3 drops U+FEFF after the XML declaration.

Wow, how'd you find that? I do replicate this result on the 2.9.13
that Apple is currently shipping, so I agree it might be worth
worrying about. (But then again, it seems very likely nobody would
ever notice.)

The attached 0001 fixes this and adds a regression test.

Hmm, 0001 seems quite odd to me. Why bother to install a value for
doc->encoding at all, if we're not going to do so until after all
the calls that will pay attention to it? I tried simply commenting
out the assignment:

Assert(doc->encoding == NULL);
+ #ifdef NOT_USED
doc->encoding = xmlStrdup((const xmlChar *) "UTF-8");
if (doc->encoding == NULL || xmlerrcxt->err_occurred)
xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY,
"could not allocate XML document");
+ #endif
doc->standalone = standalone;

and that seemed to work fine.

2. With libxml2 2.9.7 and 2.12.5, v3 removes the space between <a/>
and <b/> in this mixed-content input:

SELECT replace(xmlserialize(CONTENT 'abc<a/> <b/>' AS text INDENT),
E'\n', E'\\n');

Hm. While that's not great, it sure seems like an edge case.
There is no particularly well-defined behavior for whitespace in
INDENT mode anyway, is there? How would you tell which whitespace
was in the original input and which was INDENT's responsibility?
So I'm kind of inclined to let it go. If the proposed fix weren't
so ugly I might feel differently, but it's messy, overly familiar
with libxml2 innards, and perhaps could introduce odd cases of its
own in libxml2 versions other than the ones you tested. Plus the
comments don't actually agree with what the code is doing AFAICT.
(Why do we not need to take action if the input has leading
whitespace? Wouldn't the injected comment mess it up anyway?)

On the whole, if this is the biggest behavioral change we can find
from switching to xmlParseInNodeContext, I think we're in pretty
good shape. I had feared that there might be much worse. My current
thought is to apply this patch to HEAD only, so if there are any
small behavioral changes that users notice, we can write them off
as expected in a major version update.

3. I also tried keeping xmlParseBalancedChunkMemory() and passing an
xmlSAXHandler to control whitespace instead of calling
xmlKeepBlanksDefault().

I agree that that isn't a good way to go. While libxml2 has only
officially deprecated SAX1, I wonder how much they like SAX2 either.
Even if that worry is baseless, it seems like making use of SAX would
greatly expand the amount of libxml2 API we're depending on --- and
their API behavior has not been so stable that I want to have more
surface area for problems.

The docs also suggest xmlCtxtParseContent() as an alternative to
xmlParseInNodeContext(), but it is only available since 2.14. Given
the older versions PostgreSQL supports and the results above, I think
your approach is the best fit for this change, with these two fixes.

Yeah, that suggestion isn't real helpful for our purposes.

So my current thought is to cut down 0001 so it just removes code
without adding any, and reject 0002 as not worth trying to fix.
OK by you?

Thanks again for reviewing!

regards, tom lane

#12Rui Zhao
zhaorui126@gmail.com
In reply to: Tom Lane (#11)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

Hi Tom,

Thanks for your reply.

Wow, how'd you find that? I do replicate this result on the 2.9.13
that Apple is currently shipping, so I agree it might be worth
worrying about. (But then again, it seems very likely nobody would
ever notice.)

I noticed that the main change replaced xmlParseBalancedChunkMemory()
with xmlParseInNodeContext(). I read the latter's source and saw its
handling of doc->encoding, then asked AI to help construct a case
where that could lose XML content.

Hmm, 0001 seems quite odd to me. Why bother to install a value for
doc->encoding at all, if we're not going to do so until after all
the calls that will pay attention to it? I tried simply commenting
out the assignment:

Assert(doc->encoding == NULL);
+ #ifdef NOT_USED
doc->encoding = xmlStrdup((const xmlChar *) "UTF-8");
if (doc->encoding == NULL || xmlerrcxt->err_occurred)
xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY,
"could not allocate XML document");
+ #endif
doc->standalone = standalone;

and that seemed to work fine.

I kept the assignment at the end of xml_parse() so later calls would
still get doc->encoding set to "UTF-8". I had checked xmlNewNode(),
xmlDocSetRootElement(), xmlParseInNodeContext() and xmlAddChildList()
in libxml2 2.9.7, 2.12.5 and 2.15.4. Leaving doc->encoding unset
during those calls fixed the U+FEFF loss without changing the later
serialization.

After your suggestion, I traced later uses of doc->encoding and asked
AI again to help construct a case. I verified it in PG with libxml2
2.9.7 and 2.12.5, in a UTF8 database:

SELECT xmlserialize(CONTENT '<a value="é"/>' AS text INDENT);
-- Master: <a value="é"/>
-- With 0001: <a value="é"/>
-- With #ifdef NOT_USED: <a value="&#xE9;"/>

The reason is that xmlSaveTree() calls xmlBufAttrSerializeTxtContent()
through xmlAttrSerializeContent(), passing attr->doc. It checks the
document's encoding; when that is NULL, non-ASCII attribute characters
are written as character references. Here, &#xE9; represents the same
é character.

Hm. While that's not great, it sure seems like an edge case.
There is no particularly well-defined behavior for whitespace in
INDENT mode anyway, is there? How would you tell which whitespace
was in the original input and which was INDENT's responsibility?
So I'm kind of inclined to let it go. If the proposed fix weren't
so ugly I might feel differently, but it's messy, overly familiar
with libxml2 innards, and perhaps could introduce odd cases of its
own in libxml2 versions other than the ones you tested. Plus the
comments don't actually agree with what the code is doing AFAICT.
(Why do we not need to take action if the input has leading
whitespace? Wouldn't the injected comment mess it up anyway?)

Agreed. The workaround could introduce other differences in library
versions. I'm happy to leave this INDENT whitespace behavior to libxml2
and drop 0002.

Regards,
Rui

#13Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rui Zhao (#12)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

Rui Zhao <zhaorui126@gmail.com> writes:

Hmm, 0001 seems quite odd to me. Why bother to install a value for
doc->encoding at all, if we're not going to do so until after all
the calls that will pay attention to it? I tried simply commenting
out the assignment:
...
and that seemed to work fine.

After your suggestion, I traced later uses of doc->encoding and asked
AI again to help construct a case. I verified it in PG with libxml2
2.9.7 and 2.12.5, in a UTF8 database:

SELECT xmlserialize(CONTENT '<a value="é"/>' AS text INDENT);
-- Master: <a value="é"/>
-- With 0001: <a value="é"/>
-- With #ifdef NOT_USED: <a value="&#xE9;"/>

Interesting! I had tried substantially the same test, but using
"ñ" as a body-text character, and that case seems to get output
as a hex reference no matter what. It didn't occur to me that
characters inside tag attributes might get treated differently.

So I'll use 0001 as you have it, but I think while I'm at it
I will add test coverage for these behaviors.

Agreed. The workaround could introduce other differences in library
versions. I'm happy to leave this INDENT whitespace behavior to libxml2
and drop 0002.

We're on the same page then. Thanks again for the review!

regards, tom lane

#14Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#13)
Re: Deprecation warnings on Rocky 10.2 with current dev branch

I wrote:

So I'll use 0001 as you have it, but I think while I'm at it
I will add test coverage for these behaviors.

Pushed. I shall now watch the buildfarm from a safe distance.

regards, tom lane