Skip to content

Commit 33f4097

Browse files
committed
Check LIBXML_VERSION instead of testing in configure script.
We had put a test for libxml2's xmlStructuredErrorContext variable in configure, but of course that doesn't work on Windows builds. The next best alternative seems to be to test the LIBXML_VERSION symbol provided by xmlversion.h. Per report from Talha Bin Rizwan, though this fixes it in a different way than his proposed patch.
1 parent 2689390 commit 33f4097

File tree

4 files changed

+11
-90
lines changed

4 files changed

+11
-90
lines changed

configure

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -23737,75 +23737,6 @@ fi
2373723737

2373823738

2373923739

23740-
# Older versions of libxml2 lack the xmlStructuredErrorContext variable
23741-
# (which could be a macro referring to a function, if threading is enabled)
23742-
if test "$with_libxml" = yes ; then
23743-
{ $as_echo "$as_me:$LINENO: checking for xmlStructuredErrorContext" >&5
23744-
$as_echo_n "checking for xmlStructuredErrorContext... " >&6; }
23745-
if test "${pgac_cv_libxml_structerrctx+set}" = set; then
23746-
$as_echo_n "(cached) " >&6
23747-
else
23748-
cat >conftest.$ac_ext <<_ACEOF
23749-
/* confdefs.h. */
23750-
_ACEOF
23751-
cat confdefs.h >>conftest.$ac_ext
23752-
cat >>conftest.$ac_ext <<_ACEOF
23753-
/* end confdefs.h. */
23754-
#include <libxml/globals.h>
23755-
void *globptr;
23756-
int
23757-
main ()
23758-
{
23759-
globptr = xmlStructuredErrorContext
23760-
;
23761-
return 0;
23762-
}
23763-
_ACEOF
23764-
rm -f conftest.$ac_objext conftest$ac_exeext
23765-
if { (ac_try="$ac_link"
23766-
case "(($ac_try" in
23767-
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
23768-
*) ac_try_echo=$ac_try;;
23769-
esac
23770-
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
23771-
$as_echo "$ac_try_echo") >&5
23772-
(eval "$ac_link") 2>conftest.er1
23773-
ac_status=$?
23774-
grep -v '^ *+' conftest.er1 >conftest.err
23775-
rm -f conftest.er1
23776-
cat conftest.err >&5
23777-
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
23778-
(exit $ac_status); } && {
23779-
test -z "$ac_c_werror_flag" ||
23780-
test ! -s conftest.err
23781-
} && test -s conftest$ac_exeext && {
23782-
test "$cross_compiling" = yes ||
23783-
$as_test_x conftest$ac_exeext
23784-
}; then
23785-
pgac_cv_libxml_structerrctx=yes
23786-
else
23787-
$as_echo "$as_me: failed program was:" >&5
23788-
sed 's/^/| /' conftest.$ac_ext >&5
23789-
23790-
pgac_cv_libxml_structerrctx=no
23791-
fi
23792-
23793-
rm -rf conftest.dSYM
23794-
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
23795-
conftest$ac_exeext conftest.$ac_ext
23796-
fi
23797-
{ $as_echo "$as_me:$LINENO: result: $pgac_cv_libxml_structerrctx" >&5
23798-
$as_echo "$pgac_cv_libxml_structerrctx" >&6; }
23799-
if test x"$pgac_cv_libxml_structerrctx" = x"yes"; then
23800-
23801-
cat >>confdefs.h <<\_ACEOF
23802-
#define HAVE_XMLSTRUCTUREDERRORCONTEXT 1
23803-
_ACEOF
23804-
23805-
fi
23806-
fi
23807-
23808-
2380923740
# This test makes sure that run tests work at all. Sometimes a shared
2381023741
# library is found by the linker, but the runtime linker can't find it.
2381123742
# This check should come after all modifications of compiler or linker

configure.in

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,23 +1529,6 @@ AC_SUBST(LDAP_LIBS_FE)
15291529
AC_SUBST(LDAP_LIBS_BE)
15301530

15311531

1532-
# Older versions of libxml2 lack the xmlStructuredErrorContext variable
1533-
# (which could be a macro referring to a function, if threading is enabled)
1534-
if test "$with_libxml" = yes ; then
1535-
AC_CACHE_CHECK([for xmlStructuredErrorContext], pgac_cv_libxml_structerrctx,
1536-
[AC_TRY_LINK([#include <libxml/globals.h>
1537-
void *globptr;],
1538-
[globptr = xmlStructuredErrorContext],
1539-
[pgac_cv_libxml_structerrctx=yes],
1540-
[pgac_cv_libxml_structerrctx=no])])
1541-
if test x"$pgac_cv_libxml_structerrctx" = x"yes"; then
1542-
AC_DEFINE(HAVE_XMLSTRUCTUREDERRORCONTEXT,
1543-
1,
1544-
[Define to 1 if your libxml has xmlStructuredErrorContext.])
1545-
fi
1546-
fi
1547-
1548-
15491532
# This test makes sure that run tests work at all. Sometimes a shared
15501533
# library is found by the linker, but the runtime linker can't find it.
15511534
# This check should come after all modifications of compiler or linker

src/backend/utils/adt/xml.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,19 @@
5252
#include <libxml/tree.h>
5353
#include <libxml/uri.h>
5454
#include <libxml/xmlerror.h>
55+
#include <libxml/xmlversion.h>
5556
#include <libxml/xmlwriter.h>
5657
#include <libxml/xpath.h>
5758
#include <libxml/xpathInternals.h>
59+
60+
/*
61+
* We used to check for xmlStructuredErrorContext via a configure test; but
62+
* that doesn't work on Windows, so instead use this grottier method of
63+
* testing the library version number.
64+
*/
65+
#if LIBXML_VERSION >= 20704
66+
#define HAVE_XMLSTRUCTUREDERRORCONTEXT 1
67+
#endif
5868
#endif /* USE_LIBXML */
5969

6070
#include "catalog/namespace.h"
@@ -970,7 +980,7 @@ pg_xml_init(PgXmlStrictness strictness)
970980
*
971981
* The only known situation in which this test fails is if we compile with
972982
* headers from a libxml2 that doesn't track the structured error context
973-
* separately (<= 2.7.3), but at runtime use a version that does, or vice
983+
* separately (< 2.7.4), but at runtime use a version that does, or vice
974984
* versa. The libxml2 authors did not treat that change as constituting
975985
* an ABI break, so the LIBXML_TEST_VERSION test in pg_xml_init_library
976986
* fails to protect us from this.

src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,6 @@
632632
/* Define to 1 if you have the <winldap.h> header file. */
633633
#undef HAVE_WINLDAP_H
634634

635-
/* Define to 1 if your libxml has xmlStructuredErrorContext. */
636-
#undef HAVE_XMLSTRUCTUREDERRORCONTEXT
637-
638635
/* Define to the appropriate snprintf format for 64-bit ints. */
639636
#undef INT64_FORMAT
640637

0 commit comments

Comments
 (0)