Обсуждение: pgsql: Rewrite libxml error handling to be more robust.

Поиск
Список
Период
Сортировка

pgsql: Rewrite libxml error handling to be more robust.

От
Tom Lane
Дата:
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(-)