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:
@@ -48,7 +48,7 @@
|
|||||||
ZIPFAM::ZIPFAM(PDOSDEF tdp) : MAPFAM(tdp)
|
ZIPFAM::ZIPFAM(PDOSDEF tdp) : MAPFAM(tdp)
|
||||||
{
|
{
|
||||||
zipfile = NULL;
|
zipfile = NULL;
|
||||||
zfn = tdp->Fn;
|
//zfn = tdp->Fn;
|
||||||
target = tdp->Entry;
|
target = tdp->Entry;
|
||||||
//*fn = 0;
|
//*fn = 0;
|
||||||
entryopen = false;
|
entryopen = false;
|
||||||
@@ -65,7 +65,7 @@ ZIPFAM::ZIPFAM(PDOSDEF tdp) : MAPFAM(tdp)
|
|||||||
ZIPFAM::ZIPFAM(PZIPFAM txfp) : MAPFAM(txfp)
|
ZIPFAM::ZIPFAM(PZIPFAM txfp) : MAPFAM(txfp)
|
||||||
{
|
{
|
||||||
zipfile = txfp->zipfile;
|
zipfile = txfp->zipfile;
|
||||||
zfn = txfp->zfn;
|
//zfn = txfp->zfn;
|
||||||
target = txfp->target;
|
target = txfp->target;
|
||||||
//strcpy(fn, txfp->fn);
|
//strcpy(fn, txfp->fn);
|
||||||
finfo = txfp->finfo;
|
finfo = txfp->finfo;
|
||||||
@@ -129,7 +129,7 @@ int ZIPFAM::GetFileLength(PGLOBAL g)
|
|||||||
bool ZIPFAM::open(PGLOBAL g, const char *filename)
|
bool ZIPFAM::open(PGLOBAL g, const char *filename)
|
||||||
{
|
{
|
||||||
if (!zipfile && !(zipfile = unzOpen64(filename)))
|
if (!zipfile && !(zipfile = unzOpen64(filename)))
|
||||||
sprintf(g->Message, "Zipfile open error");
|
sprintf(g->Message, "Zipfile open error on %s", filename);
|
||||||
|
|
||||||
return (zipfile == NULL);
|
return (zipfile == NULL);
|
||||||
} // end of open
|
} // end of open
|
||||||
@@ -205,7 +205,7 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
if (mode == MODE_READ) {
|
if (mode == MODE_READ) {
|
||||||
// We used the file name relative to recorded datapath
|
// 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);
|
bool b = open(g, filename);
|
||||||
|
|
||||||
@@ -258,7 +258,8 @@ bool ZIPFAM::OpenTableFile(PGLOBAL g)
|
|||||||
} // endif fp
|
} // endif fp
|
||||||
|
|
||||||
To_Fb = fp; // Useful when closing
|
To_Fb = fp; // Useful when closing
|
||||||
} // endif b
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
strcpy(g->Message, "Only READ mode supported for ZIP files");
|
strcpy(g->Message, "Only READ mode supported for ZIP files");
|
||||||
|
@@ -51,7 +51,7 @@ protected:
|
|||||||
|
|
||||||
// Members
|
// Members
|
||||||
unzFile zipfile; // The ZIP container file
|
unzFile zipfile; // The ZIP container file
|
||||||
PSZ zfn; // The ZIP file name
|
//PSZ zfn; // The ZIP file name
|
||||||
PSZ target; // The target file name
|
PSZ target; // The target file name
|
||||||
unz_file_info finfo; // The current file info
|
unz_file_info finfo; // The current file info
|
||||||
//char fn[FILENAME_MAX]; // The current file name
|
//char fn[FILENAME_MAX]; // The current file name
|
||||||
|
@@ -108,6 +108,11 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
|
|||||||
goto skipit;
|
goto skipit;
|
||||||
} // endif info
|
} // 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
|
// num_max = atoi(p+1); // Max num of record to test
|
||||||
imax = hmax = nerr = 0;
|
imax = hmax = nerr = 0;
|
||||||
|
|
||||||
@@ -124,18 +129,15 @@ PQRYRES CSVColumns(PGLOBAL g, char *dp, PTOS topt, bool info)
|
|||||||
tdp = new(g) CSVDEF;
|
tdp = new(g) CSVDEF;
|
||||||
#if defined(ZIP_SUPPORT)
|
#if defined(ZIP_SUPPORT)
|
||||||
tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL);
|
tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL);
|
||||||
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
|
|
||||||
tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false);
|
tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false);
|
||||||
#endif // ZIP_SUPPORT
|
#endif // ZIP_SUPPORT
|
||||||
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
fn = tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
||||||
|
|
||||||
if (!tdp->Fn) {
|
if (!tdp->Fn) {
|
||||||
strcpy(g->Message, MSG(MISSING_FNAME));
|
strcpy(g->Message, MSG(MISSING_FNAME));
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif Fn
|
} // endif Fn
|
||||||
|
|
||||||
fn = (tdp->Fn) ? tdp->Fn : "unnamed";
|
|
||||||
|
|
||||||
if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))
|
if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))
|
||||||
tdp->Lrecl = 4096;
|
tdp->Lrecl = 4096;
|
||||||
|
|
||||||
@@ -497,12 +499,6 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
|
|||||||
if (Zipped) {
|
if (Zipped) {
|
||||||
#if defined(ZIP_SUPPORT)
|
#if defined(ZIP_SUPPORT)
|
||||||
txfp = new(g) ZIPFAM(this);
|
txfp = new(g) ZIPFAM(this);
|
||||||
|
|
||||||
if (!Fmtd)
|
|
||||||
tdbp = new(g) TDBCSV(this, txfp);
|
|
||||||
else
|
|
||||||
tdbp = new(g) TDBFMT(this, txfp);
|
|
||||||
|
|
||||||
#else // !ZIP_SUPPORT
|
#else // !ZIP_SUPPORT
|
||||||
strcpy(g->Message, "ZIP not supported");
|
strcpy(g->Message, "ZIP not supported");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -94,6 +94,11 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
|||||||
goto skipit;
|
goto skipit;
|
||||||
} // endif info
|
} // 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. */
|
/* Open the input file. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -103,7 +108,6 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info)
|
|||||||
tdp = new(g) JSONDEF;
|
tdp = new(g) JSONDEF;
|
||||||
#if defined(ZIP_SUPPORT)
|
#if defined(ZIP_SUPPORT)
|
||||||
tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL);
|
tdp->Entry = GetStringTableOption(g, topt, "Entry", NULL);
|
||||||
tdp->Multiple = GetIntegerTableOption(g, topt, "Multiple", 0);
|
|
||||||
tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false);
|
tdp->Zipped = GetBooleanTableOption(g, topt, "Zipped", false);
|
||||||
#endif // ZIP_SUPPORT
|
#endif // ZIP_SUPPORT
|
||||||
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
|
||||||
|
@@ -136,6 +136,11 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
|
|||||||
goto skipit;
|
goto skipit;
|
||||||
} // endif info
|
} // 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. */
|
/* Open the input file. */
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
Reference in New Issue
Block a user