Re: Use \if/\endif to remove non-libxml2 expected output in regression tests

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Daniel Gustafsson <daniel@yesql.se>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-12T23:21:28Z
Lists: pgsql-hackers

Attachments

I wrote:
> It's kind of sad that this issue is still present in the wild ten
> years later.  But anyway, I wonder if we could dodge the issue
> simply by modifying these error-provoking cases to have some
> whitespace at the end of the XML input?  I don't think I have
> a problematic version of libxml2 to test that with, though.

Hah, this idea does mostly work.  Finding that no system I had at
hand had a libxml2 old enough to exhibit the problem, I installed
libxml2 2.9.3 from source.  (That's the first version containing
the problematic CVE fix, and it does behave as xml_2.out expects.)
I found that four of the inconsistent messages could be fixed this
way.  The other three problem cases have input like '<wrong' or
all-spaces, and evidently we need the error to be recognized before
reaching end-of-input.

Now, it seems to me that we are not especially interested in whether
libxml2 produces one error message or another one for given input;
what we need to test is only that Postgres reports the error
properly.  So I don't have a problem with tweaking those bad inputs
a bit more aggressively to make them be something that different
libxml2 versions will report identically.  The result of my
experiments is attached: it results in expected/xml.out that matches
the output of both 2.9.3 and recent versions.  So if we do this
we could drop xml_2.out.

This patch is WIP because I've not updated xml_1.out to match.
But that's trivial, and dropping xml_2.out is equally boring,
so I left those parts out of this demo patch.

			regards, tom lane

Commits

  1. Trim regression test expected output for xml

  2. Add an expected-file to match behavior of latest libxml2.