summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/CMakeLists.txt1
-rw-r--r--storage/connect/block.h7
-rw-r--r--storage/connect/catalog.h1
-rw-r--r--storage/connect/colblk.cpp45
-rw-r--r--storage/connect/colblk.h13
-rw-r--r--storage/connect/connect.cc100
-rw-r--r--storage/connect/connect.h8
-rw-r--r--storage/connect/csort.h4
-rw-r--r--storage/connect/domdoc.cpp4
-rw-r--r--storage/connect/domdoc.h4
-rw-r--r--storage/connect/filamap.cpp106
-rw-r--r--storage/connect/filamap.h16
-rw-r--r--storage/connect/filamdbf.cpp19
-rw-r--r--storage/connect/filamdbf.h11
-rw-r--r--storage/connect/filamfix.cpp217
-rw-r--r--storage/connect/filamfix.h24
-rw-r--r--storage/connect/filamtxt.cpp147
-rw-r--r--storage/connect/filamtxt.h25
-rwxr-xr-xstorage/connect/filamvct.cpp17
-rw-r--r--storage/connect/filamvct.h17
-rw-r--r--storage/connect/filamzip.cpp96
-rw-r--r--storage/connect/filamzip.h6
-rw-r--r--storage/connect/ha_connect.cc668
-rw-r--r--storage/connect/ha_connect.h15
-rw-r--r--storage/connect/mycat.cc35
-rw-r--r--storage/connect/mycat.h1
-rw-r--r--storage/connect/myconn.cpp38
-rw-r--r--storage/connect/myconn.h6
-rw-r--r--storage/connect/mysql-test/connect/r/alter.result265
-rw-r--r--storage/connect/mysql-test/connect/r/alter_xml.result86
-rw-r--r--storage/connect/mysql-test/connect/r/dbf.result8
-rw-r--r--storage/connect/mysql-test/connect/r/fix.result56
-rw-r--r--storage/connect/mysql-test/connect/r/pivot.result27
-rw-r--r--storage/connect/mysql-test/connect/r/xml.result2
-rw-r--r--storage/connect/mysql-test/connect/suite.pm5
-rw-r--r--storage/connect/mysql-test/connect/t/alter.test135
-rw-r--r--storage/connect/mysql-test/connect/t/alter_xml.test29
-rw-r--r--storage/connect/mysql-test/connect/t/dbf.test1022
-rw-r--r--storage/connect/mysql-test/connect/t/fix.test216
-rw-r--r--storage/connect/mysql-test/connect/t/pivot.test309
-rw-r--r--storage/connect/myutil.cpp32
-rw-r--r--storage/connect/osutil.c9
-rw-r--r--storage/connect/plgcnx.h140
-rw-r--r--storage/connect/plgdbsem.h35
-rw-r--r--storage/connect/plgdbutl.cpp196
-rw-r--r--storage/connect/plugutil.c3
-rw-r--r--storage/connect/preparse.h27
-rw-r--r--storage/connect/reldef.cpp11
-rw-r--r--storage/connect/reldef.h4
-rw-r--r--storage/connect/tabcol.cpp25
-rw-r--r--storage/connect/tabcol.h2
-rw-r--r--storage/connect/tabdos.cpp165
-rw-r--r--storage/connect/tabdos.h55
-rw-r--r--storage/connect/tabfix.cpp4
-rw-r--r--storage/connect/tabfmt.cpp22
-rw-r--r--storage/connect/tabfmt.h7
-rw-r--r--storage/connect/table.cpp117
-rw-r--r--storage/connect/tabmac.h2
-rw-r--r--storage/connect/tabmul.h2
-rw-r--r--storage/connect/tabmysql.cpp18
-rw-r--r--storage/connect/tabmysql.h23
-rw-r--r--storage/connect/taboccur.h1
-rw-r--r--storage/connect/tabodbc.cpp16
-rw-r--r--storage/connect/tabodbc.h1
-rw-r--r--storage/connect/tabpivot.cpp8
-rw-r--r--storage/connect/tabsys.cpp2
-rw-r--r--storage/connect/tabsys.h1
-rw-r--r--storage/connect/tabtbl.cpp23
-rw-r--r--storage/connect/tabtbl.h12
-rw-r--r--storage/connect/tabutil.cpp2
-rw-r--r--storage/connect/tabutil.h3
-rw-r--r--storage/connect/tabvct.cpp46
-rw-r--r--storage/connect/tabvct.h2
-rw-r--r--storage/connect/tabwmi.cpp20
-rw-r--r--storage/connect/tabwmi.h1
-rw-r--r--storage/connect/tabxml.cpp15
-rw-r--r--storage/connect/tabxml.h6
-rw-r--r--storage/connect/user_connect.cc5
-rw-r--r--storage/connect/user_connect.h3
-rw-r--r--storage/connect/valblk.cpp22
-rw-r--r--storage/connect/valblk.h12
-rw-r--r--storage/connect/value.cpp136
-rw-r--r--storage/connect/value.h13
-rwxr-xr-xstorage/connect/xindex.cpp39
-rw-r--r--storage/connect/xindex.h15
-rw-r--r--storage/connect/xobject.cpp13
-rw-r--r--storage/connect/xobject.h17
-rw-r--r--storage/connect/xtable.h70
88 files changed, 2240 insertions, 2974 deletions
diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt
index 20fa68ea5a5..143ab0c621f 100644
--- a/storage/connect/CMakeLists.txt
+++ b/storage/connect/CMakeLists.txt
@@ -271,6 +271,7 @@ ENDIF(CONNECT_WITH_ODBC)
MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
STORAGE_ENGINE
COMPONENT connect-engine
+ RECOMPILE_FOR_EMBEDDED
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${ODBC_LIBRARY} ${IPHLPAPI_LIBRARY})
diff --git a/storage/connect/block.h b/storage/connect/block.h
index 20db70351e4..d63a899d1f5 100644
--- a/storage/connect/block.h
+++ b/storage/connect/block.h
@@ -38,10 +38,9 @@ typedef class BLOCK *PBLOCK;
class DllExport BLOCK {
public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
-#ifdef DEBTRACE
-if (debug != NULL)
- htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
-#endif
+// if (trace > 2)
+// htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
+
return (PlugSubAlloc(g, p, size));
} // end of new
diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h
index a61b1a53653..a4fba7ae920 100644
--- a/storage/connect/catalog.h
+++ b/storage/connect/catalog.h
@@ -43,7 +43,6 @@ typedef struct _colinfo {
int Key;
int Precision;
int Scale;
- int Opt;
char *Remark;
char *Datefmt;
char *Fieldfmt;
diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp
index bce26e25387..ffa29bb9821 100644
--- a/storage/connect/colblk.cpp
+++ b/storage/connect/colblk.cpp
@@ -23,6 +23,8 @@
#include "xindex.h"
#include "xtable.h"
+extern "C" int trace;
+
/***********************************************************************/
/* COLBLK protected constructor. */
/***********************************************************************/
@@ -36,7 +38,6 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
if ((Cdp = cdp)) {
Name = cdp->Name;
Format = cdp->F;
- Opt = cdp->Opt;
Long = cdp->Long;
Precision = cdp->Precision;
Buf_Type = cdp->Buf_Type;
@@ -46,7 +47,6 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
} else {
Name = NULL;
memset(&Format, 0, sizeof(FORMAT));
- Opt = 0;
Long = 0;
Precision = 0;
Buf_Type = TYPE_ERROR;
@@ -74,9 +74,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp)
//To_Orig = col1;
To_Tdb = tdbp;
-#ifdef DEBTRACE
- htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
-#endif
+ if (trace > 1)
+ htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
if (tdbp)
// Attach the new column to the table block
@@ -114,31 +113,21 @@ bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{
fmt = Format;
-#ifdef DEBTRACE
- htrc("COLBLK: %p format=%c(%d,%d)\n",
- this, *fmt.Type, fmt.Length, fmt.Prec);
-#endif
+ if (trace > 1)
+ htrc("COLBLK: %p format=%c(%d,%d)\n",
+ this, *fmt.Type, fmt.Length, fmt.Prec);
return false;
} // 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 */
/* matching Index column if there is one. */
/***********************************************************************/
bool COLBLK::Eval(PGLOBAL g)
{
-#ifdef DEBTRACE
- htrc("Col Eval: %s status=%.4X\n", Name, Status);
-#endif
+ if (trace > 1)
+ htrc("Col Eval: %s status=%.4X\n", Name, Status);
if (!GetStatus(BUF_READ)) {
// if (To_Tdb->IsNull())
@@ -155,15 +144,6 @@ bool COLBLK::Eval(PGLOBAL g)
} // 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. */
/* Now we use Format.Length for the len parameter to avoid strings */
/* to be truncated when converting from string to coded string. */
@@ -183,10 +163,9 @@ bool COLBLK::InitValue(PGLOBAL g)
AddStatus(BUF_READY);
Value->SetNullable(Nullable);
-#ifdef DEBTRACE
- htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
- this, Buf_Type, Value, ColUse, Status);
-#endif
+ if (trace > 1)
+ htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
+ this, Buf_Type, Value, ColUse, Status);
return false;
} // end of InitValue
diff --git a/storage/connect/colblk.h b/storage/connect/colblk.h
index 11fca3e4fb7..e1d4fc7e948 100644
--- a/storage/connect/colblk.h
+++ b/storage/connect/colblk.h
@@ -39,7 +39,6 @@ class DllExport COLBLK : public XOBJECT {
PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;}
- int GetOpt(void) {return Opt;}
ushort GetColUse(void) {return ColUse;}
ushort GetColUse(ushort u) {return (ColUse & u);}
ushort GetStatus(void) {return Status;}
@@ -62,10 +61,7 @@ class DllExport COLBLK : public XOBJECT {
virtual void Reset(void);
virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL, FORMAT&);
- virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
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 SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetTo_Val(PVAL valp) {}
@@ -73,8 +69,6 @@ class DllExport COLBLK : public XOBJECT {
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, 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);
protected:
@@ -87,7 +81,6 @@ class DllExport COLBLK : public XOBJECT {
bool Nullable; // True if nullable
bool Unsigned; // True if unsigned
int Index; // Column number in table
- int Opt; // Cluster/sort information
int Buf_Type; // Data type
int Long; // Internal length in table
int Precision; // Column length (as for ODBC)
@@ -150,8 +143,6 @@ class DllExport FIDBLK : public SPCBLK {
// Methods
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);
protected:
@@ -171,8 +162,6 @@ class DllExport TIDBLK : public SPCBLK {
// Methods
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);
protected:
@@ -196,8 +185,6 @@ class DllExport SIDBLK : public SPCBLK {
// Methods
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);
protected:
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc
index 9340ae97258..879814833d4 100644
--- a/storage/connect/connect.cc
+++ b/storage/connect/connect.cc
@@ -51,7 +51,7 @@
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
-extern int xtrace;
+extern "C" int trace;
/***********************************************************************/
/* Routines called internally by semantic routines. */
@@ -110,14 +110,14 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
bool rc= false;
PDBUSER dbuserp= PlgGetUser(g);
- if (xtrace) {
+ if (trace) {
printf("CntCheckDB: dbuserp=%p\n", dbuserp);
- } // endif xtrace
+ } // endif trace
if (!dbuserp || !handler)
return true;
- if (xtrace)
+ if (trace)
printf("cat=%p oldhandler=%p newhandler=%p\n", dbuserp->Catalog,
(dbuserp->Catalog) ? ((MYCAT*)dbuserp->Catalog)->GetHandler() : NULL,
handler);
@@ -149,7 +149,7 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
/*********************************************************************/
sprintf(g->Message, MSG(DATABASE_LOADED), "???");
- if (xtrace)
+ if (trace)
printf("msg=%s\n", g->Message);
return rc;
@@ -187,13 +187,13 @@ bool CntInfo(PGLOBAL g, PTDB tp, PXF info)
/***********************************************************************/
PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
{
- int rc;
+ int rc;
PTDB tdbp;
PTABLE tabp;
PDBUSER dup= PlgGetUser(g);
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);
if (!cat)
@@ -213,7 +213,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
// Get table object from the catalog
tabp= new(g) XTAB(name);
- if (xtrace)
+ if (trace)
printf("CntGetTDB: tabp=%p\n", tabp);
// Perhaps this should be made thread safe
@@ -223,7 +223,7 @@ PTDB CntGetTDB(PGLOBAL g, LPCSTR name, MODE mode, PHC h)
printf("CntGetTDB: %s\n", g->Message);
err:
- if (xtrace)
+ if (trace)
printf("Returning tdbp=%p mode=%d\n", tdbp, mode);
g->jump_level--;
@@ -237,12 +237,13 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
bool del, PHC h)
{
char *p;
- int i, n;
+ int i, n, rc;
+ bool rcop= true;
PCOL colp;
//PCOLUMN cp;
PDBUSER dup= PlgGetUser(g);
- if (xtrace)
+ if (trace)
printf("CntOpenTable: tdbp=%p mode=%d\n", tdbp, mode);
if (!tdbp) {
@@ -251,7 +252,15 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
return true;
} // 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 (mode == MODE_INSERT)
@@ -260,7 +269,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} else for (p= c1; *p; p+= n) {
// Allocate only used column blocks
- if (xtrace)
+ if (trace)
printf("Allocating column %s\n", p);
// if (*p == '*') {
@@ -273,7 +282,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
if (!colp) {
sprintf(g->Message, "Column %s not found in %s", p, tdbp->GetName());
- return true;
+ goto err;
} // endif colp
n= strlen(p) + 1;
@@ -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()) {
if (colp->InitValue(g))
- return true;
+ goto err;
if (mode == MODE_INSERT)
// Allow type conversion
if (colp->SetBuffer(g, colp->GetValue(), true, false))
- return true;
+ goto err;
colp->AddColUse(U_P); // For PLG tables
} // endfor colp
@@ -301,7 +310,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
if (!(utp= (PTDBASE)tdbp->Duplicate(g))) {
sprintf(g->Message, MSG(INV_UPDT_TABLE), tdbp->GetName());
- return true;
+ goto err;
} // endif tp
if (!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()) {
if (colp->InitValue(g))
- return true;
+ goto err;
if (colp->SetBuffer(g, colp->GetValue(), true, false))
- return true;
+ goto err;
} // endfor colp
@@ -328,7 +337,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
((PTDBASE)tdbp)->SetSetCols(tdbp->GetColumns());
// Now do open the physical table
- if (xtrace)
+ if (trace)
printf("Opening table %s in mode %d tdbp=%p\n",
tdbp->GetName(), mode, tdbp);
@@ -344,19 +353,23 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2,
} // endif del
- if (xtrace)
+ if (trace)
printf("About to open the table: tdbp=%p\n", tdbp);
if (mode != MODE_ANY && mode != MODE_ALTER) {
if (tdbp->OpenDB(g)) {
printf("%s\n", g->Message);
- return true;
+ goto err;
} else
tdbp->SetNext(NULL);
} // endif mode
- return false;
+ rcop= false;
+
+ err:
+ g->jump_level--;
+ return rcop;
} // end of CntOpenTable
/***********************************************************************/
@@ -374,14 +387,14 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp)
/***********************************************************************/
/* Evaluate all columns after a record is read. */
/***********************************************************************/
-RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
+RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
{
RCODE rc= RC_OK;
PCOL colp;
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
- if (xtrace) {
+ if (trace) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
printf("EvalColumns: %s\n", g->Message);
} // endif
@@ -390,7 +403,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
} // endif jump_level
if (setjmp(g->jumper[++g->jump_level]) != 0) {
- if (xtrace)
+ if (trace)
printf("Error reading columns: %s\n", g->Message);
rc= RC_FX;
@@ -416,7 +429,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
/***********************************************************************/
/* ReadNext: Read next record sequentially. */
/***********************************************************************/
-RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
+RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
{
RCODE rc;
@@ -432,8 +445,21 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
((PTDBASE)tdbp)->SetKindex(NULL);
} // 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) ;
-
+
+ err:
+ g->jump_level--;
return (rc != RC_OK) ? rc : EvalColumns(g, tdbp);
} // end of CntReadNext
@@ -521,7 +547,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
if (!tdbp || tdbp->GetUse() != USE_OPEN)
return rc; // Nothing to do
- if (xtrace)
+ if (trace)
printf("CntCloseTable: tdbp=%p mode=%d\n", tdbp, tdbp->GetMode());
if (tdbp->GetMode() == MODE_DELETE && tdbp->GetUse() == USE_OPEN)
@@ -545,7 +571,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
g->jump_level--;
- if (xtrace > 1)
+ if (trace > 1)
printf("Table %s closed\n", tdbp->GetName());
//if (!((PTDBDOX)tdbp)->GetModified())
@@ -554,8 +580,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
if (tdbp->GetMode() == MODE_READ || tdbp->GetMode() == MODE_ANY)
return 0;
- if (xtrace > 1)
- printf("About to reset opt\n");
+ if (trace > 1)
+ printf("About to reset indexes\n");
// Make all the eventual indexes
tbxp= (TDBDOX*)tdbp;
@@ -564,7 +590,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable());
err:
- if (xtrace > 1)
+ if (trace > 1)
printf("Done rc=%d\n", 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,
} else
valp->SetBinValue((void*)p);
- if (xtrace) {
+ if (trace) {
char bf[32];
printf("i=%d n=%d key=%s\n", i, n, valp->GetCharString(bf));
- } // endif xtrace
+ } // endif trace
p+= valp->GetClen();
@@ -855,7 +881,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
xbp->SetNval(n);
- if (xtrace)
+ if (trace)
printf("xbp=%p Nval=%d i=%d incl=%d\n", xbp, n, i, 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,
} // endfor i
- if (xtrace)
+ if (trace)
printf("k1=%d k0=%d\n", k[1], k[0]);
return k[1] - k[0];
diff --git a/storage/connect/connect.h b/storage/connect/connect.h
index 4b3e2fb7347..4c9cee46daf 100644
--- a/storage/connect/connect.h
+++ b/storage/connect/connect.h
@@ -17,7 +17,6 @@
/* Name: CONNECT.H Version 2.4 */
/* This file contains the some based classes declares. */
/***********************************************************************/
-//#include "xtable.h" // Base class declares
#include "filamtxt.h"
#include "tabdos.h"
@@ -37,7 +36,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp);
int CntCloseTable(PGLOBAL g, PTDB tdbp);
int CntIndexInit(PGLOBAL g, PTDB tdbp, int id);
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 CntUpdateRow(PGLOBAL g, PTDB tdbp);
RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all);
@@ -51,8 +50,6 @@ PGLOBAL CntExit(PGLOBAL g);
/* These classes purpose is chiefly to access protected items! */
/***********************************************************************/
class DOXDEF: public DOSDEF {
-//friend class TDBDOX;
-//friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int);
}; // end of class DOXDEF
@@ -73,10 +70,7 @@ class TDBDOX: public TDBDOS {
class XKPDEF: public KPARTDEF {
friend class TDBDOX;
friend class ha_connect;
-//friend int CntMakeIndex(PGLOBAL, const char *, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int);
public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {}
}; // end of class XKPDEF
-
-//RCODE CheckRecord(PGLOBAL g, PTDB tdbp, char *oldbuf, char *newbuf);
diff --git a/storage/connect/csort.h b/storage/connect/csort.h
index 1808f640788..55ff6268a4b 100644
--- a/storage/connect/csort.h
+++ b/storage/connect/csort.h
@@ -22,9 +22,7 @@
#define THRESH 4 /* Threshold for insertion (was 4) */
#define MTHRESH 6 /* Threshold for median */
-#ifdef DEBTRACE
-extern FILE *debug; /* Debug file */
-#endif
+//extern FILE *debug; /* Debug file */
typedef int* const CPINT;
diff --git a/storage/connect/domdoc.cpp b/storage/connect/domdoc.cpp
index 0272a1d709a..251b4f17982 100644
--- a/storage/connect/domdoc.cpp
+++ b/storage/connect/domdoc.cpp
@@ -59,7 +59,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
xp->Count--;
} else if (xp && xp->Count > 0) {
try {
- xp->Docp->Release();
+ if (xp->Docp)
+ xp->Docp->Release();
+
} catch(_com_error e) {
sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description());
} catch(...) {}
diff --git a/storage/connect/domdoc.h b/storage/connect/domdoc.h
index b0bcc1478a5..118541d8eb0 100644
--- a/storage/connect/domdoc.h
+++ b/storage/connect/domdoc.h
@@ -20,7 +20,6 @@ typedef struct _xblock { /* Loaded XML file block */
short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */
MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */
-//IXMLDOMNodeListPtr Nlist;
} XBLOCK, *PXBLOCK;
/******************************************************************/
@@ -123,9 +122,6 @@ class DOMATTR : public XMLATTRIBUTE {
friend class DOMDOC;
friend class DOMNODE;
public:
- // Properties
-//virtual char *GetText(void);
-
// Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len);
diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp
index 5a67c5d2dd2..f8a4e7d2f2b 100644
--- a/storage/connect/filamap.cpp
+++ b/storage/connect/filamap.cpp
@@ -46,6 +46,8 @@
#include "filamap.h"
#include "tabdos.h"
+extern "C" int trace;
+
/* --------------------------- Class MAPFAM -------------------------- */
/***********************************************************************/
@@ -89,9 +91,8 @@ int MAPFAM::GetFileLength(PGLOBAL g)
len = (To_Fb) ? To_Fb->Length : TXTFAM::GetFileLength(g);
-#ifdef DEBTRACE
- htrc("Mapped file length=%d\n", len);
-#endif
+ if (trace)
+ htrc("Mapped file length=%d\n", len);
return len;
} // end of GetFileLength
@@ -128,9 +129,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
&& fp->Count && fp->Mode == mode)
break;
-#ifdef DEBTRACE
- htrc("Mapping file, fp=%p\n", fp);
-#endif
+ if (trace)
+ htrc("Mapping file, fp=%p\n", fp);
+
} else
fp = NULL;
@@ -166,9 +167,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
"map", (int) rc, filename);
-#ifdef DEBTRACE
- htrc("%s\n", g->Message);
-#endif
+ if (trace)
+ htrc("CreateFileMap: %s\n", g->Message);
+
return (mode == MODE_READ && rc == ENOENT)
? PushWarning(g, Tdbp) : true;
} // endif hFile
@@ -228,10 +229,9 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
Fpos = Mempos = Memory;
Top = Memory + len;
-#ifdef DEBTRACE
- htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
- fp, fp->Count, Memory, len, Top);
-#endif
+ if (trace)
+ htrc("fp=%p count=%d MapView=%p len=%d Top=%p\n",
+ fp, fp->Count, Memory, len, Top);
return AllocateBuffer(g); // Useful for DBF files
} // end of OpenTableFile
@@ -322,8 +322,8 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/
/* Record file position in case of UPDATE or DELETE. */
/*******************************************************************/
- Fpos = Mempos;
- CurBlk = (int)Rows++;
+ Fpos = Mempos;
+ CurBlk = (int)Rows++;
} else
Placed = false;
@@ -365,20 +365,19 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
{
int n;
-#ifdef DEBTRACE
- fprintf(debug,
- "MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n",
- irc, Mempos, To_Buf, Tpos, Spos);
-#endif
+ if (trace)
+ htrc("MAP DeleteDB: irc=%d mempos=%p tobuf=%p Tpos=%p Spos=%p\n",
+ irc, Mempos, To_Buf, Tpos, Spos);
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the top of map position. */
/*******************************************************************/
Fpos = Top;
-#ifdef DEBTRACE
- htrc("Fpos placed at file top=%p\n", Fpos);
-#endif
+
+ if (trace)
+ htrc("Fpos placed at file top=%p\n", Fpos);
+
} // endif irc
if (Tpos == Spos)
@@ -394,17 +393,16 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
memmove(Tpos, Spos, n);
Tpos += n;
-#ifdef DEBTRACE
- htrc("move %d bytes\n", n);
-#endif
+ if (trace)
+ htrc("move %d bytes\n", n);
+
} // endif n
if (irc == RC_OK) {
Spos = Mempos; // New start position
-#ifdef DEBTRACE
- htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
-#endif
+ if (trace)
+ htrc("after: Tpos=%p Spos=%p\n", Tpos, Spos);
} else if (To_Fb) { // Can be NULL for deleted files
/*******************************************************************/
@@ -432,9 +430,8 @@ int MAPFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
} // endif
-#ifdef DEBTRACE
- htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
-#endif
+ if (trace)
+ htrc("done, Tpos=%p newsize=%d drc=%d\n", Tpos, n, drc);
if (!SetEndOfFile(fp->Handle)) {
sprintf(g->Message, MSG(FUNCTION_ERROR),
@@ -466,10 +463,10 @@ void MAPFAM::CloseTableFile(PGLOBAL g)
PlugCloseFile(g, To_Fb);
To_Fb = NULL; // To get correct file size in Cardinality
-#ifdef DEBTRACE
- htrc("MAP Close: closing %s count=%d\n",
- To_File, (To_Fb) ? To_Fb->Count : 0);
-#endif
+ if (trace)
+ htrc("MAP Close: closing %s count=%d\n",
+ To_File, (To_Fb) ? To_Fb->Count : 0);
+
} // end of CloseTableFile
/***********************************************************************/
@@ -491,7 +488,7 @@ MBKFAM::MBKFAM(PDOSDEF tdp) : MAPFAM(tdp)
Block = tdp->GetBlock();
Last = tdp->GetLast();
Nrec = tdp->GetElemt();
- BlkPos = tdp->GetTo_Pos();
+ BlkPos = NULL;
CurNum = Nrec;
} // end of MBKFAM standard constructor
@@ -537,37 +534,8 @@ int MBKFAM::GetRowID(void)
/***********************************************************************/
int MBKFAM::ReadBuffer(PGLOBAL g)
{
- int len;
-
- /*********************************************************************/
- /* 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;
+ strcpy(g->Message, "This AM cannot be used in this version");
+ return RC_FX;
} // end of ReadBuffer
/***********************************************************************/
@@ -657,7 +625,7 @@ int MPXFAM::ReadBuffer(PGLOBAL g)
/* New block. */
/*******************************************************************/
CurNum = 0;
-
+
if (++CurBlk >= Block)
return RC_EF;
diff --git a/storage/connect/filamap.h b/storage/connect/filamap.h
index d3503bb0c1d..7f71b90a18f 100644
--- a/storage/connect/filamap.h
+++ b/storage/connect/filamap.h
@@ -33,7 +33,6 @@ class DllExport MAPFAM : public TXTFAM {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
- virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos);
@@ -66,18 +65,16 @@ class DllExport MBKFAM : public MAPFAM {
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
// Implementation
- virtual PTXF Duplicate(PGLOBAL g)
+ virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MBKFAM(this);}
// Methods
- virtual void Reset(void);
+ virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
- virtual int MaxBlkSize(PGLOBAL g, int s)
- {return TXTFAM::MaxBlkSize(g, s);}
virtual int GetRowID(void);
- virtual int SkipRecord(PGLOBAL g, bool header);
- virtual int ReadBuffer(PGLOBAL g);
- virtual void Rewind(void);
+ virtual int SkipRecord(PGLOBAL g, bool header);
+ virtual int ReadBuffer(PGLOBAL g);
+ virtual void Rewind(void);
protected:
// No additional members
@@ -99,9 +96,6 @@ class DllExport MPXFAM : public MBKFAM {
// Methods
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 DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g);
diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp
index 2b56e5c3d2f..7ac81117f35 100644
--- a/storage/connect/filamdbf.cpp
+++ b/storage/connect/filamdbf.cpp
@@ -485,16 +485,15 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
if (!(Stream = PlugOpenFile(g, filename, opmode))) {
-#ifdef DEBTRACE
- htrc("%s\n", g->Message);
-#endif
+ if (trace)
+ htrc("%s\n", g->Message);
+
return (mode == MODE_READ && errno == ENOENT)
? PushWarning(g, Tdbp) : true;
} // endif Stream
-#ifdef DEBTRACE
- htrc("File %s is open in mode %s\n", filename, opmode);
-#endif
+ if (trace)
+ htrc("File %s is open in mode %s\n", filename, opmode);
To_Fb = dbuserp->Openlist; // Keep track of File block
@@ -853,10 +852,10 @@ void DBFFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
-#ifdef DEBTRACE
- htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
- To_File, mode, wrc, rc);
-#endif
+ if (trace)
+ htrc("DBF CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
+ To_File, mode, wrc, rc);
+
Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile
diff --git a/storage/connect/filamdbf.h b/storage/connect/filamdbf.h
index 361f2bd8360..b85b9fc47fe 100644
--- a/storage/connect/filamdbf.h
+++ b/storage/connect/filamdbf.h
@@ -43,7 +43,6 @@ class DllExport DBFBASE {
int Nerr; /* Number of bad records */
int Maxerr; /* Maximum number of bad records */
int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */
-//PSZ Defpath; /* Default data path */
}; // end of class DBFBASE
/****************************************************************************/
@@ -63,22 +62,18 @@ class DllExport DBFFAM : public FIXFAM, public DBFBASE {
// Methods
virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g);
-//virtual int GetRowID(void); // Temporarily suppressed
virtual bool OpenTableFile(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
-//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void);
protected:
- // Members
virtual bool CopyHeader(PGLOBAL g);
-//int Records; in TXTFAM
-//int Headlen; in TXTFAM
+ // Members
}; // end of class DBFFAM
/****************************************************************************/
@@ -100,17 +95,13 @@ class DllExport DBMFAM : public MPXFAM, public DBFBASE {
// Methods
virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g);
-//virtual int GetRowID(void); // Temporarily suppressed
virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g);
-//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void Rewind(void);
protected:
// Members
-//int Records; in TXTFAM
-//int Headlen; in TXTFAM
}; // end of class DBFFAM
#endif // __FILAMDBF_H
diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp
index a92d9766933..f4455f3ce5b 100644
--- a/storage/connect/filamfix.cpp
+++ b/storage/connect/filamfix.cpp
@@ -1,11 +1,11 @@
/*********** File AM Fix C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMFIX */
/* ------------- */
-/* Version 1.4 */
+/* Version 1.5 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */
+/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -52,6 +52,7 @@
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
+extern "C" int trace;
extern int num_read, num_there, num_eq[2]; // Statistics
/* --------------------------- Class FIXFAM -------------------------- */
@@ -230,9 +231,8 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
return RC_FX;
} // endif fseek
-#ifdef DEBTRACE
- htrc("File position is now %d\n", ftell(Stream));
-#endif
+ if (trace > 1)
+ htrc("File position is now %d\n", ftell(Stream));
//long tell = ftell(Stream); not used
@@ -255,9 +255,9 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#endif
-#ifdef DEBTRACE
- htrc("%s\n", g->Message);
-#endif
+ if (trace)
+ htrc("%s\n", g->Message);
+
return RC_FX;
} // endelse
@@ -272,11 +272,9 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
/***********************************************************************/
int FIXFAM::WriteBuffer(PGLOBAL g)
{
-#ifdef DEBTRACE
- fprintf(debug,
- "FIX WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
- Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
-#endif
+ if (trace > 1)
+ htrc("FIX WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
+ Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
if (Tdbp->GetMode() == MODE_INSERT) {
/*******************************************************************/
@@ -287,9 +285,8 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
return RC_OK; // We write only full blocks
} // endif CurNum
-#ifdef DEBTRACE
- htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
-#endif
+ if (trace > 1)
+ htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
// Now start the writing process.
if (fwrite(To_Buf, Lrecl, Rbuf, Stream) != (size_t)Rbuf) {
@@ -302,9 +299,8 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
-#ifdef DEBTRACE
- htrc("write done\n");
-#endif
+ if (trace > 1)
+ htrc("write done\n");
} else { // Mode == MODE_UPDATE
// T_Stream is the temporary stream or the table file stream itself
@@ -342,20 +338,19 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
/* file, and at the end erase all trailing records. */
/* This will be experimented. */
/*********************************************************************/
-#ifdef DEBTRACE
- fprintf(debug,
- "DOS DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
- irc, UseTemp, Fpos, Tpos, Spos);
-#endif
+ if (trace > 1)
+ htrc("DOS DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
+ irc, UseTemp, Fpos, Tpos, Spos);
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the end-of-file position. */
/*******************************************************************/
Fpos = Tdbp->Cardinality(g);
-#ifdef DEBTRACE
- htrc("Fpos placed at file end=%d\n", Fpos);
-#endif
+
+ if (trace > 1)
+ htrc("Fpos placed at file end=%d\n", Fpos);
+
} else // Fpos is the deleted line position
Fpos = CurBlk * Nrec + CurNum;
@@ -403,9 +398,8 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
OldBlk = -2; // To force fseek to be executed on next block
} // endif moved
-#ifdef DEBTRACE
- htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
-#endif
+ if (trace > 1)
+ htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
} else {
/*******************************************************************/
@@ -453,9 +447,9 @@ int FIXFAM::DeleteRecords(PGLOBAL g, int irc)
close(h);
-#ifdef DEBTRACE
- htrc("done, h=%d irc=%d\n", h, irc);
-#endif
+ if (trace > 1)
+ htrc("done, h=%d irc=%d\n", h, irc);
+
} // endif UseTemp
} // endif irc
@@ -485,9 +479,8 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
req = (size_t)min(n, Dbflen);
len = fread(DelBuf, Lrecl, req, Stream);
-#ifdef DEBTRACE
- htrc("after read req=%d len=%d\n", req, len);
-#endif
+ if (trace > 1)
+ htrc("after read req=%d len=%d\n", req, len);
if (len != req) {
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
@@ -505,16 +498,14 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
return true;
} // endif
-#ifdef DEBTRACE
- htrc("after write pos=%d\n", ftell(Stream));
-#endif
+ if (trace > 1)
+ htrc("after write pos=%d\n", ftell(Stream));
Tpos += (int)req;
Spos += (int)req;
-#ifdef DEBTRACE
- htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
-#endif
+ if (trace > 1)
+ htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
*b = true;
} // endfor n
@@ -563,10 +554,10 @@ void FIXFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
-#ifdef DEBTRACE
- htrc("FIX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
- To_File, mode, wrc, rc);
-#endif
+ if (trace)
+ htrc("FIX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
+ To_File, mode, wrc, rc);
+
Stream = NULL; // So we can know whether table is open
} // end of CloseTableFile
@@ -630,9 +621,8 @@ int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
DWORD nbr, drc, len = (DWORD)req;
bool brc = ReadFile(h, inbuf, len, &nbr, NULL);
-#ifdef DEBTRACE
- htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr);
-#endif
+ if (trace > 1)
+ htrc("after read req=%d brc=%d nbr=%d\n", req, brc, nbr);
if (!brc) {
char buf[256]; // , *fn = (h == Hfile) ? To_File : "Tempfile";
@@ -642,9 +632,10 @@ int BGXFAM::BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req)
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, drc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
sprintf(g->Message, MSG(READ_ERROR), To_File, buf);
-#ifdef DEBTRACE
- htrc("BIGREAD: %s\n", g->Message);
-#endif
+
+ if (trace > 1)
+ htrc("BIGREAD: %s\n", g->Message);
+
rc = -1;
} else
rc = (int)nbr;
@@ -669,9 +660,8 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
DWORD nbw, drc, len = (DWORD)req;
bool brc = WriteFile(h, inbuf, len, &nbw, NULL);
-#ifdef DEBTRACE
- htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
-#endif
+ if (trace > 1)
+ htrc("after write req=%d brc=%d nbw=%d\n", req, brc, nbw);
if (!brc || nbw != len) {
char buf[256], *fn = (h == Hfile) ? To_File : "Tempfile";
@@ -687,10 +677,10 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
sprintf(g->Message, MSG(WRITE_STRERROR), fn, buf);
-#ifdef DEBTRACE
- htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
- nbw, len, drc, g->Message);
-#endif
+ if (trace > 1)
+ htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
+ nbw, len, drc, g->Message);
+
rc = true;
} // endif brc || nbw
#else // !WIN32
@@ -701,10 +691,11 @@ bool BGXFAM::BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req)
const char *fn = (h == Hfile) ? To_File : "Tempfile";
sprintf(g->Message, MSG(WRITE_STRERROR), fn, strerror(errno));
-#ifdef DEBTRACE
- htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
- nbw, len, errno, g->Message);
-#endif
+
+ if (trace > 1)
+ htrc("BIGWRITE: nbw=%d len=%d errno=%d %s\n",
+ nbw, len, errno, g->Message);
+
rc = true;
} // endif nbr
#endif // !WIN32
@@ -739,9 +730,8 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
-#ifdef DEBTRACE
- htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
-#endif
+ if (trace)
+ htrc("OpenTableFile: filename=%s mode=%d\n", filename, mode);
#if defined(WIN32)
DWORD rc, access, creation, share = 0;
@@ -800,11 +790,9 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
} else
rc = 0;
-#ifdef DEBTRACE
- fprintf(debug,
- " rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n",
- rc, access, share, creation, Hfile, filename);
-#endif
+ if (trace > 1)
+ htrc(" rc=%d access=%p share=%p creation=%d handle=%p fn=%s\n",
+ rc, access, share, creation, Hfile, filename);
if (mode == MODE_INSERT)
/*******************************************************************/
@@ -855,10 +843,9 @@ bool BGXFAM::OpenTableFile(PGLOBAL g)
} else
rc = 0;
-#ifdef DEBTRACE
- htrc(" rc=%d oflag=%p tmode=%p handle=%p fn=%s\n",
- rc, oflag, tmode, Hfile, filename);
-#endif
+ if (trace > 1)
+ htrc(" rc=%d oflag=%p tmode=%p handle=%p fn=%s\n",
+ rc, oflag, tmode, Hfile, filename);
#endif // UNIX
@@ -940,14 +927,13 @@ int BGXFAM::Cardinality(PGLOBAL g)
if (Hfile == INVALID_HANDLE_VALUE) {
int h = open64(filename, O_RDONLY, 0);
-#ifdef DEBTRACE
- htrc(" h=%d\n", h);
-#endif
+ if (trace)
+ htrc(" h=%d\n", h);
if (h == INVALID_HANDLE_VALUE) {
-#ifdef DEBTRACE
- htrc(" errno=%d ENOENT=%d\n", errno, ENOENT);
-#endif
+ if (trace)
+ htrc(" errno=%d ENOENT=%d\n", errno, ENOENT);
+
if (errno != ENOENT) {
sprintf(g->Message, MSG(OPEN_ERROR_IS),
filename, strerror(errno));
@@ -989,10 +975,9 @@ int BGXFAM::Cardinality(PGLOBAL g)
} else
card = (int)(fsize / (BIGINT)Lrecl); // Fixed length file
-#ifdef DEBTRACE
- htrc(" Computed max_K=%d fsize=%lf lrecl=%d\n",
- card, (double)fsize, Lrecl);
-#endif
+ if (trace)
+ htrc(" Computed max_K=%d fsize=%lf lrecl=%d\n",
+ card, (double)fsize, Lrecl);
// Set number of blocks for later use
Block = (card + Nrec - 1) / Nrec;
@@ -1078,9 +1063,8 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
if (BigSeek(g, Hfile, (BIGINT)Fpos * (BIGINT)Lrecl))
return RC_FX;
-#ifdef DEBTRACE
- htrc("File position is now %d\n", Fpos);
-#endif
+ if (trace > 1)
+ htrc("File position is now %d\n", Fpos);
nbr = BigRead(g, Hfile, To_Buf, (Padded) ? Blksize : Lrecl * Nrec);
@@ -1103,11 +1087,9 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
/***********************************************************************/
int BGXFAM::WriteBuffer(PGLOBAL g)
{
-#ifdef DEBTRACE
- fprintf(debug,
- "BIG WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
- Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
-#endif
+ if (trace > 1)
+ htrc("BIG WriteDB: Mode=%d buf=%p line=%p Nrec=%d Rbuf=%d CurNum=%d\n",
+ Tdbp->GetMode(), To_Buf, Tdbp->GetLine(), Nrec, Rbuf, CurNum);
if (Tdbp->GetMode() == MODE_INSERT) {
/*******************************************************************/
@@ -1118,9 +1100,8 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
return RC_OK; // We write only full blocks
} // endif CurNum
-#ifdef DEBTRACE
- htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
-#endif
+ if (trace > 1)
+ htrc(" First line is '%.*s'\n", Lrecl - 2, To_Buf);
// Now start the writing process.
if (BigWrite(g, Hfile, To_Buf, Lrecl * Rbuf))
@@ -1130,9 +1111,8 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
-#ifdef DEBTRACE
- htrc("write done\n");
-#endif
+ if (trace > 1)
+ htrc("write done\n");
} else { // Mode == MODE_UPDATE
// Tfile is the temporary file or the table file handle itself
@@ -1167,20 +1147,19 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
/* file, and at the end erase all trailing records. */
/* This will be experimented. */
/*********************************************************************/
-#ifdef DEBTRACE
- fprintf(debug,
- "BGX DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
- irc, UseTemp, Fpos, Tpos, Spos);
-#endif
+ if (trace > 1)
+ htrc("BGX DeleteDB: rc=%d UseTemp=%d Fpos=%d Tpos=%d Spos=%d\n",
+ irc, UseTemp, Fpos, Tpos, Spos);
if (irc != RC_OK) {
/*******************************************************************/
/* EOF: position Fpos at the end-of-file position. */
/*******************************************************************/
Fpos = Tdbp->Cardinality(g);
-#ifdef DEBTRACE
- htrc("Fpos placed at file end=%d\n", Fpos);
-#endif
+
+ if (trace > 1)
+ htrc("Fpos placed at file end=%d\n", Fpos);
+
} else // Fpos is the deleted line position
Fpos = CurBlk * Nrec + CurNum;
@@ -1216,9 +1195,9 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
return RC_FX;
if (irc == RC_OK) {
-#ifdef DEBTRACE
- assert(Spos == Fpos);
-#endif
+ if (trace)
+ assert(Spos == Fpos);
+
Spos++; // New start position is on next line
if (moved) {
@@ -1228,9 +1207,8 @@ int BGXFAM::DeleteRecords(PGLOBAL g, int irc)
OldBlk = -2; // To force fseek to be executed on next block
} // endif moved
-#ifdef DEBTRACE
- htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
-#endif
+ if (trace > 1)
+ htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);
} else {
/*******************************************************************/
@@ -1362,9 +1340,8 @@ bool BGXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
Tpos += (int)req;
Spos += (int)req;
-#ifdef DEBTRACE
- htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
-#endif
+ if (trace > 1)
+ htrc("loop: Tpos=%d Spos=%d\n", Tpos, Spos);
*b = true;
} // endfor n
@@ -1412,10 +1389,10 @@ void BGXFAM::CloseTableFile(PGLOBAL g)
rc = PlugCloseFile(g, To_Fb);
fin:
-#ifdef DEBTRACE
- htrc("BGX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
- To_File, mode, wrc, rc);
-#endif
+ if (trace)
+ htrc("BGX CloseTableFile: closing %s mode=%d wrc=%d rc=%d\n",
+ To_File, mode, wrc, rc);
+
Hfile = INVALID_HANDLE_VALUE; // So we can know whether table is open
} // end of CloseTableFile
diff --git a/storage/connect/filamfix.h b/storage/connect/filamfix.h
index 758d891bf2c..6f9e6ef3b45 100644
--- a/storage/connect/filamfix.h
+++ b/storage/connect/filamfix.h
@@ -31,18 +31,16 @@ class DllExport FIXFAM : public BLKFAM {
// Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
- virtual int MaxBlkSize(PGLOBAL g, int s)
- {return TXTFAM::MaxBlkSize(g, s);}
- virtual bool AllocateBuffer(PGLOBAL g);
- virtual void ResetBuffer(PGLOBAL g);
- virtual int ReadBuffer(PGLOBAL g);
- virtual int WriteBuffer(PGLOBAL g);
- virtual int DeleteRecords(PGLOBAL g, int irc);
- virtual void CloseTableFile(PGLOBAL g);
+ virtual bool AllocateBuffer(PGLOBAL g);
+ virtual void ResetBuffer(PGLOBAL g);
+ virtual int ReadBuffer(PGLOBAL g);
+ virtual int WriteBuffer(PGLOBAL g);
+ virtual int DeleteRecords(PGLOBAL g, int irc);
+ virtual void CloseTableFile(PGLOBAL g);
protected:
- virtual bool CopyHeader(PGLOBAL g) {return false;}
- virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
+ virtual bool CopyHeader(PGLOBAL g) {return false;}
+ virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members
}; // end of class FIXFAM
@@ -64,12 +62,11 @@ class BGXFAM : public FIXFAM {
{return (PTXF)new(g) BGXFAM(this);}
// Methods
-//virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
virtual bool OpenTableFile(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 Rewind(void);
@@ -78,13 +75,12 @@ class BGXFAM : public FIXFAM {
, int org = FILE_BEGIN);
int BigRead(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);
// Members
HANDLE Hfile; // Handle(descriptor) to big file
HANDLE Tfile; // Handle(descriptor) to big temp file
-//BIGINT Xpos; // Current file position
}; // end of class BGXFAM
#endif // __FILAMFIX_H
diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp
index 1d3f17e2228..c9bef42c4be 100644
--- a/storage/connect/filamtxt.cpp
+++ b/storage/connect/filamtxt.cpp
@@ -228,25 +228,6 @@ int TXTFAM::Cardinality(PGLOBAL g)
} // 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 -------------------------- */
/***********************************************************************/
@@ -314,15 +295,6 @@ int DOSFAM::Cardinality(PGLOBAL g)
} // 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. */
/***********************************************************************/
bool DOSFAM::OpenTableFile(PGLOBAL g)
@@ -915,7 +887,8 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
// This loop is necessary because, in case of join,
// To_File can have been open several times.
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;
PlugSetPath(filename, To_File, Tdbp->GetPath());
@@ -976,7 +949,9 @@ void DOSFAM::CloseTableFile(PGLOBAL g)
/***********************************************************************/
void DOSFAM::Rewind(void)
{
- rewind(Stream);
+ if (Stream) // Can be NULL when making index on void table
+ rewind(Stream);
+
Rows = 0;
OldBlk = CurBlk = -1;
} // end of Rewind
@@ -993,7 +968,7 @@ BLKFAM::BLKFAM(PDOSDEF tdp) : DOSFAM(tdp)
Last = tdp->GetLast();
Nrec = tdp->GetElemt();
Closing = false;
- BlkPos = tdp->GetTo_Pos();
+ BlkPos = NULL;
CurLine = NULL;
NxtLine = NULL;
OutBuf = NULL;
@@ -1029,23 +1004,6 @@ int BLKFAM::Cardinality(PGLOBAL g)
} // 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 */
/* used another big buffer has to be allocated because is it used */
/* to move or update the lines into the (temp) file. */
@@ -1150,97 +1108,8 @@ int BLKFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/
int BLKFAM::ReadBuffer(PGLOBAL g)
{
- int i, n, rc = RC_OK;
-
- /*********************************************************************/
- /* 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;
+ strcpy(g->Message, "This AM cannot be used in this version");
+ return RC_FX;
} // end of ReadBuffer
/***********************************************************************/
diff --git a/storage/connect/filamtxt.h b/storage/connect/filamtxt.h
index a6105d0fe66..c3ee96ada1a 100644
--- a/storage/connect/filamtxt.h
+++ b/storage/connect/filamtxt.h
@@ -39,10 +39,10 @@ class DllExport TXTFAM : public BLOCK {
virtual int GetNextPos(void) = 0;
virtual PTXF Duplicate(PGLOBAL g) = 0;
virtual bool GetUseTemp(void) {return false;}
- virtual int GetDelRows(void) {return DelRows;}
+ virtual int GetDelRows(void) {return DelRows;}
int GetCurBlk(void) {return CurBlk;}
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;}
- int GetBlock(void) {return Block;}
+ int GetBlock(void) {return Block;}
void SetBlkPos(int *bkp) {BlkPos = bkp;}
void SetNrec(int n) {Nrec = n;}
char *GetBuf(void) {return To_Buf;}
@@ -53,7 +53,6 @@ class DllExport TXTFAM : public BLOCK {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
- virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) {return false;}
virtual void ResetBuffer(PGLOBAL g) {}
virtual int GetNerr(void) {return 0;}
@@ -71,19 +70,19 @@ class DllExport TXTFAM : public BLOCK {
protected:
// Members
- PTDBDOS Tdbp; // To table class
+ PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name
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 Blocked; // true if using blocked I/O
char *To_Buf; // Points to I/O buffer
void *DelBuf; // Buffer used to move lines in Delete
int *BlkPos; // To array of block positions
- int BlkLen; // Current block length
+ int BlkLen; // Current block length
int Buflen; // 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 Headlen; // Number of bytes in header
int Lrecl; // Logical Record Length
@@ -93,14 +92,14 @@ class DllExport TXTFAM : public BLOCK {
int OldBlk; // Index of last read block
int CurBlk; // Index of current block
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 Modif; // Number of modified lines in block
int Blksize; // Size of padded blocks
- int Ending; // Length of line end
- bool Padded; // true if fixed size blocks are padded
+ int Ending; // Length of line end
+ bool Padded; // true if fixed size blocks are padded
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
/***********************************************************************/
@@ -125,7 +124,6 @@ class DllExport DOSFAM : public TXTFAM {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g);
- virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
@@ -134,7 +132,7 @@ class DllExport DOSFAM : public TXTFAM {
virtual bool OpenTableFile(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 Rewind(void);
@@ -174,7 +172,6 @@ class DllExport BLKFAM : public DOSFAM {
// Methods
virtual void Reset(void);
virtual int Cardinality(PGLOBAL g);
- virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp
index 11c9ac69d4d..ffd46c32231 100755
--- a/storage/connect/filamvct.cpp
+++ b/storage/connect/filamvct.cpp
@@ -245,23 +245,6 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g)
} // 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. */
/* This function can be called with a null argument to test the */
/* availability of Cardinality implementation (1 yes, 0 no). */
diff --git a/storage/connect/filamvct.h b/storage/connect/filamvct.h
index 22665c6cd23..0dd1c06ad8b 100644
--- a/storage/connect/filamvct.h
+++ b/storage/connect/filamvct.h
@@ -40,7 +40,6 @@ class DllExport VCTFAM : public FIXFAM {
// Methods
virtual void Reset(void);
- virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g) {}
@@ -74,11 +73,11 @@ class DllExport VCTFAM : public FIXFAM {
char *Colfn; // Pattern for column file names (VER)
char *Tempat; // Pattern for temp file names (VER)
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 AddBlock; // True when adding new blocks on Insert
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 Bsize; // Because Nrec can be modified
int Ncol; // The number of columns;
@@ -164,7 +163,7 @@ class DllExport VECFAM : public VCTFAM {
FILE* *T_Streams; // Points to temp file structure array
PFBLOCK *To_Fbs; // Pointer to 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
}; // end of class VECFAM
@@ -189,7 +188,7 @@ class DllExport VMPFAM : public VCMFAM {
// Database routines
virtual bool OpenTableFile(PGLOBAL g);
- virtual int DeleteRecords(PGLOBAL g, int irc);
+ virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g);
protected:
@@ -220,7 +219,7 @@ class BGVFAM : public VCTFAM {
// Database routines
virtual bool OpenTableFile(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 Rewind(void);
@@ -233,11 +232,11 @@ class BGVFAM : public VCTFAM {
bool BigRead(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 OpenTempFile(PGLOBAL g);
+ virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g);
- virtual bool SetBlockInfo(PGLOBAL g);
- virtual int GetBlockInfo(PGLOBAL g);
+ virtual bool SetBlockInfo(PGLOBAL g);
+ virtual int GetBlockInfo(PGLOBAL g);
// Members
HANDLE Hfile; // Handle to big file
diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp
index 4f1a02d8257..9d0ffab32d9 100644
--- a/storage/connect/filamzip.cpp
+++ b/storage/connect/filamzip.cpp
@@ -62,6 +62,7 @@
/* DB static variables. */
/***********************************************************************/
extern int num_read, num_there, num_eq[]; // Statistics
+extern "C" int trace;
/* ------------------------------------------------------------------- */
@@ -203,9 +204,8 @@ bool ZIPFAM::AllocateBuffer(PGLOBAL g)
Buflen = Lrecl + 2; // Lrecl does not include CRLF
//Buflen *= ((Mode == MODE_DELETE) ? DOS_BUFF_LEN : 1); NIY
-#ifdef DEBTRACE
- htrc("SubAllocating a buffer of %d bytes\n", Buflen);
-#endif
+ if (trace)
+ htrc("SubAllocating a buffer of %d bytes\n", Buflen);
To_Buf = (char*)PlugSubAlloc(g, NULL, Buflen);
@@ -331,9 +331,9 @@ int ZIPFAM::ReadBuffer(PGLOBAL g)
} else
rc = Zerror(g);
-#ifdef DEBTRACE
- htrc(" Read: '%s' rc=%d\n", To_Buf, rc);
-#endif
+ if (trace > 1)
+ htrc(" Read: '%s' rc=%d\n", To_Buf, rc);
+
return rc;
} // end of ReadBuffer
@@ -373,9 +373,8 @@ void ZIPFAM::CloseTableFile(PGLOBAL g)
{
int rc = gzclose(Zfile);
-#ifdef DEBTRACE
- htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
-#endif
+ if (trace)
+ htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
Zfile = NULL; // So we can know whether table is open
//To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
@@ -403,7 +402,7 @@ ZBKFAM::ZBKFAM(PDOSDEF tdp) : ZIPFAM(tdp)
CurLine = NULL;
NxtLine = NULL;
Closing = false;
- BlkPos = tdp->GetTo_Pos();
+ BlkPos = NULL;
} // end of ZBKFAM standard constructor
ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
@@ -414,23 +413,6 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
} // 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. */
/* This function can be called with a null argument to test the */
/* availability of Cardinality implementation (1 yes, 0 no). */
@@ -509,56 +491,8 @@ int ZBKFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/
int ZBKFAM::ReadBuffer(PGLOBAL g)
{
- int n, rc = RC_OK;
-
- /*********************************************************************/
- /* 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;
+ strcpy(g->Message, "This AM cannot be used in this version");
+ return RC_FX;
} // end of ReadBuffer
/***********************************************************************/
@@ -664,9 +598,8 @@ void ZBKFAM::CloseTableFile(PGLOBAL g)
} else
rc = gzclose(Zfile);
-#ifdef DEBTRACE
- htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
-#endif
+ if (trace)
+ htrc("ZIP CloseDB: closing %s rc=%d\n", To_File, rc);
Zfile = NULL; // So we can know whether table is open
//To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
@@ -770,9 +703,6 @@ int ZIXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0;
Tdbp->SetLine(To_Buf);
-//if (++CurBlk >= Block)
-// return RC_EF;
-
if (!(n = gzread(Zfile, To_Buf, Buflen))) {
rc = RC_EF;
} else if (n > 0) {
diff --git a/storage/connect/filamzip.h b/storage/connect/filamzip.h
index f6f28ca5315..37cc130311c 100644
--- a/storage/connect/filamzip.h
+++ b/storage/connect/filamzip.h
@@ -38,7 +38,6 @@ class DllExport ZIPFAM : public TXTFAM {
virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
- virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
@@ -78,7 +77,6 @@ class DllExport ZBKFAM : public ZIPFAM {
// Methods
virtual int Cardinality(PGLOBAL g);
- virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g);
@@ -122,7 +120,7 @@ class DllExport ZIXFAM : public ZBKFAM {
// No additional Members
}; // end of class ZIXFAM
-#ifdef NOT_USED
+#if 0
/***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */
/* fixed/variable files compressed using the zlib library functions. */
@@ -166,6 +164,6 @@ class DllExport ZLBFAM : public BLKFAM {
int *Zlenp; // Pointer to block length
bool Optimized; // true when opt file is available
}; // end of class ZLBFAM
-#endif // NOT_USED
+#endif // 0
#endif // __FILAMZIP_H
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 3d4ec2dbc13..365df8d1b99 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -108,9 +108,6 @@
#include "sql_parse.h"
#include "sql_base.h"
#include <sys/stat.h>
-#if defined(NEW_WAY)
-#include "sql_table.h"
-#endif // NEW_WAY
#undef OFFSET
#define NOPARSE
@@ -143,43 +140,32 @@
#include "myutil.h"
#include "preparse.h"
#include "inihandl.h"
-
-#define PLGXINI "plgcnx.ini" /* Configuration settings file */
-#define my_strupr(p) my_caseup_str(default_charset_info, (p));
-#define my_strlwr(p) my_casedn_str(default_charset_info, (p));
-#define my_stricmp(a,b) my_strcasecmp(default_charset_info, (a), (b))
-
-#ifdef LIBXML2_SUPPORT
+#if defined(LIBXML2_SUPPORT)
#include "libdoc.h"
#endif // LIBXML2_SUPPORT
-
#include "taboccur.h"
#include "tabpivot.h"
+#define my_strupr(p) my_caseup_str(default_charset_info, (p));
+#define my_strlwr(p) my_casedn_str(default_charset_info, (p));
+#define my_stricmp(a,b) my_strcasecmp(default_charset_info, (a), (b))
-/***********************************************************************/
-/* DB static variables. */
-/***********************************************************************/
-extern "C" char plgxini[];
-extern "C" char plgini[];
-extern "C" char nmfile[];
-extern "C" char pdebug[];
/***********************************************************************/
/* Initialize the ha_connect static members. */
/***********************************************************************/
-#define CONNECT_INI "connect.ini"
+//efine CONNECT_INI "connect.ini"
extern "C" {
- char connectini[_MAX_PATH]= CONNECT_INI;
- char version[]= "Version 1.02.0001 February 03, 2014";
+ char version[]= "Version 1.02.0002 March 16, 2014";
#if defined(XMSG)
- char msglang[]; // Default message language
+ char msglang[]; // Default message language
#endif
int trace= 0; // The general trace value
} // extern "C"
-int xtrace= 0;
+static int xtrace= 0;
+
ulong ha_connect::num= 0;
//int DTVAL::Shift= 0;
@@ -192,14 +178,22 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp);
static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp);
static handler *connect_create_handler(handlerton *hton,
- TABLE_SHARE *table,
- MEM_ROOT *mem_root);
+ TABLE_SHARE *table,
+ MEM_ROOT *mem_root);
static int connect_assisted_discovery(handlerton *hton, THD* thd,
TABLE_SHARE *table_s,
HA_CREATE_INFO *info);
-handlerton *connect_hton;
+static void update_connect_xtrace(MYSQL_THD thd,
+ struct st_mysql_sys_var *var,
+ void *var_ptr, const void *save)
+{
+ xtrace= *(int *)save;
+//xtrace= *(int *)var_ptr= *(int *)save;
+} // end of update_connect_xtrace
+
+ handlerton *connect_hton;
/**
CREATE TABLE option list (table options)
@@ -252,8 +246,6 @@ ha_create_table_option connect_table_option_list[]=
ha_create_table_option connect_field_option_list[]=
{
HA_FOPTION_NUMBER("FLAG", offset, (ulonglong) -1, 0, INT_MAX32, 1),
- HA_FOPTION_NUMBER("FREQUENCY", freq, 0, 0, INT_MAX32, 1), // not used
- HA_FOPTION_NUMBER("OPT_VALUE", opt, 0, 0, 2, 1), // used for indexing
HA_FOPTION_NUMBER("FIELD_LENGTH", fldlen, 0, 0, INT_MAX32, 1),
HA_FOPTION_STRING("DATE_FORMAT", dateformat),
HA_FOPTION_STRING("FIELD_FORMAT", fieldformat),
@@ -331,11 +323,9 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir)
delete_table method in handler.cc
*/
static const char *ha_connect_exts[]= {
- ".dos", ".fix", ".csv",".bin", ".fmt", ".dbf", ".xml", ".ini", ".vec",
+ ".dos", ".fix", ".csv", ".bin", ".fmt", ".dbf", ".xml", ".ini", ".vec",
".dnx", ".fnx", ".bnx", ".vnx", ".dbx",
- NULL
-};
-
+ NULL};
/**
@brief
@@ -344,32 +334,16 @@ static const char *ha_connect_exts[]= {
static int connect_init_func(void *p)
{
DBUG_ENTER("connect_init_func");
- char dir[_MAX_PATH - sizeof(CONNECT_INI) - 1];
+
+ sql_print_information("CONNECT: %s", version);
+
+ // xtrace is now a system variable
+ trace= xtrace;
#ifdef LIBXML2_SUPPORT
XmlInitParserLib();
#endif // LIBXML2_SUPPORT
- /* Build connect.ini file name */
- my_getwd(dir, sizeof(dir) - 1, MYF(0));
- snprintf(connectini, sizeof(connectini), "%s%s", dir, CONNECT_INI);
- sql_print_information("CONNECT: %s=%s", CONNECT_INI, connectini);
-
- if ((xtrace= GetPrivateProfileInt("CONNECT", "Trace", 0, connectini)))
- {
- sql_print_information("CONNECT: xtrace=%d", xtrace);
- sql_print_information("CONNECT: plgini=%s", plgini);
- sql_print_information("CONNECT: plgxini=%s", plgxini);
- sql_print_information("CONNECT: nmfile=%s", nmfile);
- sql_print_information("CONNECT: pdebug=%s", pdebug);
- sql_print_information("CONNECT: version=%s", version);
- trace= xtrace;
- } // endif xtrace
-
-#if !defined(WIN32)
- PROFILE_Close(connectini);
-#endif // !WIN32
-
init_connect_psi_keys();
connect_hton= (handlerton *)p;
@@ -404,7 +378,7 @@ static int connect_done_func(void *p)
#endif // LIBXML2_SUPPORT
#if !defined(WIN32)
- PROFILE_End();
+//PROFILE_End(); Causes signal 11
#endif // !WIN32
for (pc= user_connect::to_users; pc; pc= pn) {
@@ -453,7 +427,7 @@ static handler* connect_create_handler(handlerton *hton,
handler *h= new (mem_root) ha_connect(hton, table);
if (xtrace)
- printf("New CONNECT %p, table: %s\n",
+ htrc("New CONNECT %p, table: %s\n",
h, table ? table->table_name.str : "<null>");
return h;
@@ -499,7 +473,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
ha_connect::~ha_connect(void)
{
if (xtrace)
- printf("Delete CONNECT %p, table: %s, xp=%p count=%d\n", this,
+ htrc("Delete CONNECT %p, table: %s, xp=%p count=%d\n", this,
table ? table->s->table_name.str : "<null>",
xp, xp ? xp->count : 0);
@@ -593,13 +567,14 @@ TABTYPE ha_connect::GetRealType(PTOS pos)
*/
ulonglong ha_connect::table_flags() const
{
- ulonglong flags= HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ |
+ ulonglong flags= HA_CAN_VIRTUAL_COLUMNS | HA_REC_NOT_IN_SEQ |
HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS |
- HA_HAS_RECORDS | HA_CAN_VIRTUAL_COLUMNS |
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
+ HA_PARTIAL_COLUMN_READ |
// HA_NULL_IN_KEY | not implemented yet
- HA_DUPLICATE_KEY_NOT_IN_ORDER |
- HA_MUST_USE_TABLE_CONDITION_PUSHDOWN;
+// HA_FAST_KEY_READ | causes error when sorting (???)
+ HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
+ HA_NO_BLOBS | HA_MUST_USE_TABLE_CONDITION_PUSHDOWN;
ha_connect *hp= (ha_connect*)this;
PTOS pos= hp->GetTableOptionStruct(table);
@@ -609,6 +584,9 @@ ulonglong ha_connect::table_flags() const
if (IsFileType(type))
flags|= HA_FILE_BASED;
+ if (IsExactType(type))
+ flags|= (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT);
+
// No data change on ALTER for outward tables
if (!IsFileType(type) || hp->FileExists(pos->filename))
flags|= HA_NO_COPY_ON_ALTER;
@@ -919,7 +897,6 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
} // endif special
pcf->Scale= 0;
- pcf->Opt= (fop) ? (int)fop->opt : 0;
if ((pcf->Length= fp->field_length) < 0)
pcf->Length= 256; // BLOB?
@@ -928,12 +905,10 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
if (fop) {
pcf->Offset= (int)fop->offset;
-// pcf->Freq= fop->freq;
pcf->Datefmt= (char*)fop->dateformat;
pcf->Fieldfmt= (char*)fop->fieldformat;
} else {
pcf->Offset= -1;
-// pcf->Freq= 0;
pcf->Datefmt= NULL;
pcf->Fieldfmt= NULL;
} // endif fop
@@ -957,7 +932,6 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
// Find if collation name ends by _ci
if (!strcmp(cp + strlen(cp) - 3, "_ci")) {
pcf->Scale= 1; // Case insensitive
- pcf->Opt= 0; // Prevent index opt until it is safe
} // endif ci
break;
@@ -970,7 +944,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
break;
case TYPE_DATE:
// Field_length is only used for DATE columns
- if (fop->fldlen)
+ if (fop && fop->fldlen)
pcf->Length= (int)fop->fldlen;
else {
int len;
@@ -1042,7 +1016,7 @@ PIXDEF ha_connect::GetIndexInfo(TABLE_SHARE *s)
for (int n= 0; (unsigned)n < s->keynames.count; n++) {
if (xtrace)
- printf("Getting created index %d info\n", n + 1);
+ htrc("Getting created index %d info\n", n + 1);
// Find the index to describe
kp= s->key_info[n];
@@ -1178,7 +1152,7 @@ PTDB ha_connect::GetTDB(PGLOBAL g)
valid_query_id= xp->last_query_id;
tp->SetMode(xmod);
} else
- printf("GetTDB: %s\n", g->Message);
+ htrc("GetTDB: %s\n", g->Message);
return tp;
} // end of GetTDB
@@ -1193,7 +1167,7 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
// Double test to be on the safe side
if (!g || !table) {
- printf("OpenTable logical error; g=%p table=%p\n", g, table);
+ htrc("OpenTable logical error; g=%p table=%p\n", g, table);
return HA_ERR_INITIALIZATION;
} // endif g
@@ -1274,9 +1248,8 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
PIXDEF oldpix= GetIndexInfo();
} // endif xmod
-// tdbp->SetOrig((PTBX)table); // used by CheckCond
} else
- printf("OpenTable: %s\n", g->Message);
+ htrc("OpenTable: %s\n", g->Message);
if (rc) {
tdbp= NULL;
@@ -1330,7 +1303,7 @@ int ha_connect::MakeRecord(char *buf)
DBUG_ENTER("ha_connect::MakeRecord");
if (xtrace > 1)
- printf("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n",
+ htrc("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n",
*table->read_set->bitmap, *table->write_set->bitmap,
*table->vcol_set->bitmap,
*table->def_read_set.bitmap, *table->def_write_set.bitmap);
@@ -1358,7 +1331,7 @@ int ha_connect::MakeRecord(char *buf)
break;
if (!colp) {
- printf("Column %s not found\n", fp->field_name);
+ htrc("Column %s not found\n", fp->field_name);
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
} // endif colp
@@ -1473,7 +1446,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
break;
if (!colp) {
- printf("Column %s not found\n", fp->field_name);
+ htrc("Column %s not found\n", fp->field_name);
rc= HA_ERR_WRONG_IN_RECORD;
goto err;
} else
@@ -1598,16 +1571,16 @@ const char *ha_connect::GetValStr(OPVAL vop, bool neg)
val= (neg) ? " NOT IN (" : " IN (";
break;
case OP_NULL:
- val= " IS NULL";
+ val= (neg) ? " IS NOT NULL" : " IS NULL";
break;
case OP_LIKE:
val= " LIKE ";
break;
case OP_XX:
- val= " BETWEEN ";
+ val= (neg) ? " NOT BETWEEN " : " BETWEEN ";
break;
case OP_EXIST:
- val= " EXISTS ";
+ val= (neg) ? " NOT EXISTS " : " EXISTS ";
break;
case OP_AND:
val= " AND ";
@@ -1643,21 +1616,20 @@ const char *ha_connect::GetValStr(OPVAL vop, bool neg)
/***********************************************************************/
-/* Check the WHERE condition and return an ODBC/WQL filter. */
+/* Check the WHERE condition and return a MYSQL/ODBC/WQL filter. */
/***********************************************************************/
-PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
+PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond)
{
char *body= filp->Body;
unsigned int i;
bool ismul= false, x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
- PPARM pfirst= NULL, pprec= NULL, pp[2]= {NULL, NULL};
OPVAL vop= OP_XX;
if (!cond)
return NULL;
if (xtrace)
- printf("Cond type=%d\n", cond->type());
+ htrc("Cond type=%d\n", cond->type());
if (cond->type() == COND::COND_ITEM) {
char *p1, *p2;
@@ -1667,7 +1639,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
return NULL;
if (xtrace)
- printf("Cond: Ftype=%d name=%s\n", cond_item->functype(),
+ htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(),
cond_item->func_name());
switch (cond_item->functype()) {
@@ -1714,7 +1686,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
Item* *args= condf->arguments();
if (xtrace)
- printf("Func type=%d argnum=%d\n", condf->functype(),
+ htrc("Func type=%d argnum=%d\n", condf->functype(),
condf->argument_count());
// neg= condf->
@@ -1728,8 +1700,10 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
case Item_func::GE_FUNC: vop= OP_GE; break;
case Item_func::GT_FUNC: vop= OP_GT; break;
case Item_func::IN_FUNC: vop= OP_IN;
+ case Item_func::BETWEEN:
+ ismul= true;
neg= ((Item_func_opt_neg *)condf)->negated;
- case Item_func::BETWEEN: ismul= true; break;
+ break;
default: return NULL;
} // endswitch functype
@@ -1743,11 +1717,11 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
for (i= 0; i < condf->argument_count(); i++) {
if (xtrace)
- printf("Argtype(%d)=%d\n", i, args[i]->type());
+ htrc("Argtype(%d)=%d\n", i, args[i]->type());
if (i >= 2 && !ismul) {
if (xtrace)
- printf("Unexpected arg for vop=%d\n", vop);
+ htrc("Unexpected arg for vop=%d\n", vop);
continue;
} // endif i
@@ -1779,8 +1753,8 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
fnm= pField->field->field_name;
if (xtrace) {
- printf("Field index=%d\n", pField->field->field_index);
- printf("Field name=%s\n", pField->field->field_name);
+ htrc("Field index=%d\n", pField->field->field_index);
+ htrc("Field name=%s\n", pField->field->field_name);
} // endif xtrace
// IN and BETWEEN clauses should be col VOP list
@@ -1801,7 +1775,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
String *res, tmp(buff, sizeof(buff), &my_charset_bin);
Item_basic_constant *pval= (Item_basic_constant *)args[i];
- switch (args[i]->type()) {
+ switch (args[i]->real_type()) {
case COND::STRING_ITEM:
case COND::INT_ITEM:
case COND::REAL_ITEM:
@@ -1818,7 +1792,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
return NULL; // To be clarified
if (xtrace)
- printf("Value=%.*s\n", res->length(), res->ptr());
+ htrc("Value=%.*s\n", res->length(), res->ptr());
// IN and BETWEEN clauses should be col VOP list
if (!i && (x || ismul))
@@ -1863,7 +1837,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
} else {
if (xtrace)
- printf("Unsupported condition\n");
+ htrc("Unsupported condition\n");
return NULL;
} // endif's type
@@ -1898,32 +1872,33 @@ const COND *ha_connect::cond_push(const COND *cond)
if (tdbp) {
AMT tty= tdbp->GetAmType();
bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
+ bool b= (tty == TYPE_AM_WMI || tty == TYPE_AM_ODBC ||
+ tty == TYPE_AM_TBL || tty == TYPE_AM_MYSQL ||
+ tty == TYPE_AM_PLG || x);
- if (tty == TYPE_AM_WMI || tty == TYPE_AM_ODBC ||
- tty == TYPE_AM_TBL || tty == TYPE_AM_MYSQL ||
- tty == TYPE_AM_PLG || x) {
+ if (b) {
PGLOBAL& g= xp->g;
- PFIL filp= (PFIL)PlugSubAlloc(g, NULL, sizeof(FILTER));
+ PCFIL filp= (PCFIL)PlugSubAlloc(g, NULL, sizeof(CONDFIL));
filp->Body= (char*)PlugSubAlloc(g, NULL, (x) ? 128 : 0);
*filp->Body= 0;
filp->Op= OP_XX;
filp->Cmds= NULL;
-
+
if (CheckCond(g, filp, tty, (Item *)cond)) {
if (xtrace)
- printf("cond_push: %s\n", filp->Body);
-
+ htrc("cond_push: %s\n", filp->Body);
+
if (!x)
PlugSubAlloc(g, NULL, strlen(filp->Body) + 1);
else
- cond= NULL; // Does this work?
-
- tdbp->SetFilter(filp);
+ cond= NULL; // Does this work?
+
+ tdbp->SetCondFil(filp);
} else if (x && cond)
- tdbp->SetFilter(filp); // Wrong filter
+ tdbp->SetCondFil(filp); // Wrong filter
- } // endif tty
+ } // endif b
} // endif tdbp
@@ -2005,7 +1980,7 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked)
DBUG_ENTER("ha_connect::open");
if (xtrace)
- printf("open: name=%s mode=%d test=%u\n", name, mode, test_if_locked);
+ htrc("open: name=%s mode=%d test=%u\n", name, mode, test_if_locked);
if (!(share= get_share()))
DBUG_RETURN(1);
@@ -2040,10 +2015,11 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt)
tdbp= GetTDB(g);
dup->Check |= CHK_OPT;
- if (tdbp || (tdbp= GetTDB(g))) {
+ if (tdbp) {
if (!((PTDBASE)tdbp)->GetDef()->Indexable()) {
sprintf(g->Message, "optimize: Table %s is not indexable", tdbp->GetName());
- rc= HA_ERR_INTERNAL_ERROR;
+ my_message(ER_INDEX_REBUILD, g->Message, MYF(0));
+ rc= HA_ERR_UNSUPPORTED;
} else if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, true))) {
if (rc == RC_INFO) {
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
@@ -2156,7 +2132,7 @@ int ha_connect::write_row(uchar *buf)
// Return result code from write operation
if (CntWriteRow(g, tdbp)) {
DBUG_PRINT("write_row", ("%s", g->Message));
- printf("write_row: %s\n", g->Message);
+ htrc("write_row: %s\n", g->Message);
rc= HA_ERR_INTERNAL_ERROR;
} // endif RC
@@ -2193,7 +2169,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data)
DBUG_ENTER("ha_connect::update_row");
if (xtrace > 1)
- printf("update_row: old=%s new=%s\n", old_data, new_data);
+ htrc("update_row: old=%s new=%s\n", old_data, new_data);
// Check values for possible change in indexed column
if ((rc= CheckRecord(g, old_data, new_data)))
@@ -2201,7 +2177,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data)
if (CntUpdateRow(g, tdbp)) {
DBUG_PRINT("update_row", ("%s", g->Message));
- printf("update_row CONNECT: %s\n", g->Message);
+ htrc("update_row CONNECT: %s\n", g->Message);
rc= HA_ERR_INTERNAL_ERROR;
} // endif RC
@@ -2235,7 +2211,7 @@ int ha_connect::delete_row(const uchar *buf)
if (CntDeleteRow(xp->g, tdbp, false)) {
rc= HA_ERR_INTERNAL_ERROR;
- printf("delete_row CONNECT: %s\n", xp->g->Message);
+ htrc("delete_row CONNECT: %s\n", xp->g->Message);
} // endif DeleteRow
DBUG_RETURN(rc);
@@ -2252,7 +2228,7 @@ int ha_connect::index_init(uint idx, bool sorted)
DBUG_ENTER("index_init");
if (xtrace)
- printf("index_init: this=%p idx=%u sorted=%d\n", this, idx, sorted);
+ htrc("index_init: this=%p idx=%u sorted=%d\n", this, idx, sorted);
if ((rc= rnd_init(0)))
return rc;
@@ -2268,7 +2244,7 @@ int ha_connect::index_init(uint idx, bool sorted)
if (indexing <= 0) {
DBUG_PRINT("index_init", ("%s", g->Message));
- printf("index_init CONNECT: %s\n", g->Message);
+ htrc("index_init CONNECT: %s\n", g->Message);
active_index= MAX_KEY;
rc= HA_ERR_INTERNAL_ERROR;
} else {
@@ -2284,7 +2260,7 @@ int ha_connect::index_init(uint idx, bool sorted)
} // endif indexing
if (xtrace)
- printf("index_init: rc=%d indexing=%d active_index=%d\n",
+ htrc("index_init: rc=%d indexing=%d active_index=%d\n",
rc, indexing, active_index);
DBUG_RETURN(rc);
@@ -2324,13 +2300,13 @@ int ha_connect::ReadIndexed(uchar *buf, OPVAL op, const uchar *key, uint key_len
break;
default: // Read error
DBUG_PRINT("ReadIndexed", ("%s", xp->g->Message));
- printf("ReadIndexed: %s\n", xp->g->Message);
+ htrc("ReadIndexed: %s\n", xp->g->Message);
rc= HA_ERR_INTERNAL_ERROR;
break;
} // endswitch RC
if (xtrace > 1)
- printf("ReadIndexed: op=%d rc=%d\n", op, rc);
+ htrc("ReadIndexed: op=%d rc=%d\n", op, rc);
table->status= (rc == RC_OK) ? 0 : STATUS_NOT_FOUND;
return rc;
@@ -2373,7 +2349,7 @@ int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len,
} // endswitch find_flag
if (xtrace > 1)
- printf("%p index_read: op=%d\n", this, op);
+ htrc("%p index_read: op=%d\n", this, op);
if (indexing > 0)
rc= ReadIndexed(buf, op, key, key_len);
@@ -2516,17 +2492,20 @@ int ha_connect::rnd_init(bool scan)
} // endif xmod
if (xtrace)
- printf("rnd_init: this=%p scan=%d xmod=%d alter=%d\n",
+ htrc("rnd_init: this=%p scan=%d xmod=%d alter=%d\n",
this, scan, xmod, alter);
if (!g || !table || xmod == MODE_INSERT)
DBUG_RETURN(HA_ERR_INITIALIZATION);
// Do not close the table if it was opened yet (locked?)
- if (IsOpened())
- DBUG_RETURN(0);
-// CloseTable(g); Was done before making things done twice
- else if (xp->CheckQuery(valid_query_id))
+ if (IsOpened()) {
+ if (tdbp->OpenDB(g)) // Rewind table
+ DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
+ else
+ DBUG_RETURN(0);
+
+ } else if (xp->CheckQuery(valid_query_id))
tdbp= NULL; // Not valid anymore
// When updating, to avoid skipped update, force the table
@@ -2608,22 +2587,23 @@ int ha_connect::rnd_next(uchar *buf)
rc= HA_ERR_RECORD_DELETED;
break;
default: // Read error
- printf("rnd_next CONNECT: %s\n", xp->g->Message);
+ htrc("rnd_next CONNECT: %s\n", xp->g->Message);
rc= (records()) ? HA_ERR_INTERNAL_ERROR : HA_ERR_END_OF_FILE;
break;
} // endswitch RC
-#ifndef DBUG_OFF
- if (rc || !(xp->nrd++ % 16384)) {
+ if (xtrace > 1 && (rc || !(xp->nrd++ % 16384))) {
ulonglong tb2= my_interval_timer();
double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL;
DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
rc, (uint)xp->nrd, (uint)xp->fnd,
(uint)xp->nfd, elapsed));
+ htrc("rnd_next: rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
+ rc, (uint)xp->nrd, (uint)xp->fnd,
+ (uint)xp->nfd, elapsed);
xp->tb1= tb2;
xp->fnd= xp->nfd= 0;
} // endif nrd
-#endif
table->status= (!rc) ? 0 : STATUS_NOT_FOUND;
DBUG_RETURN(rc);
@@ -2737,7 +2717,7 @@ int ha_connect::info(uint flag)
DBUG_ENTER("ha_connect::info");
if (xtrace)
- printf("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info);
+ htrc("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info);
if (!valid_info) {
// tdbp must be available to get updated info
@@ -2850,7 +2830,7 @@ int ha_connect::delete_all_rows()
if (!(rc= OpenTable(g))) {
if (CntDeleteRow(g, tdbp, true)) {
- printf("%s\n", g->Message);
+ htrc("%s\n", g->Message);
rc= HA_ERR_INTERNAL_ERROR;
} // endif
@@ -2958,10 +2938,10 @@ bool ha_connect::IsSameIndex(PIXDEF xp1, PIXDEF xp2)
MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
MODE newmode, bool *chk, bool *cras)
{
- if (xtrace) {
+ if ((trace= xtrace)) {
LEX_STRING *query_string= thd_query_string(thd);
- printf("%p check_mode: cmdtype=%d\n", this, thd_sql_command(thd));
- printf("Cmd=%.*s\n", (int) query_string->length, query_string->str);
+ htrc("%p check_mode: cmdtype=%d\n", this, thd_sql_command(thd));
+ htrc("Cmd=%.*s\n", (int) query_string->length, query_string->str);
} // endif xtrace
// Next code is temporarily replaced until sql_command is set
@@ -3011,7 +2991,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
newmode= MODE_ALTER;
break;
default:
- printf("Unsupported sql_command=%d", thd_sql_command(thd));
+ htrc("Unsupported sql_command=%d", thd_sql_command(thd));
strcpy(g->Message, "CONNECT Unsupported command");
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
newmode= MODE_ERROR;
@@ -3056,7 +3036,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
newmode= MODE_ALTER;
break;
default:
- printf("Unsupported sql_command=%d", thd_sql_command(thd));
+ htrc("Unsupported sql_command=%d", thd_sql_command(thd));
strcpy(g->Message, "CONNECT Unsupported command");
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
newmode= MODE_ERROR;
@@ -3066,7 +3046,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
} // endif's newmode
if (xtrace)
- printf("New mode=%d\n", newmode);
+ htrc("New mode=%d\n", newmode);
return newmode;
} // end of check_mode
@@ -3141,9 +3121,9 @@ int ha_connect::external_lock(THD *thd, int lock_type)
DBUG_ASSERT(thd == current_thd);
if (xtrace)
- printf("external_lock: this=%p thd=%p xp=%p g=%p lock_type=%d\n",
+ htrc("external_lock: this=%p thd=%p xp=%p g=%p lock_type=%d\n",
this, thd, xp, g, lock_type);
-
+
if (!g)
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
@@ -3166,17 +3146,18 @@ int ha_connect::external_lock(THD *thd, int lock_type)
// This is unlocking, do it by closing the table
if (xp->CheckQueryID() && sqlcom != SQLCOM_UNLOCK_TABLES
- && sqlcom != SQLCOM_LOCK_TABLES)
- rc= 2; // Logical error ???
-// else if (g->Xchk && (sqlcom == SQLCOM_CREATE_INDEX ||
-// sqlcom == SQLCOM_DROP_INDEX)) {
- else if (g->Xchk) {
+ && sqlcom != SQLCOM_LOCK_TABLES
+ && sqlcom != SQLCOM_DROP_TABLE) {
+ sprintf(g->Message, "external_lock: unexpected command %d", sqlcom);
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
+ DBUG_RETURN(0);
+ } else if (g->Xchk) {
if (!tdbp) {
if (!(tdbp= GetTDB(g)))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
else if (!((PTDBASE)tdbp)->GetDef()->Indexable()) {
sprintf(g->Message, "external_lock: Table %s is not indexable", tdbp->GetName());
-// DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
+// DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
DBUG_RETURN(0);
} // endif Indexable
@@ -3280,7 +3261,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
if (check_privileges(thd, options, table->s->db.str)) {
strcpy(g->Message, "This operation requires the FILE privilege");
- printf("%s\n", g->Message);
+ htrc("%s\n", g->Message);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endif check_privileges
@@ -3314,18 +3295,18 @@ int ha_connect::external_lock(THD *thd, int lock_type)
if (xtrace) {
#if 0
- printf("xcheck=%d cras=%d\n", xcheck, cras);
+ htrc("xcheck=%d cras=%d\n", xcheck, cras);
if (xcheck)
- printf("oldsep=%d oldpix=%p\n",
+ htrc("oldsep=%d oldpix=%p\n",
((PCHK)g->Xchk)->oldsep, ((PCHK)g->Xchk)->oldpix);
#endif // 0
- printf("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras);
+ htrc("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras);
} // endif xtrace
// Set or reset the good database environment
if (CntCheckDB(g, this, GetDBName(NULL))) {
- printf("%p external_lock: %s\n", this, g->Message);
+ htrc("%p external_lock: %s\n", this, g->Message);
rc= HA_ERR_INTERNAL_ERROR;
// This can NOT be called without open called first, but
// the table can have been closed since then
@@ -3346,7 +3327,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
} // endif tdbp
if (xtrace)
- printf("external_lock: rc=%d\n", rc);
+ htrc("external_lock: rc=%d\n", rc);
DBUG_RETURN(rc);
} // end of external_lock
@@ -3488,10 +3469,10 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
if (xtrace) {
if (to)
- printf("rename_table: this=%p thd=%p sqlcom=%d from=%s to=%s\n",
+ htrc("rename_table: this=%p thd=%p sqlcom=%d from=%s to=%s\n",
this, thd, sqlcom, name, to);
else
- printf("delete_table: this=%p thd=%p sqlcom=%d name=%s\n",
+ htrc("delete_table: this=%p thd=%p sqlcom=%d name=%s\n",
this, thd, sqlcom, name);
} // endif xtrace
@@ -3596,7 +3577,7 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
index_init(inx, false);
if (xtrace)
- printf("records_in_range: inx=%d indexing=%d\n", inx, indexing);
+ htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing);
if (indexing > 0) {
int nval;
@@ -3649,83 +3630,6 @@ static char *encode(PGLOBAL g, char *cnm)
@return
Return 0 if ok
*/
-#if defined(NEW_WAY)
-static bool add_fields(PGLOBAL g,
- THD *thd,
- Alter_info *alter_info,
- char *name,
- int typ, int len, int dec,
- uint type_modifier,
- char *rem,
-// CHARSET_INFO *cs,
-// void *vcolinfo,
-// engine_option_value *create_options,
- int flg,
- bool dbf,
- char v)
-{
- register Create_field *new_field;
- char *length, *decimals= NULL;
- enum_field_types type;
-//Virtual_column_info *vcol_info= (Virtual_column_info *)vcolinfo;
- engine_option_value *crop;
- LEX_STRING *comment;
- LEX_STRING *field_name;
-
- DBUG_ENTER("ha_connect::add_fields");
-
- if (len) {
- if (!v && typ == TYPE_STRING && len > 255)
- v= 'V'; // Change CHAR to VARCHAR
-
- length= (char*)PlugSubAlloc(g, NULL, 8);
- sprintf(length, "%d", len);
-
- if (typ == TYPE_DOUBLE) {
- decimals= (char*)PlugSubAlloc(g, NULL, 8);
- sprintf(decimals, "%d", min(dec, (min(len, 31) - 1)));
- } // endif dec
-
- } else
- length= NULL;
-
- if (!rem)
- rem= "";
-
- type= PLGtoMYSQL(typ, dbf, v);
- comment= thd->make_lex_string(rem, strlen(rem));
- field_name= thd->make_lex_string(name, strlen(name));
-
- switch (v) {
- case 'Z': type_modifier|= ZEROFILL_FLAG;
- case 'U': type_modifier|= UNSIGNED_FLAG; break;
- } // endswitch v
-
- if (flg) {
- engine_option_value *start= NULL, *end= NULL;
- LEX_STRING *flag= thd->make_lex_string("flag", 4);
-
- crop= new(thd->mem_root) engine_option_value(*flag, (ulonglong)flg,
- &start, &end, thd->mem_root);
- } else
- crop= NULL;
-
- if (check_string_char_length(field_name, "", NAME_CHAR_LEN,
- system_charset_info, 1)) {
- my_error(ER_TOO_LONG_IDENT, MYF(0), field_name->str); /* purecov: inspected */
- DBUG_RETURN(1); /* purecov: inspected */
- } // endif field_name
-
- if (!(new_field= new Create_field()) ||
- new_field->init(thd, field_name->str, type, length, decimals,
- type_modifier, NULL, NULL, comment, NULL,
- NULL, NULL, 0, NULL, crop, true))
- DBUG_RETURN(1);
-
- alter_info->create_list.push_back(new_field);
- DBUG_RETURN(0);
-} // end of add_fields
-#else // !NEW_WAY
static bool add_field(String *sql, const char *field_name, int typ,
int len, int dec, uint tm, const char *rem,
char *dft, char *xtra, int flag, bool dbf, char v)
@@ -3739,7 +3643,7 @@ static bool add_field(String *sql, const char *field_name, int typ,
error|= sql->append("` ");
error|= sql->append(type);
- if (len) {
+ if (len && typ != TYPE_DATE) {
error|= sql->append('(');
error|= sql->append_ulonglong(len);
@@ -3795,7 +3699,6 @@ static bool add_field(String *sql, const char *field_name, int typ,
error|= sql->append(',');
return error;
} // end of add_field
-#endif // !NEW_WAY
/**
Initialise the table share with the new columns.
@@ -3803,110 +3706,6 @@ static bool add_field(String *sql, const char *field_name, int typ,
@return
Return 0 if ok
*/
-#if defined(NEW_WAY)
-//static bool sql_unusable_for_discovery(THD *thd, const char *sql);
-
-static int init_table_share(THD *thd,
- TABLE_SHARE *table_s,
- HA_CREATE_INFO *create_info,
- Alter_info *alter_info)
-{
- KEY *not_used_1;
- uint not_used_2;
- int rc= 0;
- handler *file;
- LEX_CUSTRING frm= {0,0};
-
- DBUG_ENTER("init_table_share");
-
-#if 0
- ulonglong saved_mode= thd->variables.sql_mode;
- CHARSET_INFO *old_cs= thd->variables.character_set_client;
- Parser_state parser_state;
- char *sql_copy;
- LEX *old_lex;
- Query_arena *arena, backup;
- LEX tmp_lex;
-
- /*
- Ouch. Parser may *change* the string it's working on.
- Currently (2013-02-26) it is used to permanently disable
- conditional comments.
- Anyway, let's copy the caller's string...
- */
- if (!(sql_copy= thd->strmake(sql, sql_length)))
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
-
- if (parser_state.init(thd, sql_copy, sql_length))
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
-
- thd->variables.sql_mode= MODE_NO_ENGINE_SUBSTITUTION | MODE_NO_DIR_IN_CREATE;
- thd->variables.character_set_client= system_charset_info;
- old_lex= thd->lex;
- thd->lex= &tmp_lex;
-
- arena= thd->stmt_arena;
-
- if (arena->is_conventional())
- arena= 0;
- else
- thd->set_n_backup_active_arena(arena, &backup);
-
- lex_start(thd);
-
- if ((error= parse_sql(thd, & parser_state, NULL)))
- goto ret;
-
- if (table_s->sql_unusable_for_discovery(thd, NULL)) {
- my_error(ER_SQL_DISCOVER_ERROR, MYF(0), plugin_name(db_plugin)->str,
- db.str, table_name.str, sql_copy);
- goto ret;
- } // endif unusable
-
- thd->lex->create_info.db_type= plugin_data(db_plugin, handlerton *);
-
- if (tabledef_version.str)
- thd->lex->create_info.tabledef_version= tabledef_version;
-#endif // 0
-
- tmp_disable_binlog(thd);
-
- file= mysql_create_frm_image(thd, table_s->db.str, table_s->table_name.str,
- create_info, alter_info, C_ORDINARY_CREATE,
- &not_used_1, &not_used_2, &frm);
- if (file)
- delete file;
- else
- rc= OPEN_FRM_CORRUPTED;
-
- if (!rc && frm.str) {
- table_s->option_list= 0; // cleanup existing options ...
- table_s->option_struct= 0; // ... if it's an assisted discovery
- rc= table_s->init_from_binary_frm_image(thd, true, frm.str, frm.length);
- } // endif frm
-
-//ret:
- my_free(const_cast<uchar*>(frm.str));
- reenable_binlog(thd);
-#if 0
- lex_end(thd->lex);
- thd->lex= old_lex;
- if (arena)
- thd->restore_active_arena(arena, &backup);
- thd->variables.sql_mode= saved_mode;
- thd->variables.character_set_client= old_cs;
-#endif // 0
-
- if (thd->is_error() || rc) {
- thd->clear_error();
- my_error(ER_NO_SUCH_TABLE, MYF(0), table_s->db.str,
- table_s->table_name.str);
- DBUG_RETURN(HA_ERR_NOT_A_TABLE);
- } else
- DBUG_RETURN(0);
-
-} // end of init_table_share
-#else // !NEW_WAY
static int init_table_share(THD* thd,
TABLE_SHARE *table_s,
HA_CREATE_INFO *create_info,
@@ -3998,23 +3797,6 @@ static int init_table_share(THD* thd,
return table_s->init_from_sql_statement_string(thd, true,
sql->ptr(), sql->length());
} // end of init_table_share
-#endif // !NEW_WAY
-
-// Add an option to the create_info option list
-static void add_option(THD* thd, HA_CREATE_INFO *create_info,
- const char *opname, const char *opval)
-{
-#if defined(NEW_WAY)
- LEX_STRING *opn= thd->make_lex_string(opname, strlen(opname));
- LEX_STRING *val= thd->make_lex_string(opval, strlen(opval));
- engine_option_value *pov, **start= &create_info->option_list, *end= NULL;
-
- for (pov= *start; pov; pov= pov->next)
- end= pov;
-
- pov= new(thd->mem_root) engine_option_value(*opn, *val, false, start, &end);
-#endif // NEW_WAY
-} // end of add_option
// Used to check whether a MYSQL table is created on itself
static bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
@@ -4069,15 +3851,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
PCONNECT xp= NULL;
PGLOBAL g= GetPlug(thd, xp);
PTOS topt= table_s->option_struct;
-#if defined(NEW_WAY)
-//CHARSET_INFO *cs;
- Alter_info alter_info;
-#else // !NEW_WAY
char buf[1024];
String sql(buf, sizeof(buf), system_charset_info);
sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info);
-#endif // !NEW_WAY
if (!g)
return HA_ERR_INTERNAL_ERROR;
@@ -4136,7 +3913,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
ttp= GetTypeID(topt->type);
sprintf(g->Message, "No table_type. Was set to %s", topt->type);
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
- add_option(thd, create_info, "table_type", topt->type);
} else if (ttp == TAB_NIY) {
sprintf(g->Message, "Unsupported table type %s", topt->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
@@ -4169,9 +3945,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
} else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL)))
tab= table_s->table_name.str; // Default value
-#if defined(NEW_WAY)
-// add_option(thd, create_info, "tabname", tab);
-#endif // NEW_WAY
} // endif tab
switch (ttp) {
@@ -4403,20 +4176,16 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
len= crp->Length;
dec= crp->Prec;
flg= crp->Flag;
+ v= crp->Var;
if (!len && typ == TYPE_STRING)
len= 256; // STRBLK's have 0 length
-#if defined(NEW_WAY)
- // Now add the field
- rc= add_fields(g, thd, &alter_info, cnm, typ, len, dec,
- NOT_NULL_FLAG, "", flg, dbf, 0);
-#else // !NEW_WAY
// Now add the field
if (add_field(&sql, cnm, typ, len, dec, NOT_NULL_FLAG,
- NULL, NULL, NULL, flg, dbf, 0))
+ NULL, NULL, NULL, flg, dbf, v))
rc= HA_ERR_OUT_OF_MEM;
-#endif // !NEW_WAY
+
} // endfor crp
} else // Not a catalog table
@@ -4425,12 +4194,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
tm= NOT_NULL_FLAG;
cnm= (char*)"noname";
dft= xtra= NULL;
-#if defined(NEW_WAY)
- rem= "";
-// cs= NULL;
-#else // !NEW_WAY
rem= NULL;
-#endif // !NEW_WAY
for (crp= qrp->Colresp; crp; crp= crp->Next)
switch (crp->Fld) {
@@ -4507,23 +4271,14 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
prec= len;
// Now add the field
-#if defined(NEW_WAY)
- rc= add_fields(g, thd, &alter_info, cnm, typ, prec, dec,
- tm, rem, 0, dbf, v);
-#else // !NEW_WAY
if (add_field(&sql, cnm, typ, prec, dec, tm, rem, dft, xtra,
0, dbf, v))
rc= HA_ERR_OUT_OF_MEM;
-#endif // !NEW_WAY
} // endfor i
-#if defined(NEW_WAY)
- rc= init_table_share(thd, table_s, create_info, &alter_info);
-#else // !NEW_WAY
if (!rc)
rc= init_table_share(thd, table_s, create_info, &sql);
// rc= init_table_share(thd, table_s, create_info, dsn, &sql);
-#endif // !NEW_WAY
return rc;
} // endif ok
@@ -4599,7 +4354,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
table= table_arg; // Used by called functions
if (xtrace)
- printf("create: this=%p thd=%p xp=%p g=%p sqlcom=%d name=%s\n",
+ htrc("create: this=%p thd=%p xp=%p g=%p sqlcom=%d name=%s\n",
this, thd, xp, g, sqlcom, GetTableName());
// CONNECT engine specific table options:
@@ -4612,7 +4367,10 @@ int ha_connect::create(const char *name, TABLE *table_arg,
(options->tabname) ? "PROXY" : "DOS";
type= GetTypeID(options->type);
sprintf(g->Message, "No table_type. Will be set to %s", options->type);
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
+
+ if (sqlcom == SQLCOM_CREATE_TABLE)
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
+
} else if (type == TAB_NIY) {
sprintf(g->Message, "Unsupported table type %s", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
@@ -4802,15 +4560,25 @@ int ha_connect::create(const char *name, TABLE *table_arg,
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_NEWDATE:
- case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_TINY:
- break; // Ok
- case MYSQL_TYPE_VAR_STRING:
- case MYSQL_TYPE_STRING:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_INT24:
+ break; // Ok
+ case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_VAR_STRING:
+ case MYSQL_TYPE_STRING:
+ if (!fp->field_length) {
+ sprintf(g->Message, "Unsupported 0 length for column %s",
+ fp->field_name);
+ rc= HA_ERR_INTERNAL_ERROR;
+ my_printf_error(ER_UNKNOWN_ERROR,
+ "Unsupported 0 length for column %s",
+ MYF(0), fp->field_name);
+ DBUG_RETURN(rc);
+ } // endif fp
+
break; // To be checked
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_NULL:
@@ -4826,8 +4594,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
sprintf(g->Message, "Unsupported type for column %s",
fp->field_name);
rc= HA_ERR_INTERNAL_ERROR;
- my_printf_error(ER_UNKNOWN_ERROR,
- "Unsupported type for column '%s'",
+ my_printf_error(ER_UNKNOWN_ERROR, "Unsupported type for column %s",
MYF(0), fp->field_name);
DBUG_RETURN(rc);
break;
@@ -4835,8 +4602,8 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if ((fp)->real_maybe_null() && !IsTypeNullable(type)) {
my_printf_error(ER_UNKNOWN_ERROR,
- "Table type %s does not support nullable columns",
- MYF(0), options->type);
+ "Table type %s does not support nullable columns",
+ MYF(0), options->type);
DBUG_RETURN(HA_ERR_UNSUPPORTED);
} // endif !nullable
@@ -4900,7 +4667,10 @@ int ha_connect::create(const char *name, TABLE *table_arg,
strcat(strcat(buf, "."), lwt);
sprintf(g->Message, "No file name. Table will use %s", buf);
- push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
+
+ if (sqlcom == SQLCOM_CREATE_TABLE)
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
+
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
PlugSetPath(fn, buf, dbpath);
@@ -4910,19 +4680,18 @@ int ha_connect::create(const char *name, TABLE *table_arg,
else
sprintf(g->Message, "Error %d creating file %s", errno, fn);
- push_warning(table->in_use,
- Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
} else
::close(h);
if (type == TAB_FMT || options->readonly)
- push_warning(table->in_use, Sql_condition::WARN_LEVEL_WARN, 0,
+ push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0,
"Congratulation, you just created a read-only void table!");
} // endif
if (xtrace)
- printf("xchk=%p createas=%d\n", g->Xchk, g->Createas);
+ htrc("xchk=%p createas=%d\n", g->Xchk, g->Createas);
// To check whether indices have to be made or remade
if (!g->Xchk) {
@@ -4953,7 +4722,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
cat->SetDataPath(g, table_arg->s->db.str);
if ((rc= optimize(table->in_use, NULL))) {
- printf("Create rc=%d %s\n", rc, g->Message);
+ htrc("Create rc=%d %s\n", rc, g->Message);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
} else
@@ -4964,7 +4733,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} else {
sprintf(g->Message, "Table type %s is not indexable", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
- rc= HA_ERR_INTERNAL_ERROR;
+ rc= HA_ERR_UNSUPPORTED;
} // endif Indexable
} // endif xdp
@@ -4993,7 +4762,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
g->Xchk= NULL;
if (xtrace && g->Xchk)
- printf("oldsep=%d newsep=%d oldpix=%p newpix=%p\n",
+ htrc("oldsep=%d newsep=%d oldpix=%p newpix=%p\n",
xcp->oldsep, xcp->newsep, xcp->oldpix, xcp->newpix);
// if (g->Xchk &&
@@ -5084,28 +4853,32 @@ bool ha_connect::FileExists(const char *fn)
return true;
} // end of FileExists
+// Called by SameString and NoFieldOptionChange
+bool ha_connect::CheckString(const char *str1, const char *str2)
+{
+ bool b1= (!str1 || !*str1), b2= (!str2 || !*str2);
+
+ if (b1 && b2)
+ return true;
+ else if ((b1 && !b2) || (!b1 && b2) || stricmp(str1, str2))
+ return false;
+
+ return true;
+} // end of CheckString
+
/**
check whether a string option have changed
*/
-bool ha_connect::SameChar(TABLE *tab, char *opn)
+bool ha_connect::SameString(TABLE *tab, char *opn)
{
char *str1, *str2;
- bool b1, b2;
tshp= tab->s; // The altered table
str1= GetStringOption(opn);
tshp= NULL;
str2= GetStringOption(opn);
- b1= (!str1 || !*str1);
- b2= (!str2 || !*str2);
-
- if (b1 && b2)
- return true;
- else if ((b1 && !b2) || (!b1 && b2) || stricmp(str1, str2))
- return false;
-
- return true;
-} // end of SameChar
+ return CheckString(str1, str2);
+} // end of SameString
/**
check whether a Boolean option have changed
@@ -5142,6 +4915,29 @@ bool ha_connect::SameInt(TABLE *tab, char *opn)
} // end of SameInt
+/**
+ check whether a field option have changed
+ */
+bool ha_connect::NoFieldOptionChange(TABLE *tab)
+{
+ bool rc= true;
+ ha_field_option_struct *fop1, *fop2;
+ Field* *fld1= table->s->field;
+ Field* *fld2= tab->s->field;
+
+ for (; rc && *fld1 && *fld2; fld1++, fld2++) {
+ fop1= (*fld1)->option_struct;
+ fop2= (*fld2)->option_struct;
+
+ rc= (fop1->offset == fop2->offset &&
+ fop1->fldlen == fop2->fldlen &&
+ CheckString(fop1->dateformat, fop2->dateformat) &&
+ CheckString(fop1->fieldformat, fop2->fieldformat) &&
+ CheckString(fop1->special, fop2->special));
+ } // endfor fld
+
+ return rc;
+} // end of NoFieldOptionChange
/**
Check if a storage engine supports a particular alter table in-place
@@ -5226,7 +5022,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
Alter_inplace_info::ALTER_RENAME | index_operations;
if (ha_alter_info->handler_flags & index_operations ||
- !SameChar(altered_table, "optname") ||
+ !SameString(altered_table, "optname") ||
!SameBool(altered_table, "sepindex")) {
if (!IsTypeIndexable(type)) {
sprintf(g->Message, "Table type %s is not indexable", oldopt->type);
@@ -5247,7 +5043,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
tshp= NULL;
if (xtrace && g->Xchk)
- printf(
+ htrc(
"oldsep=%d newsep=%d oldopn=%s newopn=%s oldpix=%p newpix=%p\n",
xcp->oldsep, xcp->newsep,
SVP(xcp->oldopn), SVP(xcp->newopn),
@@ -5260,25 +5056,25 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
} // endif index operation
- if (!SameChar(altered_table, "filename")) {
- if (!outward) {
- // Conversion to outward table is only allowed for file based
- // tables whose file does not exist.
- tshp= altered_table->s;
- char *fn= GetStringOption("filename");
- tshp= NULL;
-
- if (FileExists(fn)) {
- strcpy(g->Message, "Operation denied. Table data would be lost.");
- my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
- DBUG_RETURN(HA_ALTER_ERROR);
- } else
- goto fin;
+ if (!SameString(altered_table, "filename")) {
+ if (!outward) {
+ // Conversion to outward table is only allowed for file based
+ // tables whose file does not exist.
+ tshp= altered_table->s;
+ char *fn= GetStringOption("filename");
+ tshp= NULL;
+ if (FileExists(fn)) {
+ strcpy(g->Message, "Operation denied. Table data would be lost.");
+ my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
+ DBUG_RETURN(HA_ALTER_ERROR);
} else
goto fin;
- } // endif filename
+ } else
+ goto fin;
+
+ } // endif filename
/* Is there at least one operation that requires copy algorithm? */
if (ha_alter_info->handler_flags & ~inplace_offline_operations)
@@ -5311,7 +5107,8 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
#endif // 0
// This was in check_if_incompatible_data
- if (type == newtyp &&
+ if (NoFieldOptionChange(altered_table) &&
+ type == newtyp &&
SameInt(altered_table, "lrecl") &&
SameInt(altered_table, "elements") &&
SameInt(altered_table, "header") &&
@@ -5323,7 +5120,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
fin:
if (idx) {
// Indexing is only supported inplace
- my_message(ER_UNKNOWN_ERROR,
+ my_message(ER_ALTER_OPERATION_NOT_SUPPORTED,
"Alter operations not supported together by CONNECT", MYF(0));
DBUG_RETURN(HA_ALTER_ERROR);
} else if (outward) {
@@ -5362,6 +5159,15 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info,
struct st_mysql_storage_engine connect_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
+static MYSQL_SYSVAR_INT(xtrace, xtrace,
+ PLUGIN_VAR_RQCMDARG, "Console trace value.",
+ NULL, update_connect_xtrace, 0, 0, INT_MAX, 1);
+
+static struct st_mysql_sys_var* connect_system_variables[]= {
+ MYSQL_SYSVAR(xtrace),
+ NULL
+};
+
maria_declare_plugin(connect)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -5372,10 +5178,10 @@ maria_declare_plugin(connect)
PLUGIN_LICENSE_GPL,
connect_init_func, /* Plugin Init */
connect_done_func, /* Plugin Deinit */
- 0x0001, /* version number (0.1) */
+ 0x0102, /* version number (1.02) */
NULL, /* status variables */
- NULL, /* system variables */
- "0.1", /* string version */
+ connect_system_variables, /* system variables */
+ "1.02", /* string version */
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
}
maria_declare_plugin_end;
diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h
index 908c26fefdc..f277209a78c 100644
--- a/storage/connect/ha_connect.h
+++ b/storage/connect/ha_connect.h
@@ -122,8 +122,6 @@ struct ha_table_option_struct {
struct ha_field_option_struct
{
ulonglong offset;
- ulonglong freq; // Not used by this version
- ulonglong opt; // Not used by this version
ulonglong fldlen;
const char *dateformat;
const char *fieldformat;
@@ -173,11 +171,13 @@ public:
bool GetBooleanOption(char *opname, bool bdef);
bool SetBooleanOption(char *opname, bool b);
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 SameChar(TABLE *tab, char *opn);
bool SameInt(TABLE *tab, char *opn);
bool SameBool(TABLE *tab, char *opn);
bool FileExists(const char *fn);
+ bool NoFieldOptionChange(TABLE *tab);
PFOS GetFieldOptionStruct(Field *fp);
void *GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf);
PIXDEF GetIndexInfo(TABLE_SHARE *s= NULL);
@@ -241,8 +241,8 @@ public:
*/
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
unireg.cc will call max_supported_record_length(), max_supported_keys(),
@@ -328,7 +328,7 @@ public:
condition stack.
*/
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);
/**
@@ -418,6 +418,9 @@ const char *GetValStr(OPVAL vop, bool neg);
*/
//int index_last(uchar *buf);
+ /* Index condition pushdown implementation */
+//Item *idx_cond_push(uint keyno, Item* idx_cond);
+
/** @brief
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
diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc
index 5b5bf4d3000..909bccd8864 100644
--- a/storage/connect/mycat.cc
+++ b/storage/connect/mycat.cc
@@ -96,7 +96,7 @@
extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // !WIN32
-extern int xtrace;
+extern "C" int trace;
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
@@ -168,6 +168,29 @@ bool IsFileType(TABTYPE type)
} // 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. */
/***********************************************************************/
bool IsTypeNullable(TABTYPE type)
@@ -693,7 +716,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp)
{
- if (xtrace)
+ if (trace)
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
// If not specified get the type of this table
@@ -712,7 +735,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
TABTYPE tc;
PRELDEF tdp= NULL;
- if (xtrace)
+ if (trace)
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)
PTDB tdbp= NULL;
LPCSTR name= tablep->GetName();
- if (xtrace)
+ if (trace)
printf("GetTableDB: name=%s\n", name);
// Look for the description of the requested table
tdp= GetTableDesc(g, name, type);
if (tdp) {
- if (xtrace)
+ if (trace)
printf("tdb=%p type=%s\n", tdp, tdp->GetType());
if (tablep->GetQualifier())
@@ -788,7 +811,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
} // endif tdp
if (tdbp) {
- if (xtrace)
+ if (trace)
printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(),
tdbp->GetAmType());
tablep->SetTo_Tdb(tdbp);
diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h
index 05fa96e6295..4c1d548d6a5 100644
--- a/storage/connect/mycat.h
+++ b/storage/connect/mycat.h
@@ -36,6 +36,7 @@ typedef class ha_connect *PHC;
TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type);
+bool IsExactType(TABTYPE type);
bool IsTypeNullable(TABTYPE type);
bool IsTypeFixed(TABTYPE type);
bool IsTypeIndexable(TABTYPE type);
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp
index 769aa5a581c..3d0a3d86136 100644
--- a/storage/connect/myconn.cpp
+++ b/storage/connect/myconn.cpp
@@ -1,11 +1,11 @@
/************** MyConn C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYCONN */
/* ------------- */
-/* Version 1.7 */
+/* Version 1.8 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */
+/* (C) Copyright to the author Olivier BERTRAND 2007-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -47,7 +47,8 @@
#include "myconn.h"
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
uint GetDefaultPort(void)
@@ -283,8 +284,11 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
if (!port)
port = mysqld_port;
- query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9);
- strcat(strcpy(query, srcdef), " LIMIT 0");
+ if (!strnicmp(srcdef, "select ", 7)) {
+ 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
if (myc.Open(g, host, db, user, pwd, port))
@@ -292,7 +296,7 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
// Send the source command to MySQL
if (myc.ExecSQL(g, query, &w) == RC_OK)
- qrp = myc.GetResult(g);
+ qrp = myc.GetResult(g, true);
myc.Close();
return qrp;
@@ -337,6 +341,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
const char *user, const char *pwd,
int pt)
{
+ const char *pipe = NULL;
uint cto = 60, nrt = 120;
m_DB = mysql_init(NULL);
@@ -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_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 (pwd && !strcmp(pwd, "*")) {
if (GetPromptAnswer(g, "*Enter password:")) {
@@ -364,7 +379,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
} // endif pwd
#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)
sprintf(g->Message, "mysql_real_connect failed: (%d) %s",
mysql_errno(m_DB), mysql_error(m_DB));
@@ -673,7 +688,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
/***********************************************************************/
PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
{
- char *fmt;
+ char *fmt, v;
int n;
bool uns;
PCOLRES *pcrp, crp;
@@ -702,7 +717,6 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
qrp->Nblin = 0;
qrp->Cursor = 0;
-
//for (fld = mysql_fetch_field(m_Res); fld;
// fld = mysql_fetch_field(m_Res)) {
for (fld = GetNextField(); fld; fld = GetNextField()) {
@@ -715,17 +729,19 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb)
crp->Name = (char*)PlugSubAlloc(g, NULL, fld->name_length + 1);
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",
fld->type, crp->Name);
return NULL;
} else if (crp->Type == TYPE_DATE && !pdb)
// For direct MySQL connection, display the MySQL date string
crp->Type = TYPE_STRING;
+ else
+ crp->Var = v;
crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM)
? fld->decimals : 0;
- crp->Length = fld->max_length;
+ crp->Length = max(fld->length, fld->max_length);
crp->Clen = GetTypeSize(crp->Type, crp->Length);
uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false;
diff --git a/storage/connect/myconn.h b/storage/connect/myconn.h
index 8a49239ec7a..856b6c73ef3 100644
--- a/storage/connect/myconn.h
+++ b/storage/connect/myconn.h
@@ -63,15 +63,10 @@ class DllItem MYSQLC {
bool Connected(void);
// Methods
-// int GetCurPos(void) {return (m_Res) ? N : 0;}
-// int GetProgCur(void) {return N;}
int GetResultSize(PGLOBAL g, PSZ sql);
int Open(PGLOBAL g, const char *host, const char *db,
const char *user= "root", const char *pwd= "*",
int pt= 0);
-//ulong GetThreadID(void);
-//ulong ServerVersion(void);
-//const char *ServerInfo(void);
int KillQuery(ulong id);
int ExecSQL(PGLOBAL g, const char *query, int *w = NULL);
int ExecSQLcmd(PGLOBAL g, const char *query, int *w);
@@ -87,7 +82,6 @@ class DllItem MYSQLC {
void Rewind(void);
void FreeResult(void);
void Close(void);
-//void DiscardResults(void);
protected:
MYSQL_FIELD *GetNextField(void);
diff --git a/storage/connect/mysql-test/connect/r/alter.result b/storage/connect/mysql-test/connect/r/alter.result
new file mode 100644
index 00000000000..ccfae3f4ddb
--- /dev/null
+++ b/storage/connect/mysql-test/connect/r/alter.result
@@ -0,0 +1,265 @@
+#
+# 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;
diff --git a/storage/connect/mysql-test/connect/r/alter_xml.result b/storage/connect/mysql-test/connect/r/alter_xml.result
new file mode 100644
index 00000000000..bd3b281b05b
--- /dev/null
+++ b/storage/connect/mysql-test/connect/r/alter_xml.result
@@ -0,0 +1,86 @@
+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;
diff --git a/storage/connect/mysql-test/connect/r/dbf.result b/storage/connect/mysql-test/connect/r/dbf.result
index bc09f85a631..30fac687119 100644
--- a/storage/connect/mysql-test/connect/r/dbf.result
+++ b/storage/connect/mysql-test/connect/r/dbf.result
@@ -390,22 +390,22 @@ CREATE TABLE t1
(
a BLOB
) 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
(
a TINYBLOB
) 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
(
a MEDIUMBLOB
) 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
(
a LONGBLOB
) 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
#
diff --git a/storage/connect/mysql-test/connect/r/fix.result b/storage/connect/mysql-test/connect/r/fix.result
index 96ba3f84a0d..a93948bb9c6 100644
--- a/storage/connect/mysql-test/connect/r/fix.result
+++ b/storage/connect/mysql-test/connect/r/fix.result
@@ -68,64 +68,64 @@ DROP TABLE t1;
CREATE TABLE t1
(
name char(12) not null,
-city char(12) not null,
+city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
SELECT * FROM t1;
name city birth hired
-John Boston 2 1986-01-05 2010-06-02
-Henry Boston 0 1987-06-07 2008-04-01
-George San Jose 1 1981-08-01 2010-06-02
-Sam Chicago 2 1979-11-02 2007-10-10
-James Dallas 1 1992-05-03 2009-12-14
-Bill Boston 1 1986-09-01 2008-02-10
+John Boston 1986-01-25 2010-06-02
+Henry Boston 1987-06-07 2008-04-01
+George San Jose 1981-08-10 2010-06-02
+Sam Chicago 1979-11-22 2007-10-10
+James Dallas 1992-05-13 2009-12-14
+Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1;
CREATE TABLE t1
(
name char(12) not null,
-city char(12) not null,
+city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1;
SELECT * FROM t1;
name city birth hired
-John Boston 2 1986-01-05 2010-06-02
-Henry Boston 0 1987-06-07 2008-04-01
-George San Jose 1 1981-08-01 2010-06-02
-Sam Chicago 2 1979-11-02 2007-10-10
-James Dallas 1 1992-05-03 2009-12-14
-Bill Boston 1 1986-09-01 2008-02-10
+John Boston 1986-01-25 2010-06-02
+Henry Boston 1987-06-07 2008-04-01
+George San Jose 1981-08-10 2010-06-02
+Sam Chicago 1979-11-22 2007-10-10
+James Dallas 1992-05-13 2009-12-14
+Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1;
CREATE TABLE t1
(
name char(12) not null,
-city char(12) not null,
+city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2;
SELECT * FROM t1;
name city birth hired
-John Boston 2 1986-01-05 2010-06-02
-Henry Boston 0 1987-06-07 2008-04-01
-George San Jose 1 1981-08-01 2010-06-02
-Sam Chicago 2 1979-11-02 2007-10-10
-James Dallas 1 1992-05-03 2009-12-14
-Bill Boston 1 1986-09-01 2008-02-10
+John Boston 1986-01-25 2010-06-02
+Henry Boston 1987-06-07 2008-04-01
+George San Jose 1981-08-10 2010-06-02
+Sam Chicago 1979-11-22 2007-10-10
+James Dallas 1992-05-13 2009-12-14
+Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1;
CREATE TABLE t1
(
name char(12) not null,
-city char(12) not null,
+city char(11) not null,
birth date not null date_format='DD/MM/YYYY',
hired date not null date_format='DD/MM/YYYY' flag=36
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2;
SELECT * FROM t1;
name city birth hired
-John Boston 2 1986-01-05 2010-06-02
-Henry Boston 0 1987-06-07 2008-04-01
-George San Jose 1 1981-08-01 2010-06-02
-Sam Chicago 2 1979-11-02 2007-10-10
-James Dallas 1 1992-05-03 2009-12-14
-Bill Boston 1 1986-09-01 2008-02-10
+John Boston 1986-01-25 2010-06-02
+Henry Boston 1987-06-07 2008-04-01
+George San Jose 1981-08-10 2010-06-02
+Sam Chicago 1979-11-22 2007-10-10
+James Dallas 1992-05-13 2009-12-14
+Bill Boston 1986-09-11 2008-02-10
DROP TABLE t1;
diff --git a/storage/connect/mysql-test/connect/r/pivot.result b/storage/connect/mysql-test/connect/r/pivot.result
index 2e4a924c8c3..82b1e0a0b0b 100644
--- a/storage/connect/mysql-test/connect/r/pivot.result
+++ b/storage/connect/mysql-test/connect/r/pivot.result
@@ -224,3 +224,30 @@ Kevin 0 2 6
Donald 1 0 3
DROP TABLE pivet;
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;
diff --git a/storage/connect/mysql-test/connect/r/xml.result b/storage/connect/mysql-test/connect/r/xml.result
index aeb1f5edbcd..4768573dc7c 100644
--- a/storage/connect/mysql-test/connect/r/xml.result
+++ b/storage/connect/mysql-test/connect/r/xml.result
@@ -413,7 +413,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('MYSQLD_DATADIR/test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1);
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>
<line>
<node>ÀÁÂÃ</node>
diff --git a/storage/connect/mysql-test/connect/suite.pm b/storage/connect/mysql-test/connect/suite.pm
index 3bbeffca7d9..2dabbc82e7d 100644
--- a/storage/connect/mysql-test/connect/suite.pm
+++ b/storage/connect/mysql-test/connect/suite.pm
@@ -5,6 +5,11 @@ package My::Suite::Connect;
return "No CONNECT engine" unless $ENV{HA_CONNECT_SO} or
$::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 }
bless { };
diff --git a/storage/connect/mysql-test/connect/t/alter.test b/storage/connect/mysql-test/connect/t/alter.test
new file mode 100644
index 00000000000..299381b925a
--- /dev/null
+++ b/storage/connect/mysql-test/connect/t/alter.test
@@ -0,0 +1,135 @@
+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
diff --git a/storage/connect/mysql-test/connect/t/alter_xml.test b/storage/connect/mysql-test/connect/t/alter_xml.test
new file mode 100644
index 00000000000..decf5e76cdf
--- /dev/null
+++ b/storage/connect/mysql-test/connect/t/alter_xml.test
@@ -0,0 +1,29 @@
+--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;
diff --git a/storage/connect/mysql-test/connect/t/dbf.test b/storage/connect/mysql-test/connect/t/dbf.test
index 7b364e9b921..467c608fe38 100644
--- a/storage/connect/mysql-test/connect/t/dbf.test
+++ b/storage/connect/mysql-test/connect/t/dbf.test
@@ -1,511 +1,511 @@
-let $MYSQLD_DATADIR= `select @@datadir`;
-
---echo #
---echo # Testing errors
---echo #
-CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-SHOW CREATE TABLE t1;
---replace_regex /on .*test.t1.dbf/on DATADIR\/test\/t1.dbf/
-SELECT * FROM t1;
-DROP TABLE t1;
-
---replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
---replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/
-SHOW WARNINGS;
-
-
-DELIMITER //;
-CREATE PROCEDURE test.dbf_field(in fieldno INT, in content BLOB) DETERMINISTIC
-BEGIN
- SELECT '---';
- SELECT fieldno AS `FieldN`;
- SELECT TRIM(TRAILING 0x00 FROM LEFT(content, 10)) AS `Name`;
- SELECT SUBSTRING(content, 12, 1) AS `Type`;
- SELECT CONV(HEX(REVERSE(SUBSTRING(content,13,4))),16,10) AS `Offset`;
- SELECT CONV(HEX(REVERSE(SUBSTRING(content,17,1))),16,10) AS `Length`;
- SELECT CONV(HEX(REVERSE(SUBSTRING(content,18,1))),16,10) AS `Dec`;
- SELECT HEX(REVERSE(SUBSTRING(content,19,1))) AS `Flags`;
--- SELECT CONV(HEX(REVERSE(SUBSTRING(content,20,4))),16,10) AS `Next`;
--- SELECT CONV(HEX(REVERSE(SUBSTRING(content,24,4))),16,10) AS `Step`;
-END//
-
-CREATE PROCEDURE test.dbf_header(in fname VARCHAR(1024)) DETERMINISTIC
-BEGIN
- DECLARE content BLOB;
- DECLARE offset INT;
- DECLARE fieldno INT;
- SELECT '--------';
- SELECT LOAD_FILE(fname) INTO content;
- SELECT LENGTH(content) AS FileSize;
- SELECT HEX(LEFT(content, 1)) AS DBF_Version;
- SELECT CONV(HEX(REVERSE(SUBSTRING(content,5,4))),16,10) AS NRecords;
- SELECT CONV(HEX(REVERSE(SUBSTRING(content,9,2))),16,10) AS FirstRecPos;
- SELECT CONV(HEX(REVERSE(SUBSTRING(content,11,2))),16,10) AS RecLength;
- SELECT HEX(REVERSE(SUBSTRING(content,29,2))) AS TableFlags;
- SELECT HEX(REVERSE(SUBSTRING(content,30,1))) AS CodePageMark;
- SET offset=33;
- SET fieldno=0;
- WHILE SUBSTR(content, offset, 1) <> 0x0D AND offset + 32 < LENGTH(content) DO
- CALL dbf_field(fieldno, SUBSTRING(content, offset, 32));
- SET offset=offset + 32;
- SET fieldno=fieldno + 1;
- END WHILE;
- SELECT '--------';
-END//
-DELIMITER ;//
-
-
---echo #
---echo # Testing READONLY tables
---echo #
-CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (10),(20);
-SELECT * FROM t1;
-ALTER TABLE t1 READONLY=Yes;
-SHOW CREATE TABLE t1;
---error ER_OPEN_AS_READONLY
-INSERT INTO t1 VALUES (30);
---error ER_OPEN_AS_READONLY
-UPDATE t1 SET a=30 WHERE a=10;
---error ER_OPEN_AS_READONLY
-DELETE FROM t1 WHERE a=10;
---error ER_OPEN_AS_READONLY
-TRUNCATE TABLE t1;
-ALTER TABLE t1 READONLY=NO;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (30);
-SELECT * FROM t1;
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # This SQL script crashed (dbf01.sql)
---echo #
-CREATE TABLE t1
-(
- a int(11) NOT NULL,
- b char(10) NOT NULL,
- c varchar(10) NOT NULL
-) ENGINE=CONNECT table_type=DBF file_name='t1.dbf';
-INSERT INTO t1 VALUES (1,'1','1');
-INSERT INTO t1 VALUES (2,'2','2');
-SELECT * FROM t1;
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing that table options in lower case and mixed case are understood:
---echo #
-CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT table_type=dbf file_name='t1.dbf';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (10);
-SELECT * FROM t1;
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-CREATE TABLE t1 (a CHAR(10) NOT NULL) ENGINE=CONNECT Table_Type=dbf File_Name='t1.dbf';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES ('test');
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
-#
-# TODO: this creates DBF record with length=32, which looks wrong
-#
---echo #
---echo # Testing multiple columns
---echo #
-CREATE TABLE t1
-(
- a INT NOT NULL,
- b CHAR(10) NOT NULL,
- c VARCHAR(10) NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES (1,'1','1');
-INSERT INTO t1 VALUES (2,'2','2');
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing long column name
---echo #
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a012345678901234567890123456789 INT NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-
---echo #
---echo # Testing 2 columns with long names (12)
---echo #
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a0123456789a INT NOT NULL,
- b0123456789b INT NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x11.dbf';
-
---echo #
---echo # Testing 2 columns with long names (11)
---echo #
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a012345678a INT NOT NULL,
- b012345678b INT NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x12.dbf';
-
---echo #
---echo # Testing 2 columns name length 10 (maximum possible length)
---echo #
-CREATE TABLE t1
-(
- a01234567a INT NOT NULL,
- b01234567b INT NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x13.dbf';
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (1,2);
-SELECT * FROM t1;
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t02x13.dbf
-
-
---echo #
---echo # Testing BIGINT
---echo #
-CREATE TABLE t1
-(
- a bigint NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF);
-INSERT INTO t1 VALUES (-0x8000000000000000);
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing TINYINT
---echo #
-CREATE TABLE t1
-(
- a TINYINT NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES (123);
-SELECT * FROM t1;
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing SMALLINT
---echo #
-CREATE TABLE t1
-(
- a SMALLINT NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES (0x7FFF);
-INSERT INTO t1 VALUES (-0x8000);
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing VARCHAR
---echo #
-CREATE TABLE t1
-(
- a VARCHAR(255) NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES (REPEAT('a',255));
-SELECT LENGTH(a) FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing too long CHAR
---echo # All columns longer than 255 bytes should be rejected
---echo #
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a CHAR(86) CHARACTER SET utf8 NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
---error ER_UNKNOWN_ERROR
-
-
---echo #
---echo # Testing too long VARCHAR
---echo # All columns longer than 255 bytes should be rejected
---echo #
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a VARCHAR(256) NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a VARCHAR(86) CHARACTER SET utf8 NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a VARCHAR(64000) NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-
-
---echo #
---echo # Testing BLOB
---echo #
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a BLOB
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a TINYBLOB
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a MEDIUMBLOB
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
---error ER_UNKNOWN_ERROR
-CREATE TABLE t1
-(
- a LONGBLOB
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-
-
-# TODO: utf8 does not work
-#--echo #
-#--echo # Testing varchar with utf8
-#--echo #
-#SET NAMES utf8;
-#CREATE TABLE t1
-#(
-# a VARCHAR(10) CHARACTER SET utf8
-#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-#INSERT INTO t1 VALUES (REPEAT(_ucs2 0x00DF,10));
-#SELECT * FROM t1;
-#DROP TABLE IF EXISTS t1;
-#--remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing DATE
---echo #
-CREATE TABLE t1
-(
- a DATE NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES ('2001-01-01');
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
-
---echo #
---echo # Testing FLOAT
---echo #
-CREATE TABLE t1
-(
- a FLOAT(12,4) NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES (123);
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-#
-# TODO: this return error:
-# Got error 122 'Value 123.0000000000 too long for column a of length 12'
-# from CONNECT
-#
-#CREATE TABLE t1
-#(
-# a FLOAT NOT NULL
-#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-#--error ER_GET_ERRMSG - why this error?
-#INSERT INTO t1 VALUES (123);
-#SELECT * FROM t1;
-#DROP TABLE IF EXISTS t1;
-#--remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
-#
-# TODO: this creates a column of type 'D' (date), which is wrong
-#
-#--echo #
-#--echo # Testing DATETIME
-#--echo #
-#CREATE TABLE t1
-#(
-# a DATETIME NOT NULL
-#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-#INSERT INTO t1 VALUES ('2013-02-01');
-#SELECT * FROM t1;
-#DROP TABLE t1;
-#--remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
-#
-# TODO: this creates a column of type 'D' (date), which is wrong
-#
-#--echo #
-#--echo # Testing TIMESTAMP
-#--echo #
-#CREATE TABLE t1
-#(
-# a TIMESTAMP
-#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-#INSERT INTO t1 VALUES ('2013-02-01');
-#SELECT * FROM t1;
-#DROP TABLE t1;
-#--remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
---echo #
---echo # Testing double
---echo #
-CREATE TABLE t1
-(
- a DOUBLE(20,5) NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES (123);
-INSERT INTO t1 VALUES (123456789.12345);
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE IF EXISTS t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-
-# TODO:
-# Testing with no FILE_NAME specified
-# Currently it returns:
-# ERROR 1296 (HY000): Got error 174 'Open(a+) error 21
-# on /opt/mariadb-5.5/data/: Is a directory' from CONNECT
-#CREATE TABLE t1 (a INT) ENGINE=CONNECT TABLE_TYPE=DBF;
-
---echo #
---echo # Testing ALTER
---echo #
-# Temporarily change the file name because ALTER that are not executed not in place
-# delete the data file when it has the same path/name than the default file name.
-CREATE TABLE t1
-(
- a VARCHAR(10) NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1c.dbf';
-INSERT INTO t1 VALUES ('10');
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1c.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
---horizontal_results
-ALTER TABLE t1 MODIFY a VARCHAR(10) NOT NULL;
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
---horizontal_results
-ALTER TABLE t1 MODIFY a INT(10) NOT NULL;
-SHOW CREATE TABLE t1;
-SELECT * FROM t1;
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
---horizontal_results
-
-# TODO: this does not work on Windows
-#ALTER TABLE t1 MODIFY a INT(8) NOT NULL;
-#SHOW CREATE TABLE t1;
-#--error ER_GET_ERRMSG
-#SELECT * FROM t1;
-#--vertical_results
-#--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-#eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
-#--horizontal_results
-DROP TABLE IF EXISTS t1;
---remove_file $MYSQLD_DATADIR/test/t1c.dbf
-
-
---echo #
---echo # Testing NULL
---echo #
-# TODO: NULLs should probably change to DEFAULT and produce a warning
-CREATE TABLE t1
-(
- c1 VARCHAR(10) NOT NULL,
- c2 VARCHAR(10) NOT NULL DEFAULT 'def',
- i1 INT NOT NULL,
- i2 INT NOT NULL DEFAULT 123
-) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
-INSERT INTO t1 VALUES ('10','10',10,10);
-#INSERT INTO t1 VALUES (NULL,NULL,NULL,NULL);
-INSERT INTO t1(c1,i1) VALUES ('20',20);
-INSERT INTO t1 VALUES ('30',DEFAULT,30,DEFAULT);
-SELECT * FROM t1;
---chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
---vertical_results
---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
-eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
---horizontal_results
-DROP TABLE IF EXISTS t1;
---remove_file $MYSQLD_DATADIR/test/t1.dbf
-
-DROP PROCEDURE test.dbf_field;
-DROP PROCEDURE test.dbf_header;
+let $MYSQLD_DATADIR= `select @@datadir`;
+
+--echo #
+--echo # Testing errors
+--echo #
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+SHOW CREATE TABLE t1;
+--replace_regex /on .*test.t1.dbf/on DATADIR\/test\/t1.dbf/
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+--replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/
+SHOW WARNINGS;
+
+
+DELIMITER //;
+CREATE PROCEDURE test.dbf_field(in fieldno INT, in content BLOB) DETERMINISTIC
+BEGIN
+ SELECT '---';
+ SELECT fieldno AS `FieldN`;
+ SELECT TRIM(TRAILING 0x00 FROM LEFT(content, 10)) AS `Name`;
+ SELECT SUBSTRING(content, 12, 1) AS `Type`;
+ SELECT CONV(HEX(REVERSE(SUBSTRING(content,13,4))),16,10) AS `Offset`;
+ SELECT CONV(HEX(REVERSE(SUBSTRING(content,17,1))),16,10) AS `Length`;
+ SELECT CONV(HEX(REVERSE(SUBSTRING(content,18,1))),16,10) AS `Dec`;
+ SELECT HEX(REVERSE(SUBSTRING(content,19,1))) AS `Flags`;
+-- SELECT CONV(HEX(REVERSE(SUBSTRING(content,20,4))),16,10) AS `Next`;
+-- SELECT CONV(HEX(REVERSE(SUBSTRING(content,24,4))),16,10) AS `Step`;
+END//
+
+CREATE PROCEDURE test.dbf_header(in fname VARCHAR(1024)) DETERMINISTIC
+BEGIN
+ DECLARE content BLOB;
+ DECLARE offset INT;
+ DECLARE fieldno INT;
+ SELECT '--------';
+ SELECT LOAD_FILE(fname) INTO content;
+ SELECT LENGTH(content) AS FileSize;
+ SELECT HEX(LEFT(content, 1)) AS DBF_Version;
+ SELECT CONV(HEX(REVERSE(SUBSTRING(content,5,4))),16,10) AS NRecords;
+ SELECT CONV(HEX(REVERSE(SUBSTRING(content,9,2))),16,10) AS FirstRecPos;
+ SELECT CONV(HEX(REVERSE(SUBSTRING(content,11,2))),16,10) AS RecLength;
+ SELECT HEX(REVERSE(SUBSTRING(content,29,2))) AS TableFlags;
+ SELECT HEX(REVERSE(SUBSTRING(content,30,1))) AS CodePageMark;
+ SET offset=33;
+ SET fieldno=0;
+ WHILE SUBSTR(content, offset, 1) <> 0x0D AND offset + 32 < LENGTH(content) DO
+ CALL dbf_field(fieldno, SUBSTRING(content, offset, 32));
+ SET offset=offset + 32;
+ SET fieldno=fieldno + 1;
+ END WHILE;
+ SELECT '--------';
+END//
+DELIMITER ;//
+
+
+--echo #
+--echo # Testing READONLY tables
+--echo #
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (10),(20);
+SELECT * FROM t1;
+ALTER TABLE t1 READONLY=Yes;
+SHOW CREATE TABLE t1;
+--error ER_OPEN_AS_READONLY
+INSERT INTO t1 VALUES (30);
+--error ER_OPEN_AS_READONLY
+UPDATE t1 SET a=30 WHERE a=10;
+--error ER_OPEN_AS_READONLY
+DELETE FROM t1 WHERE a=10;
+--error ER_OPEN_AS_READONLY
+TRUNCATE TABLE t1;
+ALTER TABLE t1 READONLY=NO;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (30);
+SELECT * FROM t1;
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # This SQL script crashed (dbf01.sql)
+--echo #
+CREATE TABLE t1
+(
+ a int(11) NOT NULL,
+ b char(10) NOT NULL,
+ c varchar(10) NOT NULL
+) ENGINE=CONNECT table_type=DBF file_name='t1.dbf';
+INSERT INTO t1 VALUES (1,'1','1');
+INSERT INTO t1 VALUES (2,'2','2');
+SELECT * FROM t1;
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing that table options in lower case and mixed case are understood:
+--echo #
+CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT table_type=dbf file_name='t1.dbf';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (10);
+SELECT * FROM t1;
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+CREATE TABLE t1 (a CHAR(10) NOT NULL) ENGINE=CONNECT Table_Type=dbf File_Name='t1.dbf';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('test');
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+#
+# TODO: this creates DBF record with length=32, which looks wrong
+#
+--echo #
+--echo # Testing multiple columns
+--echo #
+CREATE TABLE t1
+(
+ a INT NOT NULL,
+ b CHAR(10) NOT NULL,
+ c VARCHAR(10) NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES (1,'1','1');
+INSERT INTO t1 VALUES (2,'2','2');
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing long column name
+--echo #
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1
+(
+ a012345678901234567890123456789 INT NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+
+--echo #
+--echo # Testing 2 columns with long names (12)
+--echo #
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1
+(
+ a0123456789a INT NOT NULL,
+ b0123456789b INT NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x11.dbf';
+
+--echo #
+--echo # Testing 2 columns with long names (11)
+--echo #
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1
+(
+ a012345678a INT NOT NULL,
+ b012345678b INT NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x12.dbf';
+
+--echo #
+--echo # Testing 2 columns name length 10 (maximum possible length)
+--echo #
+CREATE TABLE t1
+(
+ a01234567a INT NOT NULL,
+ b01234567b INT NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x13.dbf';
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (1,2);
+SELECT * FROM t1;
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t02x13.dbf
+
+
+--echo #
+--echo # Testing BIGINT
+--echo #
+CREATE TABLE t1
+(
+ a bigint NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF);
+INSERT INTO t1 VALUES (-0x8000000000000000);
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing TINYINT
+--echo #
+CREATE TABLE t1
+(
+ a TINYINT NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES (123);
+SELECT * FROM t1;
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing SMALLINT
+--echo #
+CREATE TABLE t1
+(
+ a SMALLINT NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES (0x7FFF);
+INSERT INTO t1 VALUES (-0x8000);
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing VARCHAR
+--echo #
+CREATE TABLE t1
+(
+ a VARCHAR(255) NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES (REPEAT('a',255));
+SELECT LENGTH(a) FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing too long CHAR
+--echo # All columns longer than 255 bytes should be rejected
+--echo #
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1
+(
+ a CHAR(86) CHARACTER SET utf8 NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+--error ER_UNKNOWN_ERROR
+
+
+--echo #
+--echo # Testing too long VARCHAR
+--echo # All columns longer than 255 bytes should be rejected
+--echo #
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1
+(
+ a VARCHAR(256) NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1
+(
+ a VARCHAR(86) CHARACTER SET utf8 NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+--error ER_UNKNOWN_ERROR
+CREATE TABLE t1
+(
+ a VARCHAR(64000) NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+
+
+--echo #
+--echo # Testing BLOB
+--echo #
+--error ER_TABLE_CANT_HANDLE_BLOB
+CREATE TABLE t1
+(
+ a BLOB
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+--error ER_TABLE_CANT_HANDLE_BLOB
+CREATE TABLE t1
+(
+ a TINYBLOB
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+--error ER_TABLE_CANT_HANDLE_BLOB
+CREATE TABLE t1
+(
+ a MEDIUMBLOB
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+--error ER_TABLE_CANT_HANDLE_BLOB
+CREATE TABLE t1
+(
+ a LONGBLOB
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+
+
+# TODO: utf8 does not work
+#--echo #
+#--echo # Testing varchar with utf8
+#--echo #
+#SET NAMES utf8;
+#CREATE TABLE t1
+#(
+# a VARCHAR(10) CHARACTER SET utf8
+#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+#INSERT INTO t1 VALUES (REPEAT(_ucs2 0x00DF,10));
+#SELECT * FROM t1;
+#DROP TABLE IF EXISTS t1;
+#--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing DATE
+--echo #
+CREATE TABLE t1
+(
+ a DATE NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES ('2001-01-01');
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+
+--echo #
+--echo # Testing FLOAT
+--echo #
+CREATE TABLE t1
+(
+ a FLOAT(12,4) NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES (123);
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+#
+# TODO: this return error:
+# Got error 122 'Value 123.0000000000 too long for column a of length 12'
+# from CONNECT
+#
+#CREATE TABLE t1
+#(
+# a FLOAT NOT NULL
+#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+#--error ER_GET_ERRMSG - why this error?
+#INSERT INTO t1 VALUES (123);
+#SELECT * FROM t1;
+#DROP TABLE IF EXISTS t1;
+#--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+#
+# TODO: this creates a column of type 'D' (date), which is wrong
+#
+#--echo #
+#--echo # Testing DATETIME
+#--echo #
+#CREATE TABLE t1
+#(
+# a DATETIME NOT NULL
+#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+#INSERT INTO t1 VALUES ('2013-02-01');
+#SELECT * FROM t1;
+#DROP TABLE t1;
+#--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+#
+# TODO: this creates a column of type 'D' (date), which is wrong
+#
+#--echo #
+#--echo # Testing TIMESTAMP
+#--echo #
+#CREATE TABLE t1
+#(
+# a TIMESTAMP
+#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+#INSERT INTO t1 VALUES ('2013-02-01');
+#SELECT * FROM t1;
+#DROP TABLE t1;
+#--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+--echo #
+--echo # Testing double
+--echo #
+CREATE TABLE t1
+(
+ a DOUBLE(20,5) NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES (123);
+INSERT INTO t1 VALUES (123456789.12345);
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE IF EXISTS t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+
+# TODO:
+# Testing with no FILE_NAME specified
+# Currently it returns:
+# ERROR 1296 (HY000): Got error 174 'Open(a+) error 21
+# on /opt/mariadb-5.5/data/: Is a directory' from CONNECT
+#CREATE TABLE t1 (a INT) ENGINE=CONNECT TABLE_TYPE=DBF;
+
+--echo #
+--echo # Testing ALTER
+--echo #
+# Temporarily change the file name because ALTER that are not executed not in place
+# delete the data file when it has the same path/name than the default file name.
+CREATE TABLE t1
+(
+ a VARCHAR(10) NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1c.dbf';
+INSERT INTO t1 VALUES ('10');
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1c.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
+--horizontal_results
+ALTER TABLE t1 MODIFY a VARCHAR(10) NOT NULL;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
+--horizontal_results
+ALTER TABLE t1 MODIFY a INT(10) NOT NULL;
+SHOW CREATE TABLE t1;
+SELECT * FROM t1;
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
+--horizontal_results
+
+# TODO: this does not work on Windows
+#ALTER TABLE t1 MODIFY a INT(8) NOT NULL;
+#SHOW CREATE TABLE t1;
+#--error ER_GET_ERRMSG
+#SELECT * FROM t1;
+#--vertical_results
+#--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+#eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+#--horizontal_results
+DROP TABLE IF EXISTS t1;
+--remove_file $MYSQLD_DATADIR/test/t1c.dbf
+
+
+--echo #
+--echo # Testing NULL
+--echo #
+# TODO: NULLs should probably change to DEFAULT and produce a warning
+CREATE TABLE t1
+(
+ c1 VARCHAR(10) NOT NULL,
+ c2 VARCHAR(10) NOT NULL DEFAULT 'def',
+ i1 INT NOT NULL,
+ i2 INT NOT NULL DEFAULT 123
+) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
+INSERT INTO t1 VALUES ('10','10',10,10);
+#INSERT INTO t1 VALUES (NULL,NULL,NULL,NULL);
+INSERT INTO t1(c1,i1) VALUES ('20',20);
+INSERT INTO t1 VALUES ('30',DEFAULT,30,DEFAULT);
+SELECT * FROM t1;
+--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
+--vertical_results
+--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
+eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
+--horizontal_results
+DROP TABLE IF EXISTS t1;
+--remove_file $MYSQLD_DATADIR/test/t1.dbf
+
+DROP PROCEDURE test.dbf_field;
+DROP PROCEDURE test.dbf_header;
diff --git a/storage/connect/mysql-test/connect/t/fix.test b/storage/connect/mysql-test/connect/t/fix.test
index 15e642a85fd..72eb274f7d6 100644
--- a/storage/connect/mysql-test/connect/t/fix.test
+++ b/storage/connect/mysql-test/connect/t/fix.test
@@ -1,108 +1,108 @@
-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/boys.txt $MYSQLD_DATADIR/test/boys.txt
---copy_file $MTR_SUITE_DIR/std_data/boyswin.txt $MYSQLD_DATADIR/test/boyswin.txt
-
---echo #
---echo # Testing errors
---echo #
-CREATE TABLE t1
-(
- ID INT NOT NULL
-) Engine=CONNECT TABLE_TYPE=DOS FILE_NAME='nonexistent.txt';
---replace_regex /on .*test.nonexistent.txt/on DATADIR\/test\/nonexistent.txt/
-# TODO: check why this is needed for Windows
---replace_result Open(rt) Open(rb)
-SELECT * FROM t1;
-DROP TABLE t1;
-
---echo #
---echo # Testing READONLY tables
---echo #
-CREATE TABLE t1
-(
- id INT NOT NULL
-) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.txt';
-INSERT INTO t1 VALUES (10);
-SELECT * FROM t1;
-ALTER TABLE t1 READONLY=1;
-SHOW CREATE TABLE t1;
---error ER_OPEN_AS_READONLY
-INSERT INTO t1 VALUES (20);
---error ER_OPEN_AS_READONLY
-UPDATE t1 SET id=20 WHERE id=10;
---error ER_OPEN_AS_READONLY
-DELETE FROM t1 WHERE id=10;
---error ER_OPEN_AS_READONLY
-TRUNCATE TABLE t1;
-ALTER TABLE t1 READONLY=0;
-SHOW CREATE TABLE t1;
-INSERT INTO t1 VALUES (20);
-SELECT * FROM t1;
-DROP TABLE t1;
---remove_file $MYSQLD_DATADIR/test/t1.txt
-
-
---echo #
---echo # Testing manual examples
---echo #
-CREATE TABLE t1
-(
- number CHAR(4) not null,
- location CHAR(15) NOT NULL flag=5,
- director CHAR(5) NOT NULL flag=20,
- function CHAR(12) NOT NULL flag=26,
- name CHAR(22) NOT NULL flag=38
-) ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='dept.dat';
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1
-(
- name char(12) not null,
- city char(12) not null,
- birth date not null date_format='DD/MM/YYYY',
- hired date not null date_format='DD/MM/YYYY' flag=36
-) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1
-(
- name char(12) not null,
- city char(12) not null,
- birth date not null date_format='DD/MM/YYYY',
- hired date not null date_format='DD/MM/YYYY' flag=36
-) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-
-CREATE TABLE t1
-(
- name char(12) not null,
- city char(12) not null,
- birth date not null date_format='DD/MM/YYYY',
- hired date not null date_format='DD/MM/YYYY' flag=36
-) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-CREATE TABLE t1
-(
- name char(12) not null,
- city char(12) not null,
- birth date not null date_format='DD/MM/YYYY',
- hired date not null date_format='DD/MM/YYYY' flag=36
-) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2;
-SELECT * FROM t1;
-DROP TABLE t1;
-
-
-#
-# Clean up
-#
---remove_file $MYSQLD_DATADIR/test/dept.dat
---remove_file $MYSQLD_DATADIR/test/boys.txt
---remove_file $MYSQLD_DATADIR/test/boyswin.txt
+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/boys.txt $MYSQLD_DATADIR/test/boys.txt
+--copy_file $MTR_SUITE_DIR/std_data/boyswin.txt $MYSQLD_DATADIR/test/boyswin.txt
+
+--echo #
+--echo # Testing errors
+--echo #
+CREATE TABLE t1
+(
+ ID INT NOT NULL
+) Engine=CONNECT TABLE_TYPE=DOS FILE_NAME='nonexistent.txt';
+--replace_regex /on .*test.nonexistent.txt/on DATADIR\/test\/nonexistent.txt/
+# TODO: check why this is needed for Windows
+--replace_result Open(rt) Open(rb)
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Testing READONLY tables
+--echo #
+CREATE TABLE t1
+(
+ id INT NOT NULL
+) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.txt';
+INSERT INTO t1 VALUES (10);
+SELECT * FROM t1;
+ALTER TABLE t1 READONLY=1;
+SHOW CREATE TABLE t1;
+--error ER_OPEN_AS_READONLY
+INSERT INTO t1 VALUES (20);
+--error ER_OPEN_AS_READONLY
+UPDATE t1 SET id=20 WHERE id=10;
+--error ER_OPEN_AS_READONLY
+DELETE FROM t1 WHERE id=10;
+--error ER_OPEN_AS_READONLY
+TRUNCATE TABLE t1;
+ALTER TABLE t1 READONLY=0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (20);
+SELECT * FROM t1;
+DROP TABLE t1;
+--remove_file $MYSQLD_DATADIR/test/t1.txt
+
+
+--echo #
+--echo # Testing manual examples
+--echo #
+CREATE TABLE t1
+(
+ number CHAR(4) not null,
+ location CHAR(15) NOT NULL flag=5,
+ director CHAR(5) NOT NULL flag=20,
+ function CHAR(12) NOT NULL flag=26,
+ name CHAR(22) NOT NULL flag=38
+) ENGINE=CONNECT TABLE_TYPE=DOS FILE_NAME='dept.dat';
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1
+(
+ name char(12) not null,
+ city char(11) not null,
+ birth date not null date_format='DD/MM/YYYY',
+ hired date not null date_format='DD/MM/YYYY' flag=36
+) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' ENDING=1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1
+(
+ name char(12) not null,
+ city char(11) not null,
+ birth date not null date_format='DD/MM/YYYY',
+ hired date not null date_format='DD/MM/YYYY' flag=36
+) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boys.txt' LRECL=47 ENDING=1;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+CREATE TABLE t1
+(
+ name char(12) not null,
+ city char(11) not null,
+ birth date not null date_format='DD/MM/YYYY',
+ hired date not null date_format='DD/MM/YYYY' flag=36
+) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' ENDING=2;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1
+(
+ name char(12) not null,
+ city char(11) not null,
+ birth date not null date_format='DD/MM/YYYY',
+ hired date not null date_format='DD/MM/YYYY' flag=36
+) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='boyswin.txt' LRECL=47 ENDING=2;
+SELECT * FROM t1;
+DROP TABLE t1;
+
+
+#
+# Clean up
+#
+--remove_file $MYSQLD_DATADIR/test/dept.dat
+--remove_file $MYSQLD_DATADIR/test/boys.txt
+--remove_file $MYSQLD_DATADIR/test/boyswin.txt
diff --git a/storage/connect/mysql-test/connect/t/pivot.test b/storage/connect/mysql-test/connect/t/pivot.test
index 7679434bca8..3212496a220 100644
--- a/storage/connect/mysql-test/connect/t/pivot.test
+++ b/storage/connect/mysql-test/connect/t/pivot.test
@@ -1,146 +1,163 @@
--- source include/not_embedded.inc
-
-let $MYSQLD_DATADIR= `select @@datadir`;
-let $PORT= `select @@port`;
---copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt
-
---echo #
---echo # Testing the PIVOT table type
---echo #
-CREATE TABLE expenses (
-Who CHAR(10) NOT NULL,
-Week INT(2) NOT NULL,
-What CHAR(12) NOT NULL,
-Amount DOUBLE(8,2))
-ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2;
-SELECT * FROM expenses;
-
---echo #
---echo # Pivoting from What
---echo #
-CREATE TABLE pivex (
-Who CHAR(10) NOT NULL,
-Week INT(2) NOT NULL,
-Beer DOUBLE(8,2) FLAG=1,
-Car DOUBLE(8,2) FLAG=1,
-Food DOUBLE(8,2) FLAG=1)
-ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses;
---replace_result $PORT PORT
---eval ALTER TABLE pivex OPTION_LIST='port=$PORT'
-SELECT * FROM pivex;
-
---echo #
---echo # Restricting the columns in a Pivot Table
---echo #
-ALTER TABLE pivex DROP COLUMN week;
-SELECT * FROM pivex;
-
---echo #
---echo # Using a source definition
---echo #
-DROP TABLE pivex;
-CREATE TABLE pivex (
-Who CHAR(10) NOT NULL,
-Week INT(2) NOT NULL,
-Beer DOUBLE(8,2) FLAG=1,
-Car DOUBLE(8,2) FLAG=1,
-Food DOUBLE(8,2) FLAG=1)
-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';
---replace_result $PORT PORT
---eval ALTER TABLE pivex OPTION_LIST='PivotCol=what,FncCol=amount,port=$PORT'
-SELECT * FROM pivex;
-
---echo #
---echo # Pivoting from Week
---echo #
-DROP TABLE pivex;
-CREATE TABLE pivex (
-Who CHAR(10) NOT NULL,
-What CHAR(12) NOT NULL,
-`3` DOUBLE(8,2) FLAG=1,
-`4` DOUBLE(8,2) FLAG=1,
-`5` DOUBLE(8,2) FLAG=1)
-ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses;
---replace_result $PORT PORT
---eval ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=$PORT'
-SELECT * FROM pivex;
-
---echo #
---echo # Using scalar functions and expresssions
---echo #
-DROP TABLE pivex;
-CREATE TABLE pivex (
-Who CHAR(10) NOT NULL,
-What CHAR(12) NOT NULL,
-First DOUBLE(8,2) FLAG=1,
-Middle DOUBLE(8,2) FLAG=1,
-Last DOUBLE(8,2) FLAG=1)
-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';
---replace_result $PORT PORT
---eval ALTER TABLE pivex OPTION_LIST='PivotCol=wk,FncCol=amnt,port=$PORT'
-SELECT * FROM pivex;
-DROP TABLE pivex;
-DROP TABLE expenses;
-
---echo #
---echo # Make the PETS table
---echo #
-CREATE TABLE pets (
-Name VARCHAR(12) NOT NULL,
-Race CHAR(6) NOT NULL,
-Number INT NOT NULL) ENGINE=MYISAM;
-INSERT INTO pets VALUES('John','dog',2);
-INSERT INTO pets VALUES('Bill','cat',1);
-INSERT INTO pets VALUES('Mary','dog',1);
-INSERT INTO pets VALUES('Mary','cat',1);
-INSERT INTO pets VALUES('Lisbeth','rabbit',2);
-INSERT INTO pets VALUES('Kevin','cat',2);
-INSERT INTO pets VALUES('Kevin','bird',6);
-INSERT INTO pets VALUES('Donald','dog',1);
-INSERT INTO pets VALUES('Donald','fish',3);
-SELECT * FROM pets;
-
---echo #
---echo # Pivot the PETS table
---echo #
-CREATE TABLE pivet (
-name VARCHAR(12) NOT NULL,
-dog INT NOT NULL DEFAULT 0 FLAG=1,
-cat INT NOT NULL DEFAULT 0 FLAG=1,
-rabbit INT NOT NULL DEFAULT 0 FLAG=1,
-bird 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';
-SELECT * FROM pivet;
-DROP TABLE pivet;
-
---echo #
---echo # Testing the "data" column list
---echo #
-CREATE TABLE pivet (
-name VARCHAR(12) NOT NULL,
-dog 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';
---error ER_GET_ERRMSG
-SELECT * FROM pivet;
-ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1';
-SELECT * FROM pivet;
-DROP TABLE pivet;
-
---echo #
---echo # Adding a "dump" column
---echo #
-CREATE TABLE pivet (
-name VARCHAR(12) NOT NULL,
-dog INT NOT NULL DEFAULT 0 FLAG=1,
-cat INT NOT NULL DEFAULT 0 FLAG=1,
-other INT NOT NULL DEFAULT 0 FLAG=2)
-ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1';
-SELECT * FROM pivet;
-
-DROP TABLE pivet;
-DROP TABLE pets;
---remove_file $MYSQLD_DATADIR/test/expenses.txt
+-- source include/not_embedded.inc
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+let $PORT= `select @@port`;
+--copy_file $MTR_SUITE_DIR/std_data/expenses.txt $MYSQLD_DATADIR/test/expenses.txt
+
+--echo #
+--echo # Testing the PIVOT table type
+--echo #
+CREATE TABLE expenses (
+Who CHAR(10) NOT NULL,
+Week INT(2) NOT NULL,
+What CHAR(12) NOT NULL,
+Amount DOUBLE(8,2))
+ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='expenses.txt' ENDING=2;
+SELECT * FROM expenses;
+
+--echo #
+--echo # Pivoting from What
+--echo #
+CREATE TABLE pivex (
+Who CHAR(10) NOT NULL,
+Week INT(2) NOT NULL,
+Beer DOUBLE(8,2) FLAG=1,
+Car DOUBLE(8,2) FLAG=1,
+Food DOUBLE(8,2) FLAG=1)
+ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses;
+--replace_result $PORT PORT
+--eval ALTER TABLE pivex OPTION_LIST='port=$PORT'
+SELECT * FROM pivex;
+
+--echo #
+--echo # Restricting the columns in a Pivot Table
+--echo #
+ALTER TABLE pivex DROP COLUMN week;
+SELECT * FROM pivex;
+
+--echo #
+--echo # Using a source definition
+--echo #
+DROP TABLE pivex;
+CREATE TABLE pivex (
+Who CHAR(10) NOT NULL,
+Week INT(2) NOT NULL,
+Beer DOUBLE(8,2) FLAG=1,
+Car DOUBLE(8,2) FLAG=1,
+Food DOUBLE(8,2) FLAG=1)
+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';
+--replace_result $PORT PORT
+--eval ALTER TABLE pivex OPTION_LIST='PivotCol=what,FncCol=amount,port=$PORT'
+SELECT * FROM pivex;
+
+--echo #
+--echo # Pivoting from Week
+--echo #
+DROP TABLE pivex;
+CREATE TABLE pivex (
+Who CHAR(10) NOT NULL,
+What CHAR(12) NOT NULL,
+`3` DOUBLE(8,2) FLAG=1,
+`4` DOUBLE(8,2) FLAG=1,
+`5` DOUBLE(8,2) FLAG=1)
+ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=expenses;
+--replace_result $PORT PORT
+--eval ALTER TABLE pivex OPTION_LIST='PivotCol=Week,port=$PORT'
+SELECT * FROM pivex;
+
+--echo #
+--echo # Using scalar functions and expresssions
+--echo #
+DROP TABLE pivex;
+CREATE TABLE pivex (
+Who CHAR(10) NOT NULL,
+What CHAR(12) NOT NULL,
+First DOUBLE(8,2) FLAG=1,
+Middle DOUBLE(8,2) FLAG=1,
+Last DOUBLE(8,2) FLAG=1)
+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';
+--replace_result $PORT PORT
+--eval ALTER TABLE pivex OPTION_LIST='PivotCol=wk,FncCol=amnt,port=$PORT'
+SELECT * FROM pivex;
+DROP TABLE pivex;
+DROP TABLE expenses;
+
+--echo #
+--echo # Make the PETS table
+--echo #
+CREATE TABLE pets (
+Name VARCHAR(12) NOT NULL,
+Race CHAR(6) NOT NULL,
+Number INT NOT NULL) ENGINE=MYISAM;
+INSERT INTO pets VALUES('John','dog',2);
+INSERT INTO pets VALUES('Bill','cat',1);
+INSERT INTO pets VALUES('Mary','dog',1);
+INSERT INTO pets VALUES('Mary','cat',1);
+INSERT INTO pets VALUES('Lisbeth','rabbit',2);
+INSERT INTO pets VALUES('Kevin','cat',2);
+INSERT INTO pets VALUES('Kevin','bird',6);
+INSERT INTO pets VALUES('Donald','dog',1);
+INSERT INTO pets VALUES('Donald','fish',3);
+SELECT * FROM pets;
+
+--echo #
+--echo # Pivot the PETS table
+--echo #
+CREATE TABLE pivet (
+name VARCHAR(12) NOT NULL,
+dog INT NOT NULL DEFAULT 0 FLAG=1,
+cat INT NOT NULL DEFAULT 0 FLAG=1,
+rabbit INT NOT NULL DEFAULT 0 FLAG=1,
+bird 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';
+SELECT * FROM pivet;
+DROP TABLE pivet;
+
+--echo #
+--echo # Testing the "data" column list
+--echo #
+CREATE TABLE pivet (
+name VARCHAR(12) NOT NULL,
+dog 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';
+--error ER_GET_ERRMSG
+SELECT * FROM pivet;
+ALTER TABLE pivet OPTION_LIST='PivotCol=race,groupby=1,accept=1';
+SELECT * FROM pivet;
+DROP TABLE pivet;
+
+--echo #
+--echo # Adding a "dump" column
+--echo #
+CREATE TABLE pivet (
+name VARCHAR(12) NOT NULL,
+dog INT NOT NULL DEFAULT 0 FLAG=1,
+cat INT NOT NULL DEFAULT 0 FLAG=1,
+other INT NOT NULL DEFAULT 0 FLAG=2)
+ENGINE=CONNECT TABLE_TYPE=PIVOT TABNAME=pets OPTION_LIST='PivotCol=race,groupby=1';
+SELECT * FROM pivet;
+
+DROP TABLE pivet;
+DROP TABLE pets;
+
+--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
diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp
index 1594afb1b3d..ea694389eaf 100644
--- a/storage/connect/myutil.cpp
+++ b/storage/connect/myutil.cpp
@@ -58,12 +58,8 @@ int MYSQLtoPLG(char *typname, char *var)
type = TYPE_ERROR;
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) {
+ // This is to make the difference between temporal values
if (!stricmp(typname, "date"))
*var = 'D';
else if (!stricmp(typname, "datetime"))
@@ -75,7 +71,11 @@ int MYSQLtoPLG(char *typname, char *var)
else if (!stricmp(typname, "year"))
*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
@@ -200,7 +200,6 @@ int MYSQLtoPLG(int mytype, char *var)
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
- if (var) *var = 'V';
case MYSQL_TYPE_STRING:
type = TYPE_STRING;
break;
@@ -208,6 +207,25 @@ int MYSQLtoPLG(int mytype, char *var)
type = TYPE_ERROR;
} // 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;
} // end of MYSQLtoPLG
diff --git a/storage/connect/osutil.c b/storage/connect/osutil.c
index 5570e55f3b2..af5faa5b13b 100644
--- a/storage/connect/osutil.c
+++ b/storage/connect/osutil.c
@@ -78,8 +78,8 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
LPCSTR p2, p = name;
#ifdef DEBTRACE
- fprintf(debug,"SplitPath: name=%s [%s (%d)]\n",
- XSTR(name), XSTR(__FILE__), __LINE__);
+ htrc("SplitPath: name=%s [%s (%d)]\n",
+ XSTR(name), XSTR(__FILE__), __LINE__);
#endif
if (drive) *drive = '\0';
@@ -100,7 +100,7 @@ void _splitpath(LPCSTR name, LPSTR drive, LPSTR dir, LPSTR fn, LPSTR ft)
if (fn) strcpy(fn, p);
#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__);
#endif
} /* end of _splitpath */
@@ -181,7 +181,8 @@ char *_fullpath(char *absPath, const char *relPath, size_t maxLength)
} else {
char buff[2*_MAX_PATH];
- assert(getcwd(buff, _MAX_PATH) != NULL);
+ p= getcwd(buff, _MAX_PATH);
+ assert(p);
strcat(buff,"/");
strcat(buff, relPath);
strncpy(absPath, buff, maxLength);
diff --git a/storage/connect/plgcnx.h b/storage/connect/plgcnx.h
index fe3997d1986..a1208f9b885 100644
--- a/storage/connect/plgcnx.h
+++ b/storage/connect/plgcnx.h
@@ -62,146 +62,6 @@ enum INFO {INDX_RC, /* Index of PlugDB return code field */
INDX_SIZE, /* Index of returned data size field */
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 */
/* ------------------------- End of Plgcnx.h ---------------------------- */
diff --git a/storage/connect/plgdbsem.h b/storage/connect/plgdbsem.h
index e251ded13df..48acd4bf409 100644
--- a/storage/connect/plgdbsem.h
+++ b/storage/connect/plgdbsem.h
@@ -26,7 +26,6 @@
enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */
TYPE_COLUMN = 51, /* Column Name/Qualifier Block */
-// TYPE_OPVAL = 52, /* Operator value (OPVAL) */
TYPE_TDB = 53, /* Table Description Block */
TYPE_COLBLK = 54, /* Column Description Block */
TYPE_PSZ = 64, /* Pointer to String ended by 0 */
@@ -34,8 +33,6 @@ enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */
TYPE_XOBJECT = 69, /* Extended DB object */
TYPE_COLCRT = 71, /* Column creation block */
TYPE_CONST = 72, /* Constant */
-// TYPE_INDEXDEF = 73, /* Index definition block */
-// TYPE_OPER = 74, /* Operator block (OPER) */
/*-------------------- type tokenized string --------------------------*/
TYPE_DATE = 8, /* Timestamp */
@@ -144,21 +141,19 @@ enum RECFM {RECFM_NAF = -2, /* Not a file */
RECFM_PLG = 5, /* Table accessed via PLGconn */
RECFM_DBF = 6}; /* DBase formatted file */
-#if 0
enum MISC {DB_TABNO = 1, /* DB routines in Utility Table */
MAX_MULT_KEY = 10, /* Max multiple key number */
NAM_LEN = 128, /* Length of col and tab names */
ARRAY_SIZE = 50, /* Default array block size */
- MAXRES = 500, /* Default maximum result lines */
- MAXLIN = 10000, /* Default maximum data lines */
+// MAXRES = 500, /* Default maximum result lines */
+// MAXLIN = 10000, /* Default maximum data lines */
MAXBMP = 32}; /* Default XDB2 max bitmap size */
+#if 0
enum ALGMOD {AMOD_AUTO = 0, /* PLG chooses best algorithm */
AMOD_SQL = 1, /* Use SQL algorithm */
AMOD_QRY = 2}; /* Use QUERY algorithm */
-#else // !0
-#define NAM_LEN 128
-#endif // !0
+#endif // 0
enum MODE {MODE_ERROR = -1, /* Invalid mode */
MODE_ANY = 0, /* Unspecified mode */
@@ -342,9 +337,7 @@ typedef class XTAB *PTABLE;
typedef class COLUMN *PCOLUMN;
typedef class XOBJECT *PXOB;
typedef class COLBLK *PCOL;
-typedef class TBX *PTBX;
typedef class TDB *PTDB;
-typedef void *PSQL; // Not used
typedef class TDBASE *PTDBASE;
typedef class TDBDOS *PTDBDOS;
typedef class TDBFIX *PTDBFIX;
@@ -413,41 +406,25 @@ typedef struct _mblock { /* Memory block */
/* The QUERY application User Block. */
/***********************************************************************/
typedef struct { /* User application block */
-//void *Act2; /* RePoint to activity block */
-//short LineLen; /* Current output line len */
NAME Name; /* User application name */
-//NAME Password; /* User application password */
-//PSZ UserFile; /* User application filename */
char Server[17]; /* Server name */
char DBName[17]; /* Current database name */
-//char Host[65]; /* Caller's host name */
-//char User[17]; /* Caller's user name */
-//uint Granted; /* Grant bitmap */
PCATLG Catalog; /* To CATALOG class */
PQRYRES Result; /* To query result blocks */
PFBLOCK Openlist; /* To file/map open list */
PMBLOCK Memlist; /* To memory block list */
PXUSED Xlist; /* To used index list */
-//int Maxres; /* Result Max nb of lines */
-//int Maxtmp; /* Intermediate tables Maxres */
-//int Maxlin; /* Query Max nb of data lines */
-//int Maxbmp; /* Maximum XDB2 bitmap size */
int Check; /* General level of checking */
int Numlines; /* Number of lines involved */
-//ALGMOD AlgChoice; /* Choice of algorithm mode */
-//AREADEF DescArea; /* Table desc. area size */
USETEMP UseTemp; /* Use temporary file */
-//int Curtype; /* 0: static else: dynamic */
int Vtdbno; /* Used for TDB number setting */
bool Remote; /* true: if remotely called */
-//bool NotFinal; /* true: for intermediate table */
bool Proginfo; /* true: return progress info */
bool Subcor; /* Used for Progress info */
size_t ProgMax; /* Used for Progress info */
size_t ProgCur; /* Used for Progress info */
size_t ProgSav; /* Used for Progress info */
LPCSTR Step; /* Execution step name */
-//char Work[_MAX_PATH]; /* Local work path */
} DBUSERBLK, *PDBUSER;
/***********************************************************************/
@@ -535,6 +512,7 @@ typedef struct _colres {
int Prec; /* Precision */
int Flag; /* Flag option value */
XFLD Fld; /* Type of field info */
+ char Var; /* Type added information */
} COLRES;
#if defined(WIN32) && !defined(NOEX)
@@ -578,9 +556,6 @@ DllExport void PlgDBfree(MBLOCK&);
DllExport void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size);
DllExport void *PlgDBalloc(PGLOBAL, void *, MBLOCK&);
DllExport void *PlgDBrealloc(PGLOBAL, void *, MBLOCK&, size_t);
-//lExport PSZ GetIniString(PGLOBAL, void *, LPCSTR, LPCSTR, LPCSTR, LPCSTR);
-//lExport int GetIniSize(char *, char *, char *, char *);
-//lExport bool WritePrivateProfileInt(LPCSTR, LPCSTR, int, LPCSTR);
DllExport void NewPointer(PTABS, void *, void *);
DllExport char *GetIni(int n= 0);
DllExport void SetTrc(void);
diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp
index c3c74463271..2058ae0a362 100644
--- a/storage/connect/plgdbutl.cpp
+++ b/storage/connect/plgdbutl.cpp
@@ -80,9 +80,6 @@ extern pthread_mutex_t parmut;
#endif // !WIN32
#endif // THREAD
-#define PLGINI "plugdb.ini" /* Configuration settings file */
-#define PLGXINI "plgcnx.ini" /* Configuration settings file */
-
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
@@ -90,27 +87,13 @@ bool Initdone = false;
bool plugin = false; // True when called by the XDB plugin handler
extern "C" {
-extern char connectini[];
- char plgxini[_MAX_PATH] = PLGXINI;
- char plgini[_MAX_PATH] = PLGINI;
-#if defined(WIN32)
- char nmfile[_MAX_PATH] = ".\\Log\\plugdb.out";
- char pdebug[_MAX_PATH] = ".\\Log\\plgthread.out";
-
- HINSTANCE s_hModule; // Saved module handle
-#else // !WIN32
- char nmfile[_MAX_PATH] = "./Log/plugdb.out";
- char pdebug[_MAX_PATH] = "./Log/plgthread.out";
-#endif // !WIN32
-
#if defined(XMSG)
char msglang[16] = "ENGLISH"; // Default language
#endif
+extern int trace;
+extern char version[];
} // extern "C"
-extern "C" int trace;
-extern "C" char version[];
-
// The debug trace used by the main thread
FILE *pfile = NULL;
@@ -219,27 +202,6 @@ int global_open(GLOBAL *g, int msgid, const char *path, int flags, int mode)
return h;
}
-
-/**************************************************************************/
-/* Utility for external callers (such as XDB) */
-/**************************************************************************/
-DllExport char *GetIni(int n)
- {
- switch (n) {
- case 1: return plgxini; break;
- case 2: return nmfile; break;
- case 3: return pdebug; break;
- case 4: return version; break;
-#if defined(XMSG)
- case 5: return msglang; break;
-#endif // XMSG
- case 6: return connectini; break;
-// default: return plgini;
- } // endswitch GetIni
-
- return plgini;
- } // end of GetIni
-
DllExport void SetTrc(void)
{
// If tracing is on, debug must be initialized.
@@ -427,138 +389,9 @@ char *PlgGetDataPath(PGLOBAL g)
{
PCATLG cat = PlgGetCatalog(g, false);
-//if (!cat)
-// return GetIniString(g, NULL, "DataBase", "DataPath", "", plgini);
-
return (cat) ? cat->GetDataPath() : NULL;
} // end of PlgGetDataPath
-#if 0
-/***********************************************************************/
-/* PlgGetXdbPath: sets the fully qualified file name of a database */
-/* description file in lgn and the new datapath in dp. */
-/* New database description file is a Configuration Settings file */
-/* that will be used and updated in case of DB modifications such */
-/* as Insert into a VCT file. Look for it and use it if found. */
-/* By default the configuration file is DataPath\name.xdb but the */
-/* configuration file name may also be specified in Plugdb.ini. */
-/***********************************************************************/
-bool PlgSetXdbPath(PGLOBAL g, PSZ dbname, PSZ dbpath,
- char *lgn, int lgsize,
- char *path, int psize)
- {
- char *dp, datapath[_MAX_PATH], ft[_MAX_EXT] = ".xdb";
- int n;
-
- if (path) {
- dp = path;
- n = psize;
- } else {
- dp = datapath;
- n = sizeof(datapath);
- } // endif path
-
- GetPrivateProfileString("DataBase", "DataPath", "", dp, n, plgini);
-
- if (trace)
- htrc("PlgSetXdbPath: path=%s\n", dp);
-
- if (dbpath) {
- char fn[_MAX_FNAME];
-
- strcpy(lgn, dbpath);
- _splitpath(lgn, NULL, NULL, fn, NULL);
-
- if (!*fn) // Old style use command
- strcat(lgn, dbname);
-
- _splitpath(lgn, NULL, NULL, dbname, NULL); // Extract DB name
- } else if (strcspn(dbname, ":/\\.") < strlen(dbname)) {
- // dbname name contains the path name of the XDB file
- strcpy(lgn, dbname);
- _splitpath(lgn, NULL, NULL, dbname, NULL); // Extract DB name
- } else
- /*******************************************************************/
- /* New database description file is a Configuration Settings file */
- /* that will be used and updated in case of DB modifications such */
- /* as Insert into a VCT file. Look for it and use it if found. */
- /* By default the configuration file is DataPath\name.xdb but the */
- /* configuration file name may also be specified in Plugdb.ini. */
- /*******************************************************************/
- GetPrivateProfileString("DBnames", dbname, "", lgn, lgsize, plgini);
-
- if (*lgn) {
-#if !defined(UNIX)
- char drive[_MAX_DRIVE];
- char direc[_MAX_DIR];
-#endif
- char fname[_MAX_FNAME];
- char ftype[_MAX_EXT];
-
- _splitpath(lgn, NULL, NULL, fname, ftype);
-
- if (!*ftype)
- strcat(lgn, ft);
- else if (!stricmp(ftype, ".var")) {
- strcpy(g->Message, MSG(NO_MORE_VAR));
- return true;
- } // endif ftype
-
- // Given DB description path may be relative to data path
- PlugSetPath(lgn, lgn, dp);
-
- // New data path is the path of the configuration setting file
-#if !defined(UNIX)
- _splitpath(lgn, drive, direc, NULL, NULL);
- _makepath(dp, drive, direc, "", "");
-#else
-//#error This must be tested for trailing slash
- _splitpath(lgn, NULL, dp, NULL, NULL);
-#endif
- } else {
- // Try dbname[.ext] in the current directory
- strcpy(lgn, dbname);
-
- if (!strchr(dbname, '.'))
- strcat(lgn, ft);
-
- PlugSetPath(lgn, lgn, dp);
- } // endif lgn
-
- if (trace)
- htrc("PlgSetXdbPath: new DB description file=%s\n", lgn);
-
- return false;
- } // end of PlgSetXdbPath
-#endif // 0
-
-/***********************************************************************/
-/* Extract from a path name the required component. */
-/* This function assumes there is enough space in the buffer. */
-/***********************************************************************/
-#if 0
-char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
- {
- char *drive = NULL, *direc = NULL, *fname = NULL, *ftype = NULL;
-
- switch (op) { // Determine which part to extract
-#if !defined(UNIX)
- case OP_FDISK: drive = pBuff; break;
-#endif // !UNIX
- case OP_FPATH: direc = pBuff; break;
- case OP_FNAME: fname = pBuff; break;
- case OP_FTYPE: ftype = pBuff; break;
- default:
- sprintf(g->Message, MSG(INVALID_OPER), op, "ExtractFromPath");
- return NULL;
- } // endswitch op
-
- // Now do the extraction
- _splitpath(FileName, drive, direc, fname, ftype);
- return pBuff;
- } // end of PlgExtractFromPath
-#endif
-
/***********************************************************************/
/* Check the occurence and matching of a pattern against a string. */
/* Because this function is only used for catalog name checking, */
@@ -853,7 +686,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6])
else // assume standard MySQL date format
fmt = "%4d-%2d-%2d %2d:%2d:%2d";
- if (trace)
+ if (trace > 1)
htrc("ExtractDate: dts=%s fmt=%s defy=%d\n", dts, fmt, defy);
// Set default values for time only use
@@ -935,7 +768,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6])
} // endfor i
- if (trace)
+ if (trace > 1)
htrc("numval=%d val=(%d,%d,%d,%d,%d,%d)\n",
numval, val[0], val[1], val[2], val[3], val[4], val[5]);
@@ -1468,19 +1301,17 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */
pph = (PPOOLHEADER)memp;
-#if defined(DEBTRACE)
- htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n",
- memp, size, pph->To_Free, pph->FreeBlk);
-#endif
+ if (trace > 1)
+ htrc("PlgDBSubAlloc: memp=%p size=%d used=%d free=%d\n",
+ memp, size, pph->To_Free, pph->FreeBlk);
if ((uint)size > pph->FreeBlk) { /* Not enough memory left in pool */
sprintf(g->Message,
"Not enough memory in Work area for request of %d (used=%d free=%d)",
(int) size, pph->To_Free, pph->FreeBlk);
-#if defined(DEBTRACE)
- htrc("%s\n", g->Message);
-#endif
+ if (trace)
+ htrc("%s\n", g->Message);
return NULL;
} // endif size
@@ -1491,10 +1322,11 @@ void *PlgDBSubAlloc(PGLOBAL g, void *memp, size_t size)
memp = MakePtr(memp, pph->To_Free); // Points to suballocated block
pph->To_Free += size; // New offset of pool free block
pph->FreeBlk -= size; // New size of pool free block
-#if defined(DEBTRACE)
- htrc("Done memp=%p used=%d free=%d\n",
- memp, pph->To_Free, pph->FreeBlk);
-#endif
+
+ if (trace > 1)
+ htrc("Done memp=%p used=%d free=%d\n",
+ memp, pph->To_Free, pph->FreeBlk);
+
return (memp);
} // end of PlgDBSubAlloc
diff --git a/storage/connect/plugutil.c b/storage/connect/plugutil.c
index 91b850022fb..489b0555a79 100644
--- a/storage/connect/plugutil.c
+++ b/storage/connect/plugutil.c
@@ -37,8 +37,6 @@
/* IBM Linker */
/* */
/***********************************************************************/
-//efine DEBTRACE 3
-//efine DEBTRACE2
/***********************************************************************/
/* */
@@ -83,7 +81,6 @@
extern HINSTANCE s_hModule; /* Saved module handle */
#endif // WIN32
-extern char plgini[];
extern int trace;
#if defined(XMSG)
diff --git a/storage/connect/preparse.h b/storage/connect/preparse.h
index 8b57d487736..2892a958bdd 100644
--- a/storage/connect/preparse.h
+++ b/storage/connect/preparse.h
@@ -4,31 +4,6 @@
#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. */
/***********************************************************************/
typedef struct _datpar {
@@ -49,8 +24,6 @@ typedef struct _datpar {
extern "C" {
#endif
-int sqlflex(PPREP pp);
-int sqpflex(PPREP pp);
int fmdflex(PDTP pp);
#ifdef __cplusplus
diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp
index 81c9bf9faca..24ea7dfc5cf 100644
--- a/storage/connect/reldef.cpp
+++ b/storage/connect/reldef.cpp
@@ -47,10 +47,6 @@
#include "valblk.h"
#include "tabmul.h"
-/***********************************************************************/
-/* External static variables. */
-/***********************************************************************/
-//extern "C" char plgini[];
/* --------------------------- Class RELDEF -------------------------- */
@@ -204,6 +200,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
return xdefp;
} // end of GetXdef
+#if 0
/***********************************************************************/
/* DeleteTableFile: Delete an OEM table file if applicable. */
/***********************************************************************/
@@ -214,6 +211,7 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g)
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
} // end of DeleteTableFile
+#endif // 0
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
@@ -286,7 +284,6 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) ZIPFAM(defp);
else {
strcpy(g->Message, "Compress 2 not supported yet");
-// txfp = new(g) ZLBFAM(defp);
return NULL;
} // endelse
#else // !ZIP_SUPPORT
@@ -341,7 +338,6 @@ COLCRT::COLCRT(PSZ name)
Precision = -1;
Key = -1;
Scale = -1;
- Opt = -1;
DataType = '*';
} // end of COLCRT constructor for table creation
@@ -357,7 +353,6 @@ COLCRT::COLCRT(void)
Precision = 0;
Key = 0;
Scale = 0;
- Opt = 0;
DataType = '*';
} // end of COLCRT constructor for table & view definition
@@ -399,9 +394,7 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
Precision = cfp->Precision;
Scale = cfp->Scale;
Long = cfp->Length;
- Opt = cfp->Opt;
Key = cfp->Key;
-// Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) {
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h
index a877c8ee915..e0c37690a86 100644
--- a/storage/connect/reldef.h
+++ b/storage/connect/reldef.h
@@ -38,7 +38,6 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
void SetCat(PCATLG cat) { Cat=cat; }
// Methods
- virtual bool DeleteTableFile(PGLOBAL g) {return true;}
virtual bool Indexable(void) {return false;}
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0;
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0;
@@ -116,7 +115,6 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */
virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
// Methods
- virtual bool DeleteTableFile(PGLOBAL g);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
@@ -147,7 +145,6 @@ class DllExport COLCRT : public BLOCK { /* Column description block
PSZ GetName(void) {return Name;}
PSZ GetDecode(void) {return Decode;}
PSZ GetFmt(void) {return Fmt;}
- int GetOpt(void) {return Opt;}
int GetLong(void) {return Long;}
int GetPrecision(void) {return Precision;}
int GetOffset(void) {return Offset;}
@@ -164,7 +161,6 @@ class DllExport COLCRT : public BLOCK { /* Column description block
int Key; /* Key (greater than 1 if multiple) */
int Precision; /* Logical column length */
int Scale; /* Decimals for float/decimal values */
- int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */
char DataType; /* Internal data type (C, N, F, T) */
}; // end of COLCRT
diff --git a/storage/connect/tabcol.cpp b/storage/connect/tabcol.cpp
index efd863a88cf..96ec4f45861 100644
--- a/storage/connect/tabcol.cpp
+++ b/storage/connect/tabcol.cpp
@@ -22,6 +22,8 @@
#include "xtable.h"
#include "tabcol.h"
+extern "C" int trace;
+
/***********************************************************************/
/* XTAB public constructor. */
/***********************************************************************/
@@ -33,9 +35,9 @@ XTAB::XTAB(LPCSTR name, LPCSTR srcdef) : Name(name)
Schema = NULL;
Qualifier = NULL;
-#ifdef DEBTRACE
- htrc(" making new TABLE %s %s\n", Name, Srcdef);
-#endif
+ if (trace)
+ htrc("XTAB: making new TABLE %s %s\n", Name, Srcdef);
+
} // end of XTAB constructor
/***********************************************************************/
@@ -49,9 +51,9 @@ XTAB::XTAB(PTABLE tp) : Name(tp->Name)
Schema = tp->Schema;
Qualifier = tp->Qualifier;
-#ifdef DEBTRACE
- htrc(" making copy TABLE %s %s\n", Name, Srcdef);
-#endif
+ if (trace)
+ htrc(" making copy TABLE %s %s\n", Name, Srcdef);
+
} // end of XTAB constructor
/***********************************************************************/
@@ -61,9 +63,8 @@ PTABLE XTAB::Link(PTABLE tab2)
{
PTABLE tabp;
-#ifdef DEBTRACE
- htrc("Linking tables %s... to %s\n", Name, tab2->Name);
-#endif
+ if (trace)
+ htrc("Linking tables %s... to %s\n", Name, tab2->Name);
for (tabp = this; tabp->Next; tabp = tabp->Next) ;
@@ -118,9 +119,9 @@ COLUMN::COLUMN(LPCSTR name) : Name(name)
To_Col = NULL;
Qualifier = NULL;
-#ifdef DEBTRACE
- htrc(" making new COLUMN %s\n", Name);
-#endif
+ if (trace)
+ htrc(" making new COLUMN %s\n", Name);
+
} // end of COLUMN constructor
/***********************************************************************/
diff --git a/storage/connect/tabcol.h b/storage/connect/tabcol.h
index fe643e075c3..fdee653207e 100644
--- a/storage/connect/tabcol.h
+++ b/storage/connect/tabcol.h
@@ -85,8 +85,6 @@ class DllExport COLUMN: public XOBJECT { // Column Name/Qualifier block.
virtual bool Compare(PXOB) {assert(false); return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual bool Eval(PGLOBAL) {assert(false); return true;}
- virtual int CheckSpcCol(PTDB, int) {assert(false); return 2;}
- virtual bool CheckSort(PTDB) {assert(false); return false;}
private:
// Members
diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp
index 15215dc0f01..b56a392ba75 100644
--- a/storage/connect/tabdos.cpp
+++ b/storage/connect/tabdos.cpp
@@ -1,11 +1,11 @@
/************* TabDos C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABDOS */
/* ------------- */
-/* Version 4.8 */
+/* Version 4.9 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -58,27 +58,12 @@
#include "tabfix.h"
#include "tabmul.h"
-#define PLGINI "plugdb.ini" // Configuration settings file
-
-#if defined(UNIX)
-#define _fileno fileno
-#define _O_RDONLY O_RDONLY
-#endif
-
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
int num_read, num_there, num_eq[2]; // Statistics
-extern "C" char plgini[_MAX_PATH];
extern "C" int trace;
-/***********************************************************************/
-/* Min and Max blocks contains zero ended fields (blank = false). */
-/* No conversion of block values (check = true). */
-/***********************************************************************/
-PVBLK AllocValBlock(PGLOBAL, void *, int, int, int len = 0, int prec = 0,
- bool check = true, bool blank = false, bool un = false);
-
/* --------------------------- Class DOSDEF -------------------------- */
/***********************************************************************/
@@ -96,7 +81,6 @@ DOSDEF::DOSDEF(void)
Huge = false;
Accept = false;
Eof = false;
- To_Pos = NULL;
Compressed = 0;
Lrecl = 0;
AvgLen = 0;
@@ -110,6 +94,50 @@ DOSDEF::DOSDEF(void)
} // end of DOSDEF constructor
/***********************************************************************/
+/* DefineAM: define specific AM block values from XDB file. */
+/***********************************************************************/
+bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
+ {
+ char buf[8];
+ bool map = (am && (*am == 'M' || *am == 'm'));
+ LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F"
+ : (am && (*am == 'B' || *am == 'b')) ? "B"
+ : (am && !stricmp(am, "DBF")) ? "D" : "V";
+
+ Desc = Fn = Cat->GetStringCatInfo(g, "Filename", NULL);
+ Ofn = Cat->GetStringCatInfo(g, "Optname", Fn);
+ Cat->GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
+ Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
+ (toupper(*buf) == 'B') ? RECFM_BIN :
+ (toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR;
+ Lrecl = Cat->GetIntCatInfo("Lrecl", 0);
+
+ if (Recfm != RECFM_DBF)
+ Compressed = Cat->GetIntCatInfo("Compressed", 0);
+
+ Mapped = Cat->GetBoolCatInfo("Mapped", map);
+ Block = Cat->GetIntCatInfo("Blocks", 0);
+ Last = Cat->GetIntCatInfo("Last", 0);
+ Ending = Cat->GetIntCatInfo("Ending", CRLF);
+
+ if (Recfm == RECFM_FIX || Recfm == RECFM_BIN) {
+ Huge = Cat->GetBoolCatInfo("Huge", Cat->GetDefHuge());
+ Padded = Cat->GetBoolCatInfo("Padded", false);
+ Blksize = Cat->GetIntCatInfo("Blksize", 0);
+ Eof = (Cat->GetIntCatInfo("EOF", 0) != 0);
+ } else if (Recfm == RECFM_DBF) {
+ Maxerr = Cat->GetIntCatInfo("Maxerr", 0);
+ Accept = (Cat->GetIntCatInfo("Accept", 0) != 0);
+ ReadMode = Cat->GetIntCatInfo("Readmode", 0);
+ } else // (Recfm == RECFM_VAR)
+ AvgLen = Cat->GetIntCatInfo("Avglen", 0);
+
+ // Ignore wrong Index definitions for catalog commands
+ return (Cat->GetIndexInfo(g, this) /*&& !Cat->GetCatFnc()*/);
+ } // end of DefineAM
+
+#if 0
+/***********************************************************************/
/* DeleteTableFile: Delete DOS/UNIX table files using platform API. */
/* If the table file is protected (declared as read/only) we still */
/* erase the the eventual optimize and index files but return true. */
@@ -147,6 +175,7 @@ bool DOSDEF::Erase(char *filename)
return rc; // Return true if error
} // end of Erase
+#endif // 0
/***********************************************************************/
/* DeleteIndexFile: Delete DOS/UNIX index file(s) using platform API. */
@@ -222,49 +251,6 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
} // end of DeleteIndexFile
/***********************************************************************/
-/* DefineAM: define specific AM block values from XDB file. */
-/***********************************************************************/
-bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
- {
- char buf[8];
- bool map = (am && (*am == 'M' || *am == 'm'));
- LPCSTR dfm = (am && (*am == 'F' || *am == 'f')) ? "F"
- : (am && (*am == 'B' || *am == 'b')) ? "B"
- : (am && !stricmp(am, "DBF")) ? "D" : "V";
-
- Desc = Fn = Cat->GetStringCatInfo(g, "Filename", NULL);
- Ofn = Cat->GetStringCatInfo(g, "Optname", Fn);
- Cat->GetCharCatInfo("Recfm", (PSZ)dfm, buf, sizeof(buf));
- Recfm = (toupper(*buf) == 'F') ? RECFM_FIX :
- (toupper(*buf) == 'B') ? RECFM_BIN :
- (toupper(*buf) == 'D') ? RECFM_DBF : RECFM_VAR;
- Lrecl = Cat->GetIntCatInfo("Lrecl", 0);
-
- if (Recfm != RECFM_DBF)
- Compressed = Cat->GetIntCatInfo("Compressed", 0);
-
- Mapped = Cat->GetBoolCatInfo("Mapped", map);
- Block = Cat->GetIntCatInfo("Blocks", 0);
- Last = Cat->GetIntCatInfo("Last", 0);
- Ending = Cat->GetIntCatInfo("Ending", CRLF);
-
- if (Recfm == RECFM_FIX || Recfm == RECFM_BIN) {
- Huge = Cat->GetBoolCatInfo("Huge", Cat->GetDefHuge());
- Padded = Cat->GetBoolCatInfo("Padded", false);
- Blksize = Cat->GetIntCatInfo("Blksize", 0);
- Eof = (Cat->GetIntCatInfo("EOF", 0) != 0);
- } else if (Recfm == RECFM_DBF) {
- Maxerr = Cat->GetIntCatInfo("Maxerr", 0);
- Accept = (Cat->GetIntCatInfo("Accept", 0) != 0);
- ReadMode = Cat->GetIntCatInfo("Readmode", 0);
- } else // (Recfm == RECFM_VAR)
- AvgLen = Cat->GetIntCatInfo("Avglen", 0);
-
- // Ignore wrong Index definitions for catalog commands
- return (Cat->GetIndexInfo(g, this) /*&& !Cat->GetCatFnc()*/);
- } // end of DefineAM
-
-/***********************************************************************/
/* InvalidateIndex: mark all indexes as invalid. */
/***********************************************************************/
bool DOSDEF::InvalidateIndex(PGLOBAL g)
@@ -311,28 +297,31 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) BGXFAM(this);
else if (map)
txfp = new(g) MPXFAM(this);
+ else if (Compressed) {
#if defined(ZIP_SUPPORT)
- else if (Compressed)
txfp = new(g) ZIXFAM(this);
-#endif // ZIP_SUPPORT
- else
+#else // !ZIP_SUPPORT
+ sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
+ return NULL;
+#endif // !ZIP_SUPPORT
+ } else
txfp = new(g) FIXFAM(this);
tdbp = new(g) TDBFIX(this, txfp);
} else {
-#if defined(ZIP_SUPPORT)
if (Compressed) {
+#if defined(ZIP_SUPPORT)
if (Compressed == 1)
txfp = new(g) ZIPFAM(this);
else {
strcpy(g->Message, "Compress 2 not supported yet");
-// txfp = new(g) ZLBFAM(defp);
return NULL;
} // endelse
-
- } else
-#endif // ZIP_SUPPORT
- if (map)
+#else // !ZIP_SUPPORT
+ sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "ZIP");
+ return NULL;
+#endif // !ZIP_SUPPORT
+ } else if (map)
txfp = new(g) MAPFAM(this);
else
txfp = new(g) DOSFAM(this);
@@ -730,10 +719,17 @@ bool TDBDOS::OpenDB(PGLOBAL g)
/*******************************************************************/
/* Table already open, just replace it at its beginning. */
/*******************************************************************/
- Txfp->Rewind(); // see comment in Work.log
+ if (!To_Kindex) {
+ Txfp->Rewind(); // see comment in Work.log
- if (SkipHeader(g))
- return true;
+ if (SkipHeader(g))
+ return TRUE;
+
+ } else
+ /*****************************************************************/
+ /* Table is to be accessed through a sorted index table. */
+ /*****************************************************************/
+ To_Kindex->Reset();
return false;
} // endif use
@@ -927,7 +923,6 @@ DOSCOL::DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am)
Deplac = cdp->GetOffset();
Long = cdp->GetLong();
To_Val = NULL;
-
OldVal = NULL; // Currently used only in MinMax
Ldz = false;
Nod = false;
@@ -972,28 +967,6 @@ DOSCOL::DOSCOL(DOSCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp)
} // end of DOSCOL copy constructor
/***********************************************************************/
-/* VarSize: This function tells UpdateDB whether or not the block */
-/* optimization file must be redone if this column is updated, even */
-/* it is not sorted or clustered. This applies to the last column of */
-/* a variable length table that is blocked, because if it is updated */
-/* using a temporary file, the block size may be modified. */
-/***********************************************************************/
-bool DOSCOL::VarSize(void)
- {
- PTDBDOS tdbp = (PTDBDOS)To_Tdb;
- PTXF txfp = tdbp->Txfp;
-
- if (Cdp && !Cdp->GetNext() // Must be the last column
- && tdbp->Ftype == RECFM_VAR // of a DOS variable length
- && txfp->Blocked // blocked table
- && txfp->GetUseTemp()) // using a temporary file.
- return true;
- else
- return false;
-
- } // end VarSize
-
-/***********************************************************************/
/* SetBuffer: prepare a column block for write operation. */
/***********************************************************************/
bool DOSCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
diff --git a/storage/connect/tabdos.h b/storage/connect/tabdos.h
index 5f67ffad92f..a213dd142bf 100644
--- a/storage/connect/tabdos.h
+++ b/storage/connect/tabdos.h
@@ -1,7 +1,7 @@
/*************** TabDos H Declares Source Code File (.H) ***************/
-/* Name: TABDOS.H Version 3.2 */
+/* Name: TABDOS.H Version 3.3 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
/* */
/* This file contains the DOS classes declares. */
/***********************************************************************/
@@ -34,6 +34,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
virtual const char *GetType(void) {return "DOS";}
virtual PIXDEF GetIndx(void) {return To_Indx;}
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;}
+ virtual bool IsHuge(void) {return Huge;}
PSZ GetFn(void) {return Fn;}
PSZ GetOfn(void) {return Ofn;}
void SetBlock(int block) {Block = block;}
@@ -46,11 +47,8 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
bool GetEof(void) {return Eof;}
int GetBlksize(void) {return Blksize;}
int GetEnding(void) {return Ending;}
- int *GetTo_Pos(void) {return To_Pos;}
- virtual bool IsHuge(void) {return Huge;}
// Methods
- virtual bool DeleteTableFile(PGLOBAL g);
virtual bool Indexable(void) {return Compressed != 1;}
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
@@ -58,7 +56,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
bool InvalidateIndex(PGLOBAL g);
protected:
- virtual bool Erase(char *filename);
+//virtual bool Erase(char *filename);
// Members
PSZ Fn; /* Path/Name of corresponding file */
@@ -70,7 +68,6 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
bool Huge; /* true for files larger than 2GB */
bool Accept; /* true if wrong lines are accepted (DBF)*/
bool Eof; /* true if an EOF (0xA) character exists */
- int *To_Pos; /* To array of block starting positions */
int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */
int Lrecl; /* Size of biggest record */
int AvgLen; /* Average size of records */
@@ -88,14 +85,12 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
/* The last column (and record) is of variable length. */
/***********************************************************************/
class DllExport TDBDOS : public TDBASE {
-//friend class KINDEX;
friend class XINDEX;
friend class DOSCOL;
friend class MAPCOL;
friend class TXTFAM;
friend class DOSFAM;
friend class VCTCOL;
-//friend class TDBMUL;
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
public:
// Constructors
@@ -111,7 +106,6 @@ class DllExport TDBDOS : public TDBASE {
inline void IncLine(int inc) {To_Line += inc;}
inline bool IsRead(void) {return Txfp->IsRead;}
inline PXOB *GetLink(void) {return To_Link;}
-//inline PCOL *GetKeyCol(void) {return To_Key_Col;}
// Implementation
virtual AMT GetAmType(void) {return Txfp->GetAmType();}
@@ -127,15 +121,8 @@ class DllExport TDBDOS : public TDBASE {
virtual PTDB CopyOne(PTABS t);
virtual void ResetDB(void) {Txfp->Reset();}
virtual bool IsUsingTemp(PGLOBAL g);
-//virtual bool NeedIndexing(PGLOBAL g);
virtual void ResetSize(void) {MaxSize = Cardinal = -1;}
virtual int ResetTableOpt(PGLOBAL g, bool dox);
-//virtual int MakeBlockValues(PGLOBAL g);
-//virtual bool SaveBlockValues(PGLOBAL g);
-//virtual bool GetBlockValues(PGLOBAL g);
-//virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp);
-//virtual PBX InitBlockIndex(PGLOBAL g);
-//virtual int TestBlock(PGLOBAL g);
virtual void PrintAM(FILE *f, char *m);
// Database routines
@@ -162,25 +149,16 @@ class DllExport TDBDOS : public TDBASE {
virtual int EstimatedLength(PGLOBAL g);
// Optimization routines
-// void ResetBlockFilter(PGLOBAL g);
- int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
-// bool GetDistinctColumnValues(PGLOBAL g, int nrec);
+ int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
protected:
-// PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv);
-
// Members
PTXF Txfp; // To the File access method class
-//PBX To_BlkIdx; // To index test block
-//PBF To_BlkFil; // To evaluation block filter
-//PFIL SavFil; // Saved hidden filter
char *To_Line; // Points to current processed line
int Cardinal; // Table Cardinality
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
int Lrecl; // Logical Record Length
int AvgLen; // Logical Record Average Length
-//int Xeval; // BlockTest return value
-//int Beval; // BlockEval return value
}; // end of class TDBDOS
/***********************************************************************/
@@ -198,50 +176,27 @@ class DllExport DOSCOL : public COLBLK {
// Implementation
virtual int GetAmType(void) {return TYPE_AM_DOS;}
-//virtual int GetClustered(void) {return Clustered;}
-//virtual int IsClustered(void) {return (Clustered &&
-// ((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());}
-//virtual int IsSorted(void) {return Sorted;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
-//virtual PVBLK GetMin(void) {return Min;}
-//virtual PVBLK GetMax(void) {return Max;}
-//virtual int GetNdv(void) {return Ndv;}
-//virtual int GetNbm(void) {return Nbm;}
-//virtual PVBLK GetBmap(void) {return Bmap;}
-//virtual PVBLK GetDval(void) {return Dval;}
// Methods
- virtual bool VarSize(void);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint);
protected:
-//virtual bool SetMinMax(PGLOBAL g);
-//virtual bool SetBitMap(PGLOBAL g);
-// bool CheckSorted(PGLOBAL g);
-// bool AddDistinctValue(PGLOBAL g);
// Default constructor not to be used
DOSCOL(void) {}
// Members
-//PVBLK Min; // Array of block min values
-//PVBLK Max; // Array of block max values
-//PVBLK Bmap; // Array of block bitmap values
-//PVBLK Dval; // Array of column distinct values
PVAL To_Val; // To value used for Update/Insert
PVAL OldVal; // The previous value of the object.
char *Buf; // Buffer used in write operations
bool Ldz; // True if field contains leading zeros
bool Nod; // True if no decimal point
int Dcm; // Last Dcm digits are decimals
-//int Clustered; // 0:No 1:Yes
-//int Sorted; // 0:No 1:Asc (2:Desc - NIY)
int Deplac; // Offset in dos_buf
-//int Ndv; // Number of distinct values
-//int Nbm; // Number of uint in bitmap
}; // end of class DOSCOL
#endif // __TABDOS_H
diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp
index 99063e86b57..cda08b7e3a6 100644
--- a/storage/connect/tabfix.cpp
+++ b/storage/connect/tabfix.cpp
@@ -1,11 +1,11 @@
/************* TabFix C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABFIX */
/* ------------- */
-/* Version 4.8 */
+/* Version 4.9 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp
index 9a121b9ab9a..7155c93a363 100644
--- a/storage/connect/tabfmt.cpp
+++ b/storage/connect/tabfmt.cpp
@@ -460,7 +460,6 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) ZIPFAM(this);
else {
strcpy(g->Message, "Compress 2 not supported yet");
-// txfp = new(g) ZLBFAM(defp);
return NULL;
} // endelse
#else // !ZIP_SUPPORT
@@ -1273,25 +1272,6 @@ CSVCOL::CSVCOL(CSVCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
} // end of CSVCOL copy constructor
/***********************************************************************/
-/* VarSize: This function tells UpdateDB whether or not the block */
-/* optimization file must be redone if this column is updated, even */
-/* it is not sorted or clustered. This applies to a blocked table, */
-/* because if it is updated using a temporary file, the block size */
-/* may be modified. */
-/***********************************************************************/
-bool CSVCOL::VarSize(void)
- {
- PTXF txfp = ((PTDBCSV)To_Tdb)->Txfp;
-
- if (txfp->IsBlocked() && txfp->GetUseTemp())
- // Blocked table using a temporary file
- return true;
- else
- return false;
-
- } // end VarSize
-
-/***********************************************************************/
/* ReadColumn: call DOSCOL::ReadColumn after having set the offet */
/* and length of the field to read as calculated by TDBCSV::ReadDB. */
/***********************************************************************/
@@ -1353,7 +1333,7 @@ void CSVCOL::ReadColumn(PGLOBAL g)
/***********************************************************************/
void CSVCOL::WriteColumn(PGLOBAL g)
{
- char *p, buf[32];
+ char *p, buf[64];
int flen;
PTDBCSV tdbp = (PTDBCSV)To_Tdb;
diff --git a/storage/connect/tabfmt.h b/storage/connect/tabfmt.h
index d4a7f4105d6..5efa824c2e2 100644
--- a/storage/connect/tabfmt.h
+++ b/storage/connect/tabfmt.h
@@ -8,7 +8,6 @@
#include "xtable.h" // Base class declares
#include "tabdos.h"
-//pedef struct _tabdesc *PTABD; // For friend setting
typedef class TDBFMT *PTDBFMT;
/***********************************************************************/
@@ -90,8 +89,8 @@ class TDBCSV : public TDBDOS {
int Nerr; // Number of bad records
int Maxerr; // Maximum number of bad records
int Quoted; // Quoting level for quoted fields
- bool Accept; // true if bad lines are accepted
- bool Header; // true if first line contains column headers
+ bool Accept; // true if bad lines are accepted
+ bool Header; // true if first line contains column headers
char Sep; // Separator
char Qot; // Quoting character
}; // end of class TDBCSV
@@ -112,10 +111,8 @@ class CSVCOL : public DOSCOL {
virtual int GetAmType() {return TYPE_AM_CSV;}
// Methods
- virtual bool VarSize(void);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
-// void Print(FILE *, uint);
protected:
// Default constructor not to be used
diff --git a/storage/connect/table.cpp b/storage/connect/table.cpp
index 37035ed752d..9749673ad71 100644
--- a/storage/connect/table.cpp
+++ b/storage/connect/table.cpp
@@ -36,27 +36,6 @@ extern "C" int trace; // The general trace value
void NewPointer(PTABS, void *, void *);
void AddPointer(PTABS, void *);
-/* ---------------------------- class TBX ---------------------------- */
-
-/***********************************************************************/
-/* TBX public constructors. */
-/***********************************************************************/
-TBX::TBX(void)
- {
- Use = USE_NO;
- To_Orig = NULL;
- To_Filter = NULL;
- } // end of TBX constructor
-
-TBX::TBX(PTBX txp)
- {
- Use = txp->Use;
- To_Orig = txp;
- To_Filter = NULL;
- } // end of TBX copy constructor
-
-// Methods
-
/* ---------------------------- class TDB ---------------------------- */
/***********************************************************************/
@@ -64,6 +43,9 @@ TBX::TBX(PTBX txp)
/***********************************************************************/
TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
{
+ Use = USE_NO;
+ To_Orig = NULL;
+ To_CondFil = NULL;
Next = NULL;
Name = (tdp) ? tdp->GetName() : NULL;
To_Table = NULL;
@@ -72,8 +54,11 @@ TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
Mode = MODE_READ;
} // end of TDB standard constructor
-TDB::TDB(PTDB tdbp) : TBX(tdbp), Tdb_No(++Tnum)
+TDB::TDB(PTDB tdbp) : Tdb_No(++Tnum)
{
+ Use = tdbp->Use;
+ To_Orig = tdbp;
+ To_CondFil = NULL;
Next = NULL;
Name = tdbp->Name;
To_Table = tdbp->To_Table;
@@ -82,92 +67,6 @@ TDB::TDB(PTDB tdbp) : TBX(tdbp), Tdb_No(++Tnum)
Mode = tdbp->Mode;
} // end of TDB copy constructor
-/***********************************************************************/
-/* OpenTable: Call AM open routine. */
-/***********************************************************************/
-bool TDB::OpenTable(PGLOBAL g, PSQL sqlp, MODE mode)
- {
- if (trace)
- htrc("Open Tdb_No=%d use=%d type=%d tdb.Mode=%d mode=%d\n",
- Tdb_No, Use, GetAmType(), Mode, mode);
-
- switch (Use) {
- case USE_LIN:
- /*****************************************************************/
- /* If table is read/only, only MODE_READ is allowed. */
- /*****************************************************************/
- if (IsReadOnly() && mode != MODE_READ) {
- strcpy(g->Message, MSG(READ_ONLY));
- return true;
- } // endif ReadOnly
-
- /*****************************************************************/
- /* This could be done in any order. */
- /* Note: for not Read only first table in open in that mode. */
- /*****************************************************************/
- if (Next)
- Next->OpenTable(g, sqlp, MODE_READ);
-
- Mode = mode;
-
- /*****************************************************************/
- /* Pre-opening is done, allocate select buffers now. */
- /*****************************************************************/
- Use = USE_READY;
- break;
-
- case USE_READY:
- /*****************************************************************/
- /* This is to open files in reverse order. */
- /*****************************************************************/
- if (Next)
- if (Next->OpenTable(g, sqlp, mode))
- return true;
-
- /*****************************************************************/
- /* This was moved after filter conversion so filtering can be */
- /* done when making index tables for DOS files. */
- /* Also it was moved after allocating select buffers so some */
- /* data can be pre-read during open to allow storage sorting. */
- /*****************************************************************/
- if (OpenDB(g)) // Do open the table file
- return true;
-
- Use = USE_OPEN;
- break;
-
- case USE_OPEN:
- /*****************************************************************/
- /* Table is already open. */
- /* Call open routine that will just "rewind" the files. */
- /*****************************************************************/
- if (OpenDB(g)) // Rewind the table file
- return true;
-
- break;
-
- default:
- sprintf(g->Message, MSG(TDB_USE_ERROR), Use);
- return true;
- } // endswitch Use
-
- return false;
- } // end of OpenTable
-
-/***********************************************************************/
-/* CloseTable: Close a table of any AM type. */
-/***********************************************************************/
-void TDB::CloseTable(PGLOBAL g)
- {
- if (trace)
- htrc("CloseTable: tdb_no %d use=%d amtype=%d am.Mode=%d\n",
- Tdb_No, Use, GetAmType(), Mode);
-
- CloseDB(g);
- Use = USE_READY; // x'7FFD'
- Mode = MODE_ANY;
- } // end of CloseTable
-
// Methods
/***********************************************************************/
@@ -179,7 +78,7 @@ int TDB::RowNumber(PGLOBAL g, bool b)
return 0;
} // end of RowNumber
-PTBX TDB::Copy(PTABS t)
+PTDB TDB::Copy(PTABS t)
{
PTDB tp, tdb1, tdb2 = NULL, outp = NULL;
//PGLOBAL g = t->G; // Is this really useful ???
diff --git a/storage/connect/tabmac.h b/storage/connect/tabmac.h
index cfdf842cdc8..eb115b18049 100644
--- a/storage/connect/tabmac.h
+++ b/storage/connect/tabmac.h
@@ -31,7 +31,7 @@ class DllExport MACDEF : public TABDEF { /* Logical table description */
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
- virtual bool DeleteTableFile(PGLOBAL g) {return true;}
+//virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected:
// Members
diff --git a/storage/connect/tabmul.h b/storage/connect/tabmul.h
index 052b4e7d33e..379e8f88e93 100644
--- a/storage/connect/tabmul.h
+++ b/storage/connect/tabmul.h
@@ -38,7 +38,7 @@ class DllExport TDBMUL : public TDBASE {
// Methods
virtual void ResetDB(void);
virtual PTDB CopyOne(PTABS t);
- virtual bool IsSame(PTBX tp) {return tp == (PTBX)Tdbp;}
+ virtual bool IsSame(PTDB tp) {return tp == (PTDB)Tdbp;}
virtual PSZ GetFile(PGLOBAL g) {return Tdbp->GetFile(g);}
virtual int GetRecpos(void) {return 0;}
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp
index 564eddbaf2b..692cad9b9ff 100644
--- a/storage/connect/tabmysql.cpp
+++ b/storage/connect/tabmysql.cpp
@@ -527,8 +527,8 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g)
strcat(strcat(strcat(strcat(Query, " FROM "), tk), Tabname), tk);
- if (To_Filter)
- strcat(strcat(Query, " WHERE "), To_Filter->Body);
+ if (To_CondFil)
+ strcat(strcat(Query, " WHERE "), To_CondFil->Body);
if (trace)
htrc("Query=%s\n", Query);
@@ -1034,7 +1034,7 @@ int TDBMYSQL::WriteDB(PGLOBAL g)
// Statement was not prepared, we must construct and execute
// an insert query for each line to insert
int rc;
- char buf[32];
+ char buf[64];
strcpy(Qbuf, Query);
@@ -1135,7 +1135,6 @@ MYSQLCOL::MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am)
: COLBLK(NULL, tdbp, i)
{
Name = fld->name;
- Opt = 0;
Precision = Long = fld->length;
Buf_Type = MYSQLtoPLG(fld->type);
strcpy(Format.Type, GetFormatType(Buf_Type));
@@ -1144,9 +1143,6 @@ MYSQLCOL::MYSQLCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am)
ColUse = U_P;
Nullable = !IS_NOT_NULL(fld->flags);
- if (Buf_Type == TYPE_DECIM)
- Precision = ((Field_new_decimal*)fld)->precision;
-
// Set additional MySQL access method information for column.
Bind = NULL;
To_Val = NULL;
@@ -1398,11 +1394,11 @@ PCMD TDBMYEXC::MakeCMD(PGLOBAL g)
{
PCMD xcmd = NULL;
- if (To_Filter) {
+ if (To_CondFil) {
if (Cmdcol) {
- if (!stricmp(Cmdcol, To_Filter->Body) &&
- (To_Filter->Op == OP_EQ || To_Filter->Op == OP_IN)) {
- xcmd = To_Filter->Cmds;
+ if (!stricmp(Cmdcol, To_CondFil->Body) &&
+ (To_CondFil->Op == OP_EQ || To_CondFil->Op == OP_IN)) {
+ xcmd = To_CondFil->Cmds;
} else
strcpy(g->Message, "Invalid command specification filter");
diff --git a/storage/connect/tabmysql.h b/storage/connect/tabmysql.h
index 74b1d49e227..2ecfe800f88 100644
--- a/storage/connect/tabmysql.h
+++ b/storage/connect/tabmysql.h
@@ -185,14 +185,7 @@ class TDBMYEXC : public TDBMYSQL {
// Methods
virtual PTDB CopyOne(PTABS t);
-//virtual int GetAffectedRows(void) {return AftRows;}
-//virtual int GetRecpos(void) {return N;}
-//virtual int GetProgMax(PGLOBAL g);
-//virtual void ResetDB(void) {N = 0;}
-//virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual bool IsView(void) {return Isview;}
-//virtual PSZ GetServer(void) {return Server;}
-// void SetDatabase(LPCSTR db) {Database = (char*)db;}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
@@ -200,20 +193,10 @@ class TDBMYEXC : public TDBMYSQL {
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
-//virtual int DeleteDB(PGLOBAL g, int irc);
-//virtual void CloseDB(PGLOBAL g);
-
- // Specific routines
-// bool SetColumnRanks(PGLOBAL g);
-// PCOL MakeFieldColumn(PGLOBAL g, char *name);
-// PSZ FindFieldColumn(char *name);
protected:
// Internal functions
PCMD MakeCMD(PGLOBAL g);
-//bool MakeSelect(PGLOBAL g);
-//bool MakeInsert(PGLOBAL g);
-//int BindColumns(PGLOBAL g);
// Members
PCMD Cmdlist; // The commands to execute
@@ -237,15 +220,9 @@ class MYXCOL : public MYSQLCOL {
MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am = "MYSQL");
MYXCOL(MYXCOL *colp, PTDB tdbp); // Constructor used in copy process
- // Implementation
-//virtual int GetAmType(void) {return TYPE_AM_MYSQL;}
-// void InitBind(PGLOBAL g);
-
// Methods
-//virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
-// bool FindRank(PGLOBAL g);
protected:
// Default constructor not to be used
diff --git a/storage/connect/taboccur.h b/storage/connect/taboccur.h
index 0bee074234c..4538d3d71f2 100644
--- a/storage/connect/taboccur.h
+++ b/storage/connect/taboccur.h
@@ -68,7 +68,6 @@ class TDBOCCUR : public TDBPRX {
protected:
// Members
-//PTDBASE Tdbp; // To the source table or view
LPCSTR Tabname; // Name of source table
char *Colist; // Source column list
char *Xcolumn; // Occurence column name
diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp
index 1fb71e33646..cbce9adc7ac 100644
--- a/storage/connect/tabodbc.cpp
+++ b/storage/connect/tabodbc.cpp
@@ -408,7 +408,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
// Below 14 is length of 'select ' + length of ' from ' + 1
len = (strlen(colist) + strlen(buf) + 14);
- len += (To_Filter ? strlen(To_Filter->Body) + 7 : 0);
+ len += (To_CondFil ? strlen(To_CondFil->Body) + 7 : 0);
if (Catalog && *Catalog)
catp = Catalog;
@@ -441,8 +441,8 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
strcat(sql, tabname);
- if (To_Filter)
- strcat(strcat(sql, " WHERE "), To_Filter->Body);
+ if (To_CondFil)
+ strcat(strcat(sql, " WHERE "), To_CondFil->Body);
return sql;
} // end of MakeSQL
@@ -1066,7 +1066,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g)
} // endif Buf_Type
if (g->Trace) {
- char buf[32];
+ char buf[64];
htrc("ODBC Column %s: rows=%d buf=%p type=%d value=%s\n",
Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf));
@@ -1229,11 +1229,11 @@ PCMD TDBXDBC::MakeCMD(PGLOBAL g)
{
PCMD xcmd = NULL;
- if (To_Filter) {
+ if (To_CondFil) {
if (Cmdcol) {
- if (!stricmp(Cmdcol, To_Filter->Body) &&
- (To_Filter->Op == OP_EQ || To_Filter->Op == OP_IN)) {
- xcmd = To_Filter->Cmds;
+ if (!stricmp(Cmdcol, To_CondFil->Body) &&
+ (To_CondFil->Op == OP_EQ || To_CondFil->Op == OP_IN)) {
+ xcmd = To_CondFil->Cmds;
} else
strcpy(g->Message, "Invalid command specification filter");
diff --git a/storage/connect/tabodbc.h b/storage/connect/tabodbc.h
index 35864bab5ef..34c2bb8cfc7 100644
--- a/storage/connect/tabodbc.h
+++ b/storage/connect/tabodbc.h
@@ -158,7 +158,6 @@ class ODBCCOL : public COLBLK {
// PVBLK GetBlkp(void) {return Blkp;}
// Methods
-//virtual bool CheckLocal(PTDB tdbp);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp
index bc0dbb9bfc9..7cde2ab4cbd 100644
--- a/storage/connect/tabpivot.cpp
+++ b/storage/connect/tabpivot.cpp
@@ -95,7 +95,7 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol,
/***********************************************************************/
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
{
- char *query, *colname, buf[32];
+ char *query, *colname, buf[64];
int ndif, nblin, w = 0;
PVAL valp;
PCOLRES *pcrp, crp, fncrp = NULL;
@@ -121,7 +121,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // endif Exec
// We must have a storage query to get pivot column values
- Qryp = Myc.GetResult(g);
+ Qryp = Myc.GetResult(g, true);
Myc.Close();
if (!Fncol) {
@@ -405,7 +405,7 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g)
strcat(colist, Picol);
// Now we know how much was suballocated
- PlugSubAlloc(g, NULL, strlen(colist));
+ PlugSubAlloc(g, NULL, strlen(colist) + 1);
// Locate the source string (size is not known yet)
Tabsrc = (char*)PlugSubAlloc(g, NULL, 0);
@@ -423,7 +423,7 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g)
strcat(strcat(Tabsrc, " ORDER BY "), colist);
// Now we know how much was suballocated
- PlugSubAlloc(g, NULL, strlen(Tabsrc));
+ PlugSubAlloc(g, NULL, strlen(Tabsrc) + 1);
} // endif !GBdone
} else if (!Tabsrc) {
diff --git a/storage/connect/tabsys.cpp b/storage/connect/tabsys.cpp
index 2bb5532cea0..409352fdee6 100644
--- a/storage/connect/tabsys.cpp
+++ b/storage/connect/tabsys.cpp
@@ -113,6 +113,7 @@ PTDB INIDEF::GetTable(PGLOBAL g, MODE m)
return tdbp;
} // end of GetTable
+#if 0
/***********************************************************************/
/* DeleteTableFile: Delete INI table files using platform API. */
/***********************************************************************/
@@ -134,6 +135,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g)
return rc; // Return true if error
} // end of DeleteTableFile
+#endif // 0
/* ------------------------------------------------------------------- */
diff --git a/storage/connect/tabsys.h b/storage/connect/tabsys.h
index 2780eb3ca98..38b71d62ac4 100644
--- a/storage/connect/tabsys.h
+++ b/storage/connect/tabsys.h
@@ -32,7 +32,6 @@ class DllExport INIDEF : public TABDEF { /* INI table description */
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
- virtual bool DeleteTableFile(PGLOBAL g);
protected:
// Members
diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp
index 56305871c69..c78c62af9cc 100644
--- a/storage/connect/tabtbl.cpp
+++ b/storage/connect/tabtbl.cpp
@@ -1,11 +1,11 @@
/************* TabTbl C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABTBL */
/* ------------- */
-/* Version 1.6 */
+/* Version 1.7 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to PlugDB Software Development 2008-2013 */
+/* (C) Copyright to PlugDB Software Development 2008-2014 */
/* Author: Olivier BERTRAND */
/* */
/* WHAT THIS PROGRAM DOES: */
@@ -66,7 +66,6 @@
#include "global.h" // global declarations
#include "plgdbsem.h" // DB application declarations
#include "reldef.h" // DB definition declares
-//#include "filter.h" // FILTER classes dcls
#include "filamtxt.h"
#include "tabcol.h"
#include "tabdos.h" // TDBDOS and DOSCOL class dcls
@@ -245,7 +244,7 @@ bool TDBTBL::InitTableList(PGLOBAL g)
// PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath());
for (n = 0, tp = tdp->Tablep; tp; tp = tp->GetNext()) {
- if (TestFil(g, To_Filter, tp)) {
+ if (TestFil(g, To_CondFil, tp)) {
tabp = new(g) XTAB(tp);
if (tabp->GetSrc()) {
@@ -286,14 +285,14 @@ bool TDBTBL::InitTableList(PGLOBAL g)
hc->get_table()->s->connect_string.length = sln;
//NumTables = n;
- To_Filter = NULL; // To avoid doing it several times
+ To_CondFil = NULL; // To avoid doing it several times
return FALSE;
} // end of InitTableList
/***********************************************************************/
/* Test the tablename against the pseudo "local" filter. */
/***********************************************************************/
-bool TDBTBL::TestFil(PGLOBAL g, PFIL filp, PTABLE tabp)
+bool TDBTBL::TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp)
{
char *body, *fil, op[8], tn[NAME_LEN];
bool neg;
@@ -421,12 +420,12 @@ bool TDBTBL::OpenDB(PGLOBAL g)
} // endif use
/*********************************************************************/
- /* When GetMaxsize was called, To_Filter was not set yet. */
+ /* When GetMaxsize was called, To_CondFil was not set yet. */
/*********************************************************************/
- if (To_Filter && Tablist) {
+ if (To_CondFil && Tablist) {
Tablist = NULL;
Nbc = 0;
- } // endif To_Filter
+ } // endif To_CondFil
/*********************************************************************/
/* Open the first table of the list. */
@@ -661,12 +660,12 @@ bool TDBTBM::OpenDB(PGLOBAL g)
#if 0
/*********************************************************************/
- /* When GetMaxsize was called, To_Filter was not set yet. */
+ /* When GetMaxsize was called, To_CondFil was not set yet. */
/*********************************************************************/
- if (To_Filter && Tablist) {
+ if (To_CondFil && Tablist) {
Tablist = NULL;
Nbc = 0;
- } // endif To_Filter
+ } // endif To_CondFil
#endif // 0
/*********************************************************************/
diff --git a/storage/connect/tabtbl.h b/storage/connect/tabtbl.h
index 48371e40ade..fc35179f2ea 100644
--- a/storage/connect/tabtbl.h
+++ b/storage/connect/tabtbl.h
@@ -87,7 +87,7 @@ class DllExport TDBTBL : public TDBPRX {
protected:
// Internal functions
bool InitTableList(PGLOBAL g);
- bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp);
+ bool TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp);
// Members
PTABLE Tablist; // Points to the table list
@@ -133,26 +133,17 @@ class DllExport TDBTBM : public TDBTBL {
// Constructor
TDBTBM(PTBLDEF tdp = NULL);
- // Implementation
-//virtual AMT GetAmType(void) {return TYPE_AM_TBL;}
-
// Methods
virtual void ResetDB(void);
-//virtual int GetRecpos(void) {return Rows;}
-//virtual int GetBadLines(void) {return (int)Nbc;}
// Database routines
-//virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary
virtual int RowNumber(PGLOBAL g, bool b = FALSE);
-//virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
protected:
// Internal functions
-//bool InitTableList(PGLOBAL g);
-//bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp);
bool OpenTables(PGLOBAL g);
int ReadNextRemote(PGLOBAL g);
@@ -165,5 +156,4 @@ class DllExport TDBTBM : public TDBTBL {
int Nlc; // Number of local connections
}; // end of class TDBTBM
-
pthread_handler_t ThreadOpen(void *p);
diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp
index 5e10c0a6846..6d83852ccb8 100644
--- a/storage/connect/tabutil.cpp
+++ b/storage/connect/tabutil.cpp
@@ -625,7 +625,7 @@ void PRXCOL::Reset(void)
/***********************************************************************/
void PRXCOL::ReadColumn(PGLOBAL g)
{
- if (trace)
+ if (trace > 1)
htrc("PRX ReadColumn: name=%s\n", Name);
if (Colp) {
diff --git a/storage/connect/tabutil.h b/storage/connect/tabutil.h
index 7b2161a4b8b..c87065befba 100644
--- a/storage/connect/tabutil.h
+++ b/storage/connect/tabutil.h
@@ -54,7 +54,6 @@ class DllExport PRXDEF : public TABDEF { /* Logical table description */
/* This is the class declaration for the XCSV table. */
/***********************************************************************/
class DllExport TDBPRX : public TDBASE {
-//friend class MULINDX;
friend class PRXDEF;
friend class PRXCOL;
public:
@@ -126,8 +125,6 @@ class TDBTBC : public TDBCAT {
public:
// Constructors
TDBTBC(PPRXDEF tdp);
-//TDBTBC(PTBLDEF tdp);
-//TDBTBC(PXCLDEF tdp);
protected:
// Specific routines
diff --git a/storage/connect/tabvct.cpp b/storage/connect/tabvct.cpp
index 8b7d8ba91eb..2d4a649fc65 100644
--- a/storage/connect/tabvct.cpp
+++ b/storage/connect/tabvct.cpp
@@ -1,11 +1,11 @@
/************* TabVct C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABVCT */
/* ------------- */
-/* Version 3.7 */
+/* Version 3.8 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */
+/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -76,6 +76,8 @@
char *strerror(int num);
#endif // UNIX
+extern "C" int trace;
+
/***********************************************************************/
/* Char VCT column blocks are right filled with blanks (blank = true) */
/* Conversion of block values allowed conditionally for insert only. */
@@ -118,6 +120,7 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return false;
} // end of DefineAM
+#if 0
/***********************************************************************/
/* Erase: This was made a separate routine because a strange thing */
/* happened when DeleteTablefile was defined for the VCTDEF class: */
@@ -157,6 +160,7 @@ bool VCTDEF::Erase(char *filename)
return rc; // Return true if error
} // end of Erase
+#endif // 0
/***********************************************************************/
/* Prepare the column file name pattern for a split table. */
@@ -231,7 +235,8 @@ PTDB VCTDEF::GetTable(PGLOBAL g, MODE mode)
/*********************************************************************/
if (mode != MODE_INSERT)
if (tdbp->GetBlockValues(g))
- return NULL;
+ PushWarning(g, (PTDBASE)tdbp);
+// return NULL; // causes a crash when deleting index
return tdbp;
} // end of GetTable
@@ -284,10 +289,9 @@ PCOL TDBVCT::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/
bool TDBVCT::OpenDB(PGLOBAL g)
{
-#ifdef DEBTRACE
- htrc("VCT OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n",
- this, Tdb_No, Use, To_Key_Col, Mode);
-#endif
+ if (trace)
+ htrc("VCT OpenDB: tdbp=%p tdb=R%d use=%d key=%p mode=%d\n",
+ this, Tdb_No, Use, To_Key_Col, Mode);
if (Use == USE_OPEN) {
/*******************************************************************/
@@ -335,12 +339,10 @@ bool TDBVCT::OpenDB(PGLOBAL g)
/***********************************************************************/
int TDBVCT::ReadDB(PGLOBAL g)
{
-#ifdef DEBTRACE
- fprintf(debug,
- "VCT ReadDB: R%d Mode=%d CurBlk=%d CurNum=%d key=%p link=%p Kindex=%p\n",
- GetTdb_No(), Mode, Txfp->CurBlk, Txfp->CurNum,
- To_Key_Col, To_Link, To_Kindex);
-#endif
+ if (trace)
+ htrc("VCT ReadDB: R%d Mode=%d CurBlk=%d CurNum=%d key=%p link=%p Kindex=%p\n",
+ GetTdb_No(), Mode, Txfp->CurBlk, Txfp->CurNum,
+ To_Key_Col, To_Link, To_Kindex);
if (To_Kindex) {
/*******************************************************************/
@@ -515,15 +517,13 @@ void VCTCOL::ReadColumn(PGLOBAL g)
{
PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;
-#if defined(_DEBUG) || defined(DEBTRACE)
+#if defined(_DEBUG)
assert (!To_Kcol);
#endif
-#ifdef DEBTRACE
- fprintf(debug,
- "VCT ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
- Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
-#endif
+ if (trace > 1)
+ htrc("VCT ReadColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
+ Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
if (ColBlk != txfp->CurBlk)
ReadBlock(g);
@@ -549,11 +549,9 @@ void VCTCOL::WriteColumn(PGLOBAL g)
{
PTXF txfp = ((PTDBVCT)To_Tdb)->Txfp;;
-#ifdef DEBTRACE
- fprintf(debug,
- "VCT WriteColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
- Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
-#endif
+ if (trace > 1)
+ htrc("VCT WriteColumn: col %s R%d coluse=%.4X status=%.4X buf_type=%d\n",
+ Name, To_Tdb->GetTdb_No(), ColUse, Status, Buf_Type);
ColBlk = txfp->CurBlk;
ColPos = txfp->CurNum;
diff --git a/storage/connect/tabvct.h b/storage/connect/tabvct.h
index 4049b4f7683..7dc416a5779 100644
--- a/storage/connect/tabvct.h
+++ b/storage/connect/tabvct.h
@@ -36,8 +36,6 @@ class DllExport VCTDEF : public DOSDEF { /* Logical table description */
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
- // Specific file erase routine for vertical tables
- virtual bool Erase(char *filename);
int MakeFnPattern(char *fpat);
// Members
diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp
index 8f91d9b3ed8..5052268b9e2 100644
--- a/storage/connect/tabwmi.cpp
+++ b/storage/connect/tabwmi.cpp
@@ -14,7 +14,7 @@
#include "reldef.h"
#include "xtable.h"
#include "colblk.h"
-#include "filter.h"
+//#include "filter.h"
//#include "xindex.h"
#include "tabwmi.h"
#include "valblk.h"
@@ -480,8 +480,8 @@ bool TDBWMI::Initialize(PGLOBAL g)
/***********************************************************************/
void TDBWMI::DoubleSlash(PGLOBAL g)
{
- if (To_Filter && strchr(To_Filter->Body, '\\')) {
- char *body = To_Filter->Body;
+ if (To_CondFil && strchr(To_CondFil->Body, '\\')) {
+ char *body = To_CondFil->Body;
char *buf = (char*)PlugSubAlloc(g, NULL, strlen(body) * 2);
int i = 0, k = 0;
@@ -492,8 +492,8 @@ void TDBWMI::DoubleSlash(PGLOBAL g)
buf[k++] = body[i];
} while (body[i++]);
- To_Filter->Body = buf;
- } // endif To_Filter
+ To_CondFil->Body = buf;
+ } // endif To_CondFil
} // end of DoubleSlash
@@ -540,13 +540,13 @@ char *TDBWMI::MakeWQL(PGLOBAL g)
// Below 14 is length of 'select ' + length of ' from ' + 1
len = (strlen(colist) + strlen(Wclass) + 14);
- len += (To_Filter ? strlen(To_Filter->Body) + 7 : 0);
+ len += (To_CondFil ? strlen(To_CondFil->Body) + 7 : 0);
wql = (char*)PlugSubAlloc(g, NULL, len);
strcat(strcat(strcpy(wql, "SELECT "), colist), " FROM ");
strcat(wql, Wclass);
- if (To_Filter)
- strcat(strcat(wql, " WHERE "), To_Filter->Body);
+ if (To_CondFil)
+ strcat(strcat(wql, " WHERE "), To_CondFil->Body);
return wql;
} // end of MakeWQL
@@ -659,8 +659,8 @@ bool TDBWMI::OpenDB(PGLOBAL g)
return true;
} // endif Mode
- if (!To_Filter && !stricmp(Wclass, "CIM_Datafile")
- && !stricmp(Nspace, "root\\cimv2")) {
+ if (!To_CondFil && !stricmp(Wclass, "CIM_Datafile")
+ && !stricmp(Nspace, "root\\cimv2")) {
strcpy(g->Message,
"Would last forever when not filtered, use DIR table instead");
return true;
diff --git a/storage/connect/tabwmi.h b/storage/connect/tabwmi.h
index 9df57e7c579..8ff5262941e 100644
--- a/storage/connect/tabwmi.h
+++ b/storage/connect/tabwmi.h
@@ -48,7 +48,6 @@ class WMIDEF : public TABDEF { /* Logical table description */
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
- virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected:
// Members
diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp
index aa1133b0e92..77dc7617e8a 100644
--- a/storage/connect/tabxml.cpp
+++ b/storage/connect/tabxml.cpp
@@ -187,6 +187,7 @@ PTDB XMLDEF::GetTable(PGLOBAL g, MODE m)
return tdbp;
} // end of GetTable
+#if 0
/***********************************************************************/
/* DeleteTableFile: Delete XML table files using platform API. */
/***********************************************************************/
@@ -208,6 +209,7 @@ bool XMLDEF::DeleteTableFile(PGLOBAL g)
return rc; // Return true if error
} // end of DeleteTableFile
+#endif // 0
/* ------------------------- TDBXML Class ---------------------------- */
@@ -1314,7 +1316,7 @@ void XMLCOL::WriteColumn(PGLOBAL g)
PXNODE TopNode = NULL;
//PXATTR AttNode = NULL;
- if (trace)
+ if (trace > 1)
htrc("XML WriteColumn: col %s R%d coluse=%.4X status=%.4X\n",
Name, Tdbp->GetTdb_No(), ColUse, Status);
@@ -1324,14 +1326,11 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (Value != To_Val)
Value->SetValue_pval(To_Val, false); // Convert the updated value
- if (Value->IsNull())
- return;
-
/*********************************************************************/
/* If a check pass was done while updating, all node contruction */
/* has been already one. */
/*********************************************************************/
- if (Status && Tdbp->Checked) {
+ if (Status && Tdbp->Checked && !Value->IsNull()) {
assert (ColNode != NULL);
assert ((Type ? (void *)ValNode : (void *)AttNode) != NULL);
goto fin;
@@ -1345,6 +1344,12 @@ void XMLCOL::WriteColumn(PGLOBAL g)
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
/*********************************************************************/
+ /* Null values are represented by no node. */
+ /*********************************************************************/
+ if (Value->IsNull())
+ return;
+
+ /*********************************************************************/
/* Find the column and value nodes to update or insert. */
/*********************************************************************/
if (Tdbp->Clist) {
diff --git a/storage/connect/tabxml.h b/storage/connect/tabxml.h
index 817bea45b3b..1284cf6197f 100644
--- a/storage/connect/tabxml.h
+++ b/storage/connect/tabxml.h
@@ -10,9 +10,6 @@ typedef class XMLDEF *PXMLDEF;
typedef class TDBXML *PTDBXML;
typedef class XMLCOL *PXMLCOL;
-// These functions are exported from the Extended.dll
-//PTABDEF __stdcall GetXML(PGLOBAL g, void *memp);
-
/* --------------------------- XML classes --------------------------- */
/***********************************************************************/
@@ -30,7 +27,6 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
- virtual bool DeleteTableFile(PGLOBAL g);
protected:
// Members
@@ -53,7 +49,6 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */
}; // end of XMLDEF
#if defined(INCLUDE_TDBXML)
-
/***********************************************************************/
/* This is the class declaration for the simple XML tables. */
/***********************************************************************/
@@ -242,5 +237,4 @@ class XPOSCOL : public XMLCOLX {
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
}; // end of class XPOSCOL
-
#endif // INCLUDE_TDBXML
diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc
index b778d3f0883..77b978cf5a3 100644
--- a/storage/connect/user_connect.cc
+++ b/storage/connect/user_connect.cc
@@ -47,8 +47,7 @@
#include "user_connect.h"
#include "mycat.h"
-extern "C" char plgxini[];
-extern int xtrace;
+extern "C" int trace;
/****************************************************************************/
/* Initialize the user_connect static member. */
@@ -149,7 +148,7 @@ bool user_connect::CheckCleanup(void)
g->Alchecked = 0;
last_query_id= thdp->query_id;
- if (xtrace)
+ if (trace)
printf("=====> Begin new query %llu\n", last_query_id);
return true;
diff --git a/storage/connect/user_connect.h b/storage/connect/user_connect.h
index ef17a958824..44e4e94fa8a 100644
--- a/storage/connect/user_connect.h
+++ b/storage/connect/user_connect.h
@@ -63,11 +63,10 @@ public:
PCONNECT next; // Next user in chain
PCONNECT previous; // Previous user in chain
PGLOBAL g; // The common handle to CONNECT
-//char dbname[32]; // The DBCONNECT database
query_id_t last_query_id; // the latest user query id
int count; // if used by several handlers
// Statistics
ulong nrd, fnd, nfd;
- ulonglong tb1;
+ ulonglong tb1;
}; // end of user_connect class definition
diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp
index c0127072896..7490e417562 100644
--- a/storage/connect/valblk.cpp
+++ b/storage/connect/valblk.cpp
@@ -40,7 +40,10 @@
#include "plgdbsem.h"
#include "valblk.h"
-#define CheckBlanks assert(!Blanks);
+#define CheckBlanks assert(!Blanks);
+#define CheckParms(V, N) ChkIndx(N); ChkTyp(V);
+
+extern "C" int trace;
/***********************************************************************/
/* AllocValBlock: allocate a VALBLK according to type. */
@@ -50,10 +53,9 @@ PVBLK AllocValBlock(PGLOBAL g, void *mp, int type, int nval, int len,
{
PVBLK blkp;
-#ifdef DEBTRACE
- htrc("AVB: mp=%p type=%d nval=%d len=%d check=%u blank=%u\n",
- mp, type, nval, len, check, blank);
-#endif
+ if (trace)
+ htrc("AVB: mp=%p type=%d nval=%d len=%d check=%u blank=%u\n",
+ mp, type, nval, len, check, blank);
switch (type) {
case TYPE_STRING:
@@ -545,7 +547,7 @@ int TYPBLK<TYPE>::Find(PVAL vp)
template <class TYPE>
int TYPBLK<TYPE>::GetMaxLength(void)
{
- char buf[32];
+ char buf[64];
int i, n, m;
for (i = n = 0; i < Nval; i++) {
@@ -736,13 +738,13 @@ void CHRBLK::SetValue(char *sp, uint len, int n)
{
char *p = Chrp + n * Long;
-#if defined(_DEBUG) || defined(DEBTRACE)
+#if defined(_DEBUG)
if (Check && (signed)len > Long) {
PGLOBAL& g = Global;
strcpy(g->Message, MSG(SET_STR_TRUNC));
longjmp(g->jumper[g->jump_level], Type);
} // endif Check
-#endif
+#endif // _DEBUG
if (sp)
memcpy(p, sp, min((unsigned)Long, len));
@@ -785,13 +787,13 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
/***********************************************************************/
void CHRBLK::SetValues(PVBLK pv, int k, int n)
{
-#if defined(_DEBUG) || defined(DEBTRACE)
+#if defined(_DEBUG)
if (Type != pv->GetType() || Long != ((CHRBLK*)pv)->Long) {
PGLOBAL& g = Global;
strcpy(g->Message, MSG(BLKTYPLEN_MISM));
longjmp(g->jumper[g->jump_level], Type);
} // endif Type
-#endif
+#endif // _DEBUG
char *p = ((CHRBLK*)pv)->Chrp;
if (!k)
diff --git a/storage/connect/valblk.h b/storage/connect/valblk.h
index 1edfe7f76b4..6da36d3b517 100644
--- a/storage/connect/valblk.h
+++ b/storage/connect/valblk.h
@@ -26,7 +26,6 @@ const char *GetFmt(int type, bool un = false);
/* Class VALBLK represent a base class for variable blocks. */
/***********************************************************************/
class VALBLK : public BLOCK {
-//friend void SemColData(PGLOBAL g, PSEM semp);
public:
// Constructors
VALBLK(void *mp, int type, int nval, bool un = false);
@@ -79,12 +78,6 @@ class VALBLK : public BLOCK {
virtual void SetValue(char *sp, uint len, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0;
virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
-#if 0
- virtual void SetMin(PVAL valp, int n) = 0;
- virtual void SetMax(PVAL valp, int n) = 0;
- virtual void SetValues(PVBLK pv, int i, int n) = 0;
- virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);}
-#endif // 0
virtual void Move(int i, int j) = 0;
virtual int CompVal(PVAL vp, int n) = 0;
virtual int CompVal(int i1, int i2) = 0;
@@ -119,12 +112,10 @@ class TYPBLK : public VALBLK {
public:
// Constructors
TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false);
-//TYPBLK(void *mp, int size, int prec, int type);
// Implementation
virtual void Init(PGLOBAL g, bool check);
virtual int GetVlen(void) {return sizeof(TYPE);}
-//virtual PSZ GetCharValue(int n);
virtual char GetTinyValue(int n) {return (char)Typp[n];}
virtual uchar GetUTinyValue(int n) {return (uchar)Typp[n];}
virtual short GetShortValue(int n) {return (short)Typp[n];}
@@ -160,7 +151,6 @@ class TYPBLK : public VALBLK {
{Typp[n] = (TYPE)cval; SetNull(n, false);}
virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
-//virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
@@ -211,7 +201,6 @@ class CHRBLK : public VALBLK {
virtual void SetValue(char *sp, uint len, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
-//virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
@@ -263,7 +252,6 @@ class STRBLK : public VALBLK {
virtual void SetValue(char *sp, uint len, int n);
virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2);
-//virtual void SetValues(PVBLK pv, int k, int n);
virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2);
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index 8a839f3b50b..0c93fed520a 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -83,6 +83,7 @@ int DTVAL::Shift = 0;
/* Routines called externally. */
/***********************************************************************/
bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool);
+
#if !defined(WIN32)
extern "C" {
PSZ strupr(PSZ s);
@@ -277,55 +278,6 @@ const char *GetFmt(int type, bool un)
return fmt;
} // end of GetFmt
-#if 0
-/***********************************************************************/
-/* ConvertType: what this function does is to determine the type to */
-/* which should be converted a value so no precision would be lost. */
-/* This can be a numeric type if num is true or non numeric if false. */
-/* Note: this is an ultra simplified version of this function that */
-/* should become more and more complex as new types are added. */
-/* Not evaluated types (TYPE_VOID or TYPE_UNDEF) return false from */
-/* IsType... functions so match does not prevent correct setting. */
-/***********************************************************************/
-int ConvertType(int target, int type, CONV kind, bool match)
- {
- switch (kind) {
- case CNV_CHAR:
- if (match && (!IsTypeChar(target) || !IsTypeChar(type)))
- return TYPE_ERROR;
-
- return TYPE_STRING;
- case CNV_NUM:
- if (match && (!IsTypeNum(target) || !IsTypeNum(type)))
- return TYPE_ERROR;
-
- return (target == TYPE_DOUBLE || type == TYPE_DOUBLE) ? TYPE_DOUBLE
- : (target == TYPE_DATE || type == TYPE_DATE) ? TYPE_DATE
- : (target == TYPE_BIGINT || type == TYPE_BIGINT) ? TYPE_BIGINT
- : (target == TYPE_INT || type == TYPE_INT) ? TYPE_INT
- : (target == TYPE_SHORT || type == TYPE_SHORT) ? TYPE_SHORT
- : TYPE_TINY;
- default:
- if (target == TYPE_ERROR || target == type)
- return type;
-
- if (match && ((IsTypeChar(target) && !IsTypeChar(type)) ||
- (IsTypeNum(target) && !IsTypeNum(type))))
- return TYPE_ERROR;
-
- return (target == TYPE_DOUBLE || type == TYPE_DOUBLE) ? TYPE_DOUBLE
- : (target == TYPE_DATE || type == TYPE_DATE) ? TYPE_DATE
- : (target == TYPE_BIGINT || type == TYPE_BIGINT) ? TYPE_BIGINT
- : (target == TYPE_INT || type == TYPE_INT) ? TYPE_INT
- : (target == TYPE_SHORT || type == TYPE_SHORT) ? TYPE_SHORT
- : (target == TYPE_STRING || type == TYPE_STRING) ? TYPE_STRING
- : (target == TYPE_TINY || type == TYPE_TINY) ? TYPE_TINY
- : TYPE_ERROR;
- } // endswitch kind
-
- } // end of ConvertType
-#endif // 0
-
/***********************************************************************/
/* AllocateConstant: allocates a constant Value. */
/***********************************************************************/
@@ -422,76 +374,6 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
return valp;
} // end of AllocateValue
-#if 0
-/***********************************************************************/
-/* Allocate a constant Value converted to newtype. */
-/* Can also be used to copy a Value eventually converted. */
-/***********************************************************************/
-PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
- {
- PSZ p, sp;
- bool un = (uns < 0) ? false : (uns > 0) ? true : valp->IsUnsigned();
-
- if (newtype == TYPE_VOID) // Means allocate a value of the same type
- newtype = valp->GetType();
-
- switch (newtype) {
- case TYPE_STRING:
- p = (PSZ)PlugSubAlloc(g, NULL, 1 + valp->GetValLen());
-
- if ((sp = valp->GetCharString(p)) != p)
- strcpy (p, sp);
-
- valp = new(g) TYPVAL<PSZ>(g, p, valp->GetValLen(), valp->GetValPrec());
- break;
- case TYPE_SHORT:
- if (un)
- valp = new(g) TYPVAL<ushort>(valp->GetUShortValue(),
- TYPE_SHORT, 0, true);
- else
- valp = new(g) TYPVAL<short>(valp->GetShortValue(), TYPE_SHORT);
-
- break;
- case TYPE_INT:
- if (un)
- valp = new(g) TYPVAL<uint>(valp->GetUIntValue(), TYPE_INT, 0, true);
- else
- valp = new(g) TYPVAL<int>(valp->GetIntValue(), TYPE_INT);
-
- break;
- case TYPE_BIGINT:
- if (un)
- valp = new(g) TYPVAL<ulonglong>(valp->GetUBigintValue(),
- TYPE_BIGINT, 0, true);
- else
- valp = new(g) TYPVAL<longlong>(valp->GetBigintValue(), TYPE_BIGINT);
-
- break;
- case TYPE_DATE:
- valp = new(g) DTVAL(g, valp->GetIntValue());
- break;
- case TYPE_DOUBLE:
- valp = new(g) TYPVAL<double>(valp->GetFloatValue(), TYPE_DOUBLE,
- valp->GetValPrec());
- break;
- case TYPE_TINY:
- if (un)
- valp = new(g) TYPVAL<uchar>(valp->GetUTinyValue(),
- TYPE_TINY, 0, true);
- else
- valp = new(g) TYPVAL<char>(valp->GetTinyValue(), TYPE_TINY);
-
- break;
- default:
- sprintf(g->Message, MSG(BAD_VALUE_TYPE), newtype);
- return NULL;
- } // endswitch type
-
- valp->SetGlobal(g);
- return valp;
- } // end of AllocateValue
-#endif // 0
-
/* -------------------------- Class VALUE ---------------------------- */
/***********************************************************************/
@@ -673,7 +555,7 @@ template <>
bool TYPVAL<double>::SetValue_char(char *p, int n)
{
if (p) {
- char buf[32];
+ char buf[64];
for (; n > 0 && *p == ' '; p++)
n--;
@@ -1075,7 +957,7 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
return true;
- char buf[32];
+ char buf[64];
if (!(Null = valp->IsNull() && Nullable))
strncpy(Strp, valp->GetCharString(buf), Len);
@@ -1244,7 +1126,7 @@ void TYPVAL<PSZ>::SetValue(ulonglong n)
/***********************************************************************/
void TYPVAL<PSZ>::SetValue(double f)
{
- char *p, buf[32];
+ char *p, buf[64];
PGLOBAL& g = Global;
int k = sprintf(buf, "%lf", f);
@@ -1338,7 +1220,7 @@ bool TYPVAL<PSZ>::IsEqual(PVAL vp, bool chktype)
else if (Null || vp->IsNull())
return false;
- char buf[32];
+ char buf[64];
if (Ci || vp->IsCi())
return !stricmp(Strp, vp->GetCharString(buf));
@@ -1469,7 +1351,7 @@ bool DECVAL::SetValue_pval(PVAL valp, bool chktype)
if (chktype && (valp->GetType() != Type || valp->GetSize() > Len))
return true;
- char buf[32];
+ char buf[64];
if (!(Null = valp->IsNull() && Nullable))
strncpy(Strp, valp->GetCharString(buf), Len);
@@ -1568,7 +1450,7 @@ bool DECVAL::IsEqual(PVAL vp, bool chktype)
else if (Null || vp->IsNull())
return false;
- char buf[32];
+ char buf[64];
return !strcmp(Strp, vp->GetCharString(buf));
} // end of IsEqual
@@ -2091,13 +1973,13 @@ bool DTVAL::FormatValue(PVAL vp, char *fmt)
char *buf = (char*)vp->GetTo_Val(); // Should be big enough
struct tm tm, *ptm = GetGmTime(&tm);
- if (trace)
+ if (trace > 1)
htrc("FormatValue: ptm=%p len=%d\n", ptm, vp->GetValLen());
if (ptm) {
size_t n = strftime(buf, vp->GetValLen(), fmt, ptm);
- if (trace)
+ if (trace > 1)
htrc("strftime: n=%d buf=%s\n", n, (n) ? buf : "???");
return (n == 0);
diff --git a/storage/connect/value.h b/storage/connect/value.h
index f8e89ba55fd..a5eb2c886cf 100644
--- a/storage/connect/value.h
+++ b/storage/connect/value.h
@@ -46,8 +46,6 @@ DllExport char *GetFormatType(int);
DllExport int GetFormatType(char);
DllExport bool IsTypeChar(int type);
DllExport bool IsTypeNum(int type);
-//lExport int ConvertType(int, int, CONV, bool match = false);
-//lExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
bool uns = false, PSZ fmt = NULL);
DllExport ulonglong CharToNumber(char *, int, ulonglong, bool,
@@ -271,17 +269,9 @@ class DllExport DECVAL: public TYPVAL<PSZ> {
virtual int GetValPrec() {return Prec;}
// Methods
-//virtual bool SetValue_pval(PVAL valp, bool chktype);
-//virtual bool SetValue_char(char *p, int n);
-//virtual void SetValue_psz(PSZ s);
-//virtual void SetValue_pvblk(PVBLK blk, int n);
-//virtual void SetBinValue(void *p);
virtual bool GetBinValue(void *buf, int buflen, bool go);
virtual char *ShowValue(char *buf, int);
-//virtual char *GetCharString(char *p);
virtual bool IsEqual(PVAL vp, bool chktype);
-//virtual bool FormatValue(PVAL vp, char *fmt);
-//virtual bool SetConstFormat(PGLOBAL, FORMAT&);
// Members
}; // end of class DECVAL
@@ -310,15 +300,12 @@ class DllExport DTVAL : public TYPVAL<int> {
bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
bool SetFormat(PGLOBAL g, PVAL valp);
bool IsFormatted(void) {return Pdtp != NULL;}
-// bool GetTmMember(OPVAL op, int& mval);
-// bool DateDiff(DTVAL *dtp, OPVAL op, int& tdif);
bool MakeTime(struct tm *ptm);
static void SetTimeShift(void);
static int GetShift(void) {return Shift;}
// Methods
bool MakeDate(PGLOBAL g, int *val, int nval);
-// bool WeekNum(PGLOBAL g, int& nval);
struct tm *GetGmTime(struct tm *);
diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp
index 601374ef5d7..1adf9f20465 100755
--- a/storage/connect/xindex.cpp
+++ b/storage/connect/xindex.cpp
@@ -60,6 +60,7 @@
/* DB static external variables. */
/***********************************************************************/
extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
+extern "C" int trace;
/***********************************************************************/
/* Last two parameters are true to enable type checking, and last one */
@@ -267,10 +268,7 @@ int XINDEX::Qcompare(int *i1, int *i2)
if ((k = kcp->Compare(*i1, *i2)))
break;
-#ifdef DEBTRACE
- num_comp++;
-#endif
-
+//num_comp++;
return k;
} // end of Qcompare
@@ -1792,7 +1790,8 @@ int XINDEX::FastFind(int nv)
XINDXS::XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp)
: XINDEX(tdbp, xdp, pxp, cp, xp)
{
- Srtd = To_Cols[0]->GetOpt() < 0; // ?????
+//Srtd = To_Cols[0]->GetOpt() < 0; // ?????
+ Srtd = false;
} // end of XINDXS constructor
/***********************************************************************/
@@ -1800,10 +1799,7 @@ XINDXS::XINDXS(PTDBDOS tdbp, PIXDEF xdp, PXLOAD pxp, PCOL *cp, PXOB *xp)
/***********************************************************************/
int XINDXS::Qcompare(int *i1, int *i2)
{
-#ifdef DEBTRACE
- num_comp++;
-#endif
-
+//num_comp++;
return To_KeyCol->Compare(*i1, *i2);
} // end of Qcompare
@@ -2319,11 +2315,9 @@ bool XHUGE::Open(PGLOBAL g, char *filename, int id, MODE mode)
return true;
} // endif Hfile
-#ifdef DEBTRACE
- fprintf(debug,
- " access=%p share=%p creation=%d handle=%p fn=%s\n",
- access, share, creation, Hfile, filename);
-#endif
+ if (trace)
+ htrc(" access=%p share=%p creation=%d handle=%p fn=%s\n",
+ access, share, creation, Hfile, filename);
if (mode == MODE_INSERT) {
/*******************************************************************/
@@ -2766,10 +2760,9 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
Prefix = true;
} // endif kln
-#ifdef DEBTRACE
- htrc("KCOL(%p) Init: col=%s n=%d type=%d sm=%d\n",
- this, colp->GetName(), n, colp->GetResultType(), sm);
-#endif
+ if (trace)
+ htrc("KCOL(%p) Init: col=%s n=%d type=%d sm=%d\n",
+ this, colp->GetName(), n, colp->GetResultType(), sm);
// Allocate the Value object used when moving items
Type = colp->GetResultType();
@@ -2797,7 +2790,8 @@ bool KXYCOL::Init(PGLOBAL g, PCOL colp, int n, bool sm, int kln)
// Store this information to avoid sorting when already done
if (Asc)
- IsSorted = colp->GetOpt() < 0;
+// IsSorted = colp->GetOpt() < 0;
+ IsSorted = false;
//SetNulls(colp->IsNullable()); for when null columns will be indexable
return false;
@@ -2820,10 +2814,9 @@ BYTE* KXYCOL::MapInit(PGLOBAL g, PCOL colp, int *n, BYTE *m)
Type = colp->GetResultType();
-#ifdef DEBTRACE
- htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n",
- this, colp, Type, n[0], len, m);
-#endif
+ if (trace)
+ htrc("MapInit(%p): colp=%p type=%d n=%d len=%d m=%p\n",
+ this, colp, Type, n[0], len, m);
// Allocate the Value object used when moving items
Valp = AllocateValue(g, Type, len, prec, false, NULL);
diff --git a/storage/connect/xindex.h b/storage/connect/xindex.h
index b7e597b9e6d..ac886673b68 100644
--- a/storage/connect/xindex.h
+++ b/storage/connect/xindex.h
@@ -98,12 +98,6 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */
void SetNParts(uint np) {Nparts = (signed)np;}
void SetMaxSame(int mxs) {MaxSame = mxs;}
void SetMxsame(PXINDEX x);
-//int GetOffset(void) {return Offset;}
-//void SetOffset(int off) {Offset = off;}
-//int GetOffhigh(void) {return Offhigh;}
-//void SetOffhigh(int hof) {Offhigh = hof;}
-//int GetSize(void) {return Size;}
-//void SetSize(int size) {Size = size;}
int GetMaxSame(void) {return MaxSame;}
bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p);
PIXDEF GetIndexOf(PCOL colp, bool hd = false);
@@ -123,9 +117,6 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */
bool AutoInc; /* true if unique key in auto increment */
int Nparts; /* Number of key parts */
int ID; /* Index ID number */
-//int Offset; /* Offset in index file */
-//int Offhigh; /* Offset high in big index file */
-//int Size; /* Size of index file */
int MaxSame; /* Max number of same values */
}; // end of INDEXDEF
@@ -253,9 +244,6 @@ class DllExport XINDEX : public XXBASE {
virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;}
virtual void SetNval(int n) {Nval = n;}
int GetMaxSame(void) {return MaxSame;}
-// int GetDefoff(void) {return Defoff;}
-// int GetDefhigh(void) {return Defhigh;}
-// int GetSize(void) {return Size;}
// Methods
virtual void Reset(void);
@@ -288,9 +276,6 @@ class DllExport XINDEX : public XXBASE {
int Nk; // The number of indexed columns
int Nval; // The number of used columns
int Incr; // Increment of record position
-//int Defoff; // Offset of definition in index file
-//int Defhigh; // High order of offset big value
-//int Size; // Size of definition in index file
int MaxSame; // Max number of same values
}; // end of class XINDEX
diff --git a/storage/connect/xobject.cpp b/storage/connect/xobject.cpp
index aa87517bd2e..05b408da2d2 100644
--- a/storage/connect/xobject.cpp
+++ b/storage/connect/xobject.cpp
@@ -109,19 +109,6 @@ int CONSTANT::GetLengthEx(void)
return Value->GetValLen();
} // end of GetLengthEx
-#if 0
-/***********************************************************************/
-/* Convert a constant to the given type. */
-/***********************************************************************/
-void CONSTANT::Convert(PGLOBAL g, int newtype)
- {
- if (Value->GetType() != newtype)
- if (!(Value = AllocateValue(g, Value, newtype)))
- longjmp(g->jumper[g->jump_level], TYPE_CONST);
-
- } // end of Convert
-#endif // 0
-
/***********************************************************************/
/* Compare: returns true if this object is equivalent to xp. */
/***********************************************************************/
diff --git a/storage/connect/xobject.h b/storage/connect/xobject.h
index b7869be96b2..15ba6d99f33 100644
--- a/storage/connect/xobject.h
+++ b/storage/connect/xobject.h
@@ -60,17 +60,6 @@ class DllExport XOBJECT : public BLOCK {
virtual bool Init(PGLOBAL) {return false;}
virtual bool Eval(PGLOBAL) {return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&) = 0;
- virtual int CheckColumn(PGLOBAL, PSQL, PXOB &, int &) {return 0;}
- virtual int RefNum(PSQL) {return 0;}
- virtual void AddTdb(PSQL, PTDB *, int&) {}
- virtual PXOB SetSelect(PGLOBAL, PSQL, bool) {return this;}
- virtual PXOB CheckSubQuery(PGLOBAL, PSQL) {return this;}
- virtual bool CheckLocal(PTDB) {return true;}
- virtual int CheckSpcCol(PTDB, int) {return 2;}
- virtual bool CheckSort(PTDB) {return false;}
- virtual bool VerifyColumn(PTBX txp) {return false;}
- virtual bool VerifyTdb(PTDB& tdbp) {return false;}
- virtual bool IsColInside(PCOL colp) {return false;}
protected:
PVAL Value; // The current value of the object.
@@ -97,7 +86,6 @@ class DllExport XVOID : public XOBJECT {
// Methods
virtual bool Compare(PXOB xp) {return xp->GetType() == TYPE_VOID;}
virtual bool SetFormat(PGLOBAL, FORMAT&) {return true;}
- virtual int CheckSpcCol(PTDB, int) {return 0;}
}; // end of class XVOID
@@ -122,12 +110,7 @@ class DllExport CONSTANT : public XOBJECT {
virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL g, FORMAT& fmt)
{return Value->SetConstFormat(g, fmt);}
- virtual int CheckSpcCol(PTDB, int) {return 1;}
-// void Convert(PGLOBAL g, int newtype);
-// bool Rephrase(PGLOBAL g, PSZ work);
void SetValue(PVAL vp) {Value = vp;}
- virtual bool VerifyColumn(PTBX txp) {return true;}
- virtual bool VerifyTdb(PTDB& tdbp) {return true;}
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
}; // end of class CONSTANT
diff --git a/storage/connect/xtable.h b/storage/connect/xtable.h
index 8884860cb5b..74c0b986d82 100644
--- a/storage/connect/xtable.h
+++ b/storage/connect/xtable.h
@@ -33,58 +33,20 @@ class CMD : public BLOCK {
char *Cmd;
}; // end of class CMD
-// Filter passed all tables
-typedef struct _filter {
+// Condition filter structure
+typedef struct _cond_filter {
char *Body;
OPVAL Op;
PCMD Cmds;
-} FILTER, *PFIL;
+} CONDFIL, *PCFIL;
typedef class TDBCAT *PTDBCAT;
typedef class CATCOL *PCATCOL;
/***********************************************************************/
-/* Definition of class TBX (pure virtual class for TDB and OPJOIN) */
-/***********************************************************************/
-class DllExport TBX: public BLOCK { // Base class for OPJOIN and TDB classes.
- public:
- // Constructors
- TBX(void);
- TBX(PTBX txp);
-
- // Implementation
- inline PTBX GetOrig(void) {return To_Orig;}
- inline TUSE GetUse(void) {return Use;}
- inline void SetUse(TUSE n) {Use = n;}
- inline PFIL GetFilter(void) {return To_Filter;}
- inline void SetOrig(PTBX txp) {To_Orig = txp;}
- inline void SetFilter(PFIL fp) {To_Filter = fp;}
-
- // Methods
- virtual bool IsSame(PTBX tp) {return tp == this;}
- virtual int GetTdb_No(void) = 0; // Convenience during conversion
- virtual PTDB GetNext(void) = 0;
- virtual int Cardinality(PGLOBAL) = 0;
- virtual int GetMaxSize(PGLOBAL) = 0;
- virtual int GetProgMax(PGLOBAL) = 0;
- virtual int GetProgCur(void) = 0;
- virtual int GetBadLines(void) {return 0;}
- virtual PTBX Copy(PTABS t) = 0;
-
- protected:
-//virtual void PrepareFilters(PGLOBAL g) = 0;
-
- protected:
- // Members
- PTBX To_Orig; // Pointer to original if it is a copy
- PFIL To_Filter;
- TUSE Use;
- }; // end of class TBX
-
-/***********************************************************************/
/* Definition of class TDB with all its method functions. */
/***********************************************************************/
-class DllExport TDB: public TBX { // Table Descriptor Block.
+class DllExport TDB: public BLOCK { // Table Descriptor Block.
public:
// Constructors
TDB(PTABDEF tdp = NULL);
@@ -92,11 +54,17 @@ class DllExport TDB: public TBX { // Table Descriptor Block.
// Implementation
static void SetTnum(int n) {Tnum = n;}
+ inline PTDB GetOrig(void) {return To_Orig;}
+ inline TUSE GetUse(void) {return Use;}
+ inline PCFIL GetCondFil(void) {return To_CondFil;}
inline LPCSTR GetName(void) {return Name;}
inline PTABLE GetTable(void) {return To_Table;}
inline PCOL GetColumns(void) {return Columns;}
inline int GetDegree(void) {return Degree;}
inline MODE GetMode(void) {return Mode;}
+ inline void SetOrig(PTDB txp) {To_Orig = txp;}
+ inline void SetUse(TUSE n) {Use = n;}
+ inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;}
inline void SetNext(PTDB tdbp) {Next = tdbp;}
inline void SetName(LPCSTR name) {Name = name;}
inline void SetTable(PTABLE tablep) {To_Table = tablep;}
@@ -105,25 +73,30 @@ class DllExport TDB: public TBX { // Table Descriptor Block.
inline void SetMode(MODE mode) {Mode = mode;}
//Properties
+ virtual AMT GetAmType(void) {return TYPE_AM_ERROR;}
virtual int GetTdb_No(void) {return Tdb_No;}
virtual PTDB GetNext(void) {return Next;}
virtual PCATLG GetCat(void) {return NULL;}
// Methods
- virtual AMT GetAmType(void) {return TYPE_AM_ERROR;}
+ virtual bool IsSame(PTDB tp) {return tp == this;}
virtual bool GetBlockValues(PGLOBAL g) {return false;}
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
+ virtual int GetMaxSize(PGLOBAL) = 0;
+ virtual int GetProgMax(PGLOBAL) = 0;
+ virtual int GetProgCur(void) = 0;
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual bool IsReadOnly(void) {return true;}
- virtual const CHARSET_INFO *data_charset() { return NULL; }
+ virtual const CHARSET_INFO *data_charset() {return NULL;}
virtual PTDB Duplicate(PGLOBAL g) {return NULL;}
virtual PTDB CopyOne(PTABS t) {return this;}
- virtual PTBX Copy(PTABS t);
+ virtual PTDB Copy(PTABS t);
virtual void PrintAM(FILE *f, char *m)
{fprintf(f, "%s AM(%d)\n", m, GetAmType());}
virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z);
virtual PSZ GetServer(void) = 0;
+ virtual int GetBadLines(void) {return 0;}
// Database pure virtual routines
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num) = 0;
@@ -135,12 +108,11 @@ class DllExport TDB: public TBX { // Table Descriptor Block.
virtual void CloseDB(PGLOBAL) = 0;
virtual int CheckWrite(PGLOBAL g) {return 0;}
- // Database routines
- bool OpenTable(PGLOBAL g, PSQL sqlp, MODE mode);
- void CloseTable(PGLOBAL g);
-
protected:
// Members
+ PTDB To_Orig; // Pointer to original if it is a copy
+ TUSE Use;
+ PCFIL To_CondFil; // To condition filter structure
static int Tnum; // Used to generate Tdb_no's
const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN
PTDB Next; // Next in linearized queries