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

10.0-connect merge

This commit is contained in:
Sergei Golubchik
2014-03-29 17:32:46 +01:00
88 changed files with 2243 additions and 2977 deletions

View File

@@ -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})

View File

@@ -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

View File

@@ -43,7 +43,6 @@ typedef struct _colinfo {
int Key;
int Precision;
int Scale;
int Opt;
char *Remark;
char *Datefmt;
char *Fieldfmt;

View File

@@ -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())
@@ -154,15 +143,6 @@ bool COLBLK::Eval(PGLOBAL g)
return false;
} // 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 */
@@ -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

View File

@@ -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:

View File

@@ -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];

View File

@@ -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);

View File

@@ -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;

View File

@@ -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(...) {}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 -------------------------- */
/***********************************************************************/
@@ -313,15 +294,6 @@ int DOSFAM::Cardinality(PGLOBAL g)
return (g) ? -1 : 0;
} // 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. */
/***********************************************************************/
@@ -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;
@@ -1028,23 +1003,6 @@ int BLKFAM::Cardinality(PGLOBAL g)
//return (g) ? (int)((Block - 1) * Nrec + Last) : 1;
} // 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 */
@@ -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
/***********************************************************************/

View File

@@ -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);

View File

@@ -244,23 +244,6 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g)
return rc;
} // 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 */

View File

@@ -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

View File

@@ -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)
@@ -413,23 +412,6 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
Closing = txfp->Closing;
} // 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 */
@@ -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) {

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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);
@@ -167,6 +167,29 @@ bool IsFileType(TABTYPE type)
return isfile;
} // 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. */
/***********************************************************************/
@@ -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);

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
#

View File

@@ -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;

View File

@@ -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;

View File

@@ -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>

View File

@@ -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 { };

View File

@@ -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

View File

@@ -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;

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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 ---------------------------- */

View File

@@ -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);

View File

@@ -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

View File

@@ -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)

View File

@@ -3,31 +3,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. */
/***********************************************************************/
@@ -49,8 +24,6 @@ typedef struct _datpar {
extern "C" {
#endif
int sqlflex(PPREP pp);
int sqpflex(PPREP pp);
int fmdflex(PDTP pp);
#ifdef __cplusplus

View File

@@ -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);

View File

@@ -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

View File

@@ -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
/***********************************************************************/

View File

@@ -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

View File

@@ -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;
@@ -109,6 +93,50 @@ DOSDEF::DOSDEF(void)
//Mtime = 0;
} // 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 */
@@ -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. */
@@ -221,49 +250,6 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
return rc; // Return true if error
} // 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. */
/***********************************************************************/
@@ -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;
@@ -971,28 +966,6 @@ DOSCOL::DOSCOL(DOSCOL *col1, PTDB tdbp) : COLBLK(col1, tdbp)
Buf = col1->Buf;
} // 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. */
/***********************************************************************/

View File

@@ -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

View File

@@ -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: */
/* ----------------------- */

View File

@@ -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
@@ -1272,25 +1271,6 @@ CSVCOL::CSVCOL(CSVCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
Fldnum = col1->Fldnum;
} // 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;

View File

@@ -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

View File

@@ -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 ???

View File

@@ -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

View File

@@ -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);

View File

@@ -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");

View File

@@ -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

View File

@@ -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

View File

@@ -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");

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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
/* ------------------------------------------------------------------- */

View File

@@ -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

View File

@@ -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
/*********************************************************************/

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
@@ -1344,6 +1343,12 @@ void XMLCOL::WriteColumn(PGLOBAL g)
if (Tdbp->CheckRow(g, Nod || Tdbp->Colname))
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. */
/*********************************************************************/

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 *);

View File

@@ -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);

View File

@@ -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

View File

@@ -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. */
/***********************************************************************/

View File

@@ -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

View File

@@ -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