]> granicus.if.org Git - postgresql/commit
Fix up memory management problems in contrib/xml2.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Feb 2010 21:31:57 +0000 (21:31 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Feb 2010 21:31:57 +0000 (21:31 +0000)
commit936c4af1c6876e09e914eca91c37949e6885b02e
tree2226289dd6b3d80d3f53255204cd5f00d898ff8e
parent7d7db18a68b7a16df85e8dc9d345b3ee7f39d460
Fix up memory management problems in contrib/xml2.

Get rid of the code that attempted to funnel libxml2's memory allocations
into palloc.   We already knew from experience with the core xml datatype
that trying to do this is simply not reliable.  Unlike the core code, I
did not bother adding a lot of PG_TRY/PG_CATCH logic to try to ensure that
everything is cleaned up on error exit.  Hence, we might leak some memory
if one of these functions fails partway through.  Given the deprecated
status of this contrib module and the fact that errors partway through
the functions shouldn't be too common, it doesn't seem worth worrying about.

Also fix a separate bug in xpath_table, that it did the wrong things
if given a result tuple descriptor with less than 2 columns.  While
such a case isn't very useful in practice, we shouldn't fail or stomp
memory when it occurs.

Add some simple regression tests based on all the reported crash cases
that I have on hand.

This should be back-patched, but let's see if the buildfarm likes it first.
contrib/xml2/Makefile
contrib/xml2/expected/xml2.out [new file with mode: 0644]
contrib/xml2/sql/xml2.sql [new file with mode: 0644]
contrib/xml2/xpath.c