Deprecation warnings on Rocky 10.2 with current dev branch

Started by Daniel Westermann (DWE)8 days ago8 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:

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