pgsql: Rewrite libxml error handling to be more robust.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rewrite libxml error handling to be more robust.
Date: 2011-07-20 17:04:18
Message-ID: E1QjaC2-000481-PC@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Rewrite libxml error handling to be more robust.

libxml reports some errors (like invalid xmlns attributes) via the error
handler hook, but still returns a success indicator to the library caller.
This causes us to miss some errors that are important to report. Since the
"generic" error handler hook doesn't know whether the message it's getting
is for an error, warning, or notice, stop using that and instead start
using the "structured" error handler hook, which gets enough information
to be useful.

While at it, arrange to save and restore the error handler hook setting in
each libxml-using function, rather than assuming we can set and forget the
hook. This should improve the odds of working nicely with third-party
libraries that also use libxml.

In passing, volatile-ize some local variables that get modified within
PG_TRY blocks. I noticed this while testing with an older gcc version
than I'd previously tried to compile xml.c with.

Florian Pflug and Tom Lane, with extensive review/testing by Noah Misch

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/cacd42d62cb2ddf32135b151f627780a5509780f

Modified Files
--------------
configure | 69 +++++
configure.in | 17 ++
contrib/xml2/xpath.c | 131 ++++++---
contrib/xml2/xslt_proc.c | 56 +++--
src/backend/utils/adt/xml.c | 541 ++++++++++++++++++++++++++---------
src/include/pg_config.h.in | 3 +
src/include/utils/xml.h | 46 ++-
src/test/regress/expected/xml.out | 160 ++++++++++-
src/test/regress/expected/xml_1.out | 97 +++++++
src/test/regress/sql/xml.sql | 38 +++
10 files changed, 939 insertions(+), 219 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2011-07-20 17:18:39 pgsql: Support SECURITY LABEL on databases, tablespaces, and roles.
Previous Message Robert Haas 2011-07-20 13:25:24 pgsql: Improve sepgsql and SECURITY LABEL documentation.