diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-03-01 03:41:29 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-03-01 03:41:29 +0000 |
commit | 5cdd478bd08922f963dae32e47bcb2ef8f0836af (patch) | |
tree | e320021db1b8165ccd4ce3e0d4f320482d8b650d /contrib/xml2/xslt_proc.c | |
parent | 118e1cbec2d3e21a546caba9926e172964a9cb78 (diff) | |
download | postgresql-5cdd478bd08922f963dae32e47bcb2ef8f0836af.tar.gz postgresql-5cdd478bd08922f963dae32e47bcb2ef8f0836af.zip |
Back-patch today's memory management fixups in contrib/xml2.
Prior to 8.3, these changes are not critical for compatibility with core
Postgres, since core had no libxml2 calls then. However there is still
a risk if contrib/xml2 is used along with libxml2 functionality in Perl
or other loadable modules. So back-patch to all versions.
Also back-patch addition of regression tests. I'm not sure how many of
the cases are interesting without the interaction with core xml code,
but a silly regression test is still better than none at all.
Diffstat (limited to 'contrib/xml2/xslt_proc.c')
-rw-r--r-- | contrib/xml2/xslt_proc.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c index 38c28c6d956..18d9879fcfc 100644 --- a/contrib/xml2/xslt_proc.c +++ b/contrib/xml2/xslt_proc.c @@ -21,22 +21,21 @@ #include <libxslt/xsltutils.h> -/* declarations to come from xpath.c */ +/* externally accessible functions */ -extern void elog_error(int level, char *explain, int force); -extern void pgxml_parser_init(); -extern xmlChar *pgxml_texttoxmlchar(text *textstring); +Datum xslt_process(PG_FUNCTION_ARGS); -#define GET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp))) +/* declarations to come from xpath.c */ +extern void elog_error(const char *explain, bool force); +extern void pgxml_parser_init(void); /* local defs */ static void parse_params(const char **params, text *paramstr); -Datum xslt_process(PG_FUNCTION_ARGS); - - #define MAXPARAMS 20 /* must be even, see parse_params() */ +#define GET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp))) + PG_FUNCTION_INFO_V1(xslt_process); @@ -82,7 +81,7 @@ xslt_process(PG_FUNCTION_ARGS) if (doctree == NULL) { xmlCleanupParser(); - elog_error(ERROR, "Error parsing XML document", 0); + elog_error("Error parsing XML document", false); PG_RETURN_NULL(); } @@ -96,7 +95,7 @@ xslt_process(PG_FUNCTION_ARGS) { xmlFreeDoc(doctree); xmlCleanupParser(); - elog_error(ERROR, "Error parsing stylesheet as XML document", 0); + elog_error("Error parsing stylesheet as XML document", false); PG_RETURN_NULL(); } @@ -111,7 +110,7 @@ xslt_process(PG_FUNCTION_ARGS) xmlFreeDoc(doctree); xsltCleanupGlobals(); xmlCleanupParser(); - elog_error(ERROR, "Failed to parse stylesheet", 0); + elog_error("Failed to parse stylesheet", false); PG_RETURN_NULL(); } |