From 2197d06224a14dba544e05e3df1efcca83bdd9ef Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 17 Jan 2024 14:03:55 +0900 Subject: Add support for parsing of large XML data (>= 10MB) This commit adds XML_PARSE_HUGE to the libxml2 functions used in core for the parsing of XML objects, raising up the original limit of 10MB supported by libxml2. In most code paths of upstream, XML_MAX_TEXT_LENGTH (10^7) is the historical limit that gets upgraded to XML_MAX_HUGE_LENGTH (10^9) once XML_PARSE_HUGE is given to the parser calls. These are still limited by any palloc() calls for text, up to 1GB. This offers the possibility to handle within the backend XML objects larger than 10MB in general, with also a higher depth limit. This change affects the contrib module xml2, the xml data type and SQL/XML. Author: Dmitry Koval Reviewed-by: Tom Lane, Michael Paquier Discussion: https://postgr.es/m/18274-98d16bc03520665f@postgresql.org --- contrib/xml2/xpath.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'contrib/xml2/xpath.c') diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c index a967257546a..a2cec95f3fa 100644 --- a/contrib/xml2/xpath.c +++ b/contrib/xml2/xpath.c @@ -381,7 +381,7 @@ pgxml_xpath(text *document, xmlChar *xpath, xpath_workspace *workspace) { workspace->doctree = xmlReadMemory((char *) VARDATA_ANY(document), docsize, NULL, NULL, - XML_PARSE_NOENT); + XML_PARSE_HUGE | XML_PARSE_NOENT); if (workspace->doctree != NULL) { workspace->ctxt = xmlXPathNewContext(workspace->doctree); @@ -626,7 +626,7 @@ xpath_table(PG_FUNCTION_ARGS) if (xmldoc) doctree = xmlReadMemory(xmldoc, strlen(xmldoc), NULL, NULL, - XML_PARSE_NOENT); + XML_PARSE_HUGE | XML_PARSE_NOENT); else /* treat NULL as not well-formed */ doctree = NULL; -- cgit v1.2.3