Deprecation warnings on Rocky 10.2 with current dev branch
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
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
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
"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
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
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
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
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