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 1rTnyl-006QJx-MN for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jan 2024 19:04:36 +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 1rTnyi-007Cnq-7i for pgsql-hackers@arkaria.postgresql.org; Sat, 27 Jan 2024 19:04:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rTnyh-007Cnh-UO for pgsql-hackers@lists.postgresql.org; Sat, 27 Jan 2024 19:04:31 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rTnyb-00426j-0N for pgsql-hackers@lists.postgresql.org; Sat, 27 Jan 2024 19:04:31 +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 40RJ4MFq1389506 for ; Sat, 27 Jan 2024 14:04:22 -0500 From: Tom Lane To: pgsql-hackers@lists.postgresql.org Subject: PG versus libxml2 2.12.x MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <1389428.1706382218.0@sss.pgh.pa.us> Date: Sat, 27 Jan 2024 14:04:22 -0500 Message-ID: <1389505.1706382262@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: <1389428.1706382218.1@sss.pgh.pa.us> Buildfarm member caiman has been failing build for a couple weeks now. The reason turns out to be that recent libxml2 has decided to throw a "const" into the signature required for custom error handlers. (API compatibility? What's that?) I don't mind adopting the "const" --- it's a good idea in isolation. The trouble is in fixing our code to work with both old and new libxml2 versions. We could thrash around with a configure test or something, but I think the most expedient answer is just to insert some explicit casts, as shown in the attached. It's possible though that some compilers will throw a cast-away-const warning. I'm not seeing any, but ... Also, I'm seeing a deprecation warning in contrib/xml2/xpath.c for xmlLoadExtDtdDefaultValue = 1; I'm not sure why that's still there, given that we disabled external DTD access ages ago. I propose we just remove it. In short, I suggest the attached. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="v1-cope-with-libxml2-API-changes.patch"; charset="us-ascii" Content-ID: <1389428.1706382218.2@sss.pgh.pa.us> Content-Description: v1-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..a6734f3550 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -124,7 +124,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, const xmlError *error); static int errdetail_for_xml_code(int code); static void chopStringInfoNewlines(StringInfo str); static void appendStringInfoLineSeparator(StringInfo str); @@ -1196,7 +1196,8 @@ pg_xml_init(PgXmlStrictness strictness) errcxt->saved_errcxt =3D xmlGenericErrorContext; #endif = - xmlSetStructuredErrorFunc((void *) errcxt, xml_errorHandler); + xmlSetStructuredErrorFunc((void *) errcxt, + (xmlStructuredErrorFunc) xml_errorHandler); = /* * Verify that xmlSetStructuredErrorFunc set the context variable we @@ -2024,7 +2025,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, const xmlError *error) { PgXmlErrorContext *xmlerrcxt =3D (PgXmlErrorContext *) data; xmlParserCtxtPtr ctxt =3D (xmlParserCtxtPtr) error->ctxt; @@ -4803,7 +4804,8 @@ XmlTableFetchRow(TableFuncScanState *state) xtCxt =3D GetXmlTableBuilderPrivateData(state, "XmlTableFetchRow"); = /* Propagate our own error context to libxml2 */ - xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler); + xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, + (xmlStructuredErrorFunc) xml_errorHandler); = if (xtCxt->xpathobj =3D=3D NULL) { @@ -4857,7 +4859,8 @@ XmlTableGetValue(TableFuncScanState *state, int coln= um, xtCxt->xpathobj->nodesetval !=3D NULL); = /* Propagate our own error context to libxml2 */ - xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler); + xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, + (xmlStructuredErrorFunc) xml_errorHandler); = *isnull =3D false; = @@ -5000,7 +5003,8 @@ XmlTableDestroyOpaque(TableFuncScanState *state) xtCxt =3D GetXmlTableBuilderPrivateData(state, "XmlTableDestroyOpaque"); = /* Propagate our own error context to libxml2 */ - xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler); + xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, + (xmlStructuredErrorFunc) xml_errorHandler); = if (xtCxt->xpathscomp !=3D NULL) { ------- =_aaaaaaaaaa0--