Re: libxml incompatibility

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, David Lee Lambert <davidl(at)lmert(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: libxml incompatibility
Date: 2009-03-22 03:16:46
Message-ID: 4223.1237691806@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> We could possibly use xmlMemGet() to fetch the prior settings and then
> restore them after we are done, but making sure that happens after an
> error would be a bit tricky.

I experimented with this a bit, and came up with the attached patch.
Basically what it does is revert libxml to its native memory management
methods anytime LibxmlContext doesn't exist. It fixes Alvaro's original
test case and some variants that I stumbled across, but I can't say that
I have a lot of faith in it. I see at least a couple of risk factors:

* it doesn't scale to the case where some other code is doing the same
kind of thing --- the pointers we saved during xml_init might or might
not still be appropriate to restore at end of transaction.

* suppose that a plperl function does some Perlish XML stuff, then calls
a SQL function that calls something in xml.c. When we start up use of
LibxmlContext we'll wipe the internal state of libxml (which we *have*
to do; this still crashes trivially without the added xmlCleanupParser
call). Can this break anything that the perl XML code is expecting to
still be valid when control gets back to it?

If this doesn't work then I'm afraid we'll need some radical rethinking
of the way we handle libxml memory management...

Please test. I'm not much with either Perl or XML and have little
idea of how to stress this.

regards, tom lane

Attachment Content-Type Size
unknown_filename text/plain 3.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-03-22 03:55:54 Re: contrib function naming, and upgrade issues
Previous Message Bruce Momjian 2009-03-22 01:56:48 Re: Open 8.4 item list