Commit 895b2539 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

Merge remote-tracking branch 'connect/10.0' into 10.0

parents fa59ac50 b2956b2a
......@@ -22,16 +22,16 @@ fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
array.cpp blkfil.cpp colblk.cpp csort.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
reldef.cpp tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp
tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp
tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
reldef.cpp tabcol.cpp tabdos.cpp tabext.cpp tabfix.cpp tabfmt.cpp tabjson.cpp
table.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp
tabutil.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h
engmsg.h filamap.h filamdbf.h filamfix.h filamgz.h filamtxt.h
filter.h global.h ha_connect.h inihandl.h json.h jsonudf.h maputil.h msgid.h
mycat.h myconn.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h
resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h tabmysql.h
taboccur.h tabpivot.h tabsys.h tabtbl.h tabutil.h tabvir.h tabxcl.h
resource.h tabcol.h tabdos.h tabext.h tabfix.h tabfmt.h tabjson.h tabmul.h
tabmysql.h taboccur.h tabpivot.h tabsys.h tabtbl.h tabutil.h tabvir.h tabxcl.h
user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
#
......
This diff is collapsed.
/**************** Array H Declares Source Code File (.H) ***************/
/* Name: ARRAY.H Version 3.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */
/* This file contains the ARRAY and VALBASE derived classes declares. */
/***********************************************************************/
......@@ -53,8 +53,8 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
using XOBJECT::GetIntValue;
virtual void Reset(void) {Bot = -1;}
virtual int Qcompare(int *, int *);
virtual bool Compare(PXOB) {assert(FALSE); return FALSE;}
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(FALSE); return FALSE;}
virtual bool Compare(PXOB) {assert(false); return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(false); return false;}
//virtual int CheckSpcCol(PTDB, int) {return 0;}
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
......
/************* Colblk C++ Functions Source Code File (.CPP) ************/
/* Name: COLBLK.CPP Version 2.1 */
/* Name: COLBLK.CPP Version 2.2 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
/* */
/* This file contains the COLBLK class functions. */
/***********************************************************************/
......@@ -300,7 +300,7 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
#if defined(__WIN__)
Format.Prec = 1; // Case insensitive
#endif // __WIN__
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() &&
Constant = (!To_Tdb->GetDef()->GetMultiple() &&
To_Tdb->GetAmType() != TYPE_AM_PLG &&
To_Tdb->GetAmType() != TYPE_AM_PLM);
Fn = NULL;
......@@ -312,11 +312,11 @@ FIDBLK::FIDBLK(PCOLUMN cp, OPVAL op) : SPCBLK(cp), Op(op)
/***********************************************************************/
void FIDBLK::ReadColumn(PGLOBAL g)
{
if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) {
if (Fn != To_Tdb->GetFile(g)) {
char filename[_MAX_PATH];
Fn = ((PTDBASE)To_Tdb)->GetFile(g);
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath());
Fn = To_Tdb->GetFile(g);
PlugSetPath(filename, Fn, To_Tdb->GetPath());
if (Op != OP_XX) {
char buff[_MAX_PATH];
......@@ -378,10 +378,8 @@ void PRTBLK::ReadColumn(PGLOBAL g)
{
if (Pname == NULL) {
char *p;
PTDBASE tdbp = (PTDBASE)To_Tdb;
Pname = tdbp->GetDef()->GetStringCatInfo(g, "partname", "?");
Pname = To_Tdb->GetDef()->GetStringCatInfo(g, "partname", "?");
p = strrchr(Pname, '#');
Value->SetValue_psz((p) ? p + 1 : Pname);
} // endif Pname
......
......@@ -157,23 +157,22 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
/* Returns valid: true if this is a table info. */
/***********************************************************************/
bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
{
bool b;
PTDBDOS tdbp= (PTDBDOS)tp;
{
if (tp) {
bool b = (tp->GetFtype() == RECFM_NAF);
PTDBDOS tdbp = b ? NULL : (PTDBDOS)tp;
if (tdbp) {
b= tdbp->GetFtype() != RECFM_NAF;
info->data_file_length= (b) ? (ulonglong)tdbp->GetFileLength(g) : 0;
info->data_file_length = (b) ? 0 : (ulonglong)tdbp->GetFileLength(g);
if (!b || info->data_file_length)
info->records= (unsigned)tdbp->Cardinality(g);
// info->records= (unsigned)tdbp->GetMaxSize(g);
if (b || info->data_file_length)
info->records= (unsigned)tp->Cardinality(g);
// info->records= (unsigned)tp->GetMaxSize(g);
else
info->records= 0;
// info->mean_rec_length= tdbp->GetLrecl();
info->mean_rec_length= 0;
info->data_file_name= (b) ? tdbp->GetFile(g) : NULL;
info->data_file_name= (b) ? NULL : tdbp->GetFile(g);
return true;
} else {
info->data_file_length= 0;
......@@ -183,7 +182,7 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
return false;
} // endif tdbp
} // end of CntInfo
} // end of CntInfo
/***********************************************************************/
/* GetTDB: Get the table description block of a CONNECT table. */
......@@ -332,9 +331,9 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} // endfor colp
// Attach the updated columns list to the main table
((PTDBASE)tdbp)->SetSetCols(utp->GetColumns());
tdbp->SetSetCols(utp->GetColumns());
} else if (tdbp && mode == MODE_INSERT)
((PTDBASE)tdbp)->SetSetCols(tdbp->GetColumns());
tdbp->SetSetCols(tdbp->GetColumns());
// Now do open the physical table
if (trace)
......@@ -343,7 +342,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
//tdbp->SetMode(mode);
if (del/* && ((PTDBASE)tdbp)->GetFtype() != RECFM_NAF*/) {
if (del/* && (tdbp->GetFtype() != RECFM_NAF*/) {
// To avoid erasing the table when doing a partial delete
// make a fake Next
// PDOSDEF ddp= new(g) DOSDEF;
......@@ -436,7 +435,7 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
if (!tdbp)
return RC_FX;
else if (((PTDBASE)tdbp)->GetKindex()) {
else if (tdbp->GetKindex()) {
// Reading sequencially an indexed table. This happens after the
// handler function records_in_range was called and MySQL decides
// to quit using the index (!!!) Drop the index.
......@@ -483,7 +482,7 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
{
RCODE rc;
PCOL colp;
PTDBASE tp= (PTDBASE)tdbp;
//PTDBASE tp= (PTDBASE)tdbp;
if (!tdbp)
return RC_FX;
......@@ -501,13 +500,13 @@ RCODE CntWriteRow(PGLOBAL g, PTDB tdbp)
} // endif rc
// Store column values in table write buffer(s)
for (colp= tp->GetSetCols(); colp; colp= colp->GetNext())
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
if (!colp->GetColUse(U_VIRTUAL))
colp->WriteColumn(g);
if (tp->IsIndexed())
if (tdbp->IsIndexed())
// Index values must be sorted before updating
rc= (RCODE)((PTDBDOS)tp)->GetTxfp()->StoreValues(g, true);
rc= (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, true);
else
// Return result code from write operation
rc= (RCODE)tdbp->WriteDB(g);
......@@ -535,7 +534,7 @@ RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp)
RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
{
RCODE rc;
PTDBASE tp= (PTDBASE)tdbp;
//PTDBASE tp= (PTDBASE)tdbp;
if (!tdbp || tdbp->GetMode() != MODE_DELETE)
return RC_FX;
......@@ -543,16 +542,16 @@ RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
return RC_NF;
if (all) {
if (((PTDBASE)tdbp)->GetDef()->Indexable())
if (tdbp->GetDef()->Indexable())
((PTDBDOS)tdbp)->Cardinal= 0;
// Note: if all, this call will be done when closing the table
rc= (RCODE)tdbp->DeleteDB(g, RC_FX);
//} else if (tp->GetKindex() && !tp->GetKindex()->IsSorted() &&
// tp->Txfp->GetAmType() != TYPE_AM_DBF) {
} else if(tp->IsIndexed()) {
//} else if (tdbp->GetKindex() && !((PTDBASE)tdbp)->GetKindex()->IsSorted() &&
// ((PTDBASE)tdbp)->Txfp->GetAmType() != TYPE_AM_DBF) {
} else if(tdbp->IsIndexed()) {
// Index values must be sorted before updating
rc= (RCODE)((PTDBDOS)tp)->GetTxfp()->StoreValues(g, false);
rc= (RCODE)((PTDBDOS)tdbp)->GetTxfp()->StoreValues(g, false);
} else // Return result code from delete operation
rc= (RCODE)tdbp->DeleteDB(g, RC_OK);
......@@ -565,7 +564,7 @@ RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all)
int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
{
int rc= RC_OK;
TDBASE *tbxp= (PTDBASE)tdbp;
//TDBASE *tbxp= (PTDBASE)tdbp;
if (!tdbp)
return rc; // Nothing to do
......@@ -581,13 +580,13 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
tdbp, tdbp->GetMode(), nox, abort);
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) {
if (tbxp->IsIndexed())
if (tdbp->IsIndexed())
rc= ((PTDBDOS)tdbp)->GetTxfp()->DeleteSortedRows(g);
if (!rc)
rc= tdbp->DeleteDB(g, RC_EF); // Specific A.M. delete routine
} else if (tbxp->GetMode() == MODE_UPDATE && tbxp->IsIndexed())
} else if (tdbp->GetMode() == MODE_UPDATE && tdbp->IsIndexed())
rc= ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);
switch(rc) {
......@@ -595,7 +594,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
abort= true;
break;
case RC_INFO:
PushWarning(g, tbxp);
PushWarning(g, tdbp);
break;
} // endswitch rc
......@@ -631,11 +630,13 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
if (trace > 1)
printf("About to reset opt\n");
// Make all the eventual indexes
tbxp= (TDBDOX*)tdbp;
tbxp->ResetKindex(g, NULL);
tbxp->SetKey_Col(NULL);
rc= tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
if (!tdbp->IsRemote()) {
// Make all the eventual indexes
PTDBDOX tbxp = (PTDBDOX)tdbp;
tbxp->ResetKindex(g, NULL);
tbxp->SetKey_Col(NULL);
rc = tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
} // endif remote
err:
if (trace > 1)
......@@ -657,10 +658,10 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
if (!ptdb)
return -1;
else if (!((PTDBASE)ptdb)->GetDef()->Indexable()) {
else if (!ptdb->GetDef()->Indexable()) {
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName());
return 0;
} else if (((PTDBASE)ptdb)->GetDef()->Indexable() == 3) {
} else if (ptdb->GetDef()->Indexable() == 3) {
return 1;
} else
tdbp= (PTDBDOX)ptdb;
......@@ -745,7 +746,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
if (!ptdb)
return RC_FX;
else
x= ((PTDBASE)ptdb)->GetDef()->Indexable();
x= ptdb->GetDef()->Indexable();
if (!x) {
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName());
......@@ -875,7 +876,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
if (!ptdb)
return -1;
x= ((PTDBASE)ptdb)->GetDef()->Indexable();
x= ptdb->GetDef()->Indexable();
if (!x) {
sprintf(g->Message, MSG(TABLE_NO_INDEX), ptdb->GetName());
......
......@@ -116,7 +116,9 @@ bool DOMDOC::ParseFile(PGLOBAL g, char *fn)
// Parse an in memory document
char *xdoc = GetMemDoc(g, fn);
b = (xdoc) ? (bool)Docp->loadXML((_bstr_t)xdoc) : false;
// This is not equivalent to load for UTF8 characters
// It is why get node content is not the same
b = (xdoc) ? (bool)Docp->loadXML((_bstr_t)xdoc) : false;
} else
// Load the document
b = (bool)Docp->load((_bstr_t)fn);
......@@ -266,6 +268,7 @@ DOMNODE::DOMNODE(PXDOC dp, MSXML2::IXMLDOMNodePtr np) : XMLNODE(dp)
Nodep = np;
Ws = NULL;
Len = 0;
Zip = (bool)dp->zip;
} // end of DOMNODE constructor
/******************************************************************/
......@@ -316,8 +319,10 @@ RCODE DOMNODE::GetContent(PGLOBAL g, char *buf, int len)
RCODE rc = RC_OK;
// Nodep can be null for a missing HTML table column
if (Nodep) {
if (!WideCharToMultiByte(CP_UTF8, 0, Nodep->text, -1,
if (Nodep) {
if (Zip) {
strcpy(buf, Nodep->text);
} else if (!WideCharToMultiByte(CP_UTF8, 0, Nodep->text, -1,
buf, len, NULL, NULL)) {
DWORD lsr = GetLastError();
......
......@@ -93,6 +93,7 @@ class DOMNODE : public XMLNODE {
char Name[64];
WCHAR *Ws;
int Len;
bool Zip;
}; // end of class DOMNODE
/******************************************************************/
......
......@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -45,6 +45,7 @@
#include "maputil.h"
#include "filamap.h"
#include "tabdos.h"
#include "tabfmt.h"
/* --------------------------- Class MAPFAM -------------------------- */
......@@ -322,17 +323,20 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
int rc, len;
// Are we at the end of the memory
if (Mempos >= Top)
if (Mempos >= Top) {
if ((rc = GetNext(g)) != RC_OK)
return rc;
else if (Tdbp->GetAmType() == TYPE_AM_CSV && ((PTDBCSV)Tdbp)->Header)
if ((rc = SkipRecord(g, true)) != RC_OK)
return rc;
} // endif Mempos
if (!Placed) {
/*******************************************************************/
/* Record file position in case of UPDATE or DELETE. */
/*******************************************************************/
int rc;
next:
Fpos = Mempos;
CurBlk = (int)Rows++;
......
......@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -281,15 +281,25 @@ PQRYRES DBFColumns(PGLOBAL g, char *dp, const char *fn, bool info)
/************************************************************************/
switch (thisfield.Type) {
case 'C': // Characters
case 'L': // Logical 'T' or 'F'
type = TYPE_STRING;
case 'L': // Logical 'T' or 'F' or space
type = TYPE_STRING;
break;
case 'M': // Memo a .DBT block number
case 'B': // Binary a .DBT block number
case 'G': // Ole a .DBT block number
type = TYPE_STRING;
break;
//case 'I': // Long
//case '+': // Autoincrement
// type = TYPE_INT;
// break;
case 'N':
type = (thisfield.Decimals) ? TYPE_DOUBLE
: (len > 10) ? TYPE_BIGINT : TYPE_INT;
break;
case 'F':
type = TYPE_DOUBLE;
case 'F': // Float
//case 'O': // Double
type = TYPE_DOUBLE;
break;
case 'D':
type = TYPE_DATE; // Is this correct ???
......@@ -441,6 +451,7 @@ int DBFFAM::Cardinality(PGLOBAL g)
if (Accept) {
Lrecl = rln;
Blksize = Nrec * rln;
PushWarning(g, Tdbp);
} else
return -1;
......@@ -582,6 +593,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
if (Accept) {
Lrecl = reclen;
Blksize = Nrec * Lrecl;
PushWarning(g, Tdbp);
} else
return true;
......@@ -598,7 +610,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
header->Filedate[1] = datm->tm_mon + 1;
header->Filedate[2] = datm->tm_mday;
header->SetHeadlen((ushort)hlen);
header->SetReclen((ushort)reclen);
header->SetReclen(reclen);
descp = (DESCRIPTOR*)header;
// Currently only standard Xbase types are supported
......@@ -664,6 +676,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
if (Accept) {
Lrecl = header.Reclen();
Blksize = Nrec * Lrecl;
PushWarning(g, Tdbp);
} else
return true;
......@@ -956,6 +969,7 @@ int DBMFAM::Cardinality(PGLOBAL g)
if (Accept) {
Lrecl = rln;
Blksize = Nrec * Lrecl;
PushWarning(g, Tdbp);
} else
return -1;
......@@ -1008,6 +1022,7 @@ bool DBMFAM::AllocateBuffer(PGLOBAL g)
if (Accept) {
Lrecl = hp->Reclen();
Blksize = Nrec * Lrecl;
PushWarning(g, Tdbp);
} else
return true;
......
......@@ -724,20 +724,20 @@ void ZBKFAM::Rewind(void)
/***********************************************************************/
/* Constructors. */
/***********************************************************************/
ZIXFAM::ZIXFAM(PDOSDEF tdp) : ZBKFAM(tdp)
GZXFAM::GZXFAM(PDOSDEF tdp) : ZBKFAM(tdp)
{
//Block = tdp->GetBlock();
//Last = tdp->GetLast();
Nrec = (tdp->GetElemt()) ? tdp->GetElemt() : DOS_BUFF_LEN;
Blksize = Nrec * Lrecl;
} // end of ZIXFAM standard constructor
} // end of GZXFAM standard constructor
/***********************************************************************/
/* ZIX Cardinality: returns table cardinality in number of rows. */
/* This function can be called with a null argument to test the */
/* availability of Cardinality implementation (1 yes, 0 no). */
/***********************************************************************/
int ZIXFAM::Cardinality(PGLOBAL g)
int GZXFAM::Cardinality(PGLOBAL g)
{
if (Last)
return (g) ? (int)((Block - 1) * Nrec + Last) : 1;
......@@ -750,7 +750,7 @@ int ZIXFAM::Cardinality(PGLOBAL g)
/* Allocate the line buffer. For mode Delete a bigger buffer has to */
/* be allocated because is it also used to move lines into the file. */
/***********************************************************************/
bool ZIXFAM::AllocateBuffer(PGLOBAL g)
bool GZXFAM::AllocateBuffer(PGLOBAL g)
{
Buflen = Blksize;
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
......@@ -788,7 +788,7 @@ bool ZIXFAM::AllocateBuffer(PGLOBAL g)
/***********************************************************************/
/* ReadBuffer: Read one line from a compressed text file. */
/***********************************************************************/
int ZIXFAM::ReadBuffer(PGLOBAL g)
int GZXFAM::ReadBuffer(PGLOBAL g)
{
int n, rc = RC_OK;
......@@ -850,7 +850,7 @@ int ZIXFAM::ReadBuffer(PGLOBAL g)
/* WriteDB: Data Base write routine for ZDOS access method. */
/* Update is not possible without using a temporary file (NIY). */
/***********************************************************************/
int ZIXFAM::WriteBuffer(PGLOBAL g)
int GZXFAM::WriteBuffer(PGLOBAL g)
{
/*********************************************************************/
/* In Insert mode, blocs are added sequentialy to the file end. */
......
......@@ -12,7 +12,7 @@
typedef class GZFAM *PGZFAM;
typedef class ZBKFAM *PZBKFAM;
typedef class ZIXFAM *PZIXFAM;
typedef class GZXFAM *PZIXFAM;
typedef class ZLBFAM *PZLBFAM;
/***********************************************************************/
......@@ -101,16 +101,16 @@ class DllExport ZBKFAM : public GZFAM {
/* length files compressed using the gzip library functions. */
/* The file is always accessed by block. */
/***********************************************************************/
class DllExport ZIXFAM : public ZBKFAM {
class DllExport GZXFAM : public ZBKFAM {
public:
// Constructor
ZIXFAM(PDOSDEF tdp);
ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {}
GZXFAM(PDOSDEF tdp);
GZXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {}
// Implementation
virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIXFAM(this);}
{return (PTXF)new(g) GZXFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g);
......@@ -120,7 +120,7 @@ class DllExport ZIXFAM : public ZBKFAM {
protected:
// No additional Members
}; // end of class ZIXFAM
}; // end of class GZXFAM
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */
......
This diff is collapsed.
/************** filamzip H Declares Source Code File (.H) **************/
/* Name: filamzip.h Version 1.0 */
/* Name: filamzip.h Version 1.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2016 */
/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */
/* */
/* This file contains the ZIP file access method classes declares. */
/***********************************************************************/
......@@ -10,10 +10,14 @@
#include "block.h"
#include "filamap.h"
#include "filamfix.h"
#include "zip.h"
#include "unzip.h"
#define DLLEXPORT extern "C"
typedef class UNZFAM *PUNZFAM;
typedef class UZXFAM *PUZXFAM;
typedef class ZIPFAM *PZIPFAM;
typedef class ZPXFAM *PZPXFAM;
......@@ -21,16 +25,50 @@ typedef class ZPXFAM *PZPXFAM;
/* This is the ZIP utility fonctions class. */
/***********************************************************************/
class DllExport ZIPUTIL : public BLOCK {
public:
public:
// Constructor
ZIPUTIL(PSZ tgt, bool mul);
//ZIPUTIL(ZIPUTIL *zutp);
ZIPUTIL(PSZ tgt);
//ZIPUTIL(ZIPUTIL *zutp);
// Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)ZIPFAM(this); }
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods
virtual bool OpenTable(PGLOBAL g, MODE mode, char *fn);
bool OpenTable(PGLOBAL g, MODE mode, char *fn, bool append);
bool open(PGLOBAL g, char *fn, bool append);
bool addEntry(PGLOBAL g, char *entry);
void close(void);
void closeEntry(void);
int writeEntry(PGLOBAL g, char *buf, int len);
void getTime(tm_zip& tmZip);
// Members
zipFile zipfile; // The ZIP container file
PSZ target; // The target file name
//unz_file_info finfo; // The current file info
PFBLOCK fp;
//char *memory;
//uint size;
//int multiple; // Multiple targets
bool entryopen; // True when open current entry
//char fn[FILENAME_MAX]; // The current entry file name
//char mapCaseTable[256];
}; // end of ZIPUTIL
/***********************************************************************/
/* This is the unZIP utility fonctions class. */
/***********************************************************************/
class DllExport UNZIPUTL : public BLOCK {
public:
// Constructor
UNZIPUTL(PSZ tgt, bool mul);
//UNZIPUTL(UNZIPUTL *zutp);
// Implementation
//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
// Methods
bool OpenTable(PGLOBAL g, MODE mode, char *fn);
bool open(PGLOBAL g, char *fn);
bool openEntry(PGLOBAL g);
void close(void);
......@@ -50,68 +88,120 @@ class DllExport ZIPUTIL : public BLOCK {
bool entryopen; // True when open current entry
char fn[FILENAME_MAX]; // The current entry file name
char mapCaseTable[256];
}; // end of ZIPFAM
}; // end of UNZIPUTL
/***********************************************************************/
/* This is the ZIP file access method. */
/* This is the unzip file access method. */
/***********************************************************************/
class DllExport ZIPFAM : public MAPFAM {
friend class ZPXFAM;
public:
class DllExport UNZFAM : public MAPFAM {
//friend class UZXFAM;
public:
// Constructors
ZIPFAM(PDOSDEF tdp);
ZIPFAM(PZIPFAM txfp);
ZIPFAM(PDOSDEF tdp, PZPXFAM txfp);
UNZFAM(PDOSDEF tdp);
UNZFAM(PUNZFAM txfp);
// Implementation
virtual AMT GetAmType(void) { return TYPE_AM_ZIP; }
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)ZIPFAM(this); }
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
virtual PTXF Duplicate(PGLOBAL g) {return (PTXF) new(g) UNZFAM(this);}
// Methods
virtual int Cardinality(PGLOBAL g);
virtual int GetFileLength(PGLOBAL g);
//virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
//virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool OpenTableFile(PGLOBAL g);
virtual bool DeferReading(void) { return false; }
virtual int GetNext(PGLOBAL g);
//virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
//virtual int DeleteRecords(PGLOBAL g, int irc);
//virtual void CloseTableFile(PGLOBAL g, bool abort);
//virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
//virtual int DeleteRecords(PGLOBAL g, int irc);
//virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
protected:
// Members
ZIPUTIL *zutp;
PSZ target;
bool mul;
}; // end of ZIPFAM
UNZIPUTL *zutp;
PSZ target;
bool mul;
}; // end of UNZFAM
/***********************************************************************/
/* This is the fixed ZIP file access method. */
/* This is the fixed unzip file access method. */
/***********************************************************************/
class DllExport ZPXFAM : public MPXFAM {
friend class ZIPFAM;
public:
class DllExport UZXFAM : public MPXFAM {
//friend class UNZFAM;
public:
// Constructors
ZPXFAM(PDOSDEF tdp);
ZPXFAM(PZPXFAM txfp);
UZXFAM(PDOSDEF tdp);
UZXFAM(PUZXFAM txfp);
// Implementation
virtual AMT GetAmType(void) { return TYPE_AM_ZIP; }
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)ZPXFAM(this); }
virtual PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UZXFAM(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);
//virtual int ReadBuffer(PGLOBAL g);
protected:
// Members
UNZIPUTL *zutp;
PSZ target;
bool mul;
}; // end of UZXFAM
/***********************************************************************/
/* This is the zip file access method. */
/***********************************************************************/
class DllExport ZIPFAM : public DOSFAM {
public:
// Constructors
ZIPFAM(PDOSDEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
// Methods
virtual int Cardinality(PGLOBAL g) {return 0;}
virtual int GetFileLength(PGLOBAL g) {return g ? 0 : 1;}
//virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
//virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
// Members
ZIPUTIL *zutp;
PSZ target;
bool append;
}; // end of ZIPFAM
/***********************************************************************/
/* This is the fixed zip file access method. */
/***********************************************************************/
class DllExport ZPXFAM : public FIXFAM {
public:
// Constructors
ZPXFAM(PDOSDEF tdp);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
// Methods
virtual int Cardinality(PGLOBAL g) {return 0;}
virtual int GetFileLength(PGLOBAL g) {return g ? 0 : 1;}
virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g, bool abort);
protected:
protected:
// Members
ZIPUTIL *zutp;
PSZ target;
bool mul;
bool append;
}; // end of ZPXFAM
#endif // __FILAMZIP_H
This diff is collapsed.
/************ Jdbconn C++ Functions Source Code File (.CPP) ************/
/* Name: JDBCONN.CPP Version 1.0 */
/* Name: JDBCONN.CPP Version 1.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2016 */
/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */
/* */
/* This file contains the JDBC connection classes functions. */
/***********************************************************************/
......@@ -45,9 +45,9 @@
#include "plgdbsem.h"
#include "xobject.h"
#include "xtable.h"
#include "tabext.h"
#include "tabjdbc.h"
//#include "jdbconn.h"
//#include "plgcnx.h" // For DB types
#include "resource.h"
#include "valblk.h"
#include "osutil.h"
......@@ -318,13 +318,21 @@ PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table, char *colpat,
/**************************************************************************/
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sjp)
{
char *sqry;
PQRYRES qrp;
JDBConn *jcp = new(g)JDBConn(g, NULL);
if (jcp->Open(sjp))
return NULL;
qrp = jcp->GetMetaData(g, src);
if (strstr(src, "%s")) {
// Place holder for an eventual where clause
sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2);
sprintf(sqry, src, "1=1"); // dummy where clause
} else
sqry = src;
qrp = jcp->GetMetaData(g, sqry);
jcp->Close();
return qrp;
} // end of JDBCSrcCols
......@@ -818,6 +826,11 @@ int JDBConn::Open(PJPARM sop)
jpop->Append(GetPluginDir());
jpop->Append("JdbcInterface.jar");
// All wrappers are pre-compiled in JavaWrappers.jar in the plugin dir
jpop->Append(sep);
jpop->Append(GetPluginDir());
jpop->Append("JavaWrappers.jar");
//================== prepare loading of Java VM ============================
JavaVMInitArgs vm_args; // Initialization arguments
JavaVMOption* options = new JavaVMOption[N]; // JVM invocation options
......@@ -1157,6 +1170,9 @@ void JDBConn::Close()
jint rc;
jmethodID did = nullptr;
// Could have been detached in case of join
rc = jvm->AttachCurrentThread((void**)&env, nullptr);
if (gmID(m_G, did, "JdbcDisconnect", "()I"))
printf("%s\n", Msg);
else if (Check(env->CallIntMethod(job, did)))
......
/*************** json CPP Declares Source Code File (.H) ***************/
/* Name: json.cpp Version 1.2 */
/* Name: json.cpp Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */
/* This file contains the JSON classes functions. */
/***********************************************************************/
......@@ -27,8 +27,33 @@
#define EL "\r\n"
#else
#define EL "\n"
#undef SE_CATCH // Does not work for Linux
#endif
#if defined(SE_CATCH)
/**************************************************************************/
/* This is the support of catching C interrupts to prevent crashes. */
/**************************************************************************/
#include <eh.h>
class SE_Exception {
public:
SE_Exception(unsigned int n, PEXCEPTION_RECORD p) : nSE(n), eRec(p) {}
~SE_Exception() {}
unsigned int nSE;
PEXCEPTION_RECORD eRec;
}; // end of class SE_Exception
void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp)
{
throw SE_Exception(u, pExp->ExceptionRecord);
} // end of trans_func
char *GetExceptionDesc(PGLOBAL g, unsigned int e);
#endif // SE_CATCH
/***********************************************************************/
/* Parse a json string. */
/* Note: when pretty is not known, the caller set pretty to 3. */
......@@ -40,6 +65,9 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
PJSON jsp = NULL;
STRG src;
if (trace)
htrc("ParseJson: s=%.10s len=%d\n", s, len);
if (!s || !len) {
strcpy(g->Message, "Void JSON object");
return NULL;
......@@ -53,15 +81,37 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
pty[0] = false;
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
goto err;
} // endif rc
#if defined(SE_CATCH)
// Let's try to recover from any kind of interrupt
_se_translator_function f = _set_se_translator(trans_func);
try {
#endif // SE_CATCH --------------------- try section --------------------
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
goto err;
} // endif rc
#if defined(SE_CATCH) // ------------- end of try section -----------------
} catch (SE_Exception e) {
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
GetExceptionDesc(g, e.nSE), e.nSE);
_set_se_translator(f);
goto err;
} catch (...) {
strcpy(g->Message, "Exception doing setjmp");
_set_se_translator(f);
goto err;
} // end of try-catches
_set_se_translator(f);
#endif // SE_CATCH
for (i = 0; i < len; i++)
switch (s[i]) {
......@@ -140,7 +190,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
strcpy(g->Message, "More than one item in file");
err:
g->jump_level--;
g->jump_level--;
return NULL;
} // end of ParseJson
......@@ -390,14 +440,14 @@ char *ParseString(PGLOBAL g, int& i, STRG& src)
// if (charset == utf8) {
char xs[5];
uint hex;
xs[0] = s[++i];
xs[1] = s[++i];
xs[2] = s[++i];
xs[3] = s[++i];
xs[4] = 0;
hex = strtoul(xs, NULL, 16);
if (hex < 0x80) {
p[n] = (uchar)hex;
} else if (hex < 0x800) {
......@@ -414,7 +464,7 @@ char *ParseString(PGLOBAL g, int& i, STRG& src)
} else {
char xs[3];
UINT hex;
i += 2;
xs[0] = s[++i];
xs[1] = s[++i];
......@@ -468,7 +518,7 @@ PVAL ParseNumeric(PGLOBAL g, int& i, STRG& src)
case '.':
if (!found_digit || has_dot || has_e)
goto err;
has_dot = true;
break;
case 'e':
......@@ -769,7 +819,7 @@ bool JOUTSTR::Escape(const char *s)
for (unsigned int i = 0; s[i]; i++)
switch (s[i]) {
case '"':
case '"':
case '\\':
case '\t':
case '\n':
......@@ -1057,7 +1107,7 @@ void JARRAY::InitArray(PGLOBAL g)
int i;
PJVAL jvp, *pjvp = &First;
for (Size = 0, jvp = First; jvp; jvp = jvp->Next)
for (Size = 0, jvp = First; jvp; jvp = jvp->Next)
if (!jvp->Del)
Size++;
......@@ -1191,8 +1241,8 @@ bool JARRAY::IsNull(void)
/***********************************************************************/
JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON()
{
Jsp = NULL;
Value = AllocateValue(g, valp);
Jsp = NULL;
Value = AllocateValue(g, valp);
Next = NULL;
Del = false;
} // end of JVALUE constructor
......@@ -1297,7 +1347,7 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
} // end of GetText
void JVALUE::SetValue(PJSON jsp)
{
{
if (jsp && jsp->GetType() == TYPE_JVAL) {
Jsp = jsp->GetJsp();
Value = jsp->GetValue();
......
This diff is collapsed.
/* Copyright (C) Olivier Bertrand 2004 - 2016
/* Copyright (C) Olivier Bertrand 2004 - 2017
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -16,9 +16,9 @@
/*************** Mycat CC Program Source Code File (.CC) ***************/
/* PROGRAM NAME: MYCAT */
/* ------------- */
/* Version 1.5 */
/* Version 1.6 */
/* */
/* Author: Olivier Bertrand 2012 - 2016 */
/* Author: Olivier Bertrand 2012 - 2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -58,9 +58,10 @@
#endif // UNIX
#include "global.h"
#include "plgdbsem.h"
#include "reldef.h"
#include "tabcol.h"
//#include "reldef.h"
#include "xtable.h"
#include "tabext.h"
#include "tabcol.h"
#include "filamtxt.h"
#include "tabdos.h"
#include "tabfmt.h"
......@@ -559,13 +560,13 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
case TAB_XML: tdp= new(g) XMLDEF; break;
#endif // XML_SUPPORT
#if defined(VCT_SUPPORT)
case TAB_VEC: tdp = new(g)VCTDEF; break;
case TAB_VEC: tdp = new(g) VCTDEF; break;
#endif // VCT_SUPPORT
#if defined(ODBC_SUPPORT)
case TAB_ODBC: tdp= new(g) ODBCDEF; break;
#endif // ODBC_SUPPORT
#if defined(JDBC_SUPPORT)
case TAB_JDBC: tdp= new(g)JDBCDEF; break;
case TAB_JDBC: tdp= new(g) JDBCDEF; break;
#endif // JDBC_SUPPORT
#if defined(__WIN__)
case TAB_MAC: tdp= new(g) MACDEF; break;
......
/************** MyConn C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYCONN */
/* ------------- */
/* Version 1.8 */
/* Version 1.9 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2007-2016 */
/* (C) Copyright to the author Olivier BERTRAND 2007-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -375,10 +375,18 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
if (!port)
port = mysqld_port;
if (!strnicmp(srcdef, "select ", 7)) {
query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9);
strcat(strcpy(query, srcdef), " LIMIT 0");
} else
if (!strnicmp(srcdef, "select ", 7) || strstr(srcdef, "%s")) {
query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 10);
if (strstr(srcdef, "%s"))
sprintf(query, srcdef, "1=1"); // dummy where clause
else
strcpy(query, srcdef);
if (!strnicmp(srcdef, "select ", 7))
strcat(query, " LIMIT 0");
} else
query = (char *)srcdef;
// Open a MySQL connection for this table
......
Warnings:
Warning 1105 No file name. Table will use t1.xml
#
# Testing zipped XML tables
#
CREATE TABLE t1 (
ISBN CHAR(13) NOT NULL FIELD_FORMAT='@',
LANG CHAR(2) NOT NULL FIELD_FORMAT='@',
SUBJECT CHAR(12) NOT NULL FIELD_FORMAT='@',
AUTHOR_FIRSTNAME CHAR(15) NOT NULL FIELD_FORMAT='AUTHOR/FIRSTNAME',
AUTHOR_LASTNAME CHAR(8) NOT NULL FIELD_FORMAT='AUTHOR/LASTNAME',
TRANSLATOR_PREFIX CHAR(24) DEFAULT NULL FIELD_FORMAT='TRANSLATOR/@PREFIX',
TRANSLATOR_FIRSTNAME CHAR(6) DEFAULT NULL FIELD_FORMAT='TRANSLATOR/FIRSTNAME',
TRANSLATOR_LASTNAME CHAR(6) DEFAULT NULL FIELD_FORMAT='TRANSLATOR/LASTNAME',
TITLE CHAR(30) NOT NULL,
PUBLISHER_NAME CHAR(15) NOT NULL FIELD_FORMAT='PUBLISHER/NAME',
PUBLISHER_PLACE CHAR(5) NOT NULL FIELD_FORMAT='PUBLISHER/PLACE',
DATEPUB CHAR(4) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample2.zip' ZIPPED=YES
OPTION_LIST='entry=xsample2.xml,load=xsample2.xml,rownode=BOOK,xmlsup=libxml2,expand=1,mulnode=AUTHOR';
SELECT * FROM t1;
ISBN 9782212090819
LANG fr
SUBJECT applications
AUTHOR_FIRSTNAME Jean-Christophe
AUTHOR_LASTNAME Bernadac
TRANSLATOR_PREFIX NULL
TRANSLATOR_FIRSTNAME NULL
TRANSLATOR_LASTNAME NULL
TITLE Construire une application XML
PUBLISHER_NAME Eyrolles
PUBLISHER_PLACE Paris
DATEPUB 1999
ISBN 9782212090819
LANG fr
SUBJECT applications
AUTHOR_FIRSTNAME Franois
AUTHOR_LASTNAME Knab
TRANSLATOR_PREFIX NULL
TRANSLATOR_FIRSTNAME NULL
TRANSLATOR_LASTNAME NULL
TITLE Construire une application XML
PUBLISHER_NAME Eyrolles
PUBLISHER_PLACE Paris
DATEPUB 1999
ISBN 9782840825685
LANG fr
SUBJECT applications
AUTHOR_FIRSTNAME William J.
AUTHOR_LASTNAME Pardi
TRANSLATOR_PREFIX adapt de l'anglais par
TRANSLATOR_FIRSTNAME James
TRANSLATOR_LASTNAME Guerin
TITLE XML en Action
PUBLISHER_NAME Microsoft Press
PUBLISHER_PLACE Paris
DATEPUB 1999
ISBN 9782212090529
LANG fr
SUBJECT gnral
AUTHOR_FIRSTNAME Alain
AUTHOR_LASTNAME Michard
TRANSLATOR_PREFIX NULL
TRANSLATOR_FIRSTNAME NULL
TRANSLATOR_LASTNAME NULL
TITLE XML, Langage et Applications
PUBLISHER_NAME Eyrolles
PUBLISHER_PLACE Paris
DATEPUB 2003
CREATE TABLE t2
ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample2.zip' ZIPPED=YES
OPTION_LIST='xmlsup=libxml2';
SELECT * FROM t2;
ISBN 9782212090819
LANG fr
SUBJECT applications
AUTHOR Jean-Christophe Bernadac
TRANSLATOR NULL
TITLE Construire une application XML
PUBLISHER Eyrolles Paris
DATEPUB 1999
ISBN 9782840825685
LANG fr
SUBJECT applications
AUTHOR William J. Pardi
TRANSLATOR James Guerin
TITLE XML en Action
PUBLISHER Microsoft Press Paris
DATEPUB 1999
ISBN 9782212090529
LANG fr
SUBJECT gnral
AUTHOR Alain Michard
TRANSLATOR NULL
TITLE XML, Langage et Applications
PUBLISHER Eyrolles Paris
DATEPUB 2003
DROP TABLE t1,t2;
#
# Testing zipped DOS tables
#
CREATE TABLE t1 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='newdos.zip'
OPTION_LIST='ENTRY=new1.dos' ZIPPED=1;
INSERT INTO t1 VALUES(1,'One'),(2,'Two'),(3,'Three'),(4,'Four'),(5,'Five'),(6,'Six'),(7,'Seven'),(8,'Eight'),(9,'Nine'),(10,'Ten');
SELECT * FROM t1;
digit letter
1 One
2 Two
3 Three
4 Four
5 Five
6 Six
7 Seven
8 Eight
9 Nine
10 Ten
CREATE TABLE t2 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='newdos.zip'
OPTION_LIST='ENTRY=new2.dos,APPEND=1' ZIPPED=1;
INSERT INTO t2 VALUES(11,'Eleven'),(12,'Twelve'),(13,'Thirteen'),(14,'Fourteen'),(15,'Fiften'),(16,'Sixteen'),(17,'Seventeen'),(18,'Eighteen'),(19,'Nineteen'),(20,'Twenty');
SELECT * FROM t2;
digit letter
11 Eleven
12 Twelve
13 Thirteen
14 Fourteen
15 Fiften
16 Sixteen
17 Seventeen
18 Eighteen
19 Nineteen
20 Twenty
CREATE TABLE t3 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='newdos.zip'
OPTION_LIST='MULENTRIES=1' ZIPPED=1;
SELECT * FROM t3;
digit letter
1 One
2 Two
3 Three
4 Four
5 Five
6 Six
7 Seven
8 Eight
9 Nine
10 Ten
11 Eleven
12 Twelve
13 Thirteen
14 Fourteen
15 Fiften
16 Sixteen
17 Seventeen
18 Eighteen
19 Nineteen
20 Twenty
CREATE TABLE t4 (
fn VARCHAR(256)NOT NULL,
cmpsize BIGINT NOT NULL FLAG=1,
uncsize BIGINT NOT NULL FLAG=2,
method INT NOT NULL FLAG=3)
ENGINE=CONNECT TABLE_TYPE=ZIP FILE_NAME='newdos.zip';
SELECT * FROM t4;
fn cmpsize uncsize method
new1.dos 67 79 8
new2.dos 77 112 8
DROP TABLE t1,t2,t3,t4;
#
# Testing zipped CSV tables
#
CREATE TABLE t1 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='ENTRY=new1.csv' HEADER=1 ZIPPED=1;
INSERT INTO t1 VALUES(1,'One'),(2,'Two'),(3,'Three'),(4,'Four'),(5,'Five'),(6,'Six'),(7,'Seven'),(8,'Eight'),(9,'Nine'),(10,'Ten');
SELECT * FROM t1;
digit letter
1 One
2 Two
3 Three
4 Four
5 Five
6 Six
7 Seven
8 Eight
9 Nine
10 Ten
CREATE TABLE td1
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='ENTRY=new1.csv' HEADER=1 ZIPPED=1;
SELECT * FROM td1;
digit letter
1 One
2 Two
3 Three
4 Four
5 Five
6 Six
7 Seven
8 Eight
9 Nine
10 Ten
DROP TABLE td1;
CREATE TABLE t2 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='ENTRY=new2.csv,APPEND=1' HEADER=1 ZIPPED=1;
INSERT INTO t2 VALUES(11,'Eleven'),(12,'Twelve'),(13,'Thirteen'),(14,'Fourteen'),(15,'Fiften'),(16,'Sixteen'),(17,'Seventeen'),(18,'Eighteen'),(19,'Nineteen'),(20,'Twenty');
SELECT * FROM t2;
digit letter
11 Eleven
12 Twelve
13 Thirteen
14 Fourteen
15 Fiften
16 Sixteen
17 Seventeen
18 Eighteen
19 Nineteen
20 Twenty
CREATE TABLE t3
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='MULENTRIES=1' HEADER=1 ZIPPED=1;
SELECT * FROM t3;
digit letter
1 One
2 Two
3 Three
4 Four
5 Five
6 Six
7 Seven
8 Eight
9 Nine
10 Ten
11 Eleven
12 Twelve
13 Thirteen
14 Fourteen
15 Fiften
16 Sixteen
17 Seventeen
18 Eighteen
19 Nineteen
20 Twenty
CREATE TABLE t4 (
fn VARCHAR(256)NOT NULL,
cmpsize BIGINT NOT NULL FLAG=1,
uncsize BIGINT NOT NULL FLAG=2,
method INT NOT NULL FLAG=3)
ENGINE=CONNECT TABLE_TYPE=ZIP FILE_NAME='newcsv.zip';
SELECT * FROM t4;
fn cmpsize uncsize method
new1.csv 79 83 8
new2.csv 94 125 8
DROP TABLE t1,t2,t3,t4;
#
# Testing zipped JSON tables
#
CREATE TABLE t1 (
_id INT(2) NOT NULL,
name_first CHAR(9) NOT NULL FIELD_FORMAT='name:first',
name_aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
name_last CHAR(10) NOT NULL FIELD_FORMAT='name:last',
title CHAR(12) DEFAULT NULL,
birth CHAR(20) DEFAULT NULL,
death CHAR(20) DEFAULT NULL,
contribs CHAR(7) NOT NULL FIELD_FORMAT='contribs:',
awards_award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards::award',
awards_year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards::year',
awards_by CHAR(38) DEFAULT NULL FIELD_FORMAT='awards::by'
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.zip' OPTION_LIST='ENTRY=bios.json,LOAD=bios.json' ZIPPED=YES;
SELECT * FROM t1;
_id name_first name_aka name_last title birth death contribs awards_award awards_year awards_by
1 John NULL Backus NULL 1924-12-03T05:00:00Z 2007-03-17T04:00:00Z Fortran W.W. McDowell Award 1967 IEEE Computer Society
2 John NULL McCarthy NULL 1927-09-04T04:00:00Z 2011-12-24T05:00:00Z Lisp Turing Award 1971 ACM
3 Grace NULL Hopper Rear Admiral 1906-12-09T05:00:00Z 1992-01-01T05:00:00Z UNIVAC Computer Sciences Man of the Year 1969 Data Processing Management Association
4 Kristen NULL Nygaard NULL 1926-08-27T04:00:00Z 2002-08-10T04:00:00Z OOP Rosing Prize 1999 Norwegian Data Association
5 Ole-Johan NULL Dahl NULL 1931-10-12T04:00:00Z 2002-06-29T04:00:00Z OOP Rosing Prize 1999 Norwegian Data Association
6 Guido NULL van Rossum NULL 1956-01-31T05:00:00Z NULL Python Award for the Advancement of Free Software 2001 Free Software Foundation
7 Dennis NULL Ritchie NULL 1941-09-09T04:00:00Z 2011-10-12T04:00:00Z UNIX Turing Award 1983 ACM
8 Yukihiro Matz Matsumoto NULL 1965-04-14T04:00:00Z NULL Ruby Award for the Advancement of Free Software 2011 Free Software Foundation
9 James NULL Gosling NULL 1955-05-19T04:00:00Z NULL Java The Economist Innovation Award 2002 The Economist
10 Martin NULL Odersky NULL NULL NULL Scala NULL NULL NULL
CREATE TABLE t2
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.zip' ZIPPED=1
OPTION_LIST='LEVEL=5';
SELECT * FROM t2;
_id name_first name_aka name_last title birth death contribs awards_award awards_year awards_by
1 John NULL Backus NULL 1924-12-03T05:00:00Z 2007-03-17T04:00:00Z Fortran W.W. McDowell Award 1967 IEEE Computer Society
2 John NULL McCarthy NULL 1927-09-04T04:00:00Z 2011-12-24T05:00:00Z Lisp Turing Award 1971 ACM
3 Grace NULL Hopper Rear Admiral 1906-12-09T05:00:00Z 1992-01-01T05:00:00Z UNIVAC Computer Sciences Man of the Year 1969 Data Processing Management Association
4 Kristen NULL Nygaard NULL 1926-08-27T04:00:00Z 2002-08-10T04:00:00Z OOP Rosing Prize 1999 Norwegian Data Association
5 Ole-Johan NULL Dahl NULL 1931-10-12T04:00:00Z 2002-06-29T04:00:00Z OOP Rosing Prize 1999 Norwegian Data Association
6 Guido NULL van Rossum NULL 1956-01-31T05:00:00Z NULL Python Award for the Advancement of Free Software 2001 Free Software Foundation
7 Dennis NULL Ritchie NULL 1941-09-09T04:00:00Z 2011-10-12T04:00:00Z UNIX Turing Award 1983 ACM
8 Yukihiro Matz Matsumoto NULL 1965-04-14T04:00:00Z NULL Ruby Award for the Advancement of Free Software 2011 Free Software Foundation
9 James NULL Gosling NULL 1955-05-19T04:00:00Z NULL Java The Economist Innovation Award 2002 The Economist
10 Martin NULL Odersky NULL NULL NULL Scala NULL NULL NULL
CREATE TABLE t3 (
_id INT(2) NOT NULL,
firstname CHAR(9) NOT NULL FIELD_FORMAT='name:first',
aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
lastname CHAR(10) NOT NULL FIELD_FORMAT='name:last',
title CHAR(12) DEFAULT NULL,
birth date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
death date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
contribs CHAR(64) NOT NULL FIELD_FORMAT='contribs:[", "]',
award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards:[x]:award',
year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards:[x]:year',
`by` CHAR(38) DEFAULT NULL FIELD_FORMAT='awards:[x]:by'
) ENGINE=CONNECT TABLE_TYPE='json' FILE_NAME='bios.zip' ZIPPED=YES;
SELECT * FROM t3 WHERE _id = 1;
_id firstname aka lastname title birth death contribs award year by
1 John NULL Backus NULL 1924-03-12 2008-05-03 Fortran, ALGOL, Backus-Naur Form, FP W.W. McDowell Award 1967 IEEE Computer Society
1 John NULL Backus NULL 1924-03-12 2008-05-03 Fortran, ALGOL, Backus-Naur Form, FP National Medal of Science 1975 National Science Foundation
1 John NULL Backus NULL 1924-03-12 2008-05-03 Fortran, ALGOL, Backus-Naur Form, FP Turing Award 1977 ACM
1 John NULL Backus NULL 1924-03-12 2008-05-03 Fortran, ALGOL, Backus-Naur Form, FP Draper Prize 1993 National Academy of Engineering
CREATE TABLE t4 (
fn VARCHAR(256)NOT NULL,
cmpsize BIGINT NOT NULL FLAG=1,
uncsize BIGINT NOT NULL FLAG=2,
method INT NOT NULL FLAG=3)
ENGINE=CONNECT TABLE_TYPE=ZIP FILE_NAME='bios.zip';
SELECT * FROM t4;
fn cmpsize uncsize method
bios.json 1096 6848 8
DROP TABLE t1,t2,t3,t4;
[
{
"_id" : 1,
"name" : {
"first" : "John",
"last" : "Backus"
},
"birth" : "1924-12-03T05:00:00Z",
"death" : "2007-03-17T04:00:00Z",
"contribs" : [
"Fortran",
"ALGOL",
"Backus-Naur Form",
"FP"
],
"awards" : [
{
"award" : "W.W. McDowell Award",
"year" : 1967,
"by" : "IEEE Computer Society"
},
{
"award" : "National Medal of Science",
"year" : 1975,
"by" : "National Science Foundation"
},
{
"award" : "Turing Award",
"year" : 1977,
"by" : "ACM"
},
{
"award" : "Draper Prize",
"year" : 1993,
"by" : "National Academy of Engineering"
}
]
},
{
"_id" : 2,
"name" : {
"first" : "John",
"last" : "McCarthy"
},
"birth" : "1927-09-04T04:00:00Z",
"death" : "2011-12-24T05:00:00Z",
"contribs" : [
"Lisp",
"Artificial Intelligence",
"ALGOL"
],
"awards" : [
{
"award" : "Turing Award",
"year" : 1971,
"by" : "ACM"
},
{
"award" : "Kyoto Prize",
"year" : 1988,
"by" : "Inamori Foundation"
},
{
"award" : "National Medal of Science",
"year" : 1990,
"by" : "National Science Foundation"
}
]
},
{
"_id" : 3,
"name" : {
"first" : "Grace",
"last" : "Hopper"
},
"title" : "Rear Admiral",
"birth" : "1906-12-09T05:00:00Z",
"death" : "1992-01-01T05:00:00Z",
"contribs" : [
"UNIVAC",
"compiler",
"FLOW-MATIC",
"COBOL"
],
"awards" : [
{
"award" : "Computer Sciences Man of the Year",
"year" : 1969,
"by" : "Data Processing Management Association"
},
{
"award" : "Distinguished Fellow",
"year" : 1973,
"by" : " British Computer Society"
},
{
"award" : "W. W. McDowell Award",
"year" : 1976,
"by" : "IEEE Computer Society"
},
{
"award" : "National Medal of Technology",
"year" : 1991,
"by" : "United States"
}
]
},
{
"_id" : 4,
"name" : {
"first" : "Kristen",
"last" : "Nygaard"
},
"birth" : "1926-08-27T04:00:00Z",
"death" : "2002-08-10T04:00:00Z",
"contribs" : [
"OOP",
"Simula"
],
"awards" : [
{
"award" : "Rosing Prize",
"year" : 1999,
"by" : "Norwegian Data Association"
},
{
"award" : "Turing Award",
"year" : 2001,
"by" : "ACM"
},
{
"award" : "IEEE John von Neumann Medal",
"year" : 2001,
"by" : "IEEE"
}
]
},
{
"_id" : 5,
"name" : {
"first" : "Ole-Johan",
"last" : "Dahl"
},
"birth" : "1931-10-12T04:00:00Z",
"death" : "2002-06-29T04:00:00Z",
"contribs" : [
"OOP",
"Simula"
],
"awards" : [
{
"award" : "Rosing Prize",
"year" : 1999,
"by" : "Norwegian Data Association"
},
{
"award" : "Turing Award",
"year" : 2001,
"by" : "ACM"
},
{
"award" : "IEEE John von Neumann Medal",
"year" : 2001,
"by" : "IEEE"
}
]
},
{
"_id" : 6,
"name" : {
"first" : "Guido",
"last" : "van Rossum"
},
"birth" : "1956-01-31T05:00:00Z",
"contribs" : [
"Python"
],
"awards" : [
{
"award" : "Award for the Advancement of Free Software",
"year" : 2001,
"by" : "Free Software Foundation"
},
{
"award" : "NLUUG Award",
"year" : 2003,
"by" : "NLUUG"
}
]
},
{
"_id" : 7,
"name" : {
"first" : "Dennis",
"last" : "Ritchie"
},
"birth" : "1941-09-09T04:00:00Z",
"death" : "2011-10-12T04:00:00Z",
"contribs" : [
"UNIX",
"C"
],
"awards" : [
{
"award" : "Turing Award",
"year" : 1983,
"by" : "ACM"
},
{
"award" : "National Medal of Technology",
"year" : 1998,
"by" : "United States"
},
{
"award" : "Japan Prize",
"year" : 2011,
"by" : "The Japan Prize Foundation"
}
]
},
{
"_id" : 8,
"name" : {
"first" : "Yukihiro",
"aka" : "Matz",
"last" : "Matsumoto"
},
"birth" : "1965-04-14T04:00:00Z",
"contribs" : [
"Ruby"
],
"awards" : [
{
"award" : "Award for the Advancement of Free Software",
"year" : "2011",
"by" : "Free Software Foundation"
}
]
},
{
"_id" : 9,
"name" : {
"first" : "James",
"last" : "Gosling"
},
"birth" : "1955-05-19T04:00:00Z",
"contribs" : [
"Java"
],
"awards" : [
{
"award" : "The Economist Innovation Award",
"year" : 2002,
"by" : "The Economist"
},
{
"award" : "Officer of the Order of Canada",
"year" : 2007,
"by" : "Canada"
}
]
},
{
"_id" : 10,
"name" : {
"first" : "Martin",
"last" : "Odersky"
},
"contribs" : [
"Scala"
]
}
]
<?xml version="1.0" encoding="UTF-8"?>
<BIBLIO SUBJECT="XML">
<BOOK ISBN="9782212090819" LANG="fr" SUBJECT="applications">
<AUTHOR>
<FIRSTNAME>Jean-Christophe</FIRSTNAME>
<LASTNAME>Bernadac</LASTNAME>
</AUTHOR>
<AUTHOR>
<FIRSTNAME>François</FIRSTNAME>
<LASTNAME>Knab</LASTNAME>
</AUTHOR>
<TITLE>Construire une application XML</TITLE>
<PUBLISHER>
<NAME>Eyrolles</NAME>
<PLACE>Paris</PLACE>
</PUBLISHER>
<DATEPUB>1999</DATEPUB>
</BOOK>
<BOOK ISBN="9782840825685" LANG="fr" SUBJECT="applications">
<AUTHOR>
<FIRSTNAME>William J.</FIRSTNAME>
<LASTNAME>Pardi</LASTNAME>
</AUTHOR>
<TRANSLATOR PREFIX="adapté de l'anglais par">
<FIRSTNAME>James</FIRSTNAME>
<LASTNAME>Guerin</LASTNAME>
</TRANSLATOR>
<TITLE>XML en Action</TITLE>
<PUBLISHER>
<NAME>Microsoft Press</NAME>
<PLACE>Paris</PLACE>
</PUBLISHER>
<DATEPUB>1999</DATEPUB>
</BOOK>
<BOOK ISBN="9782212090529" LANG="fr" SUBJECT="général">
<AUTHOR>
<FIRSTNAME>Alain</FIRSTNAME>
<LASTNAME>Michard</LASTNAME>
</AUTHOR>
<TITLE>XML, Langage et Applications</TITLE>
<PUBLISHER>
<NAME>Eyrolles</NAME>
<PLACE>Paris</PLACE>
</PUBLISHER>
<DATEPUB>2003</DATEPUB>
</BOOK>
</BIBLIO>
--disable_query_log
--error 0,ER_UNKNOWN_ERROR
CREATE TABLE t1 (a CHAR(10)) ENGINE=CONNECT TABLE_TYPE=ZIP FILE_NAME='test.zip';
if ($mysql_errno)
{
Skip No ZIP support;
}
#if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES
# WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
# AND ENGINE='CONNECT'
# AND CREATE_OPTIONS LIKE '%`table_type`=ZIP%'
# AND CREATE OPTIONS LIKE "%`file_name`='test.zip'%"`)
#{
# DROP TABLE IF EXISTS t1;
# Skip Need ZIP support;
#}
DROP TABLE t1;
--enable_query_log
--source have_zip.inc
--source have_libxml2.inc
let $MYSQLD_DATADIR= `select @@datadir`;
--vertical_results
--copy_file $MTR_SUITE_DIR/std_data/xsample2.xml $MYSQLD_DATADIR/test/xsample2.xml
--echo #
--echo # Testing zipped XML tables
--echo #
CREATE TABLE t1 (
ISBN CHAR(13) NOT NULL FIELD_FORMAT='@',
LANG CHAR(2) NOT NULL FIELD_FORMAT='@',
SUBJECT CHAR(12) NOT NULL FIELD_FORMAT='@',
AUTHOR_FIRSTNAME CHAR(15) NOT NULL FIELD_FORMAT='AUTHOR/FIRSTNAME',
AUTHOR_LASTNAME CHAR(8) NOT NULL FIELD_FORMAT='AUTHOR/LASTNAME',
TRANSLATOR_PREFIX CHAR(24) DEFAULT NULL FIELD_FORMAT='TRANSLATOR/@PREFIX',
TRANSLATOR_FIRSTNAME CHAR(6) DEFAULT NULL FIELD_FORMAT='TRANSLATOR/FIRSTNAME',
TRANSLATOR_LASTNAME CHAR(6) DEFAULT NULL FIELD_FORMAT='TRANSLATOR/LASTNAME',
TITLE CHAR(30) NOT NULL,
PUBLISHER_NAME CHAR(15) NOT NULL FIELD_FORMAT='PUBLISHER/NAME',
PUBLISHER_PLACE CHAR(5) NOT NULL FIELD_FORMAT='PUBLISHER/PLACE',
DATEPUB CHAR(4) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample2.zip' ZIPPED=YES
OPTION_LIST='entry=xsample2.xml,load=xsample2.xml,rownode=BOOK,xmlsup=libxml2,expand=1,mulnode=AUTHOR';
SELECT * FROM t1;
#testing discovery
CREATE TABLE t2
ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xsample2.zip' ZIPPED=YES
OPTION_LIST='xmlsup=libxml2';
SELECT * FROM t2;
DROP TABLE t1,t2;
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/xsample2.xml
--remove_file $MYSQLD_DATADIR/test/xsample2.zip
--source have_zip.inc
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/bios.json $MYSQLD_DATADIR/test/bios.json
--echo #
--echo # Testing zipped DOS tables
--echo #
CREATE TABLE t1 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='newdos.zip'
OPTION_LIST='ENTRY=new1.dos' ZIPPED=1;
INSERT INTO t1 VALUES(1,'One'),(2,'Two'),(3,'Three'),(4,'Four'),(5,'Five'),(6,'Six'),(7,'Seven'),(8,'Eight'),(9,'Nine'),(10,'Ten');
SELECT * FROM t1;
CREATE TABLE t2 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='newdos.zip'
OPTION_LIST='ENTRY=new2.dos,APPEND=1' ZIPPED=1;
INSERT INTO t2 VALUES(11,'Eleven'),(12,'Twelve'),(13,'Thirteen'),(14,'Fourteen'),(15,'Fiften'),(16,'Sixteen'),(17,'Seventeen'),(18,'Eighteen'),(19,'Nineteen'),(20,'Twenty');
SELECT * FROM t2;
CREATE TABLE t3 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='newdos.zip'
OPTION_LIST='MULENTRIES=1' ZIPPED=1;
SELECT * FROM t3;
CREATE TABLE t4 (
fn VARCHAR(256)NOT NULL,
cmpsize BIGINT NOT NULL FLAG=1,
uncsize BIGINT NOT NULL FLAG=2,
method INT NOT NULL FLAG=3)
ENGINE=CONNECT TABLE_TYPE=ZIP FILE_NAME='newdos.zip';
SELECT * FROM t4;
DROP TABLE t1,t2,t3,t4;
--echo #
--echo # Testing zipped CSV tables
--echo #
CREATE TABLE t1 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='ENTRY=new1.csv' HEADER=1 ZIPPED=1;
INSERT INTO t1 VALUES(1,'One'),(2,'Two'),(3,'Three'),(4,'Four'),(5,'Five'),(6,'Six'),(7,'Seven'),(8,'Eight'),(9,'Nine'),(10,'Ten');
SELECT * FROM t1;
# Test discovery
CREATE TABLE td1
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='ENTRY=new1.csv' HEADER=1 ZIPPED=1;
SELECT * FROM td1;
DROP TABLE td1;
CREATE TABLE t2 (
digit INT(3) NOT NULL,
letter CHAR(16) NOT NULL)
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='ENTRY=new2.csv,APPEND=1' HEADER=1 ZIPPED=1;
INSERT INTO t2 VALUES(11,'Eleven'),(12,'Twelve'),(13,'Thirteen'),(14,'Fourteen'),(15,'Fiften'),(16,'Sixteen'),(17,'Seventeen'),(18,'Eighteen'),(19,'Nineteen'),(20,'Twenty');
SELECT * FROM t2;
CREATE TABLE t3
ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='newcsv.zip'
OPTION_LIST='MULENTRIES=1' HEADER=1 ZIPPED=1;
SELECT * FROM t3;
CREATE TABLE t4 (
fn VARCHAR(256)NOT NULL,
cmpsize BIGINT NOT NULL FLAG=1,
uncsize BIGINT NOT NULL FLAG=2,
method INT NOT NULL FLAG=3)
ENGINE=CONNECT TABLE_TYPE=ZIP FILE_NAME='newcsv.zip';
SELECT * FROM t4;
DROP TABLE t1,t2,t3,t4;
--echo #
--echo # Testing zipped JSON tables
--echo #
CREATE TABLE t1 (
_id INT(2) NOT NULL,
name_first CHAR(9) NOT NULL FIELD_FORMAT='name:first',
name_aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
name_last CHAR(10) NOT NULL FIELD_FORMAT='name:last',
title CHAR(12) DEFAULT NULL,
birth CHAR(20) DEFAULT NULL,
death CHAR(20) DEFAULT NULL,
contribs CHAR(7) NOT NULL FIELD_FORMAT='contribs:',
awards_award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards::award',
awards_year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards::year',
awards_by CHAR(38) DEFAULT NULL FIELD_FORMAT='awards::by'
) ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.zip' OPTION_LIST='ENTRY=bios.json,LOAD=bios.json' ZIPPED=YES;
SELECT * FROM t1;
# Test discovery
CREATE TABLE t2
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bios.zip' ZIPPED=1
OPTION_LIST='LEVEL=5';
SELECT * FROM t2;
CREATE TABLE t3 (
_id INT(2) NOT NULL,
firstname CHAR(9) NOT NULL FIELD_FORMAT='name:first',
aka CHAR(4) DEFAULT NULL FIELD_FORMAT='name:aka',
lastname CHAR(10) NOT NULL FIELD_FORMAT='name:last',
title CHAR(12) DEFAULT NULL,
birth date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
death date DEFAULT NULL date_format="YYYY-DD-MM'T'hh:mm:ss'Z'",
contribs CHAR(64) NOT NULL FIELD_FORMAT='contribs:[", "]',
award CHAR(42) DEFAULT NULL FIELD_FORMAT='awards:[x]:award',
year CHAR(4) DEFAULT NULL FIELD_FORMAT='awards:[x]:year',
`by` CHAR(38) DEFAULT NULL FIELD_FORMAT='awards:[x]:by'
) ENGINE=CONNECT TABLE_TYPE='json' FILE_NAME='bios.zip' ZIPPED=YES;
SELECT * FROM t3 WHERE _id = 1;
CREATE TABLE t4 (
fn VARCHAR(256)NOT NULL,
cmpsize BIGINT NOT NULL FLAG=1,
uncsize BIGINT NOT NULL FLAG=2,
method INT NOT NULL FLAG=3)
ENGINE=CONNECT TABLE_TYPE=ZIP FILE_NAME='bios.zip';
SELECT * FROM t4;
DROP TABLE t1,t2,t3,t4;
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/newdos.zip
--remove_file $MYSQLD_DATADIR/test/newcsv.zip
--remove_file $MYSQLD_DATADIR/test/bios.zip
--remove_file $MYSQLD_DATADIR/test/bios.json
......@@ -35,8 +35,8 @@
#include "global.h"
#include "plgdbsem.h"
#include "xobject.h"
//#include "kindex.h"
#include "xtable.h"
#include "tabext.h"
#include "odbccat.h"
#include "tabodbc.h"
#include "plgcnx.h" // For DB types
......@@ -413,12 +413,20 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
/**************************************************************************/
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop)
{
char *sqry;
ODBConn *ocp = new(g) ODBConn(g, NULL);
if (ocp->Open(dsn, sop, 10) < 1) // openReadOnly + noOdbcDialog
return NULL;
return ocp->GetMetaData(g, dsn, src);
if (strstr(src, "%s")) {
// Place holder for an eventual where clause
sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 3);
sprintf(sqry, src, "1=1", "1=1"); // dummy where clause
} else
sqry = src;
return ocp->GetMetaData(g, dsn, sqry);
} // end of ODBCSrcCols
#if 0
......@@ -1417,7 +1425,7 @@ int ODBConn::ExecDirectSQL(char *sql, ODBCCOL *tocols)
b = true;
if (trace)
htrc("ExecDirect hstmt=%p %.64s\n", hstmt, sql);
htrc("ExecDirect hstmt=%p %.256s\n", hstmt, sql);
if (m_Tdb->Srcdef) {
// Be sure this is a query returning a result set
......
/************** PlgDBSem H Declares Source Code File (.H) **************/
/* Name: PLGDBSEM.H Version 3.7 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
/* */
/* This file contains the CONNECT storage engine definitions. */
/***********************************************************************/
......@@ -57,7 +57,7 @@ enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
TAB_FIX = 2, /* Fixed column offset, fixed LRECL */
TAB_BIN = 3, /* Like FIX but can have binary fields */
TAB_CSV = 4, /* DOS files with CSV records */
TAB_FMT = 5, /* DOS files with formatted recordss */
TAB_FMT = 5, /* DOS files with formatted records */
TAB_DBF = 6, /* DBF Dbase or Foxpro files */
TAB_XML = 7, /* XML or HTML files */
TAB_INI = 8, /* INI or CFG files */
......@@ -212,11 +212,24 @@ enum OPVAL {OP_EQ = 1, /* Filtering operator = */
OP_SUB = 17, /* Expression Substract operator */
OP_MULT = 18, /* Expression Multiply operator */
OP_DIV = 19, /* Expression Divide operator */
OP_NOP = 21, /* Scalar function is nopped */
OP_NUM = 22, /* Scalar function Op Num */
OP_ABS = 23, /* Scalar function Op Abs */
OP_MAX = 24, /* Scalar function Op Max */
OP_MIN = 25, /* Scalar function Op Min */
OP_EXP = 36, /* Scalar function Op Exp */
OP_FDISK = 94, /* Operator Disk of fileid */
OP_FPATH = 95, /* Operator Path of fileid */
OP_FNAME = 96, /* Operator Name of fileid */
OP_FTYPE = 97, /* Operator Type of fileid */
OP_LAST = 82, /* Index operator Find Last */
OP_FIRST = 106, /* Index operator Find First */
OP_NEXT = 107, /* Index operator Find Next */
OP_SAME = 108, /* Index operator Find Next Same */
OP_FSTDIF = 109, /* Index operator Find First dif */
OP_NXTDIF = 110, /* Index operator Find Next dif */
OP_PREV = 116}; /* Index operator Find Previous */
#if 0
OP_NOP = 21, /* Scalar function is nopped */
OP_ABS = 23, /* Scalar function Op Abs */
OP_CEIL = 26, /* Scalar function Op Ceil */
OP_FLOOR = 27, /* Scalar function Op Floor */
OP_MOD = 28, /* Scalar function Op Mod */
......@@ -312,6 +325,7 @@ enum OPVAL {OP_EQ = 1, /* Filtering operator = */
OP_REMOVE = 201, /* Scalar function Op Remove */
OP_RENAME = 202, /* Scalar function Op Rename */
OP_FCOMP = 203}; /* Scalar function Op Compare */
#endif // 0
enum TUSE {USE_NO = 0, /* Table is not yet linearized */
USE_LIN = 1, /* Table is linearized */
......@@ -356,6 +370,7 @@ typedef class XOBJECT *PXOB;
typedef class COLBLK *PCOL;
typedef class TDB *PTDB;
typedef class TDBASE *PTDBASE;
typedef class TDBEXT *PTDBEXT;
typedef class TDBDOS *PTDBDOS;
typedef class TDBFIX *PTDBFIX;
typedef class TDBFMT *PTDBFMT;
......@@ -374,6 +389,7 @@ typedef class KXYCOL *PXCOL;
typedef class CATALOG *PCATLG;
typedef class RELDEF *PRELDEF;
typedef class TABDEF *PTABDEF;
typedef class EXTDEF *PEXTBDEF;
typedef class DOSDEF *PDOSDEF;
typedef class CSVDEF *PCSVDEF;
typedef class VCTDEF *PVCTDEF;
......@@ -619,4 +635,4 @@ int global_open(GLOBAL *g, int msgid, const char *filename, int flags, int mode)
DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir);
char *MakeEscape(PGLOBAL g, char* str, char q);
DllExport bool PushWarning(PGLOBAL, PTDBASE, int level = 1);
DllExport bool PushWarning(PGLOBAL, PTDB, int level = 1);
/********** PlgDBUtl Fpe C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: PLGDBUTL */
/* ------------- */
/* Version 3.9 */
/* Version 4.0 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -939,7 +939,11 @@ int PlugCloseFile(PGLOBAL g __attribute__((unused)), PFBLOCK fp, bool all)
#endif // LIBXML2_SUPPORT
#ifdef ZIP_SUPPORT
case TYPE_FB_ZIP:
((ZIPUTIL*)fp->File)->close();
if (fp->Mode == MODE_INSERT)
((ZIPUTIL*)fp->File)->close();
else
((UNZIPUTL*)fp->File)->close();
fp->Memory = NULL;
fp->Mode = MODE_ANY;
fp->Count = 0;
......@@ -1119,7 +1123,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp)
return amn;
} // end of GetAmName
#if defined(__WIN__) && !defined(NOCATCH)
#if defined(SE_CATCH)
/***********************************************************************/
/* GetExceptionDesc: return the description of an exception code. */
/***********************************************************************/
......@@ -1207,7 +1211,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e)
return p;
} // end of GetExceptionDesc
#endif // __WIN__ && !NOCATCH
#endif // SE_CATCH
/***********************************************************************/
/* PlgDBalloc: allocates or suballocates memory conditionally. */
......
/******************************************************************/
/* Implementation of XML document processing using PdbXML. */
/* Author: Olivier Bertrand 2007-2012 */
/* Author: Olivier Bertrand 2007-2017 */
/******************************************************************/
#include "my_global.h"
#include "global.h"
......@@ -49,7 +49,7 @@ bool XMLDOCUMENT::InitZip(PGLOBAL g, char *entry)
{
#if defined(ZIP_SUPPORT)
bool mul = (entry) ? strchr(entry, '*') || strchr(entry, '?') : false;
zip = new(g) ZIPUTIL(entry, mul);
zip = new(g) UNZIPUTL(entry, mul);
return zip == NULL;
#else // !ZIP_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
......
......@@ -101,7 +101,7 @@ class XMLDOCUMENT : public BLOCK {
// Members
#if defined(ZIP_SUPPORT)
ZIPUTIL *zip; /* Used for zipped file */
UNZIPUTL *zip; /* Used for zipped file */
#else // !ZIP_SUPPORT
bool zip; /* Always false */
#endif // !ZIP_SUPPORT
......
......@@ -244,6 +244,9 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath)
char *drive = NULL, *defdrv = NULL;
#endif
if (trace > 1)
htrc("prefix=%s fn=%s path=%s\n", prefix, FileName, defpath);
if (!strncmp(FileName, "//", 2) || !strncmp(FileName, "\\\\", 2)) {
strcpy(pBuff, FileName); // Remote file
return pBuff;
......
......@@ -621,8 +621,8 @@ bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR, int)
/***********************************************************************/
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
{
RECFM rfm;
PTDBASE tdbp = NULL;
RECFM rfm;
PTDB tdbp = NULL;
// If define block not here yet, get it now
if (!Pxdef && !(Pxdef = GetXdef(g)))
......@@ -632,7 +632,7 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
/* Allocate a TDB of the proper type. */
/* Column blocks will be allocated only when needed. */
/*********************************************************************/
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode)))
if (!(tdbp = Pxdef->GetTable(g, mode)))
return NULL;
else
rfm = tdbp->GetFtype();
......
......@@ -64,15 +64,16 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
}; // end of RELDEF
/***********************************************************************/
/* These classes correspond to the data base description contained in */
/* a .XDB file the A.M. DOS, FIX, CSV, MAP, BIN, VCT, PLG, ODBC, DOM. */
/* This class corresponds to the data base description for tables */
/* of type DOS, FIX, CSV, DBF, BIN, VCT, JSON, XML... */
/***********************************************************************/
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
friend class CATALOG;
friend class PLUGCAT;
friend class MYCAT;
friend class TDBASE;
public:
friend class TDB;
friend class TDBEXT;
public:
// Constructor
TABDEF(void); // Constructor
......@@ -112,11 +113,11 @@ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
int Sort; /* Table already sorted ??? */
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */
int Degree; /* Number of columns in the table */
int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */
int Pseudo; /* Bit: 1 ROWID }Ok, 2 FILEID Ok */
bool Read_Only; /* true for read only tables */
const CHARSET_INFO *m_data_charset;
const char *csname; /* Table charset name */
}; // end of TABDEF
}; // end of TABDEF
/***********************************************************************/
/* Externally defined OEM tables. */
......@@ -190,11 +191,12 @@ class DllExport COLCRT : public BLOCK { /* Column description block
/***********************************************************************/
/* Column definition block. */
/***********************************************************************/
class DllExport COLDEF : public COLCRT { /* Column description block */
class DllExport COLDEF : public COLCRT { /* Column description block */
friend class TABDEF;
friend class COLBLK;
friend class DBFFAM;
friend class TDBASE;
friend class TDB;
friend class TDBASE;
friend class TDBDOS;
public:
COLDEF(void); // Constructor
......
......@@ -102,6 +102,7 @@ DOSDEF::DOSDEF(void)
Mapped = false;
Zipped = false;
Mulentries = false;
Append = false;
Padded = false;
Huge = false;
Accept = false;
......@@ -132,10 +133,13 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
: (am && (*am == 'B' || *am == 'b')) ? "B"
: (am && !stricmp(am, "DBF")) ? "D" : "V";
if ((Zipped = GetBoolCatInfo("Zipped", false)))
Mulentries = ((Entry = GetStringCatInfo(g, "Entry", NULL)))
? strchr(Entry, '*') || strchr(Entry, '?')
: GetBoolCatInfo("Mulentries", false);
if ((Zipped = GetBoolCatInfo("Zipped", false))) {
Entry = GetStringCatInfo(g, "Entry", NULL);
Mulentries = (Entry && *Entry) ? strchr(Entry, '*') || strchr(Entry, '?')
: false;
Mulentries = GetBoolCatInfo("Mulentries", Mulentries);
Append = GetBoolCatInfo("Append", false);
}
Desc = Fn = GetStringCatInfo(g, "Filename", NULL);
Ofn = GetStringCatInfo(g, "Optname", Fn);
......@@ -347,10 +351,26 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
if (Zipped) {
#if defined(ZIP_SUPPORT)
if (Recfm == RECFM_VAR) {
txfp = new(g)ZIPFAM(this);
tdbp = new(g)TDBDOS(this, txfp);
if (mode == MODE_READ || mode == MODE_ANY) {
txfp = new(g) UNZFAM(this);
} else if (mode == MODE_INSERT) {
txfp = new(g) ZIPFAM(this);
} else {
strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's mode
tdbp = new(g) TDBDOS(this, txfp);
} else {
txfp = new(g)ZPXFAM(this);
if (mode == MODE_READ || mode == MODE_ANY) {
txfp = new(g) UZXFAM(this);
} else if (mode == MODE_INSERT) {
txfp = new(g) ZPXFAM(this);
} else {
strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's mode
tdbp = new(g)TDBFIX(this, txfp);
} // endif Recfm
......@@ -376,7 +396,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) MPXFAM(this);
else if (Compressed) {
#if defined(GZ_SUPPORT)
txfp = new(g) ZIXFAM(this);
txfp = new(g) GZXFAM(this);
#else // !GZ_SUPPORT
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL;
......@@ -484,7 +504,7 @@ TDBDOS::TDBDOS(PGLOBAL g, PTDBDOS tdbp) : TDBASE(tdbp)
} // end of TDBDOS copy constructor
// Method
PTDB TDBDOS::CopyOne(PTABS t)
PTDB TDBDOS::Clone(PTABS t)
{
PTDB tp;
PDOSCOL cp1, cp2;
......@@ -498,7 +518,7 @@ PTDB TDBDOS::CopyOne(PTABS t)
} // endfor cp1
return tp;
} // end of CopyOne
} // end of Clone
/***********************************************************************/
/* Allocate DOS column description block. */
......
......@@ -28,7 +28,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
friend class TDBFIX;
friend class TXTFAM;
friend class DBFBASE;
friend class ZIPUTIL;
friend class UNZIPUTL;
public:
// Constructor
DOSDEF(void);
......@@ -43,7 +43,8 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
PSZ GetOfn(void) {return Ofn;}
PSZ GetEntry(void) {return Entry;}
bool GetMul(void) {return Mulentries;}
void SetBlock(int block) {Block = block;}
bool GetAppend(void) {return Append;}
void SetBlock(int block) { Block = block; }
int GetBlock(void) {return Block;}
int GetLast(void) {return Last;}
void SetLast(int last) {Last = last;}
......@@ -81,6 +82,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
bool Mapped; /* 0: disk file, 1: memory mapped file */
bool Zipped; /* true for zipped table file */
bool Mulentries; /* true for multiple entries */
bool Append; /* Used when creating zipped table */
bool Padded; /* true for padded table file */
bool Huge; /* true for files larger than 2GB */
bool Accept; /* true if wrong lines are accepted */
......@@ -140,7 +142,7 @@ class DllExport TDBDOS : public TDBASE {
{return (PTDB)new(g) TDBDOS(g, this);}
// Methods
virtual PTDB CopyOne(PTABS t);
virtual PTDB Clone(PTABS t);
virtual void ResetDB(void) {Txfp->Reset();}
virtual bool IsUsingTemp(PGLOBAL g);
virtual bool IsIndexed(void) {return Indxd;}
......
This diff is collapsed.
This diff is collapsed.
......@@ -77,7 +77,7 @@ TDBFIX::TDBFIX(PGLOBAL g, PTDBFIX tdbp) : TDBDOS(g, tdbp)
} // end of TDBFIX copy constructor
// Method
PTDB TDBFIX::CopyOne(PTABS t)
PTDB TDBFIX::Clone(PTABS t)
{
PTDB tp;
PGLOBAL g = t->G;
......@@ -105,7 +105,7 @@ PTDB TDBFIX::CopyOne(PTABS t)
} // endif Ftype
return tp;
} // end of CopyOne
} // end of Clone
/***********************************************************************/
/* Reset read/write position values. */
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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