Skip site navigation (1) Skip section navigation (2)

pgsql: Rewrite xml.c's memory management (yet again).

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rewrite xml.c's memory management (yet again).
Date: 2009-05-13 20:27:18
Message-ID: 20090513202718.13B6D754065@cvs.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Rewrite xml.c's memory management (yet again).  Give up on the idea of
redirecting libxml's allocations into a Postgres context.  Instead, just let
it use malloc directly, and add PG_TRY blocks as needed to be sure we release
libxml data structures in error recovery code paths.  This is ugly but seems
much more likely to play nicely with third-party uses of libxml, as seen in
recent trouble reports about using Perl XML facilities in pl/perl and bug
#4774 about contrib/xml2.

I left the code for allocation redirection in place, but it's only
built/used if you #define USE_LIBXMLCONTEXT.  This is because I found it
useful to corral libxml's allocations in a palloc context when hunting
for libxml memory leaks, and we're surely going to have more of those
in the future with this type of approach.  But we don't want it turned on
in a normal build because it breaks exactly what we need to fix.

I have not re-indented most of the code sections that are now wrapped
by PG_TRY(); that's for ease of review.  pg_indent will fix it.

This is a pre-existing bug in 8.3, but I don't dare back-patch this change
until it's gotten a reasonable amount of field testing.

Modified Files:
--------------
    pgsql/src/backend/access/transam:
        xact.c (r1.272 -> r1.273)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/transam/xact.c?r1=1.272&r2=1.273)
    pgsql/src/backend/utils/adt:
        xml.c (r1.87 -> r1.88)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/xml.c?r1=1.87&r2=1.88)
    pgsql/src/include/utils:
        xml.h (r1.25 -> r1.26)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/xml.h?r1=1.25&r2=1.26)

pgsql-committers by date

Next:From: User DimDate: 2009-05-13 20:52:23
Subject: preprepare - preprepare: New Directory
Previous:From: User DimDate: 2009-05-13 16:16:38
Subject: preprepare - preprepare: Imported Sources

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group