Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b2fd1da

Browse files
committed
Fix incompatibilities with libxml2 >= 2.12.0.
libxml2 changed the required signature of error handler callbacks to make the passed xmlError struct "const". This is causing build failures on buildfarm member caiman, and no doubt will start showing up in the field quite soon. Add a version check to adjust the declaration of xml_errorHandler() according to LIBXML_VERSION. 2.12.x also produces deprecation warnings for contrib/xml2/xpath.c's assignment to xmlLoadExtDtdDefaultValue. I see no good reason for that to still be there, seeing that we disabled external DTDs (at a lower level) years ago for security reasons. Let's just remove it. Back-patch to all supported branches, since they might all get built with newer libxml2 once it gets a bit more popular. (The back branches produce another deprecation warning about xpath.c's use of xmlSubstituteEntitiesDefault(). We ought to consider whether to back-patch all or part of commit 65c5864 to silence that. It's less urgent though, since it won't break the buildfarm.) Discussion: https://postgr.es/m/1389505.1706382262@sss.pgh.pa.us
1 parent e6511fe commit b2fd1da

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

contrib/xml2/xpath.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ pgxml_parser_init(PgXmlStrictness strictness)
7575
xmlInitParser();
7676

7777
xmlSubstituteEntitiesDefault(1);
78-
xmlLoadExtDtdDefaultValue = 1;
7978

8079
return xmlerrcxt;
8180
}

src/backend/utils/adt/xml.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@
6565
#if LIBXML_VERSION >= 20704
6666
#define HAVE_XMLSTRUCTUREDERRORCONTEXT 1
6767
#endif
68+
69+
/*
70+
* libxml2 2.12 decided to insert "const" into the error handler API.
71+
*/
72+
#if LIBXML_VERSION >= 21200
73+
#define PgXmlErrorPtr const xmlError *
74+
#else
75+
#define PgXmlErrorPtr xmlErrorPtr
76+
#endif
77+
6878
#endif /* USE_LIBXML */
6979

7080
#include "access/htup_details.h"
@@ -119,7 +129,7 @@ struct PgXmlErrorContext
119129

120130
static xmlParserInputPtr xmlPgEntityLoader(const char *URL, const char *ID,
121131
xmlParserCtxtPtr ctxt);
122-
static void xml_errorHandler(void *data, xmlErrorPtr error);
132+
static void xml_errorHandler(void *data, PgXmlErrorPtr error);
123133
static void xml_ereport_by_code(int level, int sqlcode,
124134
const char *msg, int errcode);
125135
static void chopStringInfoNewlines(StringInfo str);
@@ -1752,7 +1762,7 @@ xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode, const char *msg)
17521762
* Error handler for libxml errors and warnings
17531763
*/
17541764
static void
1755-
xml_errorHandler(void *data, xmlErrorPtr error)
1765+
xml_errorHandler(void *data, PgXmlErrorPtr error)
17561766
{
17571767
PgXmlErrorContext *xmlerrcxt = (PgXmlErrorContext *) data;
17581768
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt;

0 commit comments

Comments
 (0)