summaryrefslogtreecommitdiff
path: root/storage/connect/libdoc.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2016-12-23 16:58:32 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2016-12-23 16:58:32 +0100
commite6b563f8be68d57df2a4c9b8e2b6c130855b18e4 (patch)
tree4aa72a2eb96696302cfc996e28ccdf76d9bfdeaa /storage/connect/libdoc.cpp
parent952306502ebf1b26c627c5dc8b141581eeb30671 (diff)
downloadmariadb-git-e6b563f8be68d57df2a4c9b8e2b6c130855b18e4.tar.gz
Fix some XML table type bugs:
- in DOMNODELIST::DropItem if (Listp == NULL || Listp->length <= n) return true; is wrong, should be: if (Listp == NULL || Listp->length < n) return true; - Crash in discovery with libxml2 in XMLColumns because: if (!tdp->Usedom) // nl was destroyed vp->nl = vp->pn->GetChildElements(g); is executed with vp->pn uninitialized. Fixed by adding: vp->pn = node; line 264. -In discovery with libxml2 some columns are not found. Because list was not recovered properly, nodes being modified and not reallocated. Fixed lines 214 and 277. modified: storage/connect/domdoc.cpp modified: storage/connect/tabxml.cpp Add support for zipped table files modified: storage/connect/domdoc.cpp modified: storage/connect/domdoc.h modified: storage/connect/filamap.cpp modified: storage/connect/filamap.h modified: storage/connect/filamzip.cpp modified: storage/connect/filamzip.h modified: storage/connect/ha_connect.cc modified: storage/connect/libdoc.cpp modified: storage/connect/plgdbutl.cpp modified: storage/connect/plgxml.cpp modified: storage/connect/plgxml.h modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabxml.cpp
Diffstat (limited to 'storage/connect/libdoc.cpp')
-rw-r--r--storage/connect/libdoc.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp
index c2882fc0d7c..2470d37c353 100644
--- a/storage/connect/libdoc.cpp
+++ b/storage/connect/libdoc.cpp
@@ -1,6 +1,6 @@
/******************************************************************/
/* Implementation of XML document processing using libxml2 */
-/* Author: Olivier Bertrand 2007-2015 */
+/* Author: Olivier Bertrand 2007-2016 */
/******************************************************************/
#include "my_global.h"
#include <string.h>
@@ -68,8 +68,8 @@ class LIBXMLDOC : public XMLDOCUMENT {
virtual void SetNofree(bool b) {Nofreelist = b;}
// Methods
- virtual bool Initialize(PGLOBAL g);
- virtual bool ParseFile(char *fn);
+ virtual bool Initialize(PGLOBAL g, char *entry, bool zipped);
+ virtual bool ParseFile(PGLOBAL g, char *fn);
virtual bool NewDoc(PGLOBAL g, char *ver);
virtual void AddComment(PGLOBAL g, char *com);
virtual PXNODE GetRoot(PGLOBAL g);
@@ -373,22 +373,33 @@ LIBXMLDOC::LIBXMLDOC(char *nsl, char *nsdf, char *enc, PFBLOCK fp)
/******************************************************************/
/* Initialize XML parser and check library compatibility. */
/******************************************************************/
-bool LIBXMLDOC::Initialize(PGLOBAL g)
- {
+bool LIBXMLDOC::Initialize(PGLOBAL g, char *entry, bool zipped)
+{
+ if (zipped && InitZip(g, entry))
+ return true;
+
int n = xmlKeepBlanksDefault(1);
return MakeNSlist(g);
- } // end of Initialize
+} // end of Initialize
/******************************************************************/
/* Parse the XML file and construct node tree in memory. */
/******************************************************************/
-bool LIBXMLDOC::ParseFile(char *fn)
+bool LIBXMLDOC::ParseFile(PGLOBAL g, char *fn)
{
if (trace)
htrc("ParseFile\n");
- if ((Docp = xmlParseFile(fn))) {
- if (Docp->encoding)
+ if (zip) {
+ // Parse an in memory document
+ char *xdoc = GetMemDoc(g, fn);
+
+ Docp = (xdoc) ? xmlParseDoc((const xmlChar *)xdoc) : NULL;
+ } else
+ Docp = xmlParseFile(fn);
+
+ if (Docp) {
+ if (Docp->encoding)
Encoding = (char*)Docp->encoding;
return false;
@@ -609,6 +620,7 @@ void LIBXMLDOC::CloseDoc(PGLOBAL g, PFBLOCK xp)
} // endif xp
CloseXML2File(g, xp, false);
+ CloseZip();
} // end of Close
/******************************************************************/