Commit 1e07df99 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-22561 Unable to access DBF inside a ZIP archive

  modified:   storage/connect/filamdbf.cpp
  modified:   storage/connect/filamdbf.h
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filamzip.h
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/plgxml.cpp
  modified:   storage/connect/tabdos.cpp
  modified:   storage/connect/tabdos.h
  modified:   storage/connect/tabfix.h

- Add/Init Level class member
  modified:   storage/connect/mongo.cpp
  modified:   storage/connect/mongo.h
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabjson.h

- Typo
  modified:   storage/connect/connect.cc
parent 2654ddd2
......@@ -355,7 +355,6 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} // endif mode
rcop = false;
} catch (int n) {
if (trace(1))
htrc("Exception %d: %s\n", n, g->Message);
......
This diff is collapsed.
......@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM;
/****************************************************************************/
/* Functions used externally. */
/****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info);
PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, PTOS tiop, bool info);
/****************************************************************************/
/* This is the base class for dBASE file access methods. */
......
This diff is collapsed.
/************** filamzip H Declares Source Code File (.H) **************/
/* Name: filamzip.h Version 1.2 */
/* Name: filamzip.h Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */
/* (C) Copyright to the author Olivier BERTRAND 2016-2020 */
/* */
/* This file contains the ZIP file access method classes declares. */
/***********************************************************************/
......@@ -11,6 +11,7 @@
#include "block.h"
#include "filamap.h"
#include "filamfix.h"
#include "filamdbf.h"
#include "zip.h"
#include "unzip.h"
......@@ -18,6 +19,7 @@
typedef class UNZFAM *PUNZFAM;
typedef class UZXFAM *PUZXFAM;
typedef class UZDFAM* PUZDFAM;
typedef class ZIPFAM *PZIPFAM;
typedef class ZPXFAM *PZPXFAM;
......@@ -53,7 +55,7 @@ class DllExport ZIPUTIL : public BLOCK {
class DllExport UNZIPUTL : public BLOCK {
public:
// Constructor
UNZIPUTL(PCSZ tgt, bool mul);
UNZIPUTL(PCSZ tgt, PCSZ pw, bool mul);
UNZIPUTL(PDOSDEF tdp);
// Implementation
......@@ -143,6 +145,36 @@ class DllExport UZXFAM : public MPXFAM {
PDOSDEF tdfp;
}; // end of UZXFAM
/***********************************************************************/
/* This is the fixed unzip file access method. */
/***********************************************************************/
class DllExport UZDFAM : public DBMFAM {
//friend class UNZFAM;
public:
// Constructors
UZDFAM(PDOSDEF tdp);
UZDFAM(PUZDFAM txfp);
// Implementation
virtual AMT GetAmType(void) { return TYPE_AM_ZIP; }
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UZDFAM(this); }
// Methods
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
virtual bool OpenTableFile(PGLOBAL g);
virtual int GetNext(PGLOBAL g);
//virtual int ReadBuffer(PGLOBAL g);
protected:
int dbfhead(PGLOBAL g, void* buf);
int ScanHeader(PGLOBAL g, int* rln);
// Members
UNZIPUTL* zutp;
PDOSDEF tdfp;
}; // end of UZDFAM
/***********************************************************************/
/* This is the zip file access method. */
/***********************************************************************/
......
......@@ -5884,7 +5884,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} else switch (ttp) {
case TAB_DBF:
qrp= DBFColumns(g, dpath, fn, fnc == FNC_COL);
qrp= DBFColumns(g, dpath, fn, topt, fnc == FNC_COL);
break;
#if defined(ODBC_SUPPORT)
case TAB_ODBC:
......@@ -6735,11 +6735,6 @@ int ha_connect::create(const char *name, TABLE *table_arg,
PCSZ m= GetListOption(g, "Mulentries", options->oplist, "NO");
bool mul= *m == '1' || *m == 'Y' || *m == 'y' || !stricmp(m, "ON");
if (!entry && !mul) {
my_message(ER_UNKNOWN_ERROR, "Missing entry name", MYF(0));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endif entry
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
PlugSetPath(zbuf, options->filename, dbpath);
PlugSetPath(buf, fn, dbpath);
......
......@@ -380,7 +380,6 @@ MGODEF::MGODEF(void)
Uri = NULL;
Colist = NULL;
Filter = NULL;
Level = 0;
Base = 0;
Version = 0;
Pipe = false;
......
......@@ -82,7 +82,6 @@ class DllExport MGODEF : public EXTDEF { /* Table description */
PSZ Wrapname; /* Java wrapper name */
PCSZ Colist; /* Options list */
PCSZ Filter; /* Filtering query */
int Level; /* Used for catalog table */
int Base; /* The array index base */
int Version; /* The Java driver version */
bool Pipe; /* True is Colist is a pipeline */
......
......@@ -49,7 +49,7 @@ bool XMLDOCUMENT::InitZip(PGLOBAL g, PCSZ entry)
{
#if defined(ZIP_SUPPORT)
bool mul = (entry) ? strchr(entry, '*') || strchr(entry, '?') : false;
zip = new(g) UNZIPUTL(entry, mul);
zip = new(g) UNZIPUTL(entry, NULL, mul);
return zip == NULL;
#else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
......
/************* TabDos C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABDOS */
/* ------------- */
/* Version 4.9.4 */
/* Version 4.9.5 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2019 */
/* (C) Copyright to the author Olivier BERTRAND 1998-2020 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -359,7 +359,26 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
/* Allocate table and file processing class of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (Zipped) {
if (Recfm == RECFM_DBF) {
if (Catfunc == FNC_NO) {
if (Zipped) {
if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) {
txfp = new(g) UZDFAM(this);
} else {
strcpy(g->Message, "Zipped DBF tables are read only");
return NULL;
} // endif's mode
} else if (map)
txfp = new(g) DBMFAM(this);
else
txfp = new(g) DBFFAM(this);
tdbp = new(g) TDBFIX(this, txfp);
} else
tdbp = new(g) TDBDCL(this); // Catfunc should be 'C'
} else if (Zipped) {
#if defined(ZIP_SUPPORT)
if (Recfm == RECFM_VAR) {
if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) {
......@@ -389,17 +408,6 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
return NULL;
#endif // !ZIP_SUPPORT
} else if (Recfm == RECFM_DBF) {
if (Catfunc == FNC_NO) {
if (map)
txfp = new(g) DBMFAM(this);
else
txfp = new(g) DBFFAM(this);
tdbp = new(g) TDBFIX(this, txfp);
} else // Catfunc should be 'C'
tdbp = new(g) TDBDCL(this);
} else if (Recfm != RECFM_VAR && Compressed < 2) {
if (Huge)
txfp = new(g) BGXFAM(this);
......
......@@ -30,6 +30,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
friend class DBFBASE;
friend class UNZIPUTL;
friend class JSONCOL;
friend class TDBDCL;
public:
// Constructor
DOSDEF(void);
......
......@@ -98,18 +98,20 @@ class DllExport BINCOL : public DOSCOL {
/* This is the class declaration for the DBF columns catalog table. */
/***********************************************************************/
class TDBDCL : public TDBCAT {
public:
// Constructor
TDBDCL(PDOSDEF tdp) : TDBCAT(tdp) {Fn = tdp->GetFn();}
public:
// Constructor
TDBDCL(PDOSDEF tdp) : TDBCAT(tdp)
{Fn = tdp->GetFn(); Topt = tdp->GetTopt();}
protected:
protected:
// Specific routines
virtual PQRYRES GetResult(PGLOBAL g)
{return DBFColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, false);}
virtual PQRYRES GetResult(PGLOBAL g)
{return DBFColumns(g, ((PTABDEF)To_Def)->GetPath(), Fn, Topt, false);}
// Members
// Members
PCSZ Fn; // The DBF file (path) name
}; // end of class TDBOCL
PTOS Topt;
}; // end of class TDBOCL
#endif // __TABFIX__
......@@ -739,6 +739,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
/***********************************************************************/
TDBJSN::TDBJSN(PJDEF tdp, PTXF txfp) : TDBDOS(tdp, txfp)
{
G = NULL;
Top = NULL;
Row = NULL;
Val = NULL;
......
......@@ -104,7 +104,6 @@ class DllExport JSONDEF : public DOSDEF { /* Table description */
PCSZ Xcol; /* Name of expandable column */
int Limit; /* Limit of multiple values */
int Pretty; /* Depends on file structure */
int Level; /* Used for catalog table */
int Base; /* The array index base */
bool Strict; /* Strict syntax checking */
char Sep; /* The Jpath separator */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment