Commit 41a2ca5c authored by Sergei Golubchik's avatar Sergei Golubchik

10.0-connect merge

parents 9d04a256 5c5834b0
...@@ -271,6 +271,7 @@ ENDIF(CONNECT_WITH_ODBC) ...@@ -271,6 +271,7 @@ ENDIF(CONNECT_WITH_ODBC)
MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES} MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
STORAGE_ENGINE STORAGE_ENGINE
COMPONENT connect-engine COMPONENT connect-engine
RECOMPILE_FOR_EMBEDDED
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${ODBC_LIBRARY} ${IPHLPAPI_LIBRARY}) ${ODBC_LIBRARY} ${IPHLPAPI_LIBRARY})
...@@ -38,10 +38,9 @@ typedef class BLOCK *PBLOCK; ...@@ -38,10 +38,9 @@ typedef class BLOCK *PBLOCK;
class DllExport BLOCK { class DllExport BLOCK {
public: public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) { void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
#ifdef DEBTRACE // if (trace > 2)
if (debug != NULL) // htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
#endif
return (PlugSubAlloc(g, p, size)); return (PlugSubAlloc(g, p, size));
} // end of new } // end of new
......
...@@ -43,7 +43,6 @@ typedef struct _colinfo { ...@@ -43,7 +43,6 @@ typedef struct _colinfo {
int Key; int Key;
int Precision; int Precision;
int Scale; int Scale;
int Opt;
char *Remark; char *Remark;
char *Datefmt; char *Datefmt;
char *Fieldfmt; char *Fieldfmt;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "xindex.h" #include "xindex.h"
#include "xtable.h" #include "xtable.h"
extern "C" int trace;
/***********************************************************************/ /***********************************************************************/
/* COLBLK protected constructor. */ /* COLBLK protected constructor. */
/***********************************************************************/ /***********************************************************************/
...@@ -36,7 +38,6 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i) ...@@ -36,7 +38,6 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
if ((Cdp = cdp)) { if ((Cdp = cdp)) {
Name = cdp->Name; Name = cdp->Name;
Format = cdp->F; Format = cdp->F;
Opt = cdp->Opt;
Long = cdp->Long; Long = cdp->Long;
Precision = cdp->Precision; Precision = cdp->Precision;
Buf_Type = cdp->Buf_Type; Buf_Type = cdp->Buf_Type;
...@@ -46,7 +47,6 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i) ...@@ -46,7 +47,6 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
} else { } else {
Name = NULL; Name = NULL;
memset(&Format, 0, sizeof(FORMAT)); memset(&Format, 0, sizeof(FORMAT));
Opt = 0;
Long = 0; Long = 0;
Precision = 0; Precision = 0;
Buf_Type = TYPE_ERROR; Buf_Type = TYPE_ERROR;
...@@ -74,9 +74,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp) ...@@ -74,9 +74,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp)
//To_Orig = col1; //To_Orig = col1;
To_Tdb = tdbp; To_Tdb = tdbp;
#ifdef DEBTRACE if (trace > 1)
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
#endif
if (tdbp) if (tdbp)
// Attach the new column to the table block // Attach the new column to the table block
...@@ -114,31 +113,21 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) ...@@ -114,31 +113,21 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{ {
fmt = Format; fmt = Format;
#ifdef DEBTRACE if (trace > 1)
htrc("COLBLK: %p format=%c(%d,%d)\n", htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec); this, *fmt.Type, fmt.Length, fmt.Prec);
#endif
return false; return false;
} // end of SetFormat } // end of SetFormat
/***********************************************************************/
/* CheckColumn: a column descriptor is found, say it by returning 1. */
/***********************************************************************/
int COLBLK::CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &p, int &ag)
{
return 1;
} // end of CheckColumn
/***********************************************************************/ /***********************************************************************/
/* Eval: get the column value from the last read record or from a */ /* Eval: get the column value from the last read record or from a */
/* matching Index column if there is one. */ /* matching Index column if there is one. */
/***********************************************************************/ /***********************************************************************/
bool COLBLK::Eval(PGLOBAL g) bool COLBLK::Eval(PGLOBAL g)
{ {
#ifdef DEBTRACE if (trace > 1)
htrc("Col Eval: %s status=%.4X\n", Name, Status); htrc("Col Eval: %s status=%.4X\n", Name, Status);
#endif
if (!GetStatus(BUF_READ)) { if (!GetStatus(BUF_READ)) {
// if (To_Tdb->IsNull()) // if (To_Tdb->IsNull())
...@@ -154,15 +143,6 @@ bool COLBLK::Eval(PGLOBAL g) ...@@ -154,15 +143,6 @@ bool COLBLK::Eval(PGLOBAL g)
return false; return false;
} // end of Eval } // end of Eval
/***********************************************************************/
/* CheckSort: */
/* Used to check that a table is involved in the sort list items. */
/***********************************************************************/
bool COLBLK::CheckSort(PTDB tdbp)
{
return (tdbp == To_Tdb);
} // end of CheckSort
/***********************************************************************/ /***********************************************************************/
/* InitValue: prepare a column block for read operation. */ /* InitValue: prepare a column block for read operation. */
/* Now we use Format.Length for the len parameter to avoid strings */ /* Now we use Format.Length for the len parameter to avoid strings */
...@@ -183,10 +163,9 @@ bool COLBLK::InitValue(PGLOBAL g) ...@@ -183,10 +163,9 @@ bool COLBLK::InitValue(PGLOBAL g)
AddStatus(BUF_READY); AddStatus(BUF_READY);
Value->SetNullable(Nullable); Value->SetNullable(Nullable);
#ifdef DEBTRACE if (trace > 1)
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n", htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
this, Buf_Type, Value, ColUse, Status); this, Buf_Type, Value, ColUse, Status);
#endif
return false; return false;
} // end of InitValue } // end of InitValue
......
...@@ -39,7 +39,6 @@ class DllExport COLBLK : public XOBJECT { ...@@ -39,7 +39,6 @@ class DllExport COLBLK : public XOBJECT {
PCOL GetNext(void) {return Next;} PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;} PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;} int GetIndex(void) {return Index;}
int GetOpt(void) {return Opt;}
ushort GetColUse(void) {return ColUse;} ushort GetColUse(void) {return ColUse;}
ushort GetColUse(ushort u) {return (ColUse & u);} ushort GetColUse(ushort u) {return (ColUse & u);}
ushort GetStatus(void) {return Status;} ushort GetStatus(void) {return Status;}
...@@ -62,10 +61,7 @@ class DllExport COLBLK : public XOBJECT { ...@@ -62,10 +61,7 @@ class DllExport COLBLK : public XOBJECT {
virtual void Reset(void); virtual void Reset(void);
virtual bool Compare(PXOB xp); virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL, FORMAT&); virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
virtual bool IsSpecial(void) {return false;} virtual bool IsSpecial(void) {return false;}
virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;}
virtual bool CheckSort(PTDB tdbp);
virtual bool Eval(PGLOBAL g); virtual bool Eval(PGLOBAL g);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetTo_Val(PVAL valp) {} virtual void SetTo_Val(PVAL valp) {}
...@@ -73,8 +69,6 @@ class DllExport COLBLK : public XOBJECT { ...@@ -73,8 +69,6 @@ class DllExport COLBLK : public XOBJECT {
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint); virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint); virtual void Print(PGLOBAL g, char *, uint);
virtual bool VarSize(void) {return false;}
virtual bool IsColInside(PCOL colp) {return this == colp;}
bool InitValue(PGLOBAL g); bool InitValue(PGLOBAL g);
protected: protected:
...@@ -87,7 +81,6 @@ class DllExport COLBLK : public XOBJECT { ...@@ -87,7 +81,6 @@ class DllExport COLBLK : public XOBJECT {
bool Nullable; // True if nullable bool Nullable; // True if nullable
bool Unsigned; // True if unsigned bool Unsigned; // True if unsigned
int Index; // Column number in table int Index; // Column number in table
int Opt; // Cluster/sort information
int Buf_Type; // Data type int Buf_Type; // Data type
int Long; // Internal length in table int Long; // Internal length in table
int Precision; // Column length (as for ODBC) int Precision; // Column length (as for ODBC)
...@@ -150,8 +143,6 @@ class DllExport FIDBLK : public SPCBLK { ...@@ -150,8 +143,6 @@ class DllExport FIDBLK : public SPCBLK {
// Methods // Methods
virtual void Reset(void) {} // This is a pseudo constant column virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 2 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
...@@ -171,8 +162,6 @@ class DllExport TIDBLK : public SPCBLK { ...@@ -171,8 +162,6 @@ class DllExport TIDBLK : public SPCBLK {
// Methods // Methods
virtual void Reset(void) {} // This is a pseudo constant column virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 3 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
...@@ -196,8 +185,6 @@ class DllExport SIDBLK : public SPCBLK { ...@@ -196,8 +185,6 @@ class DllExport SIDBLK : public SPCBLK {
// Methods // Methods
virtual void Reset(void) {} // This is a pseudo constant column virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 3 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
protected: protected:
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
/***********************************************************************/ /***********************************************************************/
/* DB static variables. */ /* DB static variables. */
/***********************************************************************/ /***********************************************************************/
extern int xtrace; extern "C" int trace;
/***********************************************************************/ /***********************************************************************/
/* Routines called internally by semantic routines. */ /* Routines called internally by semantic routines. */
...@@ -110,14 +110,14 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname) ...@@ -110,14 +110,14 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
bool rc= false; bool rc= false;
PDBUSER dbuserp= PlgGetUser(g); PDBUSER dbuserp= PlgGetUser(g);
if (xtrace) { if (trace) {
printf("CntCheckDB: dbuserp=%p\n", dbuserp); printf("CntCheckDB: dbuserp=%p\n", dbuserp);
} // endif xtrace } // endif trace
if (!dbuserp || !handler) if (!dbuserp || !handler)
return true; return true;
if (xtrace) if (trace)
printf("cat=%p oldhandler=%p newhandler=%p\n", dbuserp->Catalog, printf("cat=%p oldhandler=%p newhandler=%p\n", dbuserp->Catalog,
(dbuserp->Catalog) ? ((MYCAT*)dbuserp->Catalog)->GetHandler() : NULL, (dbuserp->Catalog) ? ((MYCAT*)dbuserp->Catalog)->GetHandler() : NULL,
handler); handler);
...@@ -149,7 +149,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname) ...@@ -149,7 +149,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
/*********************************************************************/ /*********************************************************************/
sprintf(g->Message, MSG(DATABASE_LOADED), "???"); sprintf(g->Message, MSG(DATABASE_LOADED), "???");
if (xtrace) if (trace)
printf("msg=%s\n", g->Message); printf("msg=%s\n", g->Message);
return rc; return rc;
...@@ -187,13 +187,13 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info) ...@@ -187,13 +187,13 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
/***********************************************************************/ /***********************************************************************/
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
{ {
int rc; int rc;
PTDB tdbp; PTDB tdbp;
PTABLE tabp; PTABLE tabp;
PDBUSER dup= PlgGetUser(g); PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL; // Safe over longjmp PCATLG cat= (dup) ? dup->Catalog : NULL; // Safe over longjmp
if (xtrace) if (trace)
printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat); printf("CntGetTDB: name=%s mode=%d cat=%p\n", name, mode, cat);
if (!cat) if (!cat)
...@@ -213,7 +213,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) ...@@ -213,7 +213,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
// Get table object from the catalog // Get table object from the catalog
tabp= new(g) XTAB(name); tabp= new(g) XTAB(name);
if (xtrace) if (trace)
printf("CntGetTDB: tabp=%p\n", tabp); printf("CntGetTDB: tabp=%p\n", tabp);
// Perhaps this should be made thread safe // Perhaps this should be made thread safe
...@@ -223,7 +223,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h) ...@@ -223,7 +223,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
printf("CntGetTDB: %s\n", g->Message); printf("CntGetTDB: %s\n", g->Message);
err: err:
if (xtrace) if (trace)
printf("Returning tdbp=%p mode=%d\n", tdbp, mode); printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
g->jump_level--; g->jump_level--;
...@@ -237,12 +237,13 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -237,12 +237,13 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
bool del, PHC h) bool del, PHC h)
{ {
char *p; char *p;
int i, n; int i, n, rc;
bool rcop= true;
PCOL colp; PCOL colp;
//PCOLUMN cp; //PCOLUMN cp;
PDBUSER dup= PlgGetUser(g); PDBUSER dup= PlgGetUser(g);
if (xtrace) if (trace)
printf("CntOpenTable: tdbp=%p mode=%d\n", tdbp, mode); printf("CntOpenTable: tdbp=%p mode=%d\n", tdbp, mode);
if (!tdbp) { if (!tdbp) {
...@@ -251,7 +252,15 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -251,7 +252,15 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
return true; return true;
} // endif tdbp } // endif tdbp
//tdbp->SetMode(mode); done in ha_connect::GetTDB // Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return true;
} // endif jump_level
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
goto err;
} // endif rc
if (!c1) { if (!c1) {
if (mode == MODE_INSERT) if (mode == MODE_INSERT)
...@@ -260,7 +269,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -260,7 +269,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} else for (p= c1; *p; p+= n) { } else for (p= c1; *p; p+= n) {
// Allocate only used column blocks // Allocate only used column blocks
if (xtrace) if (trace)
printf("Allocating column %s\n", p); printf("Allocating column %s\n", p);
// if (*p == '*') { // if (*p == '*') {
...@@ -273,7 +282,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -273,7 +282,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
if (!colp) { if (!colp) {
sprintf(g->Message, "Column %s not found in %s", p, tdbp->GetName()); sprintf(g->Message, "Column %s not found in %s", p, tdbp->GetName());
return true; goto err;
} // endif colp } // endif colp
n= strlen(p) + 1; n= strlen(p) + 1;
...@@ -281,12 +290,12 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -281,12 +290,12 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
for (i= 0, colp= tdbp->GetColumns(); colp; i++, colp= colp->GetNext()) { for (i= 0, colp= tdbp->GetColumns(); colp; i++, colp= colp->GetNext()) {
if (colp->InitValue(g)) if (colp->InitValue(g))
return true; goto err;
if (mode == MODE_INSERT) if (mode == MODE_INSERT)
// Allow type conversion // Allow type conversion
if (colp->SetBuffer(g, colp->GetValue(), true, false)) if (colp->SetBuffer(g, colp->GetValue(), true, false))
return true; goto err;
colp->AddColUse(U_P); // For PLG tables colp->AddColUse(U_P); // For PLG tables
} // endfor colp } // endfor colp
...@@ -301,7 +310,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -301,7 +310,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
if (!(utp= (PTDBASE)tdbp->Duplicate(g))) { if (!(utp= (PTDBASE)tdbp->Duplicate(g))) {
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName()); sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
return true; goto err;
} // endif tp } // endif tp
if (!c2) if (!c2)
...@@ -315,10 +324,10 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -315,10 +324,10 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
for (i= 0, colp= utp->GetColumns(); colp; i++, colp= colp->GetNext()) { for (i= 0, colp= utp->GetColumns(); colp; i++, colp= colp->GetNext()) {
if (colp->InitValue(g)) if (colp->InitValue(g))
return true; goto err;
if (colp->SetBuffer(g, colp->GetValue(), true, false)) if (colp->SetBuffer(g, colp->GetValue(), true, false))
return true; goto err;
} // endfor colp } // endfor colp
...@@ -328,7 +337,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -328,7 +337,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
((PTDBASE)tdbp)->SetSetCols(tdbp->GetColumns()); ((PTDBASE)tdbp)->SetSetCols(tdbp->GetColumns());
// Now do open the physical table // Now do open the physical table
if (xtrace) if (trace)
printf("Opening table %s in mode %d tdbp=%p\n", printf("Opening table %s in mode %d tdbp=%p\n",
tdbp->GetName(), mode, tdbp); tdbp->GetName(), mode, tdbp);
...@@ -344,19 +353,23 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, ...@@ -344,19 +353,23 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} // endif del } // endif del
if (xtrace) if (trace)
printf("About to open the table: tdbp=%p\n", tdbp); printf("About to open the table: tdbp=%p\n", tdbp);
if (mode != MODE_ANY && mode != MODE_ALTER) { if (mode != MODE_ANY && mode != MODE_ALTER) {
if (tdbp->OpenDB(g)) { if (tdbp->OpenDB(g)) {
printf("%s\n", g->Message); printf("%s\n", g->Message);
return true; goto err;
} else } else
tdbp->SetNext(NULL); tdbp->SetNext(NULL);
} // endif mode } // endif mode
return false; rcop= false;
err:
g->jump_level--;
return rcop;
} // end of CntOpenTable } // end of CntOpenTable
/***********************************************************************/ /***********************************************************************/
...@@ -374,14 +387,14 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp) ...@@ -374,14 +387,14 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp)
/***********************************************************************/ /***********************************************************************/
/* Evaluate all columns after a record is read. */ /* Evaluate all columns after a record is read. */
/***********************************************************************/ /***********************************************************************/
RCODE EvalColumns(PGLOBAL g, PTDB tdbp) RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
{ {
RCODE rc= RC_OK; RCODE rc= RC_OK;
PCOL colp; PCOL colp;
// Save stack and allocation environment and prepare error return // Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) { if (g->jump_level == MAX_JUMP) {
if (xtrace) { if (trace) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS)); strcpy(g->Message, MSG(TOO_MANY_JUMPS));
printf("EvalColumns: %s\n", g->Message); printf("EvalColumns: %s\n", g->Message);
} // endif } // endif
...@@ -390,7 +403,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp) ...@@ -390,7 +403,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
} // endif jump_level } // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) { if (setjmp(g->jumper[++g->jump_level]) != 0) {
if (xtrace) if (trace)
printf("Error reading columns: %s\n", g->Message); printf("Error reading columns: %s\n", g->Message);
rc= RC_FX; rc= RC_FX;
...@@ -416,7 +429,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp) ...@@ -416,7 +429,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
/***********************************************************************/ /***********************************************************************/
/* ReadNext: Read next record sequentially. */ /* ReadNext: Read next record sequentially. */
/***********************************************************************/ /***********************************************************************/
RCODE CntReadNext(PGLOBAL g, PTDB tdbp) RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
{ {
RCODE rc; RCODE rc;
...@@ -432,8 +445,21 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp) ...@@ -432,8 +445,21 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
((PTDBASE)tdbp)->SetKindex(NULL); ((PTDBASE)tdbp)->SetKindex(NULL);
} // endif index } // endif index
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return RC_FX;
} // endif jump_level
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
rc= RC_FX;
goto err;
} // endif rc
while ((rc= (RCODE)tdbp->ReadDB(g)) == RC_NF) ; while ((rc= (RCODE)tdbp->ReadDB(g)) == RC_NF) ;
err:
g->jump_level--;
return (rc != RC_OK) ? rc : EvalColumns(g, tdbp); return (rc != RC_OK) ? rc : EvalColumns(g, tdbp);
} // end of CntReadNext } // end of CntReadNext
...@@ -521,7 +547,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp) ...@@ -521,7 +547,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
if (!tdbp || tdbp->GetUse() != USE_OPEN) if (!tdbp || tdbp->GetUse() != USE_OPEN)
return rc; // Nothing to do return rc; // Nothing to do
if (xtrace) if (trace)
printf("CntCloseTable: tdbp=%p mode=%d\n", tdbp, tdbp->GetMode()); printf("CntCloseTable: tdbp=%p mode=%d\n", tdbp, tdbp->GetMode());
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN) if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN)
...@@ -545,7 +571,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp) ...@@ -545,7 +571,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
g->jump_level--; g->jump_level--;
if (xtrace > 1) if (trace > 1)
printf("Table %s closed\n", tdbp->GetName()); printf("Table %s closed\n", tdbp->GetName());
//if (!((PTDBDOX)tdbp)->GetModified()) //if (!((PTDBDOX)tdbp)->GetModified())
...@@ -554,8 +580,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp) ...@@ -554,8 +580,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
if (tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY) if (tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
return 0; return 0;
if (xtrace > 1) if (trace > 1)
printf("About to reset opt\n"); printf("About to reset indexes\n");
// Make all the eventual indexes // Make all the eventual indexes
tbxp= (TDBDOX*)tdbp; tbxp= (TDBDOX*)tdbp;
...@@ -564,7 +590,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp) ...@@ -564,7 +590,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable()); rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable());
err: err:
if (xtrace > 1) if (trace > 1)
printf("Done rc=%d\n", rc); printf("Done rc=%d\n", rc);
return (rc == RC_OK || rc == RC_INFO) ? 0 : rc; return (rc == RC_OK || rc == RC_INFO) ? 0 : rc;
...@@ -833,10 +859,10 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, ...@@ -833,10 +859,10 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
} else } else
valp->SetBinValue((void*)p); valp->SetBinValue((void*)p);
if (xtrace) { if (trace) {
char bf[32]; char bf[32];
printf("i=%d n=%d key=%s\n", i, n, valp->GetCharString(bf)); printf("i=%d n=%d key=%s\n", i, n, valp->GetCharString(bf));
} // endif xtrace } // endif trace
p+= valp->GetClen(); p+= valp->GetClen();
...@@ -855,7 +881,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, ...@@ -855,7 +881,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
xbp->SetNval(n); xbp->SetNval(n);
if (xtrace) if (trace)
printf("xbp=%p Nval=%d i=%d incl=%d\n", xbp, n, i, incl[i]); printf("xbp=%p Nval=%d i=%d incl=%d\n", xbp, n, i, incl[i]);
k[i]= xbp->Range(g, i + 1, incl[i]); k[i]= xbp->Range(g, i + 1, incl[i]);
...@@ -864,7 +890,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len, ...@@ -864,7 +890,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
} // endfor i } // endfor i
if (xtrace) if (trace)
printf("k1=%d k0=%d\n", k[1], k[0]); printf("k1=%d k0=%d\n", k[1], k[0]);
return k[1] - k[0]; return k[1] - k[0];
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
/* Name: CONNECT.H Version 2.4 */ /* Name: CONNECT.H Version 2.4 */
/* This file contains the some based classes declares. */ /* This file contains the some based classes declares. */
/***********************************************************************/ /***********************************************************************/
//#include "xtable.h" // Base class declares
#include "filamtxt.h" #include "filamtxt.h"
#include "tabdos.h" #include "tabdos.h"
...@@ -37,7 +36,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp); ...@@ -37,7 +36,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp);
int CntCloseTable(PGLOBAL g, PTDB tdbp); int CntCloseTable(PGLOBAL g, PTDB tdbp);
int CntIndexInit(PGLOBAL g, PTDB tdbp, int id); int CntIndexInit(PGLOBAL g, PTDB tdbp, int id);
RCODE CntReadNext(PGLOBAL g, PTDB tdbp); RCODE CntReadNext(PGLOBAL g, PTDB tdbp);
RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n); RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n);
RCODE CntWriteRow(PGLOBAL g, PTDB tdbp); RCODE CntWriteRow(PGLOBAL g, PTDB tdbp);
RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp); RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp);
RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all); RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all);
...@@ -51,8 +50,6 @@ PGLOBAL CntExit(PGLOBAL g); ...@@ -51,8 +50,6 @@ PGLOBAL CntExit(PGLOBAL g);
/* These classes purpose is chiefly to access protected items! */ /* These classes purpose is chiefly to access protected items! */
/***********************************************************************/ /***********************************************************************/
class DOXDEF: public DOSDEF { class DOXDEF: public DOSDEF {
//friend class TDBDOX;
//friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int); friend int CntIndexInit(PGLOBAL, PTDB, int);
}; // end of class DOXDEF }; // end of class DOXDEF
...@@ -73,10 +70,7 @@ class TDBDOX: public TDBDOS { ...@@ -73,10 +70,7 @@ class TDBDOX: public TDBDOS {
class XKPDEF: public KPARTDEF { class XKPDEF: public KPARTDEF {
friend class TDBDOX; friend class TDBDOX;
friend class ha_connect; friend class ha_connect;
//friend int CntMakeIndex(PGLOBAL, const char *, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int); friend int CntIndexInit(PGLOBAL, PTDB, int);
public: public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {} XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {}
}; // end of class XKPDEF }; // end of class XKPDEF
//RCODE CheckRecord(PGLOBAL g, PTDB tdbp, char *oldbuf, char *newbuf);
...@@ -22,9 +22,7 @@ ...@@ -22,9 +22,7 @@
#define THRESH 4 /* Threshold for insertion (was 4) */ #define THRESH 4 /* Threshold for insertion (was 4) */
#define MTHRESH 6 /* Threshold for median */ #define MTHRESH 6 /* Threshold for median */
#ifdef DEBTRACE //extern FILE *debug; /* Debug file */
extern FILE *debug; /* Debug file */
#endif
typedef int* const CPINT; typedef int* const CPINT;
......
...@@ -59,7 +59,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all) ...@@ -59,7 +59,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
xp->Count--; xp->Count--;
} else if (xp && xp->Count > 0) { } else if (xp && xp->Count > 0) {
try { try {
xp->Docp->Release(); if (xp->Docp)
xp->Docp->Release();
} catch(_com_error e) { } catch(_com_error e) {
sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description()); sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description());
} catch(...) {} } catch(...) {}
......
...@@ -20,7 +20,6 @@ typedef struct _xblock { /* Loaded XML file block */ ...@@ -20,7 +20,6 @@ typedef struct _xblock { /* Loaded XML file block */
short Type; /* TYPE_FB_XML */ short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */ int Retcode; /* Return code from Load */
MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */ MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */
//IXMLDOMNodeListPtr Nlist;
} XBLOCK, *PXBLOCK; } XBLOCK, *PXBLOCK;
/******************************************************************/ /******************************************************************/
...@@ -123,9 +122,6 @@ class DOMATTR : public XMLATTRIBUTE { ...@@ -123,9 +122,6 @@ class DOMATTR : public XMLATTRIBUTE {
friend class DOMDOC; friend class DOMDOC;
friend class DOMNODE; friend class DOMNODE;
public: public:
// Properties
//virtual char *GetText(void);
// Methods // Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len); virtual bool SetText(PGLOBAL g, char *txtp, int len);
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include "filamap.h" #include "filamap.h"
#include "tabdos.h" #include "tabdos.h"
extern "C" int trace;
/* --------------------------- Class MAPFAM -------------------------- */ /* --------------------------- Class MAPFAM -------------------------- */
/***********************************************************************/ /***********************************************************************/
...@@ -89,9 +91,8 @@ int MAPFAM::GetFileLength(PGLOBAL g) ...@@ -89,9 +91,8 @@ int MAPFAM::GetFileLength(PGLOBAL g)
len = (To_Fb) ? To_Fb->Length : TXTFAM::GetFileLength(g); len = (To_Fb) ? To_Fb->Length : TXTFAM::GetFileLength(g);
#ifdef DEBTRACE if (trace)
htrc("Mapped file length=%d\n", len); htrc("Mapped file length=%d\n", len);
#endif
return len; return len;
} // end of GetFileLength } // end of GetFileLength
...@@ -128,9 +129,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -128,9 +129,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
&& fp->Count && fp->Mode == mode) && fp->Count && fp->Mode == mode)
break; break;
#ifdef DEBTRACE if (trace)
htrc("Mapping file, fp=%p\n", fp); htrc("Mapping file, fp=%p\n", fp);
#endif
} else } else
fp = NULL; fp = NULL;
...@@ -166,9 +167,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -166,9 +167,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
sprintf(g->Message, MSG(OPEN_MODE_ERROR), sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"map", (int) rc, filename); "map", (int) rc, filename);
#ifdef DEBTRACE if (trace)
htrc("%s\n", g->Message); htrc("CreateFileMap: %s\n", g->Message);
#endif
return (mode == MODE_READ && rc == ENOENT) return (mode == MODE_READ && rc == ENOENT)
? PushWarning(g, Tdbp) : true; ? PushWarning(g, Tdbp) : true;
} // endif hFile } // endif hFile
...@@ -228,10 +229,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g) ...@@ -228,10 +229,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
Fpos = Mempos = Memory; Fpos = Mempos = Memory;
Top = Memory + len; Top = Memory + len;
#ifdef DEBTRACE if (trace)
htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n", htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
fp, fp->Count, Memory, len, Top); fp, fp->Count, Memory, len, Top);
#endif
return AllocateBuffer(g); // Useful for DBF files return AllocateBuffer(g); // Useful for DBF files
} // end of OpenTableFile } // end of OpenTableFile
...@@ -322,8 +322,8 @@ int MAPFAM::ReadBuffer(PGLOBAL g) ...@@ -322,8 +322,8 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
/* Record file position in case of UPDATE or DELETE. */ /* Record file position in case of UPDATE or DELETE. */
/*******************************************************************/ /*******************************************************************/
Fpos = Mempos; Fpos = Mempos;
CurBlk = (int)Rows++; CurBlk = (int)Rows++;
} else } else
Placed = false; Placed = false;
...@@ -365,20 +365,19 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -365,20 +365,19 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
{ {
int n; int n;
#ifdef DEBTRACE if (trace)
fprintf(debug, htrc("MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n",
"MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n", irc, Mempos, To_Buf, Tpos, Spos);
irc, Mempos, To_Buf, Tpos, Spos);
#endif
if (irc != RC_OK) { if (irc != RC_OK) {
/*******************************************************************/ /*******************************************************************/
/* EOF: position Fpos at the top of map position. */ /* EOF: position Fpos at the top of map position. */
/*******************************************************************/ /*******************************************************************/
Fpos = Top; Fpos = Top;
#ifdef DEBTRACE
htrc("Fpos placed at file top=%p\n", Fpos); if (trace)
#endif htrc("Fpos placed at file top=%p\n", Fpos);
} // endif irc } // endif irc
if (Tpos == Spos) if (Tpos == Spos)
...@@ -394,17 +393,16 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -394,17 +393,16 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
memmove(Tpos, Spos, n); memmove(Tpos, Spos, n);
Tpos += n; Tpos += n;
#ifdef DEBTRACE if (trace)
htrc("move %d bytes\n", n); htrc("move %d bytes\n", n);
#endif
} // endif n } // endif n
if (irc == RC_OK) { if (irc == RC_OK) {
Spos = Mempos; // New start position Spos = Mempos; // New start position
#ifdef DEBTRACE if (trace)
htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos); htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
#endif
} else if (To_Fb) { // Can be NULL for deleted files } else if (To_Fb) { // Can be NULL for deleted files
/*******************************************************************/ /*******************************************************************/
...@@ -432,9 +430,8 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc) ...@@ -432,9 +430,8 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX; return RC_FX;
} // endif } // endif
#ifdef DEBTRACE if (trace)
htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc); htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
#endif
if (!SetEndOfFile(fp->Handle)) { if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR), sprintf(g->Message, MSG(FUNCTION_ERROR),
...@@ -466,10 +463,10 @@ void MAPFAM::CloseTableFile(PGLOBAL g) ...@@ -466,10 +463,10 @@ void MAPFAM::CloseTableFile(PGLOBAL g)
PlugCloseFile(g, To_Fb); PlugCloseFile(g, To_Fb);
To_Fb = NULL; // To get correct file size in Cardinality To_Fb = NULL; // To get correct file size in Cardinality
#ifdef DEBTRACE if (trace)
htrc("MAP Close: closing %s count=%d\n", htrc("MAP Close: closing %s count=%d\n",
To_File, (To_Fb) ? To_Fb->Count : 0); To_File, (To_Fb) ? To_Fb->Count : 0);
#endif
} // end of CloseTableFile } // end of CloseTableFile
/***********************************************************************/ /***********************************************************************/
...@@ -491,7 +488,7 @@ MBKFAM::MBKFAM(PDOSDEF tdp) : MAPFAM(tdp) ...@@ -491,7 +488,7 @@ MBKFAM::MBKFAM(PDOSDEF tdp) : MAPFAM(tdp)
Block = tdp->GetBlock(); Block = tdp->GetBlock();
Last = tdp->GetLast(); Last = tdp->GetLast();
Nrec = tdp->GetElemt(); Nrec = tdp->GetElemt();
BlkPos = tdp->GetTo_Pos(); BlkPos = NULL;
CurNum = Nrec; CurNum = Nrec;
} // end of MBKFAM standard constructor } // end of MBKFAM standard constructor
...@@ -537,37 +534,8 @@ int MBKFAM::GetRowID(void) ...@@ -537,37 +534,8 @@ int MBKFAM::GetRowID(void)
/***********************************************************************/ /***********************************************************************/
int MBKFAM::ReadBuffer(PGLOBAL g) int MBKFAM::ReadBuffer(PGLOBAL g)
{ {
int len; strcpy(g->Message, "This AM cannot be used in this version");
return RC_FX;
/*********************************************************************/
/* Sequential block reading when Placed is not true. */
/*********************************************************************/
if (Placed) {
Placed = false;
} else if (Mempos >= Top) { // Are we at the end of the memory
return RC_EF;
} else if (++CurNum < Nrec) {
Fpos = Mempos;
} else {
/*******************************************************************/
/* New block. */
/*******************************************************************/
CurNum = 0;
if (++CurBlk >= Block)
return RC_EF;
Fpos = Mempos = Memory + BlkPos[CurBlk];
} // endif's
// Immediately calculate next position (Used by DeleteDB)
while (*Mempos++ != '\n') ; // What about Unix ???
// Set caller line buffer
len = (Mempos - Fpos) - Ending;
memcpy(Tdbp->GetLine(), Fpos, len);
Tdbp->GetLine()[len] = '\0';
return RC_OK;
} // end of ReadBuffer } // end of ReadBuffer
/***********************************************************************/ /***********************************************************************/
...@@ -657,7 +625,7 @@ int MPXFAM::ReadBuffer(PGLOBAL g) ...@@ -657,7 +625,7 @@ int MPXFAM::ReadBuffer(PGLOBAL g)
/* New block. */ /* New block. */
/*******************************************************************/ /*******************************************************************/
CurNum = 0; CurNum = 0;
if (++CurBlk >= Block) if (++CurBlk >= Block)
return RC_EF; return RC_EF;
......
...@@ -33,7 +33,6 @@ class DllExport MAPFAM : public TXTFAM { ...@@ -33,7 +33,6 @@ class DllExport MAPFAM : public TXTFAM {
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
...@@ -66,18 +65,16 @@ class DllExport MBKFAM : public MAPFAM { ...@@ -66,18 +65,16 @@ class DllExport MBKFAM : public MAPFAM {
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {} MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MBKFAM(this);} {return (PTXF)new(g) MBKFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
virtual int GetRowID(void); virtual int GetRowID(void);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// No additional members // No additional members
...@@ -99,9 +96,6 @@ class DllExport MPXFAM : public MBKFAM { ...@@ -99,9 +96,6 @@ class DllExport MPXFAM : public MBKFAM {
// Methods // Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);}
//virtual int GetRowID(void);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool DeferReading(void) {return false;} virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
......
...@@ -485,16 +485,15 @@ bool DBFFAM::OpenTableFile(PGLOBAL g) ...@@ -485,16 +485,15 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
if (!(Stream = PlugOpenFile(g, filename, opmode))) { if (!(Stream = PlugOpenFile(g, filename, opmode))) {
#ifdef DEBTRACE if (trace)
htrc("%s\n", g->Message); htrc("%s\n", g->Message);
#endif
return (mode == MODE_READ && errno == ENOENT) return (mode == MODE_READ && errno == ENOENT)
? PushWarning(g, Tdbp) : true; ? PushWarning(g, Tdbp) : true;
} // endif Stream } // endif Stream
#ifdef DEBTRACE if (trace)
htrc("File %s is open in mode %s\n", filename, opmode); htrc("File %s is open in mode %s\n", filename, opmode);
#endif
To_Fb = dbuserp->Openlist; // Keep track of File block To_Fb = dbuserp->Openlist; // Keep track of File block
...@@ -853,10 +852,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g) ...@@ -853,10 +852,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb); rc = PlugCloseFile(g, To_Fb);
fin: fin:
#ifdef DEBTRACE if (trace)
htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n", htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
To_File, mode, wrc, rc); To_File, mode, wrc, rc);
#endif
Stream = NULL; // So we can know whether table is open Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile } // end of CloseTableFile
......
...@@ -43,7 +43,6 @@ class DllExport DBFBASE { ...@@ -43,7 +43,6 @@ class DllExport DBFBASE {
int Nerr; /* Number of bad records */ int Nerr; /* Number of bad records */
int Maxerr; /* Maximum number of bad records */ int Maxerr; /* Maximum number of bad records */
int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */ int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */
//PSZ Defpath; /* Default data path */
}; // end of class DBFBASE }; // end of class DBFBASE
/****************************************************************************/ /****************************************************************************/
...@@ -63,22 +62,18 @@ class DllExport DBFFAM : public FIXFAM, public DBFBASE { ...@@ -63,22 +62,18 @@ class DllExport DBFFAM : public FIXFAM, public DBFBASE {
// Methods // Methods
virtual int GetNerr(void) {return Nerr;} virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members
virtual bool CopyHeader(PGLOBAL g); virtual bool CopyHeader(PGLOBAL g);
//int Records; in TXTFAM // Members
//int Headlen; in TXTFAM
}; // end of class DBFFAM }; // end of class DBFFAM
/****************************************************************************/ /****************************************************************************/
...@@ -100,17 +95,13 @@ class DllExport DBMFAM : public MPXFAM, public DBFBASE { ...@@ -100,17 +95,13 @@ class DllExport DBMFAM : public MPXFAM, public DBFBASE {
// Methods // Methods
virtual int GetNerr(void) {return Nerr;} virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
//int Records; in TXTFAM
//int Headlen; in TXTFAM
}; // end of class DBFFAM }; // end of class DBFFAM
#endif // __FILAMDBF_H #endif // __FILAMDBF_H
This diff is collapsed.
...@@ -31,18 +31,16 @@ class DllExport FIXFAM : public BLKFAM { ...@@ -31,18 +31,16 @@ class DllExport FIXFAM : public BLKFAM {
// Methods // Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) virtual bool AllocateBuffer(PGLOBAL g);
{return TXTFAM::MaxBlkSize(g, s);} virtual void ResetBuffer(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual int WriteBuffer(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
protected: protected:
virtual bool CopyHeader(PGLOBAL g) {return false;} virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members // No additional members
}; // end of class FIXFAM }; // end of class FIXFAM
...@@ -64,12 +62,11 @@ class BGXFAM : public FIXFAM { ...@@ -64,12 +62,11 @@ class BGXFAM : public FIXFAM {
{return (PTXF)new(g) BGXFAM(this);} {return (PTXF)new(g) BGXFAM(this);}
// Methods // Methods
//virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
...@@ -78,13 +75,12 @@ class BGXFAM : public FIXFAM { ...@@ -78,13 +75,12 @@ class BGXFAM : public FIXFAM {
, int org = FILE_BEGIN); , int org = FILE_BEGIN);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
// Members // Members
HANDLE Hfile; // Handle(descriptor) to big file HANDLE Hfile; // Handle(descriptor) to big file
HANDLE Tfile; // Handle(descriptor) to big temp file HANDLE Tfile; // Handle(descriptor) to big temp file
//BIGINT Xpos; // Current file position
}; // end of class BGXFAM }; // end of class BGXFAM
#endif // __FILAMFIX_H #endif // __FILAMFIX_H
...@@ -228,25 +228,6 @@ int TXTFAM::Cardinality(PGLOBAL g) ...@@ -228,25 +228,6 @@ int TXTFAM::Cardinality(PGLOBAL g)
} // end of Cardinality } // end of Cardinality
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/* Note: This function is meant only for fixed length files but is */
/* placed here to be available to FIXFAM and MPXFAM classes. */
/***********************************************************************/
int TXTFAM::MaxBlkSize(PGLOBAL g, int s)
{
int savcur = CurBlk, blm1 = Block - 1;
int size, last = s - blm1 * Nrec;
// Roughly estimate the table size as the sum of blocks
// that can contain good rows
for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
size += (CurBlk == blm1) ? last : Nrec;
CurBlk = savcur;
return size;
} // end of MaxBlkSize
/* --------------------------- Class DOSFAM -------------------------- */ /* --------------------------- Class DOSFAM -------------------------- */
/***********************************************************************/ /***********************************************************************/
...@@ -313,15 +294,6 @@ int DOSFAM::Cardinality(PGLOBAL g) ...@@ -313,15 +294,6 @@ int DOSFAM::Cardinality(PGLOBAL g)
return (g) ? -1 : 0; return (g) ? -1 : 0;
} // end of Cardinality } // end of Cardinality
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/* Note: This function is not really implemented yet. */
/***********************************************************************/
int DOSFAM::MaxBlkSize(PGLOBAL g, int s)
{
return s;
} // end of MaxBlkSize
/***********************************************************************/ /***********************************************************************/
/* OpenTableFile: Open a DOS/UNIX table file using C standard I/Os. */ /* OpenTableFile: Open a DOS/UNIX table file using C standard I/Os. */
/***********************************************************************/ /***********************************************************************/
...@@ -915,7 +887,8 @@ int DOSFAM::RenameTempFile(PGLOBAL g) ...@@ -915,7 +887,8 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
// This loop is necessary because, in case of join, // This loop is necessary because, in case of join,
// To_File can have been open several times. // To_File can have been open several times.
for (PFBLOCK fb = PlgGetUser(g)->Openlist; fb; fb = fb->Next) for (PFBLOCK fb = PlgGetUser(g)->Openlist; fb; fb = fb->Next)
rc = PlugCloseFile(g, fb); if (fb == To_Fb || fb == To_Fbt)
rc = PlugCloseFile(g, fb);
tempname = (char*)To_Fbt->Fname; tempname = (char*)To_Fbt->Fname;
PlugSetPath(filename, To_File, Tdbp->GetPath()); PlugSetPath(filename, To_File, Tdbp->GetPath());
...@@ -976,7 +949,9 @@ void DOSFAM::CloseTableFile(PGLOBAL g) ...@@ -976,7 +949,9 @@ void DOSFAM::CloseTableFile(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
void DOSFAM::Rewind(void) void DOSFAM::Rewind(void)
{ {
rewind(Stream); if (Stream) // Can be NULL when making index on void table
rewind(Stream);
Rows = 0; Rows = 0;
OldBlk = CurBlk = -1; OldBlk = CurBlk = -1;
} // end of Rewind } // end of Rewind
...@@ -993,7 +968,7 @@ BLKFAM::BLKFAM(PDOSDEF tdp) : DOSFAM(tdp) ...@@ -993,7 +968,7 @@ BLKFAM::BLKFAM(PDOSDEF tdp) : DOSFAM(tdp)
Last = tdp->GetLast(); Last = tdp->GetLast();
Nrec = tdp->GetElemt(); Nrec = tdp->GetElemt();
Closing = false; Closing = false;
BlkPos = tdp->GetTo_Pos(); BlkPos = NULL;
CurLine = NULL; CurLine = NULL;
NxtLine = NULL; NxtLine = NULL;
OutBuf = NULL; OutBuf = NULL;
...@@ -1028,23 +1003,6 @@ int BLKFAM::Cardinality(PGLOBAL g) ...@@ -1028,23 +1003,6 @@ int BLKFAM::Cardinality(PGLOBAL g)
//return (g) ? (int)((Block - 1) * Nrec + Last) : 1; //return (g) ? (int)((Block - 1) * Nrec + Last) : 1;
} // end of Cardinality } // end of Cardinality
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/***********************************************************************/
int BLKFAM::MaxBlkSize(PGLOBAL g, int s)
{
int savcur = CurBlk;
int size;
// Roughly estimate the table size as the sum of blocks
// that can contain good rows
for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
size += (CurBlk == Block - 1) ? Last : Nrec;
CurBlk = savcur;
return size;
} // end of MaxBlkSize
/***********************************************************************/ /***********************************************************************/
/* Allocate the line buffer. For mode Delete or when a temp file is */ /* Allocate the line buffer. For mode Delete or when a temp file is */
/* used another big buffer has to be allocated because is it used */ /* used another big buffer has to be allocated because is it used */
...@@ -1150,97 +1108,8 @@ int BLKFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -1150,97 +1108,8 @@ int BLKFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/ /***********************************************************************/
int BLKFAM::ReadBuffer(PGLOBAL g) int BLKFAM::ReadBuffer(PGLOBAL g)
{ {
int i, n, rc = RC_OK; strcpy(g->Message, "This AM cannot be used in this version");
return RC_FX;
/*********************************************************************/
/* Sequential reading when Placed is not true. */
/*********************************************************************/
if (Placed) {
Placed = false;
} else if (++CurNum < Rbuf) {
CurLine = NxtLine;
// Get the position of the next line in the buffer
while (*NxtLine++ != '\n') ;
// Set caller line buffer
n = NxtLine - CurLine - Ending;
memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0';
goto fin;
} else if (Rbuf < Nrec && CurBlk != -1) {
return RC_EF;
} else {
/*******************************************************************/
/* New block. */
/*******************************************************************/
CurNum = 0;
if (++CurBlk >= Block)
return RC_EF;
} // endif's
if (OldBlk == CurBlk)
goto ok; // Block is already there
// fseek is required only in non sequential reading
if (CurBlk != OldBlk + 1)
if (fseek(Stream, BlkPos[CurBlk], SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), BlkPos[CurBlk]);
return RC_FX;
} // endif fseek
// Calculate the length of block to read
BlkLen = BlkPos[CurBlk + 1] - BlkPos[CurBlk];
if (trace)
htrc("File position is now %d\n", ftell(Stream));
// Read the entire next block
n = fread(To_Buf, 1, (size_t)BlkLen, Stream);
if (n == BlkLen) {
// ReadBlks++;
num_read++;
Rbuf = (CurBlk == Block - 1) ? Last : Nrec;
ok:
rc = RC_OK;
// Get the position of the current line
for (i = 0, CurLine = To_Buf; i < CurNum; i++)
while (*CurLine++ != '\n') ; // What about Unix ???
// Now get the position of the next line
for (NxtLine = CurLine; *NxtLine++ != '\n';) ;
// Set caller line buffer
n = NxtLine - CurLine - Ending;
memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0';
} else if (feof(Stream)) {
rc = RC_EF;
} else {
#if defined(UNIX)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#endif
if (trace)
htrc("%s\n", g->Message);
return RC_FX;
} // endelse
OldBlk = CurBlk; // Last block actually read
IsRead = true; // Is read indeed
fin:
// Store the current record file position for Delete and Update
Fpos = BlkPos[CurBlk] + CurLine - To_Buf;
return rc;
} // end of ReadBuffer } // end of ReadBuffer
/***********************************************************************/ /***********************************************************************/
......
...@@ -39,10 +39,10 @@ class DllExport TXTFAM : public BLOCK { ...@@ -39,10 +39,10 @@ class DllExport TXTFAM : public BLOCK {
virtual int GetNextPos(void) = 0; virtual int GetNextPos(void) = 0;
virtual PTXF Duplicate(PGLOBAL g) = 0; virtual PTXF Duplicate(PGLOBAL g) = 0;
virtual bool GetUseTemp(void) {return false;} virtual bool GetUseTemp(void) {return false;}
virtual int GetDelRows(void) {return DelRows;} virtual int GetDelRows(void) {return DelRows;}
int GetCurBlk(void) {return CurBlk;} int GetCurBlk(void) {return CurBlk;}
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;} void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;}
int GetBlock(void) {return Block;} int GetBlock(void) {return Block;}
void SetBlkPos(int *bkp) {BlkPos = bkp;} void SetBlkPos(int *bkp) {BlkPos = bkp;}
void SetNrec(int n) {Nrec = n;} void SetNrec(int n) {Nrec = n;}
char *GetBuf(void) {return To_Buf;} char *GetBuf(void) {return To_Buf;}
...@@ -53,7 +53,6 @@ class DllExport TXTFAM : public BLOCK { ...@@ -53,7 +53,6 @@ class DllExport TXTFAM : public BLOCK {
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) {return false;} virtual bool AllocateBuffer(PGLOBAL g) {return false;}
virtual void ResetBuffer(PGLOBAL g) {} virtual void ResetBuffer(PGLOBAL g) {}
virtual int GetNerr(void) {return 0;} virtual int GetNerr(void) {return 0;}
...@@ -71,19 +70,19 @@ class DllExport TXTFAM : public BLOCK { ...@@ -71,19 +70,19 @@ class DllExport TXTFAM : public BLOCK {
protected: protected:
// Members // Members
PTDBDOS Tdbp; // To table class PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name PSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block PFBLOCK To_Fb; // Pointer to file block
bool Placed; // true if Recpos was externally set bool Placed; // true if Recpos was externally set
bool IsRead; // false for deferred reading bool IsRead; // false for deferred reading
bool Blocked; // true if using blocked I/O bool Blocked; // true if using blocked I/O
char *To_Buf; // Points to I/O buffer char *To_Buf; // Points to I/O buffer
void *DelBuf; // Buffer used to move lines in Delete void *DelBuf; // Buffer used to move lines in Delete
int *BlkPos; // To array of block positions int *BlkPos; // To array of block positions
int BlkLen; // Current block length int BlkLen; // Current block length
int Buflen; // Buffer length int Buflen; // Buffer length
int Dbflen; // Delete buffer length int Dbflen; // Delete buffer length
int Rows; // Number of rows read so far int Rows; // Number of rows read so far
int DelRows; // Number of deleted rows int DelRows; // Number of deleted rows
int Headlen; // Number of bytes in header int Headlen; // Number of bytes in header
int Lrecl; // Logical Record Length int Lrecl; // Logical Record Length
...@@ -93,14 +92,14 @@ class DllExport TXTFAM : public BLOCK { ...@@ -93,14 +92,14 @@ class DllExport TXTFAM : public BLOCK {
int OldBlk; // Index of last read block int OldBlk; // Index of last read block
int CurBlk; // Index of current block int CurBlk; // Index of current block
int CurNum; // Current buffer line number int CurNum; // Current buffer line number
int ReadBlks; // Number of blocks read (selected) int ReadBlks; // Number of blocks read (selected)
int Rbuf; // Number of lines read in buffer int Rbuf; // Number of lines read in buffer
int Modif; // Number of modified lines in block int Modif; // Number of modified lines in block
int Blksize; // Size of padded blocks int Blksize; // Size of padded blocks
int Ending; // Length of line end int Ending; // Length of line end
bool Padded; // true if fixed size blocks are padded bool Padded; // true if fixed size blocks are padded
bool Eof; // true if an EOF (0xA) character exists bool Eof; // true if an EOF (0xA) character exists
char *CrLf; // End of line character(s) char *CrLf; // End of line character(s)
}; // end of class TXTFAM }; // end of class TXTFAM
/***********************************************************************/ /***********************************************************************/
...@@ -125,7 +124,6 @@ class DllExport DOSFAM : public TXTFAM { ...@@ -125,7 +124,6 @@ class DllExport DOSFAM : public TXTFAM {
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
...@@ -134,7 +132,7 @@ class DllExport DOSFAM : public TXTFAM { ...@@ -134,7 +132,7 @@ class DllExport DOSFAM : public TXTFAM {
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
...@@ -174,7 +172,6 @@ class DllExport BLKFAM : public DOSFAM { ...@@ -174,7 +172,6 @@ class DllExport BLKFAM : public DOSFAM {
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
......
...@@ -244,23 +244,6 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g) ...@@ -244,23 +244,6 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g)
return rc; return rc;
} // end of SetBlockInfo } // end of SetBlockInfo
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/***********************************************************************/
int VCTFAM::MaxBlkSize(PGLOBAL g, int s)
{
int savcur = CurBlk;
int size;
// Roughly estimate the table size as the sum of blocks
// that can contain good rows
for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
size += (CurBlk == Block - 1) ? Last : Nrec;
CurBlk = savcur;
return size;
} // end of MaxBlkSize
/***********************************************************************/ /***********************************************************************/
/* VCT Cardinality: returns table cardinality in number of rows. */ /* VCT Cardinality: returns table cardinality in number of rows. */
/* This function can be called with a null argument to test the */ /* This function can be called with a null argument to test the */
......
...@@ -40,7 +40,6 @@ class DllExport VCTFAM : public FIXFAM { ...@@ -40,7 +40,6 @@ class DllExport VCTFAM : public FIXFAM {
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g); virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g) {} virtual void ResetBuffer(PGLOBAL g) {}
...@@ -74,11 +73,11 @@ class DllExport VCTFAM : public FIXFAM { ...@@ -74,11 +73,11 @@ class DllExport VCTFAM : public FIXFAM {
char *Colfn; // Pattern for column file names (VER) char *Colfn; // Pattern for column file names (VER)
char *Tempat; // Pattern for temp file names (VER) char *Tempat; // Pattern for temp file names (VER)
int *Clens; // Pointer to col size array int *Clens; // Pointer to col size array
int *Deplac; // Pointer to col start position array int *Deplac; // Pointer to col start position array
bool *Isnum; // Pointer to buffer type isnum result bool *Isnum; // Pointer to buffer type isnum result
bool AddBlock; // True when adding new blocks on Insert bool AddBlock; // True when adding new blocks on Insert
bool Split; // true: split column file vector format bool Split; // true: split column file vector format
int Header; // 0: no, 1: separate, 2: in data file int Header; // 0: no, 1: separate, 2: in data file
int MaxBlk; // Max number of blocks (True vector format) int MaxBlk; // Max number of blocks (True vector format)
int Bsize; // Because Nrec can be modified int Bsize; // Because Nrec can be modified
int Ncol; // The number of columns; int Ncol; // The number of columns;
...@@ -164,7 +163,7 @@ class DllExport VECFAM : public VCTFAM { ...@@ -164,7 +163,7 @@ class DllExport VECFAM : public VCTFAM {
FILE* *T_Streams; // Points to temp file structure array FILE* *T_Streams; // Points to temp file structure array
PFBLOCK *To_Fbs; // Pointer to file block array PFBLOCK *To_Fbs; // Pointer to file block array
PFBLOCK *T_Fbs; // Pointer to temp file block array PFBLOCK *T_Fbs; // Pointer to temp file block array
void* *To_Bufs; // Pointer to col val block array void* *To_Bufs; // Pointer to col val block array
bool InitUpdate; // Used to initialize updating bool InitUpdate; // Used to initialize updating
}; // end of class VECFAM }; // end of class VECFAM
...@@ -189,7 +188,7 @@ class DllExport VMPFAM : public VCMFAM { ...@@ -189,7 +188,7 @@ class DllExport VMPFAM : public VCMFAM {
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
protected: protected:
...@@ -220,7 +219,7 @@ class BGVFAM : public VCTFAM { ...@@ -220,7 +219,7 @@ class BGVFAM : public VCTFAM {
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
...@@ -233,11 +232,11 @@ class BGVFAM : public VCTFAM { ...@@ -233,11 +232,11 @@ class BGVFAM : public VCTFAM {
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g); virtual bool CleanUnusedSpace(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g); virtual bool SetBlockInfo(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g); virtual int GetBlockInfo(PGLOBAL g);
// Members // Members
HANDLE Hfile; // Handle to big file HANDLE Hfile; // Handle to big file
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
/* DB static variables. */ /* DB static variables. */
/***********************************************************************/ /***********************************************************************/
extern int num_read, num_there, num_eq[]; // Statistics extern int num_read, num_there, num_eq[]; // Statistics
extern "C" int trace;
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
...@@ -203,9 +204,8 @@ bool ZIPFAM::AllocateBuffer(PGLOBAL g) ...@@ -203,9 +204,8 @@ bool ZIPFAM::AllocateBuffer(PGLOBAL g)
Buflen = Lrecl + 2; // Lrecl does not include CRLF Buflen = Lrecl + 2; // Lrecl does not include CRLF
//Buflen *= ((Mode == MODE_DELETE) ? DOS_BUFF_LEN : 1); NIY //Buflen *= ((Mode == MODE_DELETE) ? DOS_BUFF_LEN : 1); NIY
#ifdef DEBTRACE if (trace)
htrc("SubAllocating a buffer of %d bytes\n", Buflen); htrc("SubAllocating a buffer of %d bytes\n", Buflen);
#endif
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen); To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
...@@ -331,9 +331,9 @@ int ZIPFAM::ReadBuffer(PGLOBAL g) ...@@ -331,9 +331,9 @@ int ZIPFAM::ReadBuffer(PGLOBAL g)
} else } else
rc = Zerror(g); rc = Zerror(g);
#ifdef DEBTRACE if (trace > 1)
htrc(" Read: '%s' rc=%d\n", To_Buf, rc); htrc(" Read: '%s' rc=%d\n", To_Buf, rc);
#endif
return rc; return rc;
} // end of ReadBuffer } // end of ReadBuffer
...@@ -373,9 +373,8 @@ void ZIPFAM::CloseTableFile(PGLOBAL g) ...@@ -373,9 +373,8 @@ void ZIPFAM::CloseTableFile(PGLOBAL g)
{ {
int rc = gzclose(Zfile); int rc = gzclose(Zfile);
#ifdef DEBTRACE if (trace)
htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc); htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
#endif
Zfile = NULL; // So we can know whether table is open Zfile = NULL; // So we can know whether table is open
//To_Fb->Count = 0; // Avoid double closing by PlugCloseAll //To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
...@@ -403,7 +402,7 @@ ZBKFAM::ZBKFAM(PDOSDEF tdp) : ZIPFAM(tdp) ...@@ -403,7 +402,7 @@ ZBKFAM::ZBKFAM(PDOSDEF tdp) : ZIPFAM(tdp)
CurLine = NULL; CurLine = NULL;
NxtLine = NULL; NxtLine = NULL;
Closing = false; Closing = false;
BlkPos = tdp->GetTo_Pos(); BlkPos = NULL;
} // end of ZBKFAM standard constructor } // end of ZBKFAM standard constructor
ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp) ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
...@@ -413,23 +412,6 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp) ...@@ -413,23 +412,6 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
Closing = txfp->Closing; Closing = txfp->Closing;
} // end of ZBKFAM copy constructor } // end of ZBKFAM copy constructor
/***********************************************************************/
/* Use BlockTest to reduce the table estimated size. */
/***********************************************************************/
int ZBKFAM::MaxBlkSize(PGLOBAL g, int s)
{
int savcur = CurBlk;
int size;
// Roughly estimate the table size as the sum of blocks
// that can contain good rows
for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
size += (CurBlk == Block - 1) ? Last : Nrec;
CurBlk = savcur;
return size;
} // end of MaxBlkSize
/***********************************************************************/ /***********************************************************************/
/* ZBK Cardinality: returns table cardinality in number of rows. */ /* ZBK Cardinality: returns table cardinality in number of rows. */
/* This function can be called with a null argument to test the */ /* This function can be called with a null argument to test the */
...@@ -509,56 +491,8 @@ int ZBKFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -509,56 +491,8 @@ int ZBKFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/ /***********************************************************************/
int ZBKFAM::ReadBuffer(PGLOBAL g) int ZBKFAM::ReadBuffer(PGLOBAL g)
{ {
int n, rc = RC_OK; strcpy(g->Message, "This AM cannot be used in this version");
return RC_FX;
/*********************************************************************/
/* Sequential reading when Placed is not true. */
/*********************************************************************/
if (++CurNum < Rbuf) {
CurLine = NxtLine;
// Get the position of the next line in the buffer
while (*NxtLine++ != '\n') ;
// Set caller line buffer
n = NxtLine - CurLine - Ending;
memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0';
return RC_OK;
} else if (Rbuf < Nrec && CurBlk != -1)
return RC_EF;
/*********************************************************************/
/* New block. */
/*********************************************************************/
CurNum = 0;
if (++CurBlk >= Block)
return RC_EF;
BlkLen = BlkPos[CurBlk + 1] - BlkPos[CurBlk];
if (!(n = gzread(Zfile, To_Buf, BlkLen))) {
rc = RC_EF;
} else if (n > 0) {
// Get the position of the current line
CurLine = To_Buf;
// Now get the position of the next line
for (NxtLine = CurLine; *NxtLine++ != '\n';) ;
// Set caller line buffer
n = NxtLine - CurLine - Ending;
memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0';
Rbuf = (CurBlk == Block - 1) ? Last : Nrec;
IsRead = true;
rc = RC_OK;
num_read++;
} else
rc = Zerror(g);
return rc;
} // end of ReadBuffer } // end of ReadBuffer
/***********************************************************************/ /***********************************************************************/
...@@ -664,9 +598,8 @@ void ZBKFAM::CloseTableFile(PGLOBAL g) ...@@ -664,9 +598,8 @@ void ZBKFAM::CloseTableFile(PGLOBAL g)
} else } else
rc = gzclose(Zfile); rc = gzclose(Zfile);
#ifdef DEBTRACE if (trace)
htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc); htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
#endif
Zfile = NULL; // So we can know whether table is open Zfile = NULL; // So we can know whether table is open
//To_Fb->Count = 0; // Avoid double closing by PlugCloseAll //To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
...@@ -770,9 +703,6 @@ int ZIXFAM::ReadBuffer(PGLOBAL g) ...@@ -770,9 +703,6 @@ int ZIXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0; CurNum = 0;
Tdbp->SetLine(To_Buf); Tdbp->SetLine(To_Buf);
//if (++CurBlk >= Block)
// return RC_EF;
if (!(n = gzread(Zfile, To_Buf, Buflen))) { if (!(n = gzread(Zfile, To_Buf, Buflen))) {
rc = RC_EF; rc = RC_EF;
} else if (n > 0) { } else if (n > 0) {
......
...@@ -38,7 +38,6 @@ class DllExport ZIPFAM : public TXTFAM { ...@@ -38,7 +38,6 @@ class DllExport ZIPFAM : public TXTFAM {
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
...@@ -78,7 +77,6 @@ class DllExport ZBKFAM : public ZIPFAM { ...@@ -78,7 +77,6 @@ class DllExport ZBKFAM : public ZIPFAM {
// Methods // Methods
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
...@@ -122,7 +120,7 @@ class DllExport ZIXFAM : public ZBKFAM { ...@@ -122,7 +120,7 @@ class DllExport ZIXFAM : public ZBKFAM {
// No additional Members // No additional Members
}; // end of class ZIXFAM }; // end of class ZIXFAM
#ifdef NOT_USED #if 0
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */ /* This is the DOS/UNIX Access Method class declaration for PlugDB */
/* fixed/variable files compressed using the zlib library functions. */ /* fixed/variable files compressed using the zlib library functions. */
...@@ -166,6 +164,6 @@ class DllExport ZLBFAM : public BLKFAM { ...@@ -166,6 +164,6 @@ class DllExport ZLBFAM : public BLKFAM {
int *Zlenp; // Pointer to block length int *Zlenp; // Pointer to block length
bool Optimized; // true when opt file is available bool Optimized; // true when opt file is available
}; // end of class ZLBFAM }; // end of class ZLBFAM
#endif // NOT_USED #endif // 0
#endif // __FILAMZIP_H #endif // __FILAMZIP_H
This diff is collapsed.
...@@ -122,8 +122,6 @@ struct ha_table_option_struct { ...@@ -122,8 +122,6 @@ struct ha_table_option_struct {
struct ha_field_option_struct struct ha_field_option_struct
{ {
ulonglong offset; ulonglong offset;
ulonglong freq; // Not used by this version
ulonglong opt; // Not used by this version
ulonglong fldlen; ulonglong fldlen;
const char *dateformat; const char *dateformat;
const char *fieldformat; const char *fieldformat;
...@@ -173,11 +171,13 @@ public: ...@@ -173,11 +171,13 @@ public:
bool GetBooleanOption(char *opname, bool bdef); bool GetBooleanOption(char *opname, bool bdef);
bool SetBooleanOption(char *opname, bool b); bool SetBooleanOption(char *opname, bool b);
int GetIntegerOption(char *opname); int GetIntegerOption(char *opname);
bool CheckString(const char *str1, const char *str2);
bool SameString(TABLE *tab, char *opn);
bool SetIntegerOption(char *opname, int n); bool SetIntegerOption(char *opname, int n);
bool SameChar(TABLE *tab, char *opn);
bool SameInt(TABLE *tab, char *opn); bool SameInt(TABLE *tab, char *opn);
bool SameBool(TABLE *tab, char *opn); bool SameBool(TABLE *tab, char *opn);
bool FileExists(const char *fn); bool FileExists(const char *fn);
bool NoFieldOptionChange(TABLE *tab);
PFOS GetFieldOptionStruct(Field *fp); PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf); void *GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf);
PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL); PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL);
...@@ -241,8 +241,8 @@ public: ...@@ -241,8 +241,8 @@ public:
*/ */
ulong index_flags(uint inx, uint part, bool all_parts) const ulong index_flags(uint inx, uint part, bool all_parts) const
{ {
return HA_READ_NEXT | HA_READ_RANGE; return HA_READ_NEXT | HA_READ_RANGE | HA_READ_ORDER | HA_KEYREAD_ONLY;
} } // end of index_flags
/** @brief /** @brief
unireg.cc will call max_supported_record_length(), max_supported_keys(), unireg.cc will call max_supported_record_length(), max_supported_keys(),
...@@ -328,7 +328,7 @@ public: ...@@ -328,7 +328,7 @@ public:
condition stack. condition stack.
*/ */
virtual const COND *cond_push(const COND *cond); virtual const COND *cond_push(const COND *cond);
PFIL CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond); PCFIL CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond);
const char *GetValStr(OPVAL vop, bool neg); const char *GetValStr(OPVAL vop, bool neg);
/** /**
...@@ -418,6 +418,9 @@ const char *GetValStr(OPVAL vop, bool neg); ...@@ -418,6 +418,9 @@ const char *GetValStr(OPVAL vop, bool neg);
*/ */
//int index_last(uchar *buf); //int index_last(uchar *buf);
/* Index condition pushdown implementation */
//Item *idx_cond_push(uint keyno, Item* idx_cond);
/** @brief /** @brief
Unlike index_init(), rnd_init() can be called two consecutive times Unlike index_init(), rnd_init() can be called two consecutive times
without rnd_end() in between (it only makes sense if scan=1). In this without rnd_end() in between (it only makes sense if scan=1). In this
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
extern "C" HINSTANCE s_hModule; // Saved module handle extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // !WIN32 #endif // !WIN32
extern int xtrace; extern "C" int trace;
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
...@@ -167,6 +167,29 @@ bool IsFileType(TABTYPE type) ...@@ -167,6 +167,29 @@ bool IsFileType(TABTYPE type)
return isfile; return isfile;
} // end of IsFileType } // end of IsFileType
/***********************************************************************/
/* Return true for table types returning exact row count. */
/***********************************************************************/
bool IsExactType(TABTYPE type)
{
bool exact;
switch (type) {
case TAB_FIX:
case TAB_BIN:
case TAB_DBF:
// case TAB_XML: depends on Multiple || Xpand || Coltype
case TAB_VEC:
exact= true;
break;
default:
exact= false;
break;
} // endswitch type
return exact;
} // end of IsExactType
/***********************************************************************/ /***********************************************************************/
/* Return true for table types accepting null fields. */ /* Return true for table types accepting null fields. */
/***********************************************************************/ /***********************************************************************/
...@@ -693,7 +716,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp) ...@@ -693,7 +716,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp) LPCSTR type, PRELDEF *prp)
{ {
if (xtrace) if (trace)
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
// If not specified get the type of this table // If not specified get the type of this table
...@@ -712,7 +735,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) ...@@ -712,7 +735,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
TABTYPE tc; TABTYPE tc;
PRELDEF tdp= NULL; PRELDEF tdp= NULL;
if (xtrace) if (trace)
printf("MakeTableDesc: name=%s am=%s\n", name, SVP(am)); printf("MakeTableDesc: name=%s am=%s\n", name, SVP(am));
/*********************************************************************/ /*********************************************************************/
...@@ -771,14 +794,14 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) ...@@ -771,14 +794,14 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
PTDB tdbp= NULL; PTDB tdbp= NULL;
LPCSTR name= tablep->GetName(); LPCSTR name= tablep->GetName();
if (xtrace) if (trace)
printf("GetTableDB: name=%s\n", name); printf("GetTableDB: name=%s\n", name);
// Look for the description of the requested table // Look for the description of the requested table
tdp= GetTableDesc(g, name, type); tdp= GetTableDesc(g, name, type);
if (tdp) { if (tdp) {
if (xtrace) if (trace)
printf("tdb=%p type=%s\n", tdp, tdp->GetType()); printf("tdb=%p type=%s\n", tdp, tdp->GetType());
if (tablep->GetQualifier()) if (tablep->GetQualifier())
...@@ -788,7 +811,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) ...@@ -788,7 +811,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
} // endif tdp } // endif tdp
if (tdbp) { if (tdbp) {
if (xtrace) if (trace)
printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(),
tdbp->GetAmType()); tdbp->GetAmType());
tablep->SetTo_Tdb(tdbp); tablep->SetTo_Tdb(tdbp);
......
...@@ -36,6 +36,7 @@ typedef class ha_connect *PHC; ...@@ -36,6 +36,7 @@ typedef class ha_connect *PHC;
TABTYPE GetTypeID(const char *type); TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type); bool IsFileType(TABTYPE type);
bool IsExactType(TABTYPE type);
bool IsTypeNullable(TABTYPE type); bool IsTypeNullable(TABTYPE type);
bool IsTypeFixed(TABTYPE type); bool IsTypeFixed(TABTYPE type);
bool IsTypeIndexable(TABTYPE type); bool IsTypeIndexable(TABTYPE type);
......
/************** MyConn C++ Program Source Code File (.CPP) **************/ /************** MyConn C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYCONN */ /* PROGRAM NAME: MYCONN */
/* ------------- */ /* ------------- */
/* Version 1.7 */ /* Version 1.8 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2007-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
#include "myconn.h" #include "myconn.h"
extern "C" int trace; extern "C" int trace;
extern MYSQL_PLUGIN_IMPORT uint mysqld_port; extern MYSQL_PLUGIN_IMPORT uint mysqld_port;
extern MYSQL_PLUGIN_IMPORT char *mysqld_unix_port;
// Returns the current used port // Returns the current used port
uint GetDefaultPort(void) uint GetDefaultPort(void)
...@@ -283,8 +284,11 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, ...@@ -283,8 +284,11 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
if (!port) if (!port)
port = mysqld_port; port = mysqld_port;
query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9); if (!strnicmp(srcdef, "select ", 7)) {
strcat(strcpy(query, srcdef), " LIMIT 0"); query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9);
strcat(strcpy(query, srcdef), " LIMIT 0");
} else
query = (char *)srcdef;
// Open a MySQL connection for this table // Open a MySQL connection for this table
if (myc.Open(g, host, db, user, pwd, port)) if (myc.Open(g, host, db, user, pwd, port))
...@@ -292,7 +296,7 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, ...@@ -292,7 +296,7 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
// Send the source command to MySQL // Send the source command to MySQL
if (myc.ExecSQL(g, query, &w) == RC_OK) if (myc.ExecSQL(g, query, &w) == RC_OK)
qrp = myc.GetResult(g); qrp = myc.GetResult(g, true);
myc.Close(); myc.Close();
return qrp; return qrp;
...@@ -337,6 +341,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, ...@@ -337,6 +341,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
const char *user, const char *pwd, const char *user, const char *pwd,
int pt) int pt)
{ {
const char *pipe = NULL;
uint cto = 60, nrt = 120; uint cto = 60, nrt = 120;
m_DB = mysql_init(NULL); m_DB = mysql_init(NULL);
...@@ -353,6 +358,16 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, ...@@ -353,6 +358,16 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt); mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt);
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...); //mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...);
#if defined(WIN32)
if (!strcmp(host, ".")) {
mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL);
pipe = mysqld_unix_port;
} // endif host
#else // !WIN32
if (!strcmp(host, "localhost"))
pipe = mysqld_unix_port;
#endif // !WIN32
#if 0 #if 0
if (pwd && !strcmp(pwd, "*")) { if (pwd && !strcmp(pwd, "*")) {
if (GetPromptAnswer(g, "*Enter password:")) { if (GetPromptAnswer(g, "*Enter password:")) {
...@@ -364,7 +379,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, ...@@ -364,7 +379,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
} // endif pwd } // endif pwd
#endif // 0 #endif // 0
if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, NULL, CLIENT_MULTI_RESULTS)) { if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, pipe, CLIENT_MULTI_RESULTS)) {
#if defined(_DEBUG) #if defined(_DEBUG)
sprintf(g->Message, "mysql_real_connect failed: (%d) %s", sprintf(g->Message, "mysql_real_connect failed: (%d) %s",
mysql_errno(m_DB), mysql_error(m_DB)); mysql_errno(m_DB), mysql_error(m_DB));
...@@ -673,7 +688,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void) ...@@ -673,7 +688,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
/***********************************************************************/ /***********************************************************************/
PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
{ {
char *fmt; char *fmt, v;
int n; int n;
bool uns; bool uns;
PCOLRES *pcrp, crp; PCOLRES *pcrp, crp;
...@@ -702,7 +717,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) ...@@ -702,7 +717,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
qrp->Nblin = 0; qrp->Nblin = 0;
qrp->Cursor = 0; qrp->Cursor = 0;
//for (fld = mysql_fetch_field(m_Res); fld; //for (fld = mysql_fetch_field(m_Res); fld;
// fld = mysql_fetch_field(m_Res)) { // fld = mysql_fetch_field(m_Res)) {
for (fld = GetNextField(); fld; fld = GetNextField()) { for (fld = GetNextField(); fld; fld = GetNextField()) {
...@@ -715,17 +729,19 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) ...@@ -715,17 +729,19 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1); crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1);
strcpy(crp->Name, fld->name); strcpy(crp->Name, fld->name);
if ((crp->Type = MYSQLtoPLG(fld->type)) == TYPE_ERROR) { if ((crp->Type = MYSQLtoPLG(fld->type, &v)) == TYPE_ERROR) {
sprintf(g->Message, "Type %d not supported for column %s", sprintf(g->Message, "Type %d not supported for column %s",
fld->type, crp->Name); fld->type, crp->Name);
return NULL; return NULL;
} else if (crp->Type == TYPE_DATE && !pdb) } else if (crp->Type == TYPE_DATE && !pdb)
// For direct MySQL connection, display the MySQL date string // For direct MySQL connection, display the MySQL date string
crp->Type = TYPE_STRING; crp->Type = TYPE_STRING;
else
crp->Var = v;
crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM) crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM)
? fld->decimals : 0; ? fld->decimals : 0;
crp->Length = fld->max_length; crp->Length = max(fld->length, fld->max_length);
crp->Clen = GetTypeSize(crp->Type, crp->Length); crp->Clen = GetTypeSize(crp->Type, crp->Length);
uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false; uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false;
......
...@@ -63,15 +63,10 @@ class DllItem MYSQLC { ...@@ -63,15 +63,10 @@ class DllItem MYSQLC {
bool Connected(void); bool Connected(void);
// Methods // Methods
// int GetCurPos(void) {return (m_Res) ? N : 0;}
// int GetProgCur(void) {return N;}
int GetResultSize(PGLOBAL g, PSZ sql); int GetResultSize(PGLOBAL g, PSZ sql);
int Open(PGLOBAL g, const char *host, const char *db, int Open(PGLOBAL g, const char *host, const char *db,
const char *user= "root", const char *pwd= "*", const char *user= "root", const char *pwd= "*",
int pt= 0); int pt= 0);
//ulong GetThreadID(void);
//ulong ServerVersion(void);
//const char *ServerInfo(void);
int KillQuery(ulong id); int KillQuery(ulong id);
int ExecSQL(PGLOBAL g, const char *query, int *w = NULL); int ExecSQL(PGLOBAL g, const char *query, int *w = NULL);
int ExecSQLcmd(PGLOBAL g, const char *query, int *w); int ExecSQLcmd(PGLOBAL g, const char *query, int *w);
...@@ -87,7 +82,6 @@ class DllItem MYSQLC { ...@@ -87,7 +82,6 @@ class DllItem MYSQLC {
void Rewind(void); void Rewind(void);
void FreeResult(void); void FreeResult(void);
void Close(void); void Close(void);
//void DiscardResults(void);
protected: protected:
MYSQL_FIELD *GetNextField(void); MYSQL_FIELD *GetNextField(void);
......
#
# Testing indexing with ALTER on inward table (in-place)
#
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT;
Warnings:
Warning 1105 No table_type. Will be set to DOS
Warning 1105 No file name. Table will use t1.dos
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
CREATE INDEX xc ON t1(c);
DESCRIBE SELECT * FROM t1 WHERE c = 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref xc xc 4 const 1
DROP INDEX xc ON t1;
CREATE INDEX xd ON t1(d);
DROP INDEX xd ON t1;
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d A NULL NULL NULL XPLUG
ALTER TABLE t1 DROP INDEX xc, DROP INDEX xd;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
#
# Testing modifying columns inward table (not in-place)
#
ALTER TABLE t1 MODIFY COLUMN c CHAR(5) NOT NULL;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(5) NOT NULL,
`d` char(10) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL;
#
# Fails because indexing must be in-place
#
ALTER TABLE t1 MODIFY COLUMN c CHAR(10) NOT NULL, ADD INDEX xd (d);
ERROR 0A000: Alter operations not supported together by CONNECT
#
# Testing changing table type (not in-place)
#
ALTER TABLE t1 TABLE_TYPE=CSV HEADER=1 QUOTED=1;
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` char(10) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=CSV `HEADER`=1 `QUOTED`=1
# create an outward table used to see the t1 file
CREATE TABLE t2 (line VARCHAR(100) NOT NULL) ENGINE=CONNECT FILE_NAME='t1.csv';
Warnings:
Warning 1105 No table_type. Will be set to DOS
SELECT * FROM t2;
line
"c","d"
1,"One"
2,"Two"
3,"Three"
#
# Testing changing engine
#
DROP TABLE t1;
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT;
Warnings:
Warning 1105 No table_type. Will be set to DOS
Warning 1105 No file name. Table will use t1.dos
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
ALTER TABLE t1 ENGINE = MYISAM;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` char(10) NOT NULL,
KEY `xc` (`c`),
KEY `xd` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c A NULL NULL NULL BTREE
t1 1 xd 1 d A NULL NULL NULL BTREE
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
ALTER TABLE t1 ENGINE = CONNECT TABLE_TYPE=DBF;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` char(10) NOT NULL,
KEY `xc` (`c`),
KEY `xd` (`d`)
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=DBF
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d A NULL NULL NULL XPLUG
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
DROP TABLE t1, t2;
#
# Testing ALTER on outward tables
#
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=fix FILE_NAME='tf1.txt' ENDING=1;
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
CREATE TABLE t2 (line VARCHAR(100) NOT NULL) ENGINE=CONNECT FILE_NAME='tf1.txt';
Warnings:
Warning 1105 No table_type. Will be set to DOS
SELECT * FROM t2;
line
1One
2Two
3Three
#
# Indexing works the same
#
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d A NULL NULL NULL XPLUG
SELECT d FROM t1 WHERE c = 2;
d
Two
ALTER TABLE t1 DROP INDEX xc, DROP INDEX xd;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
#
# Other alterations do not modify the file
#
ALTER TABLE t1 MODIFY COLUMN c CHAR(5) NOT NULL;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
SELECT * FROM t2;
line
1One
2Two
3Three
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(5) NOT NULL,
`d` char(10) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=fix `FILE_NAME`='tf1.txt' `ENDING`=1
SELECT * FROM t1;
ERROR HY000: Got error 174 'File tf1.txt is not fixed length, len=66 lrecl=16' from CONNECT
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
#
# Changing column order
#
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL AFTER d;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
SELECT * FROM t2;
line
1One
2Two
3Three
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` char(10) NOT NULL,
`c` int(11) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=fix `FILE_NAME`='tf1.txt' `ENDING`=1
# Wrong result
SELECT * FROM t1;
d c
1
2
3
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL FIRST;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
# What should have been done
ALTER TABLE t1 MODIFY c INT NOT NULL FLAG=0 AFTER d, MODIFY d CHAR(10) NOT NULL FLAG=11;
Warnings:
Warning 1105 This is an outward table, table data were not modified.
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` char(10) NOT NULL `FLAG`=11,
`c` int(11) NOT NULL `FLAG`=0
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=fix `FILE_NAME`='tf1.txt' `ENDING`=1
SELECT * FROM t1;
d c
One 1
Two 2
Three 3
#
# Changing to another engine is Ok
# However, the data file is not deleted.
#
ALTER TABLE t1 ENGINE=MARIA;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` char(10) NOT NULL `FLAG`=11,
`c` int(11) NOT NULL `FLAG`=0
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 `TABLE_TYPE`=fix `FILE_NAME`='tf1.txt' `ENDING`=1
SELECT * from t1;
d c
One 1
Two 2
Three 3
SELECT * from t2;
line
1One
2Two
3Three
#
# Changing back to CONNECT fails
# Sure enough, the data file was not deleted.
#
ALTER TABLE t1 ENGINE=CONNECT;
ERROR HY000: Operation denied. Table data would be lost.
#
# But changing back to CONNECT succeed
# if the data file does not exist.
#
ALTER TABLE t1 ENGINE=CONNECT;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`d` char(10) NOT NULL `FLAG`=11,
`c` int(11) NOT NULL `FLAG`=0
) ENGINE=CONNECT DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 `TABLE_TYPE`=fix `FILE_NAME`='tf1.txt' `ENDING`=1
SELECT * from t1;
d c
One 1
Two 2
Three 3
SELECT * from t2;
line
1One
2Two
3Three
DROP TABLE t1, t2;
Warnings:
Warning 1105 No file name. Table will use t1.xml
#
# Testing changing table type (not in-place)
#
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV HEADER=1 QUOTED=1;
Warnings:
Warning 1105 No file name. Table will use t1.csv
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
# This would fail if the top node name is not specified.
# This is because the XML top node name defaults to the table name.
# Sure enough the temporary table name begins with '#' and is rejected by XML.
# Therefore the top node name must be specified (along with the row nodes name).
ALTER TABLE t1 TABLE_TYPE=XML TABNAME=t1 OPTION_LIST='rownode=row';
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` char(10) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `HEADER`=1 `QUOTED`=1 `TABLE_TYPE`=XML `TABNAME`=t1 `OPTION_LIST`='rownode=row'
# Let us see the XML file
CREATE TABLE t2 (line VARCHAR(100) NOT NULL) ENGINE=CONNECT FILE_NAME='t1.xml';
Warnings:
Warning 1105 No table_type. Will be set to DOS
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<t1>
<row>
<TH>c</TH>
<TH>d</TH>
</row>
<row>
<c>1</c>
<d>One</d>
</row>
<row>
<c>2</c>
<d>Two</d>
</row>
<row>
<c>3</c>
<d>Three</d>
</row>
</t1>
# NOTE: The first (ignored) row is due to the remaining HEADER=1 option.
# Testing field option modification
ALTER TABLE t1 MODIFY d CHAR(10) NOT NULL FIELD_FORMAT='@', HEADER=0;
SELECT * FROM t1;
c d
1 One
2 Two
3 Three
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` int(11) NOT NULL,
`d` char(10) NOT NULL `FIELD_FORMAT`='@'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `QUOTED`=1 `TABLE_TYPE`=XML `TABNAME`=t1 `OPTION_LIST`='rownode=row' `HEADER`=0
SELECT * FROM t2;
line
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<t1>
<row d="One">
<c>1</c>
</row>
<row d="Two">
<c>2</c>
</row>
<row d="Three">
<c>3</c>
</row>
</t1>
DROP TABLE t1, t2;
...@@ -390,22 +390,22 @@ CREATE TABLE t1 ...@@ -390,22 +390,22 @@ CREATE TABLE t1
( (
a BLOB a BLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
CREATE TABLE t1 CREATE TABLE t1
( (
a TINYBLOB a TINYBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
CREATE TABLE t1 CREATE TABLE t1
( (
a MEDIUMBLOB a MEDIUMBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
CREATE TABLE t1 CREATE TABLE t1
( (
a LONGBLOB a LONGBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
# #
# Testing DATE # Testing DATE
# #
......
...@@ -68,64 +68,64 @@ DROP TABLE t1; ...@@ -68,64 +68,64 @@ DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
SELECT * FROM t1; SELECT * FROM t1;
name city birth hired name city birth hired
John Boston 2 1986-01-05 2010-06-02 John Boston 1986-01-25 2010-06-02
Henry Boston 0 1987-06-07 2008-04-01 Henry Boston 1987-06-07 2008-04-01
George San Jose 1 1981-08-01 2010-06-02 George San Jose 1981-08-10 2010-06-02
Sam Chicago 2 1979-11-02 2007-10-10 Sam Chicago 1979-11-22 2007-10-10
James Dallas 1 1992-05-03 2009-12-14 James Dallas 1992-05-13 2009-12-14
Bill Boston 1 1986-09-01 2008-02-10 Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1;
SELECT * FROM t1; SELECT * FROM t1;
name city birth hired name city birth hired
John Boston 2 1986-01-05 2010-06-02 John Boston 1986-01-25 2010-06-02
Henry Boston 0 1987-06-07 2008-04-01 Henry Boston 1987-06-07 2008-04-01
George San Jose 1 1981-08-01 2010-06-02 George San Jose 1981-08-10 2010-06-02
Sam Chicago 2 1979-11-02 2007-10-10 Sam Chicago 1979-11-22 2007-10-10
James Dallas 1 1992-05-03 2009-12-14 James Dallas 1992-05-13 2009-12-14
Bill Boston 1 1986-09-01 2008-02-10 Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2;
SELECT * FROM t1; SELECT * FROM t1;
name city birth hired name city birth hired
John Boston 2 1986-01-05 2010-06-02 John Boston 1986-01-25 2010-06-02
Henry Boston 0 1987-06-07 2008-04-01 Henry Boston 1987-06-07 2008-04-01
George San Jose 1 1981-08-01 2010-06-02 George San Jose 1981-08-10 2010-06-02
Sam Chicago 2 1979-11-02 2007-10-10 Sam Chicago 1979-11-22 2007-10-10
James Dallas 1 1992-05-03 2009-12-14 James Dallas 1992-05-13 2009-12-14
Bill Boston 1 1986-09-01 2008-02-10 Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2;
SELECT * FROM t1; SELECT * FROM t1;
name city birth hired name city birth hired
John Boston 2 1986-01-05 2010-06-02 John Boston 1986-01-25 2010-06-02
Henry Boston 0 1987-06-07 2008-04-01 Henry Boston 1987-06-07 2008-04-01
George San Jose 1 1981-08-01 2010-06-02 George San Jose 1981-08-10 2010-06-02
Sam Chicago 2 1979-11-02 2007-10-10 Sam Chicago 1979-11-22 2007-10-10
James Dallas 1 1992-05-03 2009-12-14 James Dallas 1992-05-13 2009-12-14
Bill Boston 1 1986-09-01 2008-02-10 Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1; DROP TABLE t1;
...@@ -224,3 +224,30 @@ Kevin 0 2 6 ...@@ -224,3 +224,30 @@ Kevin 0 2 6
Donald 1 0 3 Donald 1 0 3
DROP TABLE pivet; DROP TABLE pivet;
DROP TABLE pets; DROP TABLE pets;
#
# MDEV-5734
#
CREATE TABLE fruit (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) DEFAULT NULL,
`cnt` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
INSERT INTO fruit VALUES (1,'apple',1),(2,'banana',1),(3,'apple',2),(4,'cherry',4),(5,'durazno',2);
SELECT * FROM fruit;
id name cnt
1 apple 1
2 banana 1
3 apple 2
4 cherry 4
5 durazno 2
CREATE TABLE fruit_pivot ENGINE=CONNECT TABLE_TYPE=pivot TABNAME=fruit;
SELECT * FROM fruit_pivot;
id apple banana cherry durazno
1 1 0 0 0
2 0 1 0 0
3 2 0 0 0
4 0 0 4 0
5 0 0 0 2
DROP TABLE fruit_pivot;
DROP TABLE fruit;
...@@ -413,7 +413,7 @@ DROP TABLE t1; ...@@ -413,7 +413,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml'); SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1); SELECT CAST(@a AS CHAR CHARACTER SET latin1);
CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?> CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?>
<!-- Created by CONNECT Version 1.02.0001 February 03, 2014 --> <!-- Created by CONNECT Version 1.02.0002 March 16, 2014 -->
<t1> <t1>
<line> <line>
<node>ÀÁÂÃ</node> <node>ÀÁÂÃ</node>
......
...@@ -5,6 +5,11 @@ package My::Suite::Connect; ...@@ -5,6 +5,11 @@ package My::Suite::Connect;
return "No CONNECT engine" unless $ENV{HA_CONNECT_SO} or return "No CONNECT engine" unless $ENV{HA_CONNECT_SO} or
$::mysqld_variables{'connect'} eq "ON"; $::mysqld_variables{'connect'} eq "ON";
# RECOMPILE_FOR_EMBEDDED also means that a plugin
# cannot be dynamically loaded into embedded
return "Not run for embedded server" if $::opt_embedded_server and
$ENV{HA_CONNECT_SO};
sub is_default { 1 } sub is_default { 1 }
bless { }; bless { };
......
let $MYSQLD_DATADIR= `select @@datadir`;
--echo #
--echo # Testing indexing with ALTER on inward table (in-place)
--echo #
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT;
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
SELECT * FROM t1;
CREATE INDEX xc ON t1(c);
DESCRIBE SELECT * FROM t1 WHERE c = 2;
DROP INDEX xc ON t1;
CREATE INDEX xd ON t1(d);
DROP INDEX xd ON t1;
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1;
ALTER TABLE t1 DROP INDEX xc, DROP INDEX xd;
SHOW INDEX FROM t1;
--echo #
--echo # Testing modifying columns inward table (not in-place)
--echo #
ALTER TABLE t1 MODIFY COLUMN c CHAR(5) NOT NULL;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL;
--echo #
--echo # Fails because indexing must be in-place
--echo #
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE t1 MODIFY COLUMN c CHAR(10) NOT NULL, ADD INDEX xd (d);
--echo #
--echo # Testing changing table type (not in-place)
--echo #
ALTER TABLE t1 TABLE_TYPE=CSV HEADER=1 QUOTED=1;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
--echo # create an outward table used to see the t1 file
CREATE TABLE t2 (line VARCHAR(100) NOT NULL) ENGINE=CONNECT FILE_NAME='t1.csv';
SELECT * FROM t2;
--echo #
--echo # Testing changing engine
--echo #
DROP TABLE t1;
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT;
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
ALTER TABLE t1 ENGINE = MYISAM;
SHOW CREATE TABLE t1;
SHOW INDEX FROM t1;
SELECT * FROM t1;
ALTER TABLE t1 ENGINE = CONNECT TABLE_TYPE=DBF;
SHOW CREATE TABLE t1;
SHOW INDEX FROM t1;
SELECT * FROM t1;
DROP TABLE t1, t2;
--echo #
--echo # Testing ALTER on outward tables
--echo #
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=fix FILE_NAME='tf1.txt' ENDING=1;
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
SELECT * FROM t1;
CREATE TABLE t2 (line VARCHAR(100) NOT NULL) ENGINE=CONNECT FILE_NAME='tf1.txt';
SELECT * FROM t2;
--echo #
--echo # Indexing works the same
--echo #
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1;
SELECT d FROM t1 WHERE c = 2;
ALTER TABLE t1 DROP INDEX xc, DROP INDEX xd;
SHOW INDEX FROM t1;
--echo #
--echo # Other alterations do not modify the file
--echo #
ALTER TABLE t1 MODIFY COLUMN c CHAR(5) NOT NULL;
SELECT * FROM t2;
SHOW CREATE TABLE t1;
#Wrong result
--error ER_GET_ERRMSG
SELECT * FROM t1;
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL;
--echo #
--echo # Changing column order
--echo #
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL AFTER d;
SELECT * FROM t2;
SHOW CREATE TABLE t1;
--echo # Wrong result
SELECT * FROM t1;
ALTER TABLE t1 MODIFY COLUMN c INT NOT NULL FIRST;
--echo # What should have been done
ALTER TABLE t1 MODIFY c INT NOT NULL FLAG=0 AFTER d, MODIFY d CHAR(10) NOT NULL FLAG=11;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
--echo #
--echo # Changing to another engine is Ok
--echo # However, the data file is not deleted.
--echo #
ALTER TABLE t1 ENGINE=MARIA;
SHOW CREATE TABLE t1;
SELECT * from t1;
SELECT * from t2;
--echo #
--echo # Changing back to CONNECT fails
--echo # Sure enough, the data file was not deleted.
--echo #
--error ER_UNKNOWN_ERROR
ALTER TABLE t1 ENGINE=CONNECT;
--echo #
--echo # But changing back to CONNECT succeed
--echo # if the data file does not exist.
--echo #
--remove_file $MYSQLD_DATADIR/test/tf1.txt
ALTER TABLE t1 ENGINE=CONNECT;
SHOW CREATE TABLE t1;
SELECT * from t1;
SELECT * from t2;
DROP TABLE t1, t2;
#
# Clean up
#
--remove_file $MYSQLD_DATADIR/test/tf1.txt
--source have_libxml2.inc
--echo #
--echo # Testing changing table type (not in-place)
--echo #
CREATE TABLE t1 (c INT NOT NULL, d CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=CSV HEADER=1 QUOTED=1;
INSERT INTO t1 VALUES (1,'One'), (2,'Two'), (3,'Three');
SELECT * FROM t1;
--echo # This would fail if the top node name is not specified.
--echo # This is because the XML top node name defaults to the table name.
--echo # Sure enough the temporary table name begins with '#' and is rejected by XML.
--echo # Therefore the top node name must be specified (along with the row nodes name).
ALTER TABLE t1 TABLE_TYPE=XML TABNAME=t1 OPTION_LIST='rownode=row';
SELECT * FROM t1;
SHOW CREATE TABLE t1;
--echo # Let us see the XML file
CREATE TABLE t2 (line VARCHAR(100) NOT NULL) ENGINE=CONNECT FILE_NAME='t1.xml';
SELECT * FROM t2;
--echo # NOTE: The first (ignored) row is due to the remaining HEADER=1 option.
--echo # Testing field option modification
ALTER TABLE t1 MODIFY d CHAR(10) NOT NULL FIELD_FORMAT='@', HEADER=0;
SELECT * FROM t1;
SHOW CREATE TABLE t1;
SELECT * FROM t2;
DROP TABLE t1, t2;
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/dept.dat $MYSQLD_DATADIR/test/dept.dat --copy_file $MTR_SUITE_DIR/std_data/dept.dat $MYSQLD_DATADIR/test/dept.dat
--copy_file $MTR_SUITE_DIR/std_data/boys.txt $MYSQLD_DATADIR/test/boys.txt --copy_file $MTR_SUITE_DIR/std_data/boys.txt $MYSQLD_DATADIR/test/boys.txt
--copy_file $MTR_SUITE_DIR/std_data/boyswin.txt $MYSQLD_DATADIR/test/boyswin.txt --copy_file $MTR_SUITE_DIR/std_data/boyswin.txt $MYSQLD_DATADIR/test/boyswin.txt
--echo # --echo #
--echo # Testing errors --echo # Testing errors
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
ID INT NOT NULL ID INT NOT NULL
) Engine=CONNECT TABLE_TYPE=DOS FILE_NAME='nonexistent.txt'; ) Engine=CONNECT TABLE_TYPE=DOS FILE_NAME='nonexistent.txt';
--replace_regex /on .*test.nonexistent.txt/on DATADIR\/test\/nonexistent.txt/ --replace_regex /on .*test.nonexistent.txt/on DATADIR\/test\/nonexistent.txt/
# TODO: check why this is needed for Windows # TODO: check why this is needed for Windows
--replace_result Open(rt) Open(rb) --replace_result Open(rt) Open(rb)
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo # --echo #
--echo # Testing READONLY tables --echo # Testing READONLY tables
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
id INT NOT NULL id INT NOT NULL
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.txt'; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.txt';
INSERT INTO t1 VALUES (10); INSERT INTO t1 VALUES (10);
SELECT * FROM t1; SELECT * FROM t1;
ALTER TABLE t1 READONLY=1; ALTER TABLE t1 READONLY=1;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
INSERT INTO t1 VALUES (20); INSERT INTO t1 VALUES (20);
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
UPDATE t1 SET id=20 WHERE id=10; UPDATE t1 SET id=20 WHERE id=10;
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
DELETE FROM t1 WHERE id=10; DELETE FROM t1 WHERE id=10;
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
TRUNCATE TABLE t1; TRUNCATE TABLE t1;
ALTER TABLE t1 READONLY=0; ALTER TABLE t1 READONLY=0;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (20); INSERT INTO t1 VALUES (20);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.txt --remove_file $MYSQLD_DATADIR/test/t1.txt
--echo # --echo #
--echo # Testing manual examples --echo # Testing manual examples
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
number CHAR(4) not null, number CHAR(4) not null,
location CHAR(15) NOT NULL flag=5, location CHAR(15) NOT NULL flag=5,
director CHAR(5) NOT NULL flag=20, director CHAR(5) NOT NULL flag=20,
function CHAR(12) NOT NULL flag=26, function CHAR(12) NOT NULL flag=26,
name CHAR(22) NOT NULL flag=38 name CHAR(22) NOT NULL flag=38
) ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='dept.dat'; ) ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='dept.dat';
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 CREATE TABLE t1
( (
name char(12) not null, name char(12) not null,
city char(12) not null, city char(11) not null,
birth date not null date_format='DD/MM/YYYY', birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36 hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2; ) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
# #
# Clean up # Clean up
# #
--remove_file $MYSQLD_DATADIR/test/dept.dat --remove_file $MYSQLD_DATADIR/test/dept.dat
--remove_file $MYSQLD_DATADIR/test/boys.txt --remove_file $MYSQLD_DATADIR/test/boys.txt
--remove_file $MYSQLD_DATADIR/test/boyswin.txt --remove_file $MYSQLD_DATADIR/test/boyswin.txt
-- source include/not_embedded.inc -- source include/not_embedded.inc
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
let $PORT= `select @@port`; let $PORT= `select @@port`;
--copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt --copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt
--echo # --echo #
--echo # Testing the PIVOT table type --echo # Testing the PIVOT table type
--echo # --echo #
CREATE TABLE expenses ( CREATE TABLE expenses (
Who CHAR(10) NOT NULL, Who CHAR(10) NOT NULL,
Week INT(2) NOT NULL, Week INT(2) NOT NULL,
What CHAR(12) NOT NULL, What CHAR(12) NOT NULL,
Amount DOUBLE(8,2)) Amount DOUBLE(8,2))
ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2; ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2;
SELECT * FROM expenses; SELECT * FROM expenses;
--echo # --echo #
--echo # Pivoting from What --echo # Pivoting from What
--echo # --echo #
CREATE TABLE pivex ( CREATE TABLE pivex (
Who CHAR(10) NOT NULL, Who CHAR(10) NOT NULL,
Week INT(2) NOT NULL, Week INT(2) NOT NULL,
Beer DOUBLE(8,2) FLAG=1, Beer DOUBLE(8,2) FLAG=1,
Car DOUBLE(8,2) FLAG=1, Car DOUBLE(8,2) FLAG=1,
Food DOUBLE(8,2) FLAG=1) Food DOUBLE(8,2) FLAG=1)
ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses;
--replace_result $PORT PORT --replace_result $PORT PORT
--eval ALTER TABLE pivex OPTION_LIST='port=$PORT' --eval ALTER TABLE pivex OPTION_LIST='port=$PORT'
SELECT * FROM pivex; SELECT * FROM pivex;
--echo # --echo #
--echo # Restricting the columns in a Pivot Table --echo # Restricting the columns in a Pivot Table
--echo # --echo #
ALTER TABLE pivex DROP COLUMN week; ALTER TABLE pivex DROP COLUMN week;
SELECT * FROM pivex; SELECT * FROM pivex;
--echo # --echo #
--echo # Using a source definition --echo # Using a source definition
--echo # --echo #
DROP TABLE pivex; DROP TABLE pivex;
CREATE TABLE pivex ( CREATE TABLE pivex (
Who CHAR(10) NOT NULL, Who CHAR(10) NOT NULL,
Week INT(2) NOT NULL, Week INT(2) NOT NULL,
Beer DOUBLE(8,2) FLAG=1, Beer DOUBLE(8,2) FLAG=1,
Car DOUBLE(8,2) FLAG=1, Car DOUBLE(8,2) FLAG=1,
Food DOUBLE(8,2) FLAG=1) Food DOUBLE(8,2) FLAG=1)
ENGINE=CONNECT TABLE_TYPE=PIVOT ENGINE=CONNECT TABLE_TYPE=PIVOT
SRCDEF='select who, week, what, sum(amount) as amount from expenses where week in (4,5) group by who, week, what'; SRCDEF='select who, week, what, sum(amount) as amount from expenses where week in (4,5) group by who, week, what';
--replace_result $PORT PORT --replace_result $PORT PORT
--eval ALTER TABLE pivex OPTION_LIST='PivotCol=what,FncCol=amount,port=$PORT' --eval ALTER TABLE pivex OPTION_LIST='PivotCol=what,FncCol=amount,port=$PORT'
SELECT * FROM pivex; SELECT * FROM pivex;
--echo # --echo #
--echo # Pivoting from Week --echo # Pivoting from Week
--echo # --echo #
DROP TABLE pivex; DROP TABLE pivex;
CREATE TABLE pivex ( CREATE TABLE pivex (
Who CHAR(10) NOT NULL, Who CHAR(10) NOT NULL,
What CHAR(12) NOT NULL, What CHAR(12) NOT NULL,
`3` DOUBLE(8,2) FLAG=1, `3` DOUBLE(8,2) FLAG=1,
`4` DOUBLE(8,2) FLAG=1, `4` DOUBLE(8,2) FLAG=1,
`5` DOUBLE(8,2) FLAG=1) `5` DOUBLE(8,2) FLAG=1)
ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses; ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses;
--replace_result $PORT PORT --replace_result $PORT PORT
--eval ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=$PORT' --eval ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=$PORT'
SELECT * FROM pivex; SELECT * FROM pivex;
--echo # --echo #
--echo # Using scalar functions and expresssions --echo # Using scalar functions and expresssions
--echo # --echo #
DROP TABLE pivex; DROP TABLE pivex;
CREATE TABLE pivex ( CREATE TABLE pivex (
Who CHAR(10) NOT NULL, Who CHAR(10) NOT NULL,
What CHAR(12) NOT NULL, What CHAR(12) NOT NULL,
First DOUBLE(8,2) FLAG=1, First DOUBLE(8,2) FLAG=1,
Middle DOUBLE(8,2) FLAG=1, Middle DOUBLE(8,2) FLAG=1,
Last DOUBLE(8,2) FLAG=1) Last DOUBLE(8,2) FLAG=1)
ENGINE=CONNECT TABLE_TYPE=PIVOT ENGINE=CONNECT TABLE_TYPE=PIVOT
SRCDEF='select who, what, case when week=3 then ''First'' when week=5 then ''Last'' else ''Middle'' end as wk, sum(amount) * 6.56 as amnt from expenses group by who, what, wk'; SRCDEF='select who, what, case when week=3 then ''First'' when week=5 then ''Last'' else ''Middle'' end as wk, sum(amount) * 6.56 as amnt from expenses group by who, what, wk';
--replace_result $PORT PORT --replace_result $PORT PORT
--eval ALTER TABLE pivex OPTION_LIST='PivotCol=wk,FncCol=amnt,port=$PORT' --eval ALTER TABLE pivex OPTION_LIST='PivotCol=wk,FncCol=amnt,port=$PORT'
SELECT * FROM pivex; SELECT * FROM pivex;
DROP TABLE pivex; DROP TABLE pivex;
DROP TABLE expenses; DROP TABLE expenses;
--echo # --echo #
--echo # Make the PETS table --echo # Make the PETS table
--echo # --echo #
CREATE TABLE pets ( CREATE TABLE pets (
Name VARCHAR(12) NOT NULL, Name VARCHAR(12) NOT NULL,
Race CHAR(6) NOT NULL, Race CHAR(6) NOT NULL,
Number INT NOT NULL) ENGINE=MYISAM; Number INT NOT NULL) ENGINE=MYISAM;
INSERT INTO pets VALUES('John','dog',2); INSERT INTO pets VALUES('John','dog',2);
INSERT INTO pets VALUES('Bill','cat',1); INSERT INTO pets VALUES('Bill','cat',1);
INSERT INTO pets VALUES('Mary','dog',1); INSERT INTO pets VALUES('Mary','dog',1);
INSERT INTO pets VALUES('Mary','cat',1); INSERT INTO pets VALUES('Mary','cat',1);
INSERT INTO pets VALUES('Lisbeth','rabbit',2); INSERT INTO pets VALUES('Lisbeth','rabbit',2);
INSERT INTO pets VALUES('Kevin','cat',2); INSERT INTO pets VALUES('Kevin','cat',2);
INSERT INTO pets VALUES('Kevin','bird',6); INSERT INTO pets VALUES('Kevin','bird',6);
INSERT INTO pets VALUES('Donald','dog',1); INSERT INTO pets VALUES('Donald','dog',1);
INSERT INTO pets VALUES('Donald','fish',3); INSERT INTO pets VALUES('Donald','fish',3);
SELECT * FROM pets; SELECT * FROM pets;
--echo # --echo #
--echo # Pivot the PETS table --echo # Pivot the PETS table
--echo # --echo #
CREATE TABLE pivet ( CREATE TABLE pivet (
name VARCHAR(12) NOT NULL, name VARCHAR(12) NOT NULL,
dog INT NOT NULL DEFAULT 0 FLAG=1, dog INT NOT NULL DEFAULT 0 FLAG=1,
cat INT NOT NULL DEFAULT 0 FLAG=1, cat INT NOT NULL DEFAULT 0 FLAG=1,
rabbit INT NOT NULL DEFAULT 0 FLAG=1, rabbit INT NOT NULL DEFAULT 0 FLAG=1,
bird INT NOT NULL DEFAULT 0 FLAG=1, bird INT NOT NULL DEFAULT 0 FLAG=1,
fish INT NOT NULL DEFAULT 0 FLAG=1) fish INT NOT NULL DEFAULT 0 FLAG=1)
ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1';
SELECT * FROM pivet; SELECT * FROM pivet;
DROP TABLE pivet; DROP TABLE pivet;
--echo # --echo #
--echo # Testing the "data" column list --echo # Testing the "data" column list
--echo # --echo #
CREATE TABLE pivet ( CREATE TABLE pivet (
name VARCHAR(12) NOT NULL, name VARCHAR(12) NOT NULL,
dog INT NOT NULL DEFAULT 0 FLAG=1, dog INT NOT NULL DEFAULT 0 FLAG=1,
cat INT NOT NULL DEFAULT 0 FLAG=1) cat INT NOT NULL DEFAULT 0 FLAG=1)
ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1';
--error ER_GET_ERRMSG --error ER_GET_ERRMSG
SELECT * FROM pivet; SELECT * FROM pivet;
ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1'; ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1';
SELECT * FROM pivet; SELECT * FROM pivet;
DROP TABLE pivet; DROP TABLE pivet;
--echo # --echo #
--echo # Adding a "dump" column --echo # Adding a "dump" column
--echo # --echo #
CREATE TABLE pivet ( CREATE TABLE pivet (
name VARCHAR(12) NOT NULL, name VARCHAR(12) NOT NULL,
dog INT NOT NULL DEFAULT 0 FLAG=1, dog INT NOT NULL DEFAULT 0 FLAG=1,
cat INT NOT NULL DEFAULT 0 FLAG=1, cat INT NOT NULL DEFAULT 0 FLAG=1,
other INT NOT NULL DEFAULT 0 FLAG=2) other INT NOT NULL DEFAULT 0 FLAG=2)
ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1'; ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1';
SELECT * FROM pivet; SELECT * FROM pivet;
DROP TABLE pivet; DROP TABLE pivet;
DROP TABLE pets; DROP TABLE pets;
--remove_file $MYSQLD_DATADIR/test/expenses.txt
--echo #
--echo # MDEV-5734
--echo #
CREATE TABLE fruit (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(32) DEFAULT NULL,
`cnt` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
INSERT INTO fruit VALUES (1,'apple',1),(2,'banana',1),(3,'apple',2),(4,'cherry',4),(5,'durazno',2);
SELECT * FROM fruit;
CREATE TABLE fruit_pivot ENGINE=CONNECT TABLE_TYPE=pivot TABNAME=fruit;
SELECT * FROM fruit_pivot;
DROP TABLE fruit_pivot;
DROP TABLE fruit;
--remove_file $MYSQLD_DATADIR/test/expenses.txt
...@@ -58,12 +58,8 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -58,12 +58,8 @@ int MYSQLtoPLG(char *typname, char *var)
type = TYPE_ERROR; type = TYPE_ERROR;
if (var) { if (var) {
// This is to make the difference between CHAR and VARCHAR
if (type == TYPE_STRING && stricmp(typname, "char"))
*var = 'V';
// This is to make the difference between temporal values
if (type == TYPE_DATE) { if (type == TYPE_DATE) {
// This is to make the difference between temporal values
if (!stricmp(typname, "date")) if (!stricmp(typname, "date"))
*var = 'D'; *var = 'D';
else if (!stricmp(typname, "datetime")) else if (!stricmp(typname, "datetime"))
...@@ -75,7 +71,11 @@ int MYSQLtoPLG(char *typname, char *var) ...@@ -75,7 +71,11 @@ int MYSQLtoPLG(char *typname, char *var)
else if (!stricmp(typname, "year")) else if (!stricmp(typname, "year"))
*var = 'Y'; *var = 'Y';
} // endif type } else if (type == TYPE_STRING && stricmp(typname, "char"))
// This is to make the difference between CHAR and VARCHAR
*var = 'V';
else
*var = 0;
} // endif var } // endif var
...@@ -200,7 +200,6 @@ int MYSQLtoPLG(int mytype, char *var) ...@@ -200,7 +200,6 @@ int MYSQLtoPLG(int mytype, char *var)
case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_LONG_BLOB:
if (var) *var = 'V';
case MYSQL_TYPE_STRING: case MYSQL_TYPE_STRING:
type = TYPE_STRING; type = TYPE_STRING;
break; break;
...@@ -208,6 +207,25 @@ int MYSQLtoPLG(int mytype, char *var) ...@@ -208,6 +207,25 @@ int MYSQLtoPLG(int mytype, char *var)
type = TYPE_ERROR; type = TYPE_ERROR;
} // endswitch mytype } // endswitch mytype
if (var) switch (mytype) {
// This is to make the difference between CHAR and VARCHAR
case MYSQL_TYPE_VAR_STRING:
#if !defined(ALPHA)
case MYSQL_TYPE_VARCHAR:
#endif // !ALPHA)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB: *var = 'V'; break;
// This is to make the difference between temporal values
case MYSQL_TYPE_TIMESTAMP: *var = 'S'; break;
case MYSQL_TYPE_DATE: *var = 'D'; break;
case MYSQL_TYPE_DATETIME: *var = 'A'; break;
case MYSQL_TYPE_YEAR: *var = 'Y'; break;
case MYSQL_TYPE_TIME: *var = 'T'; break;
default: *var = 0;
} // endswitch mytype
return type; return type;
} // end of MYSQLtoPLG } // end of MYSQLtoPLG
......
...@@ -78,8 +78,8 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft) ...@@ -78,8 +78,8 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
LPCSTR p2, p = name; LPCSTR p2, p = name;
#ifdef DEBTRACE #ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s [%s (%d)]\n", htrc("SplitPath: name=%s [%s (%d)]\n",
XSTR(name), XSTR(__FILE__), __LINE__); XSTR(name), XSTR(__FILE__), __LINE__);
#endif #endif
if (drive) *drive = '\0'; if (drive) *drive = '\0';
...@@ -100,7 +100,7 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft) ...@@ -100,7 +100,7 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
if (fn) strcpy(fn, p); if (fn) strcpy(fn, p);
#ifdef DEBTRACE #ifdef DEBTRACE
fprintf(debug,"SplitPath: name=%s drive=%s dir=%s filename=%s type=%s [%s(%d)]\n", htrc("SplitPath: name=%s drive=%s dir=%s filename=%s type=%s [%s(%d)]\n",
XSTR(name), XSTR(drive), XSTR(dir), XSTR(fn), XSTR(ft), __FILE__, __LINE__); XSTR(name), XSTR(drive), XSTR(dir), XSTR(fn), XSTR(ft), __FILE__, __LINE__);
#endif #endif
} /* end of _splitpath */ } /* end of _splitpath */
...@@ -181,7 +181,8 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength) ...@@ -181,7 +181,8 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength)
} else { } else {
char buff[2*_MAX_PATH]; char buff[2*_MAX_PATH];
assert(getcwd(buff, _MAX_PATH) != NULL); p= getcwd(buff, _MAX_PATH);
assert(p);
strcat(buff,"/"); strcat(buff,"/");
strcat(buff, relPath); strcat(buff, relPath);
strncpy(absPath, buff, maxLength); strncpy(absPath, buff, maxLength);
......
...@@ -62,146 +62,6 @@ enum INFO {INDX_RC, /* Index of PlugDB return code field */ ...@@ -62,146 +62,6 @@ enum INFO {INDX_RC, /* Index of PlugDB return code field */
INDX_SIZE, /* Index of returned data size field */ INDX_SIZE, /* Index of returned data size field */
INDX_MAX}; /* Size of info array */ INDX_MAX}; /* Size of info array */
#ifdef NOT_USED
/**************************************************************************/
/* Internal message types. */
/**************************************************************************/
enum MSGTYP {MST_OPEN = 10, /* Code for old connecting message */
MST_COMMAND = 11, /* Code for send command message */
MST_RESULT = 12, /* Code for get result message */
MST_CLOSE = 13, /* Code for disconnecting message */
MST_PROGRESS = 14, /* Code for progress message */
MST_CANCEL = 15, /* Code for cancel message */
MST_PROCESSED = 16, /* Code for already processed msg */
MST_ERROR = 17, /* Code for get error message */
MST_CHAR = 18, /* Code for get char value message */
MST_LONG = 19, /* Code for get int value message */
MST_COLUMN = 20, /* Code for get col value message */
MST_MESSAGE = 21, /* Code for get message message */
MST_HEADER = 22, /* Code for get header message */
MST_SOCKET = 23, /* Code for socket error message */
MST_SHUTDOWN = 24, /* Code for shutdown message */
MST_SOCKPROG = 25, /* Code for socket progress message */
MST_POST = 26, /* Code for post command message */
MST_NEW_OPEN = 27, /* Code for new connecting message */
MST_PROG_NUM = 5}; /* Num of integers in progress msg */
/**************************************************************************/
/* Vendors. */
/**************************************************************************/
enum VENDOR {VDR_UNKNOWN = -2, /* Not known or not connected */
VDR_PlugDB = -1, /* PlugDB */
VDR_OTHER = 0}; /* OEM */
/**************************************************************************/
/* Attribute keys of Result Description structure (arranged by type). */
/**************************************************************************/
enum CKEYS {K_ProgMsg, K_Lang, K_ActiveDB, K_Cmax};
enum LKEYS {K_NBcol, K_NBlin, K_CurPos, K_RC, K_Result, K_Elapsed,
K_Continued, K_Maxsize, K_Affrows, K_Lmax, K_Maxcol,
K_Maxres, K_Maxlin, K_NBparm};
enum NKEYS {K_Type, K_Length, K_Prec, K_DataLen, K_Unsigned, K_Nmax};
/**************************************************************************/
/* Result description structures. */
/**************************************************************************/
typedef struct _MsgTagAttr {
bool fSupplied;
char Attr[MAXMESSAGE];
} MTAG, *PMTAG;
typedef struct _CharTagAttr {
bool fSupplied;
char Attr[MAXDBNAME];
} CTAG, *PCTAG;
typedef struct _LongTagAttr {
bool fSupplied;
int Attr;
} LTAG, *PLTAG;
typedef struct _ColVar {
LTAG Lat[K_Nmax];
CTAG Cat;
} COLVAR, *LPCOLVAR;
typedef struct _ResDesc {
int Maxcol; /* Max number of columns */
int Colnum; /* Number of columns */
MTAG Mat; /* Message */
CTAG Cat[K_Cmax]; /* Character attributes */
LTAG Lat[K_Lmax]; /* Long int attributes */
COLVAR Col[1]; /* Column attributes */
} RDESC, *PRDESC;
/**************************************************************************/
/* Exported PlugDB client functions in Plgcnx DLL. */
/**************************************************************************/
#if !defined(CNXFUNC)
#if defined(UNIX) || defined(UNIV_LINUX)
#undef __stdcall
#define __stdcall
#endif
#if defined(NOLIB) /* Dynamic link of plgcnx.dll */
#define CNXFUNC(f) (__stdcall *f)
#else /* LIB */ /* Static link with plgcnx.lib */
#define CNXFUNC(f) __stdcall f
#endif
#endif
#if !defined(CNXKEY)
#define CNXKEY uint
#endif
#if !defined(XTRN)
#define XTRN
#endif
//#if !defined(NO_FUNC)
#ifdef __cplusplus
extern "C" {
#endif
XTRN int CNXFUNC(PLGConnect) (CNXKEY *, const char *, bool);
XTRN int CNXFUNC(PLGSendCommand) (CNXKEY, const char *, void *, int, int *);
XTRN int CNXFUNC(PLGGetResult) (CNXKEY, void *, int, int *, bool);
XTRN int CNXFUNC(PLGDisconnect) (CNXKEY);
XTRN int CNXFUNC(PLGGetErrorMsg) (CNXKEY, char *, int, int *);
XTRN bool CNXFUNC(PLGGetCharValue)(CNXKEY, char *, int, int);
XTRN bool CNXFUNC(PLGGetIntValue)(CNXKEY, int *, int);
XTRN bool CNXFUNC(PLGGetColValue) (CNXKEY, int *, int, int);
XTRN bool CNXFUNC(PLGGetMessage) (CNXKEY, char *, int);
XTRN bool CNXFUNC(PLGGetHeader) (CNXKEY, char *, int, int, int);
#ifdef __cplusplus
}
#endif
//#endif /* !NO_FUNC */
/**************************************************************************/
/* Convenience function Definitions */
/**************************************************************************/
#define PLGPostCommand(T,C) PLGSendCommand(T,C,NULL,0,NULL)
#if defined(FNCMAC)
#define PLGGetProgMsg(T,C,S) PLGGetCharValue(T,C,S,K_ProgMsg)
#define PLGGetLangID(T,C,S) PLGGetCharValue(T,C,S,K_Lang)
#define PLGGetActiveDB(T,C,S) PLGGetCharValue(T,C,S,K_ActiveDB)
#define PLGGetCursorPos(T,L) PLGGetIntValue(T,L,K_CurPos)
#define PLGGetResultType(T,L) PLGGetIntValue(T,L,K_Result)
#define PLGGetNBcol(T,L) PLGGetIntValue(T,L,K_NBcol)
#define PLGGetNBlin(T,L) PLGGetIntValue(T,L,K_NBlin)
#define PLGGetRetCode(T,L) PLGGetIntValue(T,L,K_RC)
#define PLGGetElapsed(T,L) PLGGetIntValue(T,L,K_Elapsed)
#define PLGGetContinued(T,L) PLGGetIntValue(T,L,K_Continued)
#define PLGGetMaxSize(T,L) PLGGetIntValue(T,L,K_Maxsize)
#define PLGGetLength(T,L,C) PLGGetColValue(T,L,K_Length,C)
#define PLGGetDataSize(T,L,C) PLGGetColValue(T,L,K_DataLen,C)
#define PLGGetDecimal(T,L,C) PLGGetColValue(T,L,K_Prec,C)
#define PLGGetType(T,L,C) PLGGetColValue(T,L,K_Type,C)
#endif /* FNCMAC */
#endif // NOT_USED
#endif /* !_PLGCNX_H */ #endif /* !_PLGCNX_H */
/* ------------------------- End of Plgcnx.h ---------------------------- */ /* ------------------------- End of Plgcnx.h ---------------------------- */
This diff is collapsed.
This diff is collapsed.
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
/* IBM Linker */ /* IBM Linker */
/* */ /* */
/***********************************************************************/ /***********************************************************************/
//efine DEBTRACE 3
//efine DEBTRACE2
/***********************************************************************/ /***********************************************************************/
/* */ /* */
...@@ -83,7 +81,6 @@ ...@@ -83,7 +81,6 @@
extern HINSTANCE s_hModule; /* Saved module handle */ extern HINSTANCE s_hModule; /* Saved module handle */
#endif // WIN32 #endif // WIN32
extern char plgini[];
extern int trace; extern int trace;
#if defined(XMSG) #if defined(XMSG)
......
...@@ -3,31 +3,6 @@ ...@@ -3,31 +3,6 @@
#include "checklvl.h" #include "checklvl.h"
/***********************************************************************/
/* Struct of variables used by the SQL pre-parsers. */
/***********************************************************************/
typedef struct _prepar {
struct _prepar *Next;
char *Debinp; // Start of input buffer
char *Endinp; // End of input buffer
char *Pluginp; // Points on current parsing position
char *Plugbuf; // Start of output buffer
char *Plugptr; // Current output position
char *Debchar; // Next/current start of command
char *Debselp; // Beginning of selection
char *Debline; // Start of current line
char *Plugpar[32]; // Parameters
int Numparms; // Number of defined parameters
int Nprms; // Number of ODBC parameters
int Lines; // Line number
int Chars; // Index of selection start in line
int Endchars; // Index of selection end in line
int Frinp, Frbuf; // 0: no, 1: free, 2: delete Debinp/Plugbuf
int Outsize; // Size of output buffer
FILE *Argfile; // File containing arguments
int Addargs; // 1 if arguments are added to the list
} PREPAR, *PPREP;
/***********************************************************************/ /***********************************************************************/
/* Struct of variables used by the date format pre-parser. */ /* Struct of variables used by the date format pre-parser. */
/***********************************************************************/ /***********************************************************************/
...@@ -49,8 +24,6 @@ typedef struct _datpar { ...@@ -49,8 +24,6 @@ typedef struct _datpar {
extern "C" { extern "C" {
#endif #endif
int sqlflex(PPREP pp);
int sqpflex(PPREP pp);
int fmdflex(PDTP pp); int fmdflex(PDTP pp);
#ifdef __cplusplus #ifdef __cplusplus
......
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.
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