pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: PG versus libxml2 2.12.x
Date: Mon, 29 Jan 2024 10:59:06 -0500
Message-ID: <1883324.1706543946@sss.pgh.pa.us> (raw)
In-Reply-To: <1784723.1706541587@sss.pgh.pa.us>
References: <1389505.1706382262@sss.pgh.pa.us>
	<a9e2f184-6267-4f74-9922-9211d78f6f9a@eisentraut.org>
	<1784723.1706541587@sss.pgh.pa.us>

I wrote:
> Peter Eisentraut <peter@eisentraut.org> 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

Attachments:

  [text/x-diff] v2-cope-with-libxml2-API-changes.patch (1.7K, ../1883324.1706543946@sss.pgh.pa.us/2-v2-cope-with-libxml2-API-changes.patch)
  download | inline diff:
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 = 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 >= 20704
 #define HAVE_XMLSTRUCTUREDERRORCONTEXT 1
 #endif
+
+/*
+ * libxml2 2.12 decided to insert "const" into the error handler API.
+ */
+#if LIBXML_VERSION >= 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 *errcxt,
  * Error handler for libxml errors and warnings
  */
 static void
-xml_errorHandler(void *data, xmlErrorPtr error)
+xml_errorHandler(void *data, PgXmlErrorPtr error)
 {
 	PgXmlErrorContext *xmlerrcxt = (PgXmlErrorContext *) data;
 	xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt;

view thread (5+ messages)

Message-ID: <1883324.1706543946@sss.pgh.pa.us>
Permalink:  ../1883324.1706543946@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1883324.1706543946@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, peter@eisentraut.org, pgsql-hackers@lists.postgresql.org
  Subject: Re: PG versus libxml2 2.12.x
  In-Reply-To: <1883324.1706543946@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox