Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rUU2S-00BB4I-L3 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jan 2024 15:59:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rUU2R-00FKEI-Ku for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jan 2024 15:59:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rUU2R-00FKE9-C1 for pgsql-hackers@lists.postgresql.org; Mon, 29 Jan 2024 15:59:11 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rUU2O-003zcN-TL for pgsql-hackers@lists.postgresql.org; Mon, 29 Jan 2024 15:59:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 40TFx6ul1883325; Mon, 29 Jan 2024 10:59:06 -0500 From: Tom Lane To: Peter Eisentraut cc: pgsql-hackers@lists.postgresql.org Subject: Re: PG versus libxml2 2.12.x In-reply-to: <1784723.1706541587@sss.pgh.pa.us> References: <1389505.1706382262@sss.pgh.pa.us> <1784723.1706541587@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 29 Jan 2024 10:19:47 -0500" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1883066.1706543896.0@sss.pgh.pa.us> Date: Mon, 29 Jan 2024 10:59:06 -0500 Message-ID: <1883324.1706543946@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1883066.1706543896.1@sss.pgh.pa.us> I wrote: > Peter Eisentraut writes: >> In PL/Tcl, we used to have these CONST84 and CONST86 things, for similar >> reasons. Maybe that would be another approach. > Yeah, if the simple cast approach turns out to create warnings, > we'll have to fall back on using actually different declarations. > I'm hoping to not have to go there. Actually ... what I really want to avoid is adding a configure test. The alternative to that would be an #if test on LIBXML_VERSION, which I'd initially not wanted to do ... but I now notice that we already have one of those for a nearby purpose (coping with a different change in libxml2's error APIs). So adding another one of those doesn't seem so bad after all. I now like the attached approach better. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="v2-cope-with-libxml2-API-changes.patch"; charset="us-ascii" Content-ID: <1883066.1706543896.2@sss.pgh.pa.us> Content-Description: v2-cope-with-libxml2-API-changes.patch Content-Transfer-Encoding: quoted-printable diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index a967257546..b999b1f706 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -74,8 +74,6 @@ pgxml_parser_init(PgXmlStrictness strictness) /* Initialize libxml */ xmlInitParser(); = - xmlLoadExtDtdDefaultValue =3D 1; - return xmlerrcxt; } = diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index f869c680af..3e24aba546 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -67,6 +67,16 @@ #if LIBXML_VERSION >=3D 20704 #define HAVE_XMLSTRUCTUREDERRORCONTEXT 1 #endif + +/* + * libxml2 2.12 decided to insert "const" into the error handler API. + */ +#if LIBXML_VERSION >=3D 21200 +#define PgXmlErrorPtr const xmlError * +#else +#define PgXmlErrorPtr xmlErrorPtr +#endif + #endif /* USE_LIBXML */ = #include "access/htup_details.h" @@ -124,7 +134,7 @@ static xmlParserInputPtr xmlPgEntityLoader(const char = *URL, const char *ID, xmlParserCtxtPtr ctxt); static void xml_errsave(Node *escontext, PgXmlErrorContext *errcxt, int sqlcode, const char *msg); -static void xml_errorHandler(void *data, xmlErrorPtr error); +static void xml_errorHandler(void *data, PgXmlErrorPtr error); static int errdetail_for_xml_code(int code); static void chopStringInfoNewlines(StringInfo str); static void appendStringInfoLineSeparator(StringInfo str); @@ -2024,7 +2034,7 @@ xml_errsave(Node *escontext, PgXmlErrorContext *errc= xt, * Error handler for libxml errors and warnings */ static void -xml_errorHandler(void *data, xmlErrorPtr error) +xml_errorHandler(void *data, PgXmlErrorPtr error) { PgXmlErrorContext *xmlerrcxt =3D (PgXmlErrorContext *) data; xmlParserCtxtPtr ctxt =3D (xmlParserCtxtPtr) error->ctxt; ------- =_aaaaaaaaaa0--