Hi hackers, There is a breaking change of API since the v2.12.0 of libxml2[1][2]. My compiler complains about incompatible function signatures:
/usr/bin/clang -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing -format-attribute -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-unused-command-line-argument -Wno-compou nd-token-split-by-macro -Wno-cast-function-type-strict -g -Og -g3 -I. -I. -I../../../../src/include -D_GNU_SOURCE -I/usr/include/libxml2 -c -o xml.o xml.c xml.c:1199:45: error: incompatible function pointer types passing 'void (void *, xmlErrorPtr)' (aka 'void (void *, struct _xmlError *)') to parameter of type ' xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types] xmlSetStructuredErrorFunc((void *) errcxt, xml_errorHandler); ^~~~~~~~~~~~~~~~ /usr/include/libxml2/libxml/xmlerror.h:898:29: note: passing argument to parameter 'handler' here xmlStructuredErrorFunc handler); ^ xml.c:4806:55: error: incompatible function pointer types passing 'void (void *, xmlErrorPtr)' (aka 'void (void *, struct _xmlError *)') to parameter of type ' xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types] xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler); ^~~~~~~~~~~~~~~~ /usr/include/libxml2/libxml/xmlerror.h:898:29: note: passing argument to parameter 'handler' here xmlStructuredErrorFunc handler); ^ xml.c:4860:55: error: incompatible function pointer types passing 'void (void *, xmlErrorPtr)' (aka 'void (void *, struct _xmlError *)') to parameter of type ' xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types] xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler); ^~~~~~~~~~~~~~~~ /usr/include/libxml2/libxml/xmlerror.h:898:29: note: passing argument to parameter 'handler' here xmlStructuredErrorFunc handler); ^ xml.c:5003:55: error: incompatible function pointer types passing 'void (void *, xmlErrorPtr)' (aka 'void (void *, struct _xmlError *)') to parameter of type ' xmlStructuredErrorFunc' (aka 'void (*)(void *, const struct _xmlError *)') [-Wincompatible-function-pointer-types] xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler); ^~~~~~~~~~~~~~~~ /usr/include/libxml2/libxml/xmlerror.h:898:29: note: passing argument to parameter 'handler' here xmlStructuredErrorFunc handler); ^ 4 errors generated. make[4]: *** [<builtin>: xml.o] Error 1 Here is a quick workaround for it. [1] https://github.com/GNOME/libxml2/commit/61034116d0a3c8b295c6137956adc3ae55720711 [2] https://github.com/GNOME/libxml2/commit/45470611b047db78106dcb2fdbd4164163c15ab7 Best Regards, Xing
From bded3361f7f2ac7b4734d59de8ddb07875d9489d Mon Sep 17 00:00:00 2001 From: Xing Guo <higuox...@gmail.com> Date: Sun, 3 Dec 2023 23:09:51 +0800 Subject: [PATCH v1] Make PostgreSQL work with newer version of libxml2. There's a breaking change of API since v2.12.0 of libxml2. This patch helps resolve it. See: https://github.com/GNOME/libxml2/commit/61034116d0a3c8b295c6137956adc3ae55720711 --- src/backend/utils/adt/xml.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index c401e7b821..8a391ca5fa 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -124,7 +124,11 @@ static xmlParserInputPtr xmlPgEntityLoader(const char *URL, const char *ID, xmlParserCtxtPtr ctxt); static void xml_errsave(Node *escontext, PgXmlErrorContext *errcxt, int sqlcode, const char *msg); +#if LIBXML_VERSION >= 21200 +static void xml_errorHandler(void *data, const xmlError *error); +#else static void xml_errorHandler(void *data, xmlErrorPtr error); +#endif static int errdetail_for_xml_code(int code); static void chopStringInfoNewlines(StringInfo str); static void appendStringInfoLineSeparator(StringInfo str); @@ -2023,8 +2027,11 @@ xml_errsave(Node *escontext, PgXmlErrorContext *errcxt, /* * Error handler for libxml errors and warnings */ -static void -xml_errorHandler(void *data, xmlErrorPtr error) +#if LIBXML_VERSION >= 21200 +static void xml_errorHandler(void *data, const xmlError *error) +#else +static void xml_errorHandler(void *data, xmlErrorPtr error) +#endif { PgXmlErrorContext *xmlerrcxt = (PgXmlErrorContext *) data; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt; -- 2.43.0