1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- MDEV-11295: developing handling files contained in ZIP file.

Fix bug using multiple zip files
  modified:   storage/connect/filamzip.cpp
  modified:   storage/connect/filamzip.h
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabjson.cpp

- Add error msg when trying to make discovery on multiple tables
  modified:   storage/connect/tabfmt.cpp
  modified:   storage/connect/tabjson.cpp
  modified:   storage/connect/tabxml.cpp
This commit is contained in:
Olivier Bertrand
2016-12-14 14:37:31 +01:00
parent 8a3fc7c041
commit b3d2ac3492
5 changed files with 25 additions and 19 deletions

View File

@@ -48,7 +48,7 @@
ZIPFAM::ZIPFAM(PDOSDEF tdp) : MAPFAM(tdp)
{
zipfile = NULL;
zfn = tdp->Fn;
//zfn = tdp->Fn;
target = tdp->Entry;
//*fn = 0;
entryopen = false;
@@ -65,7 +65,7 @@ ZIPFAM::ZIPFAM(PDOSDEF tdp) : MAPFAM(tdp)
ZIPFAM::ZIPFAM(PZIPFAM txfp) : MAPFAM(txfp)
{
zipfile = txfp->zipfile;
zfn = txfp->zfn;
//zfn = txfp->zfn;
target = txfp->target;
//strcpy(fn, txfp->fn);
finfo = txfp->finfo;
@@ -129,7 +129,7 @@ int ZIPFAM::GetFileLength(PGLOBAL g)
bool ZIPFAM::open(PGLOBAL g, const char *filename)
{
if (!zipfile && !(zipfile = unzOpen64(filename)))
sprintf(g->Message, "Zipfile open error");
sprintf(g->Message, "Zipfile open error on %s", filename);
return (zipfile == NULL);
} // end of open
@@ -205,7 +205,7 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
/*********************************************************************/
if (mode == MODE_READ) {
// We used the file name relative to recorded datapath
PlugSetPath(filename, zfn, Tdbp->GetPath());
PlugSetPath(filename, To_File, Tdbp->GetPath());
bool b = open(g, filename);
@@ -258,7 +258,8 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
} // endif fp
To_Fb = fp; // Useful when closing
} // endif b
} else
return true;
} else {
strcpy(g->Message, "Only READ mode supported for ZIP files");

View File

@@ -51,7 +51,7 @@ protected:
// Members
unzFile zipfile; // The ZIP container file
PSZ zfn; // The ZIP file name
//PSZ zfn; // The ZIP file name
PSZ target; // The target file name
unz_file_info finfo; // The current file info
//char fn[FILENAME_MAX]; // The current file name

View File

@@ -108,6 +108,11 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
goto skipit;
} // endif info
if (GetIntegerTableOption(g, topt, "Multiple", 0)) {
strcpy(g->Message, "Cannot find column definition for multiple table");
return NULL;
} // endif Multiple
// num_max = atoi(p+1); // Max num of record to test
imax = hmax = nerr = 0;
@@ -124,18 +129,15 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
tdp = new(g) CSVDEF;
#if defined(ZIP_SUPPORT)
tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL);
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false);
#endif // ZIP_SUPPORT
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
fn = tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
if (!tdp->Fn) {
strcpy(g->Message, MSG(MISSING_FNAME));
return NULL;
} // endif Fn
fn = (tdp->Fn) ? tdp->Fn : "unnamed";
if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))
tdp->Lrecl = 4096;
@@ -497,12 +499,6 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
if (Zipped) {
#if defined(ZIP_SUPPORT)
txfp = new(g) ZIPFAM(this);
if (!Fmtd)
tdbp = new(g) TDBCSV(this, txfp);
else
tdbp = new(g) TDBFMT(this, txfp);
#else // !ZIP_SUPPORT
strcpy(g->Message, "ZIP not supported");
return NULL;

View File

@@ -94,7 +94,12 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
goto skipit;
} // endif info
/*********************************************************************/
if (GetIntegerTableOption(g, topt, "Multiple", 0)) {
strcpy(g->Message, "Cannot find column definition for multiple table");
return NULL;
} // endif Multiple
/*********************************************************************/
/* Open the input file. */
/*********************************************************************/
lvl = GetIntegerTableOption(g, topt, "Level", 0);
@@ -103,7 +108,6 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
tdp = new(g) JSONDEF;
#if defined(ZIP_SUPPORT)
tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL);
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false);
#endif // ZIP_SUPPORT
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);

View File

@@ -136,7 +136,12 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
goto skipit;
} // endif info
/*********************************************************************/
if (GetIntegerTableOption(g, topt, "Multiple", 0)) {
strcpy(g->Message, "Cannot find column definition for multiple table");
return NULL;
} // endif Multiple
/*********************************************************************/
/* Open the input file. */
/*********************************************************************/
if (!(fn = GetStringTableOption(g, topt, "Filename", NULL))) {