Commit 671d9b6c authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-22571 and MDEV-22572. Allow multiple ZIP table

  and enable using special column in them.
  modified:   storage/connect/tabzip.cpp
  modified:   storage/connect/tabzip.h

- Fix some compiler errors
  modified:   storage/connect/tabcmg.cpp
parent 41acc81f
......@@ -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. */
/***********************************************************************/
......
......@@ -4507,12 +4507,12 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
case TAB_DIR:
case TAB_ZIP:
case TAB_OEM:
if (table && table->pos_in_table_list) // if SELECT
{
//Switch_to_definer_security_ctx backup_ctx(thd, table->pos_in_table_list);
if (table && table->pos_in_table_list) { // if SELECT
#if MYSQL_VERSION_ID > 100200
Switch_to_definer_security_ctx backup_ctx(thd, table->pos_in_table_list);
#endif // VERSION_ID > 100200
return check_global_access(thd, FILE_ACL);
}
else
} else
return check_global_access(thd, FILE_ACL);
case TAB_ODBC:
case TAB_JDBC:
......@@ -4528,7 +4528,7 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
case TAB_VIR:
// This is temporary until a solution is found
return false;
} // endswitch type
} // endswitch type
my_printf_error(ER_UNKNOWN_ERROR, "check_privileges failed", MYF(0));
return true;
......@@ -5882,7 +5882,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:
......@@ -6733,11 +6733,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");
......
......@@ -26,6 +26,8 @@
#include "tabmul.h"
#include "filter.h"
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
/* -------------------------- Class CMGDISC -------------------------- */
/***********************************************************************/
......
/************* 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 */
......
......@@ -23,6 +23,7 @@
#include "filamzip.h"
#include "resource.h" // for IDS_COLUMNS
#include "tabdos.h"
#include "tabmul.h"
#include "tabzip.h"
/* -------------------------- Class ZIPDEF --------------------------- */
......@@ -41,7 +42,14 @@ bool ZIPDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
PTDB ZIPDEF::GetTable(PGLOBAL g, MODE m)
{
return new(g) TDBZIP(this);
PTDB tdbp = NULL;
tdbp = new(g) TDBZIP(this);
if (Multiple)
tdbp = new(g) TDBMUL(tdbp);
return tdbp;
} // end of GetTable
/* ------------------------------------------------------------------- */
......@@ -108,7 +116,7 @@ int TDBZIP::Cardinality(PGLOBAL g)
Cardinal = (err == UNZ_OK) ? (int)ginfo.number_entry : 0;
} else
Cardinal = 0;
Cardinal = 10; // Dummy for multiple tables
} // endif Cardinal
......@@ -187,6 +195,7 @@ int TDBZIP::DeleteDB(PGLOBAL g, int irc)
void TDBZIP::CloseDB(PGLOBAL g)
{
close();
nexterr = UNZ_OK; // For multiple tables
Use = USE_READY; // Just to be clean
} // end of CloseDB
......
......@@ -48,6 +48,8 @@ class DllExport TDBZIP : public TDBASE {
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
virtual PCSZ GetFile(PGLOBAL) {return zfn;}
virtual void SetFile(PGLOBAL, PCSZ fn) {zfn = fn;}
// Methods
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
......
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