Commit 85e8aee4 authored by Olivier Bertrand's avatar Olivier Bertrand

- Temporary

modified:
  storage/connect/catalog.h
  storage/connect/colblk.cpp
  storage/connect/colblk.h
  storage/connect/connect.cc
  storage/connect/filamap.cpp
  storage/connect/filamfix.cpp
  storage/connect/filamfix.h
  storage/connect/filamtxt.cpp
  storage/connect/filamvct.cpp
  storage/connect/filamzip.cpp
  storage/connect/filamzip.h
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
  storage/connect/reldef.cpp
  storage/connect/reldef.h
  storage/connect/tabdos.cpp
  storage/connect/tabdos.h
  storage/connect/tabfix.cpp
  storage/connect/tabfix.h
  storage/connect/tabfmt.cpp
  storage/connect/tabfmt.h
  storage/connect/table.cpp
  storage/connect/tabmac.h
  storage/connect/tabmul.h
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabsys.cpp
  storage/connect/tabsys.h
  storage/connect/tabtbl.cpp
  storage/connect/tabtbl.h
  storage/connect/tabvct.cpp
  storage/connect/tabvct.h
  storage/connect/tabwmi.cpp
  storage/connect/tabwmi.h
  storage/connect/tabxml.cpp
  storage/connect/tabxml.h
  storage/connect/valblk.cpp
  storage/connect/valblk.h
  storage/connect/value.cpp
  storage/connect/value.h
  storage/connect/xobject.cpp
  storage/connect/xobject.h
  storage/connect/xtable.h
parent 126bb345
...@@ -44,6 +44,7 @@ typedef struct _colinfo { ...@@ -44,6 +44,7 @@ typedef struct _colinfo {
int Precision; int Precision;
int Scale; int Scale;
int Opt; int Opt;
int Freq;
char *Remark; char *Remark;
char *Datefmt; char *Datefmt;
char *Fieldfmt; char *Fieldfmt;
......
...@@ -39,6 +39,7 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i) ...@@ -39,6 +39,7 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
Opt = cdp->Opt; Opt = cdp->Opt;
Long = cdp->Long; Long = cdp->Long;
Precision = cdp->Precision; Precision = cdp->Precision;
Freq = cdp->Freq;
Buf_Type = cdp->Buf_Type; Buf_Type = cdp->Buf_Type;
ColUse |= cdp->Flags; // Used by CONNECT ColUse |= cdp->Flags; // Used by CONNECT
Nullable = !!(cdp->Flags & U_NULLS); Nullable = !!(cdp->Flags & U_NULLS);
...@@ -49,6 +50,7 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i) ...@@ -49,6 +50,7 @@ COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
Opt = 0; Opt = 0;
Long = 0; Long = 0;
Precision = 0; Precision = 0;
Freq = 0;
Buf_Type = TYPE_ERROR; Buf_Type = TYPE_ERROR;
Nullable = false; Nullable = false;
Unsigned = false; Unsigned = false;
......
...@@ -36,6 +36,10 @@ class DllExport COLBLK : public XOBJECT { ...@@ -36,6 +36,10 @@ class DllExport COLBLK : public XOBJECT {
virtual int GetAmType() {return TYPE_AM_ERROR;} virtual int GetAmType() {return TYPE_AM_ERROR;}
virtual void SetOk(void) {Status |= BUF_EMPTY;} virtual void SetOk(void) {Status |= BUF_EMPTY;}
virtual PTDB GetTo_Tdb(void) {return To_Tdb;} virtual PTDB GetTo_Tdb(void) {return To_Tdb;}
#if defined(BLK_INDX)
virtual int GetClustered(void) {return 0;}
virtual int IsClustered(void) {return FALSE;}
#endif // BLK_INDX
PCOL GetNext(void) {return Next;} PCOL GetNext(void) {return Next;}
PSZ GetName(void) {return Name;} PSZ GetName(void) {return Name;}
int GetIndex(void) {return Index;} int GetIndex(void) {return Index;}
...@@ -76,7 +80,9 @@ class DllExport COLBLK : public XOBJECT { ...@@ -76,7 +80,9 @@ class DllExport COLBLK : public XOBJECT {
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint); virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint); virtual void Print(PGLOBAL g, char *, uint);
#if defined(BLK_INDX)
virtual bool VarSize(void) {return false;} virtual bool VarSize(void) {return false;}
#endif // BLK_INDX
virtual bool IsColInside(PCOL colp) {return this == colp;} virtual bool IsColInside(PCOL colp) {return this == colp;}
bool InitValue(PGLOBAL g); bool InitValue(PGLOBAL g);
...@@ -94,6 +100,7 @@ class DllExport COLBLK : public XOBJECT { ...@@ -94,6 +100,7 @@ class DllExport COLBLK : public XOBJECT {
int Buf_Type; // Data type int Buf_Type; // Data type
int Long; // Internal length in table int Long; // Internal length in table
int Precision; // Column length (as for ODBC) int Precision; // Column length (as for ODBC)
int Freq; // Evaluated ceiling of distinct values
FORMAT Format; // Output format FORMAT Format; // Output format
ushort ColUse; // Column usage ushort ColUse; // Column usage
ushort Status; // Column read status ushort Status; // Column read status
......
...@@ -433,7 +433,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr) ...@@ -433,7 +433,7 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr)
/***********************************************************************/ /***********************************************************************/
/* ReadNext: Read next record sequentially. */ /* ReadNext: Read next record sequentially. */
/***********************************************************************/ /***********************************************************************/
RCODE CntReadNext(PGLOBAL g, PTDB tdbp) RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
{ {
RCODE rc; RCODE rc;
...@@ -449,8 +449,21 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp) ...@@ -449,8 +449,21 @@ RCODE CntReadNext(PGLOBAL g, PTDB tdbp)
((PTDBASE)tdbp)->SetKindex(NULL); ((PTDBASE)tdbp)->SetKindex(NULL);
} // endif index } // endif index
// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return RC_FX;
} // endif jump_level
if ((setjmp(g->jumper[++g->jump_level])) != 0) {
rc= RC_FX;
goto err;
} // endif rc
while ((rc= (RCODE)tdbp->ReadDB(g)) == RC_NF) ; while ((rc= (RCODE)tdbp->ReadDB(g)) == RC_NF) ;
err:
g->jump_level--;
return (rc != RC_OK) ? rc : EvalColumns(g, tdbp); return (rc != RC_OK) ? rc : EvalColumns(g, tdbp);
} // end of CntReadNext } // end of CntReadNext
...@@ -578,7 +591,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp) ...@@ -578,7 +591,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp)
tbxp= (TDBDOX*)tdbp; tbxp= (TDBDOX*)tdbp;
tbxp->SetKindex(NULL); tbxp->SetKindex(NULL);
tbxp->To_Key_Col= NULL; tbxp->To_Key_Col= NULL;
rc= tbxp->ResetTableOpt(g, ((PTDBASE)tdbp)->GetDef()->Indexable()); rc= tbxp->ResetTableOpt(g, false, ((PTDBASE)tdbp)->GetDef()->Indexable());
err: err:
if (xtrace > 1) if (xtrace > 1)
......
/*********** File AM Map C++ Program Source Code File (.CPP) ***********/ /*********** File AM Map C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMAP */ /* PROGRAM NAME: FILAMAP */
/* ------------- */ /* ------------- */
/* Version 1.4 */ /* Version 1.5 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -322,8 +322,30 @@ int MAPFAM::ReadBuffer(PGLOBAL g) ...@@ -322,8 +322,30 @@ int MAPFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
/* Record file position in case of UPDATE or DELETE. */ /* Record file position in case of UPDATE or DELETE. */
/*******************************************************************/ /*******************************************************************/
Fpos = Mempos; #if defined(BLK_INDX)
CurBlk = (int)Rows++; int rc;
next:
#endif // BLK_INDX
Fpos = Mempos;
CurBlk = (int)Rows++;
#if defined(BLK_INDX)
/*******************************************************************/
/* Check whether optimization on ROWID */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
// Skip this record
if ((rc = SkipRecord(g, FALSE)) != RC_OK)
return rc;
goto next;
} // endswitch rc
#endif // BLK_INDX
} else } else
Placed = false; Placed = false;
...@@ -491,7 +513,11 @@ MBKFAM::MBKFAM(PDOSDEF tdp) : MAPFAM(tdp) ...@@ -491,7 +513,11 @@ MBKFAM::MBKFAM(PDOSDEF tdp) : MAPFAM(tdp)
Block = tdp->GetBlock(); Block = tdp->GetBlock();
Last = tdp->GetLast(); Last = tdp->GetLast();
Nrec = tdp->GetElemt(); Nrec = tdp->GetElemt();
#if defined(BLK_INDX)
BlkPos = tdp->GetTo_Pos(); BlkPos = tdp->GetTo_Pos();
#else // !BLK_INDX
BlkPos = NULL;
#endif // !BLK_INDX
CurNum = Nrec; CurNum = Nrec;
} // end of MBKFAM standard constructor } // end of MBKFAM standard constructor
...@@ -537,6 +563,7 @@ int MBKFAM::GetRowID(void) ...@@ -537,6 +563,7 @@ int MBKFAM::GetRowID(void)
/***********************************************************************/ /***********************************************************************/
int MBKFAM::ReadBuffer(PGLOBAL g) int MBKFAM::ReadBuffer(PGLOBAL g)
{ {
#if defined(BLK_INDX)
int len; int len;
/*********************************************************************/ /*********************************************************************/
...@@ -554,9 +581,21 @@ int MBKFAM::ReadBuffer(PGLOBAL g) ...@@ -554,9 +581,21 @@ int MBKFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
CurNum = 0; CurNum = 0;
next:
if (++CurBlk >= Block) if (++CurBlk >= Block)
return RC_EF; return RC_EF;
/*******************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
Fpos = Mempos = Memory + BlkPos[CurBlk]; Fpos = Mempos = Memory + BlkPos[CurBlk];
} // endif's } // endif's
...@@ -568,6 +607,10 @@ int MBKFAM::ReadBuffer(PGLOBAL g) ...@@ -568,6 +607,10 @@ int MBKFAM::ReadBuffer(PGLOBAL g)
memcpy(Tdbp->GetLine(), Fpos, len); memcpy(Tdbp->GetLine(), Fpos, len);
Tdbp->GetLine()[len] = '\0'; Tdbp->GetLine()[len] = '\0';
return RC_OK; return RC_OK;
#else // !BLK_POS
strcpy(g->Message, "This AM cannot be used in this version");
return RC_FX;
#endif // !BLK_POS
} // end of ReadBuffer } // end of ReadBuffer
/***********************************************************************/ /***********************************************************************/
...@@ -657,10 +700,26 @@ int MPXFAM::ReadBuffer(PGLOBAL g) ...@@ -657,10 +700,26 @@ int MPXFAM::ReadBuffer(PGLOBAL g)
/* New block. */ /* New block. */
/*******************************************************************/ /*******************************************************************/
CurNum = 0; CurNum = 0;
#if defined(BLK_INDX)
next:
#endif // BLK_INDX
if (++CurBlk >= Block) if (++CurBlk >= Block)
return RC_EF; return RC_EF;
#if defined(BLK_INDX)
/*******************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
#endif // BLK_INDX
Fpos = Mempos = Headlen + Memory + CurBlk * Blksize; Fpos = Mempos = Headlen + Memory + CurBlk * Blksize;
} // endif's } // endif's
......
/*********** File AM Fix C++ Program Source Code File (.CPP) ***********/ /*********** File AM Fix C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMFIX */ /* PROGRAM NAME: FILAMFIX */
/* ------------- */ /* ------------- */
/* Version 1.4 */ /* Version 1.5 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -168,9 +168,24 @@ int FIXFAM::ReadBuffer(PGLOBAL g) ...@@ -168,9 +168,24 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0; CurNum = 0;
Tdbp->SetLine(To_Buf); Tdbp->SetLine(To_Buf);
#if defined(BLK_INDX)
next:
#endif // BLK_INDX
if (++CurBlk >= Block) if (++CurBlk >= Block)
return RC_EF; return RC_EF;
#if defined(BLK_INDX)
/*****************************************************************/
/* Before reading a new block, check whether block indexing */
/* can be done, as well as for join as for local filtering. */
/*****************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
#endif // BLK_INDX
} // endif's } // endif's
if (OldBlk == CurBlk) { if (OldBlk == CurBlk) {
...@@ -1028,9 +1043,24 @@ int BGXFAM::ReadBuffer(PGLOBAL g) ...@@ -1028,9 +1043,24 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0; CurNum = 0;
Tdbp->SetLine(To_Buf); Tdbp->SetLine(To_Buf);
#if defined(BLK_INDX)
next:
#endif // BLK_INDX
if (++CurBlk >= Block) if (++CurBlk >= Block)
return RC_EF; return RC_EF;
#if defined(BLK_INDX)
/*****************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*****************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
#endif // BLK_INDX
} // endif's } // endif's
if (OldBlk == CurBlk) { if (OldBlk == CurBlk) {
......
...@@ -33,16 +33,16 @@ class DllExport FIXFAM : public BLKFAM { ...@@ -33,16 +33,16 @@ class DllExport FIXFAM : public BLKFAM {
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
protected: protected:
virtual bool CopyHeader(PGLOBAL g) {return false;} virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members // No additional members
}; // end of class FIXFAM }; // end of class FIXFAM
...@@ -69,7 +69,7 @@ class BGXFAM : public FIXFAM { ...@@ -69,7 +69,7 @@ class BGXFAM : public FIXFAM {
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
...@@ -78,7 +78,7 @@ class BGXFAM : public FIXFAM { ...@@ -78,7 +78,7 @@ class BGXFAM : public FIXFAM {
, int org = FILE_BEGIN); , int org = FILE_BEGIN);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
// Members // Members
......
/*********** File AM Txt C++ Program Source Code File (.CPP) ***********/ /*********** File AM Txt C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMTXT */ /* PROGRAM NAME: FILAMTXT */
/* ------------- */ /* ------------- */
/* Version 1.4 */ /* Version 1.5 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -235,13 +235,20 @@ int TXTFAM::Cardinality(PGLOBAL g) ...@@ -235,13 +235,20 @@ int TXTFAM::Cardinality(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TXTFAM::MaxBlkSize(PGLOBAL g, int s) int TXTFAM::MaxBlkSize(PGLOBAL g, int s)
{ {
int savcur = CurBlk, blm1 = Block - 1; int rc = RC_OK, savcur = CurBlk, blm1 = Block - 1;
int size, last = s - blm1 * Nrec; int size, last = s - blm1 * Nrec;
// Roughly estimate the table size as the sum of blocks // Roughly estimate the table size as the sum of blocks
// that can contain good rows // that can contain good rows
for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++) for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
#if defined(BLK_INDX)
if ((rc = Tdbp->TestBlock(g)) == RC_OK)
size += (CurBlk == blm1) ? last : Nrec;
else if (rc == RC_EF)
break;
#else // !BLK_INDX
size += (CurBlk == blm1) ? last : Nrec; size += (CurBlk == blm1) ? last : Nrec;
#endif // !BLK_INDX
CurBlk = savcur; CurBlk = savcur;
return size; return size;
...@@ -543,6 +550,9 @@ int DOSFAM::ReadBuffer(PGLOBAL g) ...@@ -543,6 +550,9 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
/* Record file position in case of UPDATE or DELETE. */ /* Record file position in case of UPDATE or DELETE. */
/*******************************************************************/ /*******************************************************************/
#if defined(BLK_INDX)
next:
#endif // BLK_INDX
if (RecordPos(g)) if (RecordPos(g))
return RC_FX; return RC_FX;
...@@ -551,6 +561,22 @@ int DOSFAM::ReadBuffer(PGLOBAL g) ...@@ -551,6 +561,22 @@ int DOSFAM::ReadBuffer(PGLOBAL g)
if (trace > 1) if (trace > 1)
htrc("ReadBuffer: CurBlk=%d\n", CurBlk); htrc("ReadBuffer: CurBlk=%d\n", CurBlk);
#if defined(BLK_INDX)
/*******************************************************************/
/* Check whether optimization on ROWID */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
// Skip this record
if ((rc = SkipRecord(g, FALSE)) != RC_OK)
return rc;
goto next;
} // endswitch rc
#endif // BLK_INDX
} else } else
Placed = false; Placed = false;
...@@ -993,7 +1019,11 @@ BLKFAM::BLKFAM(PDOSDEF tdp) : DOSFAM(tdp) ...@@ -993,7 +1019,11 @@ BLKFAM::BLKFAM(PDOSDEF tdp) : DOSFAM(tdp)
Last = tdp->GetLast(); Last = tdp->GetLast();
Nrec = tdp->GetElemt(); Nrec = tdp->GetElemt();
Closing = false; Closing = false;
#if defined(BLK_INDX)
BlkPos = tdp->GetTo_Pos(); BlkPos = tdp->GetTo_Pos();
#else // !BLK_INDX
BlkPos = NULL;
#endif // !BLK_INDX
CurLine = NULL; CurLine = NULL;
NxtLine = NULL; NxtLine = NULL;
OutBuf = NULL; OutBuf = NULL;
...@@ -1033,13 +1063,20 @@ int BLKFAM::Cardinality(PGLOBAL g) ...@@ -1033,13 +1063,20 @@ int BLKFAM::Cardinality(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int BLKFAM::MaxBlkSize(PGLOBAL g, int s) int BLKFAM::MaxBlkSize(PGLOBAL g, int s)
{ {
int savcur = CurBlk; int rc = RC_OK, savcur = CurBlk;
int size; int size;
// Roughly estimate the table size as the sum of blocks // Roughly estimate the table size as the sum of blocks
// that can contain good rows // that can contain good rows
for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++) for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
#if defined(BLK_INDX)
if ((rc = Tdbp->TestBlock(g)) == RC_OK)
size += (CurBlk == Block - 1) ? Last : Nrec;
else if (rc == RC_EF)
break;
#else // !BLK_INDX
size += (CurBlk == Block - 1) ? Last : Nrec; size += (CurBlk == Block - 1) ? Last : Nrec;
#endif // !BLK_INDX
CurBlk = savcur; CurBlk = savcur;
return size; return size;
...@@ -1150,6 +1187,7 @@ int BLKFAM::SkipRecord(PGLOBAL g, bool header) ...@@ -1150,6 +1187,7 @@ int BLKFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/ /***********************************************************************/
int BLKFAM::ReadBuffer(PGLOBAL g) int BLKFAM::ReadBuffer(PGLOBAL g)
{ {
#if defined(BLK_INDX)
int i, n, rc = RC_OK; int i, n, rc = RC_OK;
/*********************************************************************/ /*********************************************************************/
...@@ -1176,9 +1214,21 @@ int BLKFAM::ReadBuffer(PGLOBAL g) ...@@ -1176,9 +1214,21 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
CurNum = 0; CurNum = 0;
next:
if (++CurBlk >= Block) if (++CurBlk >= Block)
return RC_EF; return RC_EF;
/*******************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
} // endif's } // endif's
if (OldBlk == CurBlk) if (OldBlk == CurBlk)
...@@ -1241,6 +1291,10 @@ int BLKFAM::ReadBuffer(PGLOBAL g) ...@@ -1241,6 +1291,10 @@ int BLKFAM::ReadBuffer(PGLOBAL g)
// Store the current record file position for Delete and Update // Store the current record file position for Delete and Update
Fpos = BlkPos[CurBlk] + CurLine - To_Buf; Fpos = BlkPos[CurBlk] + CurLine - To_Buf;
return rc; return rc;
#else // !BLK_POS
strcpy(g->Message, "This AM cannot be used in this version");
return RC_FX;
#endif // !BLK_POS
} // end of ReadBuffer } // end of ReadBuffer
/***********************************************************************/ /***********************************************************************/
......
/*********** File AM Vct C++ Program Source Code File (.CPP) ***********/ /*********** File AM Vct C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMVCT */ /* PROGRAM NAME: FILAMVCT */
/* ------------- */ /* ------------- */
/* Version 2.4 */ /* Version 2.5 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -249,13 +249,20 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g) ...@@ -249,13 +249,20 @@ bool VCTFAM::SetBlockInfo(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int VCTFAM::MaxBlkSize(PGLOBAL g, int s) int VCTFAM::MaxBlkSize(PGLOBAL g, int s)
{ {
int savcur = CurBlk; int rc = RC_OK, savcur = CurBlk;
int size; int size;
// Roughly estimate the table size as the sum of blocks // Roughly estimate the table size as the sum of blocks
// that can contain good rows // that can contain good rows
for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++) for (size = 0, CurBlk = 0; CurBlk < Block; CurBlk++)
#if defined(BLK_INDX)
if ((rc = Tdbp->TestBlock(g)) == RC_OK)
size += (CurBlk == Block - 1) ? Last : Nrec;
else if (rc == RC_EF)
break;
#else // !BLK_INDX
size += (CurBlk == Block - 1) ? Last : Nrec; size += (CurBlk == Block - 1) ? Last : Nrec;
#endif // !BLK_INDX
CurBlk = savcur; CurBlk = savcur;
return size; return size;
...@@ -572,9 +579,25 @@ int VCTFAM::ReadBuffer(PGLOBAL g) ...@@ -572,9 +579,25 @@ int VCTFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
CurNum = 0; CurNum = 0;
#if defined(BLK_INDX)
next:
#endif // BLK_INDX
if (++CurBlk == Block) if (++CurBlk == Block)
return RC_EF; // End of file return RC_EF; // End of file
#if defined(BLK_INDX)
/*******************************************************************/
/* Before reading a new block, check whether block optimizing */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
#endif // BLK_INDX
num_there++; num_there++;
} // endif CurNum } // endif CurNum
......
This diff is collapsed.
...@@ -122,7 +122,7 @@ class DllExport ZIXFAM : public ZBKFAM { ...@@ -122,7 +122,7 @@ class DllExport ZIXFAM : public ZBKFAM {
// No additional Members // No additional Members
}; // end of class ZIXFAM }; // end of class ZIXFAM
#ifdef NOT_USED #if defined(BLK_INDX)
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for PlugDB */ /* This is the DOS/UNIX Access Method class declaration for PlugDB */
/* fixed/variable files compressed using the zlib library functions. */ /* fixed/variable files compressed using the zlib library functions. */
...@@ -166,6 +166,6 @@ class DllExport ZLBFAM : public BLKFAM { ...@@ -166,6 +166,6 @@ class DllExport ZLBFAM : public BLKFAM {
int *Zlenp; // Pointer to block length int *Zlenp; // Pointer to block length
bool Optimized; // true when opt file is available bool Optimized; // true when opt file is available
}; // end of class ZLBFAM }; // end of class ZLBFAM
#endif // NOT_USED #endif // BLK_INDX
#endif // __FILAMZIP_H #endif // __FILAMZIP_H
This diff is collapsed.
...@@ -334,8 +334,11 @@ public: ...@@ -334,8 +334,11 @@ public:
condition stack. condition stack.
*/ */
virtual const COND *cond_push(const COND *cond); virtual const COND *cond_push(const COND *cond);
PFIL CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond); PCFIL CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond);
const char *GetValStr(OPVAL vop, bool neg); const char *GetValStr(OPVAL vop, bool neg);
#if defined(BLK_INDX)
PFIL CondFilter(PGLOBAL g, Item *cond);
#endif // BLK_INDX
/** /**
Number of rows in table. It will only be called if Number of rows in table. It will only be called if
......
...@@ -29,6 +29,10 @@ enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */ ...@@ -29,6 +29,10 @@ enum BLKTYP {TYPE_TABLE = 50, /* Table Name/Srcdef/... Block */
// TYPE_OPVAL = 52, /* Operator value (OPVAL) */ // TYPE_OPVAL = 52, /* Operator value (OPVAL) */
TYPE_TDB = 53, /* Table Description Block */ TYPE_TDB = 53, /* Table Description Block */
TYPE_COLBLK = 54, /* Column Description Block */ TYPE_COLBLK = 54, /* Column Description Block */
#if defined(BLK_INDX)
TYPE_FILTER = 55, /* Filter Description Block */
TYPE_ARRAY = 63, /* General array type */
#endif // BLK_INDX
TYPE_PSZ = 64, /* Pointer to String ended by 0 */ TYPE_PSZ = 64, /* Pointer to String ended by 0 */
TYPE_SQL = 65, /* Pointer to SQL block */ TYPE_SQL = 65, /* Pointer to SQL block */
TYPE_XOBJECT = 69, /* Extended DB object */ TYPE_XOBJECT = 69, /* Extended DB object */
...@@ -144,21 +148,19 @@ enum RECFM {RECFM_NAF = -2, /* Not a file */ ...@@ -144,21 +148,19 @@ enum RECFM {RECFM_NAF = -2, /* Not a file */
RECFM_PLG = 5, /* Table accessed via PLGconn */ RECFM_PLG = 5, /* Table accessed via PLGconn */
RECFM_DBF = 6}; /* DBase formatted file */ RECFM_DBF = 6}; /* DBase formatted file */
#if 0
enum MISC {DB_TABNO = 1, /* DB routines in Utility Table */ enum MISC {DB_TABNO = 1, /* DB routines in Utility Table */
MAX_MULT_KEY = 10, /* Max multiple key number */ MAX_MULT_KEY = 10, /* Max multiple key number */
NAM_LEN = 128, /* Length of col and tab names */ NAM_LEN = 128, /* Length of col and tab names */
ARRAY_SIZE = 50, /* Default array block size */ ARRAY_SIZE = 50, /* Default array block size */
MAXRES = 500, /* Default maximum result lines */ // MAXRES = 500, /* Default maximum result lines */
MAXLIN = 10000, /* Default maximum data lines */ // MAXLIN = 10000, /* Default maximum data lines */
MAXBMP = 32}; /* Default XDB2 max bitmap size */ MAXBMP = 32}; /* Default XDB2 max bitmap size */
#if 0
enum ALGMOD {AMOD_AUTO = 0, /* PLG chooses best algorithm */ enum ALGMOD {AMOD_AUTO = 0, /* PLG chooses best algorithm */
AMOD_SQL = 1, /* Use SQL algorithm */ AMOD_SQL = 1, /* Use SQL algorithm */
AMOD_QRY = 2}; /* Use QUERY algorithm */ AMOD_QRY = 2}; /* Use QUERY algorithm */
#else // !0 #endif // 0
#define NAM_LEN 128
#endif // !0
enum MODE {MODE_ERROR = -1, /* Invalid mode */ enum MODE {MODE_ERROR = -1, /* Invalid mode */
MODE_ANY = 0, /* Unspecified mode */ MODE_ANY = 0, /* Unspecified mode */
...@@ -342,7 +344,7 @@ typedef class XTAB *PTABLE; ...@@ -342,7 +344,7 @@ typedef class XTAB *PTABLE;
typedef class COLUMN *PCOLUMN; typedef class COLUMN *PCOLUMN;
typedef class XOBJECT *PXOB; typedef class XOBJECT *PXOB;
typedef class COLBLK *PCOL; typedef class COLBLK *PCOL;
typedef class TBX *PTBX; //pedef class TBX *PTBX;
typedef class TDB *PTDB; typedef class TDB *PTDB;
typedef void *PSQL; // Not used typedef void *PSQL; // Not used
typedef class TDBASE *PTDBASE; typedef class TDBASE *PTDBASE;
...@@ -376,6 +378,9 @@ typedef class COLDEF *PCOLDEF; ...@@ -376,6 +378,9 @@ typedef class COLDEF *PCOLDEF;
typedef class CONSTANT *PCONST; typedef class CONSTANT *PCONST;
typedef class VALUE *PVAL; typedef class VALUE *PVAL;
typedef class VALBLK *PVBLK; typedef class VALBLK *PVBLK;
#if defined(BLK_INDX)
typedef class FILTER *PFIL;
#endif // BLK_INDX
typedef struct _fblock *PFBLOCK; typedef struct _fblock *PFBLOCK;
typedef struct _mblock *PMBLOCK; typedef struct _mblock *PMBLOCK;
...@@ -431,7 +436,9 @@ typedef struct { /* User application block */ ...@@ -431,7 +436,9 @@ typedef struct { /* User application block */
//int Maxres; /* Result Max nb of lines */ //int Maxres; /* Result Max nb of lines */
//int Maxtmp; /* Intermediate tables Maxres */ //int Maxtmp; /* Intermediate tables Maxres */
//int Maxlin; /* Query Max nb of data lines */ //int Maxlin; /* Query Max nb of data lines */
//int Maxbmp; /* Maximum XDB2 bitmap size */ #if defined(BLK_INDX)
int Maxbmp; /* Maximum XDB2 bitmap size */
#endif // BLK_INDX
int Check; /* General level of checking */ int Check; /* General level of checking */
int Numlines; /* Number of lines involved */ int Numlines; /* Number of lines involved */
//ALGMOD AlgChoice; /* Choice of algorithm mode */ //ALGMOD AlgChoice; /* Choice of algorithm mode */
...@@ -481,6 +488,38 @@ typedef struct _tabs { ...@@ -481,6 +488,38 @@ typedef struct _tabs {
PTABADR P3; PTABADR P3;
} TABS; } TABS;
#if defined(BLK_INDX)
/***********************************************************************/
/* Argument of expression, function, filter etc. (Xobject) */
/***********************************************************************/
typedef struct _arg { /* Argument */
PXOB To_Obj; /* To the argument object */
PVAL Value; /* Argument value */
bool Conv; /* TRUE if conversion is required */
} ARGBLK, *PARG;
typedef struct _oper { /* Operator */
PSZ Name; /* The input/output operator name */
OPVAL Val; /* Operator numeric value */
int Mod; /* The modificator */
} OPER, *POPER;
#if 0
/***********************************************************************/
/* Definitions and table of Scalar Functions. */
/***********************************************************************/
typedef struct _sfdsc { /* Scalar function description block*/
char Name[16]; /* Scalar function name */
EVAL EvalType; /* Type of Init and Eval functions */
OPVAL Op; /* Equivalent operator number */
int R_Type; /* Result Type */
int R_Length; /* Result Length */
int R_Prec; /* Result Precision */
int Numarg; /* Number of arguments */
} SFDSC, *PSFDSC;
#endif // 0
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* Following definitions are used to define table fields (columns). */ /* Following definitions are used to define table fields (columns). */
/***********************************************************************/ /***********************************************************************/
......
...@@ -382,7 +382,9 @@ PDBUSER PlgMakeUser(PGLOBAL g) ...@@ -382,7 +382,9 @@ PDBUSER PlgMakeUser(PGLOBAL g)
//#endif //#endif
//dbuserp->Maxres = MAXRES; //dbuserp->Maxres = MAXRES;
//dbuserp->Maxlin = MAXLIN; //dbuserp->Maxlin = MAXLIN;
//dbuserp->Maxbmp = MAXBMP; #if defined(BLK_INDX)
dbuserp->Maxbmp = MAXBMP;
#endif // BLK_INDX
//dbuserp->AlgChoice = AMOD_AUTO; //dbuserp->AlgChoice = AMOD_AUTO;
dbuserp->UseTemp = TMP_AUTO; dbuserp->UseTemp = TMP_AUTO;
dbuserp->Check = CHK_ALL; dbuserp->Check = CHK_ALL;
......
...@@ -204,6 +204,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) ...@@ -204,6 +204,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
return xdefp; return xdefp;
} // end of GetXdef } // end of GetXdef
#if 0
/***********************************************************************/ /***********************************************************************/
/* DeleteTableFile: Delete an OEM table file if applicable. */ /* DeleteTableFile: Delete an OEM table file if applicable. */
/***********************************************************************/ /***********************************************************************/
...@@ -214,6 +215,7 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g) ...@@ -214,6 +215,7 @@ bool OEMDEF::DeleteTableFile(PGLOBAL g)
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true; return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
} // end of DeleteTableFile } // end of DeleteTableFile
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* Define: initialize the table definition block from XDB file. */ /* Define: initialize the table definition block from XDB file. */
...@@ -285,8 +287,11 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -285,8 +287,11 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
if (cmpr == 1) if (cmpr == 1)
txfp = new(g) ZIPFAM(defp); txfp = new(g) ZIPFAM(defp);
else { else {
#if defined(BLK_INDX)
txfp = new(g) ZLBFAM(defp);
#else // !BLK_INDX
strcpy(g->Message, "Compress 2 not supported yet"); strcpy(g->Message, "Compress 2 not supported yet");
// txfp = new(g) ZLBFAM(defp); #endif // !BLK_INDX
return NULL; return NULL;
} // endelse } // endelse
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
...@@ -339,6 +344,7 @@ COLCRT::COLCRT(PSZ name) ...@@ -339,6 +344,7 @@ COLCRT::COLCRT(PSZ name)
Offset = -1; Offset = -1;
Long = -1; Long = -1;
Precision = -1; Precision = -1;
Freq = -1;
Key = -1; Key = -1;
Scale = -1; Scale = -1;
Opt = -1; Opt = -1;
...@@ -355,6 +361,7 @@ COLCRT::COLCRT(void) ...@@ -355,6 +361,7 @@ COLCRT::COLCRT(void)
Offset = 0; Offset = 0;
Long = 0; Long = 0;
Precision = 0; Precision = 0;
Freq = 0;
Key = 0; Key = 0;
Scale = 0; Scale = 0;
Opt = 0; Opt = 0;
...@@ -368,6 +375,16 @@ COLCRT::COLCRT(void) ...@@ -368,6 +375,16 @@ COLCRT::COLCRT(void)
/***********************************************************************/ /***********************************************************************/
COLDEF::COLDEF(void) : COLCRT() COLDEF::COLDEF(void) : COLCRT()
{ {
#if defined(BLK_INDX)
To_Min = NULL;
To_Max = NULL;
To_Pos = NULL;
Xdb2 = FALSE;
To_Bmap = NULL;
To_Dval = NULL;
Ndv = 0;
Nbm = 0;
#endif // BLK_INDX
Buf_Type = TYPE_ERROR; Buf_Type = TYPE_ERROR;
Clen = 0; Clen = 0;
Poff = 0; Poff = 0;
...@@ -401,7 +418,7 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) ...@@ -401,7 +418,7 @@ int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
Long = cfp->Length; Long = cfp->Length;
Opt = cfp->Opt; Opt = cfp->Opt;
Key = cfp->Key; Key = cfp->Key;
// Freq = cfp->Freq; Freq = cfp->Freq;
if (cfp->Remark && *cfp->Remark) { if (cfp->Remark && *cfp->Remark) {
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1); Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
......
...@@ -38,7 +38,7 @@ class DllExport RELDEF : public BLOCK { // Relation definition block ...@@ -38,7 +38,7 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
void SetCat(PCATLG cat) { Cat=cat; } void SetCat(PCATLG cat) { Cat=cat; }
// Methods // Methods
virtual bool DeleteTableFile(PGLOBAL g) {return true;} //virtual bool DeleteTableFile(PGLOBAL g) {return true;}
virtual bool Indexable(void) {return false;} virtual bool Indexable(void) {return false;}
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0; virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0;
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0; virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0;
...@@ -116,7 +116,7 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */ ...@@ -116,7 +116,7 @@ class DllExport OEMDEF : public TABDEF { /* OEM table */
virtual AMT GetDefType(void) {return TYPE_AM_OEM;} virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
// Methods // Methods
virtual bool DeleteTableFile(PGLOBAL g); //virtual bool DeleteTableFile(PGLOBAL g);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode); virtual PTDB GetTable(PGLOBAL g, MODE mode);
...@@ -148,6 +148,7 @@ class DllExport COLCRT : public BLOCK { /* Column description block ...@@ -148,6 +148,7 @@ class DllExport COLCRT : public BLOCK { /* Column description block
PSZ GetDecode(void) {return Decode;} PSZ GetDecode(void) {return Decode;}
PSZ GetFmt(void) {return Fmt;} PSZ GetFmt(void) {return Fmt;}
int GetOpt(void) {return Opt;} int GetOpt(void) {return Opt;}
int GetFreq(void) {return Freq;}
int GetLong(void) {return Long;} int GetLong(void) {return Long;}
int GetPrecision(void) {return Precision;} int GetPrecision(void) {return Precision;}
int GetOffset(void) {return Offset;} int GetOffset(void) {return Offset;}
...@@ -165,6 +166,7 @@ class DllExport COLCRT : public BLOCK { /* Column description block ...@@ -165,6 +166,7 @@ class DllExport COLCRT : public BLOCK { /* Column description block
int Precision; /* Logical column length */ int Precision; /* Logical column length */
int Scale; /* Decimals for float/decimal values */ int Scale; /* Decimals for float/decimal values */
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */ int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */
int Freq; /* Estimated number of different values */
char DataType; /* Internal data type (C, N, F, T) */ char DataType; /* Internal data type (C, N, F, T) */
}; // end of COLCRT }; // end of COLCRT
...@@ -188,10 +190,36 @@ class DllExport COLDEF : public COLCRT { /* Column description block ...@@ -188,10 +190,36 @@ class DllExport COLDEF : public COLCRT { /* Column description block
int GetClen(void) {return Clen;} int GetClen(void) {return Clen;}
int GetType(void) {return Buf_Type;} int GetType(void) {return Buf_Type;}
int GetPoff(void) {return Poff;} int GetPoff(void) {return Poff;}
#if defined(BLK_INDX)
void *GetMin(void) {return To_Min;}
void SetMin(void *minp) {To_Min = minp;}
void *GetMax(void) {return To_Max;}
void SetMax(void *maxp) {To_Max = maxp;}
bool GetXdb2(void) {return Xdb2;}
void SetXdb2(bool b) {Xdb2 = b;}
void *GetBmap(void) {return To_Bmap;}
void SetBmap(void *bmp) {To_Bmap = bmp;}
void *GetDval(void) {return To_Dval;}
void SetDval(void *dvp) {To_Dval = dvp;}
int GetNdv(void) {return Ndv;}
void SetNdv(int ndv) {Ndv = ndv;}
int GetNbm(void) {return Nbm;}
void SetNbm(int nbm) {Nbm = nbm;}
#endif // BLK_INDX
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff); int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff);
void Define(PGLOBAL g, PCOL colp); void Define(PGLOBAL g, PCOL colp);
protected: protected:
#if defined(BLK_INDX)
void *To_Min; /* Point to array of block min values */
void *To_Max; /* Point to array of block max values */
int *To_Pos; /* Point to array of block positions */
bool Xdb2; /* TRUE if to be optimized by XDB2 */
void *To_Bmap; /* To array of block bitmap values */
void *To_Dval; /* To array of column distinct values */
int Ndv; /* Number of distinct values */
int Nbm; /* Number of ULONG in bitmap (XDB2) */
#endif // BLK_INDX
int Buf_Type; /* Internal data type */ int Buf_Type; /* Internal data type */
int Clen; /* Internal data size in chars (bytes) */ int Clen; /* Internal data size in chars (bytes) */
int Poff; /* Calculated offset for Packed tables */ int Poff; /* Calculated offset for Packed tables */
......
This diff is collapsed.
/*************** TabDos H Declares Source Code File (.H) ***************/ /*************** 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. */ /* This file contains the DOS classes declares. */
/***********************************************************************/ /***********************************************************************/
...@@ -12,9 +12,16 @@ ...@@ -12,9 +12,16 @@
#include "xtable.h" // Table base class declares #include "xtable.h" // Table base class declares
#include "colblk.h" // Column base class declares #include "colblk.h" // Column base class declares
#include "xindex.h" #include "xindex.h"
#if defined(BLK_INDX)
#include "filter.h"
#endif // BLK_INDX
//pedef struct _tabdesc *PTABD; // For friend setting //pedef struct _tabdesc *PTABD; // For friend setting
typedef class TXTFAM *PTXF; typedef class TXTFAM *PTXF;
#if defined(BLK_INDX)
typedef class BLOCKFILTER *PBF;
typedef class BLOCKINDEX *PBX;
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* DOS table. */ /* DOS table. */
...@@ -34,6 +41,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ ...@@ -34,6 +41,7 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
virtual const char *GetType(void) {return "DOS";} virtual const char *GetType(void) {return "DOS";}
virtual PIXDEF GetIndx(void) {return To_Indx;} virtual PIXDEF GetIndx(void) {return To_Indx;}
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;} virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;}
virtual bool IsHuge(void) {return Huge;}
PSZ GetFn(void) {return Fn;} PSZ GetFn(void) {return Fn;}
PSZ GetOfn(void) {return Ofn;} PSZ GetOfn(void) {return Ofn;}
void SetBlock(int block) {Block = block;} void SetBlock(int block) {Block = block;}
...@@ -46,19 +54,28 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ ...@@ -46,19 +54,28 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
bool GetEof(void) {return Eof;} bool GetEof(void) {return Eof;}
int GetBlksize(void) {return Blksize;} int GetBlksize(void) {return Blksize;}
int GetEnding(void) {return Ending;} int GetEnding(void) {return Ending;}
#if defined(BLK_INDX)
bool IsOptimized(void) {return (Optimized == 1);}
void SetOptimized(int opt) {Optimized = opt;}
void SetAllocBlks(int blks) {AllocBlks = blks;}
int GetAllocBlks(void) {return AllocBlks;}
int *GetTo_Pos(void) {return To_Pos;} int *GetTo_Pos(void) {return To_Pos;}
virtual bool IsHuge(void) {return Huge;} #endif // BLK_INDX
// Methods // Methods
virtual bool DeleteTableFile(PGLOBAL g); //virtual bool DeleteTableFile(PGLOBAL g);
virtual bool Indexable(void) {return Compressed != 1;} virtual bool Indexable(void) {return Compressed != 1;}
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf); virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode); virtual PTDB GetTable(PGLOBAL g, MODE mode);
bool InvalidateIndex(PGLOBAL g); bool InvalidateIndex(PGLOBAL g);
#if defined(BLK_INDX)
bool GetOptFileName(PGLOBAL g, char *filename);
void RemoveOptValues(PGLOBAL g);
#endif // BLK_INDX
protected: protected:
virtual bool Erase(char *filename); //virtual bool Erase(char *filename);
// Members // Members
PSZ Fn; /* Path/Name of corresponding file */ PSZ Fn; /* Path/Name of corresponding file */
...@@ -70,7 +87,11 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */ ...@@ -70,7 +87,11 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
bool Huge; /* true for files larger than 2GB */ bool Huge; /* true for files larger than 2GB */
bool Accept; /* true if wrong lines are accepted (DBF)*/ bool Accept; /* true if wrong lines are accepted (DBF)*/
bool Eof; /* true if an EOF (0xA) character exists */ bool Eof; /* true if an EOF (0xA) character exists */
int *To_Pos; /* To array of block starting positions */ #if defined(BLK_INDX)
int *To_Pos; /* To array of block starting positions */
int Optimized; /* 0: No, 1:Yes, 2:Redo optimization */
int AllocBlks; /* Number of suballocated opt blocks */
#endif // BLK_INDX
int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */ int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */
int Lrecl; /* Size of biggest record */ int Lrecl; /* Size of biggest record */
int AvgLen; /* Average size of records */ int AvgLen; /* Average size of records */
...@@ -129,13 +150,15 @@ class DllExport TDBDOS : public TDBASE { ...@@ -129,13 +150,15 @@ class DllExport TDBDOS : public TDBASE {
virtual bool IsUsingTemp(PGLOBAL g); virtual bool IsUsingTemp(PGLOBAL g);
//virtual bool NeedIndexing(PGLOBAL g); //virtual bool NeedIndexing(PGLOBAL g);
virtual void ResetSize(void) {MaxSize = Cardinal = -1;} virtual void ResetSize(void) {MaxSize = Cardinal = -1;}
virtual int ResetTableOpt(PGLOBAL g, bool dox); virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox);
//virtual int MakeBlockValues(PGLOBAL g); #if defined(BLK_INDX)
//virtual bool SaveBlockValues(PGLOBAL g); virtual int MakeBlockValues(PGLOBAL g);
//virtual bool GetBlockValues(PGLOBAL g); virtual bool SaveBlockValues(PGLOBAL g);
//virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp); virtual bool GetBlockValues(PGLOBAL g);
virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp);
//virtual PBX InitBlockIndex(PGLOBAL g); //virtual PBX InitBlockIndex(PGLOBAL g);
//virtual int TestBlock(PGLOBAL g); virtual int TestBlock(PGLOBAL g);
#endif // BLK_INDX
virtual void PrintAM(FILE *f, char *m); virtual void PrintAM(FILE *f, char *m);
// Database routines // Database routines
...@@ -162,25 +185,31 @@ class DllExport TDBDOS : public TDBASE { ...@@ -162,25 +185,31 @@ class DllExport TDBDOS : public TDBASE {
virtual int EstimatedLength(PGLOBAL g); virtual int EstimatedLength(PGLOBAL g);
// Optimization routines // Optimization routines
// void ResetBlockFilter(PGLOBAL g); int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); #if defined(BLK_INDX)
// bool GetDistinctColumnValues(PGLOBAL g, int nrec); void ResetBlockFilter(PGLOBAL g);
bool GetDistinctColumnValues(PGLOBAL g, int nrec);
protected: protected:
// PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv); PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv);
#endif // BLK_INDX
// Members // Members
PTXF Txfp; // To the File access method class PTXF Txfp; // To the File access method class
#if defined(BLK_INDX)
//PBX To_BlkIdx; // To index test block //PBX To_BlkIdx; // To index test block
//PBF To_BlkFil; // To evaluation block filter PBF To_BlkFil; // To evaluation block filter
//PFIL SavFil; // Saved hidden filter PFIL SavFil; // Saved hidden filter
#endif // BLK_INDX
char *To_Line; // Points to current processed line char *To_Line; // Points to current processed line
int Cardinal; // Table Cardinality int Cardinal; // Table Cardinality
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT) RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
int Lrecl; // Logical Record Length int Lrecl; // Logical Record Length
int AvgLen; // Logical Record Average Length int AvgLen; // Logical Record Average Length
#if defined(BLK_INDX)
//int Xeval; // BlockTest return value //int Xeval; // BlockTest return value
//int Beval; // BlockEval return value int Beval; // BlockEval return value
#endif // BLK_INDX
}; // end of class TDBDOS }; // end of class TDBDOS
/***********************************************************************/ /***********************************************************************/
...@@ -198,50 +227,60 @@ class DllExport DOSCOL : public COLBLK { ...@@ -198,50 +227,60 @@ class DllExport DOSCOL : public COLBLK {
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_DOS;} 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 void SetTo_Val(PVAL valp) {To_Val = valp;}
//virtual PVBLK GetMin(void) {return Min;} #if defined(BLK_INDX)
//virtual PVBLK GetMax(void) {return Max;} virtual int GetClustered(void) {return Clustered;}
//virtual int GetNdv(void) {return Ndv;} virtual int IsClustered(void) {return (Clustered &&
//virtual int GetNbm(void) {return Nbm;} ((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());}
//virtual PVBLK GetBmap(void) {return Bmap;} virtual int IsSorted(void) {return Sorted;}
//virtual PVBLK GetDval(void) {return Dval;} 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;}
#endif // BLK_INDX
// Methods // Methods
#if defined(BLK_INDX)
virtual bool VarSize(void); virtual bool VarSize(void);
#endif // BLK_INDX
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void Print(PGLOBAL g, FILE *, uint); virtual void Print(PGLOBAL g, FILE *, uint);
protected: protected:
//virtual bool SetMinMax(PGLOBAL g); #if defined(BLK_INDX)
//virtual bool SetBitMap(PGLOBAL g); virtual bool SetMinMax(PGLOBAL g);
// bool CheckSorted(PGLOBAL g); virtual bool SetBitMap(PGLOBAL g);
// bool AddDistinctValue(PGLOBAL g); bool CheckSorted(PGLOBAL g);
bool AddDistinctValue(PGLOBAL g);
#endif // BLK_INDX
// Default constructor not to be used // Default constructor not to be used
DOSCOL(void) {} DOSCOL(void) {}
// Members // Members
//PVBLK Min; // Array of block min values #if defined(BLK_INDX)
//PVBLK Max; // Array of block max values PVBLK Min; // Array of block min values
//PVBLK Bmap; // Array of block bitmap values PVBLK Max; // Array of block max values
//PVBLK Dval; // Array of column distinct values PVBLK Bmap; // Array of block bitmap values
PVBLK Dval; // Array of column distinct values
#endif // BLK_INDX
PVAL To_Val; // To value used for Update/Insert PVAL To_Val; // To value used for Update/Insert
PVAL OldVal; // The previous value of the object. PVAL OldVal; // The previous value of the object.
char *Buf; // Buffer used in write operations char *Buf; // Buffer used in write operations
bool Ldz; // True if field contains leading zeros bool Ldz; // True if field contains leading zeros
bool Nod; // True if no decimal point bool Nod; // True if no decimal point
int Dcm; // Last Dcm digits are decimals 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 Deplac; // Offset in dos_buf
//int Ndv; // Number of distinct values #if defined(BLK_INDX)
//int Nbm; // Number of uint in bitmap int Clustered; // 0:No 1:Yes
int Sorted; // 0:No 1:Asc (2:Desc - NIY)
int Ndv; // Number of distinct values
int Nbm; // Number of uint in bitmap
#endif // BLK_INDX
}; // end of class DOSCOL }; // end of class DOSCOL
#endif // __TABDOS_H #endif // __TABDOS_H
/************* TabFix C++ Program Source Code File (.CPP) **************/ /************* TabFix C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABFIX */ /* PROGRAM NAME: TABFIX */
/* ------------- */ /* ------------- */
/* Version 4.8 */ /* Version 4.9 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -45,6 +45,10 @@ ...@@ -45,6 +45,10 @@
#include "filamfix.h" #include "filamfix.h"
#include "filamdbf.h" #include "filamdbf.h"
#include "tabfix.h" // TDBFIX, FIXCOL classes declares #include "tabfix.h" // TDBFIX, FIXCOL classes declares
#if defined(BLK_INDX)
#include "array.h"
#include "blkfil.h"
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* DB static variables. */ /* DB static variables. */
...@@ -123,10 +127,52 @@ PCOL TDBFIX::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) ...@@ -123,10 +127,52 @@ PCOL TDBFIX::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/ /***********************************************************************/
/* Remake the indexes after the table was modified. */ /* Remake the indexes after the table was modified. */
/***********************************************************************/ /***********************************************************************/
int TDBFIX::ResetTableOpt(PGLOBAL g, bool dox) int TDBFIX::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
{ {
#if defined(BLK_INDX)
int prc, rc = RC_OK;
To_Filter = NULL; // Disable filtering
//To_BlkIdx = NULL; // and block filtering
To_BlkFil = NULL; // and index filtering
RestoreNrec(); // May have been modified
MaxSize = -1; // Size must be recalculated
Cardinal = -1; // as well as Cardinality
if (dop) {
Columns = NULL; // Not used anymore
Txfp->Reset();
// OldBlk = CurBlk = -1;
// ReadBlks = CurNum = Rbuf = Modif = 0;
Use = USE_READY; // So the table can be reopened
Mode = MODE_ANY; // Just to be clean
rc = MakeBlockValues(g); // Redo optimization
} // endif dop
if (dox && (rc == RC_OK || rc == RC_INFO)) {
// Remake eventual indexes
Columns = NULL; // Not used anymore
Txfp->Reset(); // New start
Use = USE_READY; // So the table can be reopened
Mode = MODE_READ; // New mode
prc = rc;
if (!(PlgGetUser(g)->Check & CHK_OPT)) {
// After the table was modified the indexes
// are invalid and we should mark them as such...
rc = ((PDOSDEF)To_Def)->InvalidateIndex(g);
} else
// ... or we should remake them.
rc = MakeIndex(g, NULL, FALSE);
rc = (rc == RC_INFO) ? prc : rc;
} // endif dox
return rc;
#else // !BLK_INDX
RestoreNrec(); // May have been modified RestoreNrec(); // May have been modified
return TDBDOS::ResetTableOpt(g, dox); return TDBDOS::ResetTableOpt(g, dop, dox);
#endif // !BLK_INDX
} // end of ResetTableOpt } // end of ResetTableOpt
/***********************************************************************/ /***********************************************************************/
...@@ -163,8 +209,17 @@ int TDBFIX::Cardinality(PGLOBAL g) ...@@ -163,8 +209,17 @@ int TDBFIX::Cardinality(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
int TDBFIX::GetMaxSize(PGLOBAL g) int TDBFIX::GetMaxSize(PGLOBAL g)
{ {
if (MaxSize < 0) if (MaxSize < 0) {
MaxSize = Cardinality(g); MaxSize = Cardinality(g);
#if defined(BLK_INDX)
if (MaxSize > 0 && (To_BlkFil = InitBlockFilter(g, To_Filter))
&& !To_BlkFil->Correlated()) {
// Use BlockTest to reduce the estimated size
MaxSize = Txfp->MaxBlkSize(g, MaxSize);
ResetBlockFilter(g);
} // endif To_BlkFil
#endif // BLK_INDX
} // endif MaxSize
return MaxSize; return MaxSize;
} // end of GetMaxSize } // end of GetMaxSize
...@@ -246,6 +301,9 @@ bool TDBFIX::OpenDB(PGLOBAL g) ...@@ -246,6 +301,9 @@ bool TDBFIX::OpenDB(PGLOBAL g)
else else
Txfp->Rewind(); // see comment in Work.log Txfp->Rewind(); // see comment in Work.log
#if defined(BLK_INDX)
ResetBlockFilter(g);
#endif // BLK_INDX
return false; return false;
} // endif use } // endif use
...@@ -277,6 +335,13 @@ bool TDBFIX::OpenDB(PGLOBAL g) ...@@ -277,6 +335,13 @@ bool TDBFIX::OpenDB(PGLOBAL g)
/*********************************************************************/ /*********************************************************************/
To_Line = Txfp->GetBuf(); // For WriteDB To_Line = Txfp->GetBuf(); // For WriteDB
#if defined(BLK_INDX)
/*********************************************************************/
/* Allocate the block filter tree if evaluation is possible. */
/*********************************************************************/
To_BlkFil = InitBlockFilter(g, To_Filter);
#endif // BLK_INDX
if (trace) if (trace)
htrc("OpenDos: R%hd mode=%d\n", Tdb_No, Mode); htrc("OpenDos: R%hd mode=%d\n", Tdb_No, Mode);
......
...@@ -38,7 +38,7 @@ class DllExport TDBFIX : public TDBDOS { ...@@ -38,7 +38,7 @@ class DllExport TDBFIX : public TDBDOS {
virtual void ResetDB(void); virtual void ResetDB(void);
virtual bool IsUsingTemp(PGLOBAL g); virtual bool IsUsingTemp(PGLOBAL g);
virtual int RowNumber(PGLOBAL g, bool b = false); virtual int RowNumber(PGLOBAL g, bool b = false);
virtual int ResetTableOpt(PGLOBAL g, bool dox); virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox);
virtual void ResetSize(void); virtual void ResetSize(void);
virtual int GetBadLines(void) {return Txfp->GetNerr();} virtual int GetBadLines(void) {return Txfp->GetNerr();}
......
...@@ -459,9 +459,12 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -459,9 +459,12 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
if (Compressed == 1) if (Compressed == 1)
txfp = new(g) ZIPFAM(this); txfp = new(g) ZIPFAM(this);
else { else {
#if defined(BLK_INDX)
txfp = new(g) ZLBFAM(this);
#else // !BLK_INDX
strcpy(g->Message, "Compress 2 not supported yet"); strcpy(g->Message, "Compress 2 not supported yet");
// txfp = new(g) ZLBFAM(defp);
return NULL; return NULL;
#endif // !BLK_INDX
} // endelse } // endelse
#else // !ZIP_SUPPORT #else // !ZIP_SUPPORT
strcpy(g->Message, "Compress not supported"); strcpy(g->Message, "Compress not supported");
...@@ -1272,6 +1275,7 @@ CSVCOL::CSVCOL(CSVCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp) ...@@ -1272,6 +1275,7 @@ CSVCOL::CSVCOL(CSVCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
Fldnum = col1->Fldnum; Fldnum = col1->Fldnum;
} // end of CSVCOL copy constructor } // end of CSVCOL copy constructor
#if defined(BLK_INDX)
/***********************************************************************/ /***********************************************************************/
/* VarSize: This function tells UpdateDB whether or not the block */ /* VarSize: This function tells UpdateDB whether or not the block */
/* optimization file must be redone if this column is updated, even */ /* optimization file must be redone if this column is updated, even */
...@@ -1290,6 +1294,7 @@ bool CSVCOL::VarSize(void) ...@@ -1290,6 +1294,7 @@ bool CSVCOL::VarSize(void)
return false; return false;
} // end VarSize } // end VarSize
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* ReadColumn: call DOSCOL::ReadColumn after having set the offet */ /* ReadColumn: call DOSCOL::ReadColumn after having set the offet */
......
...@@ -112,7 +112,9 @@ class CSVCOL : public DOSCOL { ...@@ -112,7 +112,9 @@ class CSVCOL : public DOSCOL {
virtual int GetAmType() {return TYPE_AM_CSV;} virtual int GetAmType() {return TYPE_AM_CSV;}
// Methods // Methods
#if defined(BLK_INDX)
virtual bool VarSize(void); virtual bool VarSize(void);
#endif // BLK_INDX
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
// void Print(FILE *, uint); // void Print(FILE *, uint);
......
...@@ -36,27 +36,6 @@ extern "C" int trace; // The general trace value ...@@ -36,27 +36,6 @@ extern "C" int trace; // The general trace value
void NewPointer(PTABS, void *, void *); void NewPointer(PTABS, void *, void *);
void AddPointer(PTABS, 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 ---------------------------- */ /* ---------------------------- class TDB ---------------------------- */
/***********************************************************************/ /***********************************************************************/
...@@ -64,6 +43,12 @@ TBX::TBX(PTBX txp) ...@@ -64,6 +43,12 @@ TBX::TBX(PTBX txp)
/***********************************************************************/ /***********************************************************************/
TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum) TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
{ {
Use = USE_NO;
To_Orig = NULL;
#if defined(BLK_INDX)
To_Filter = NULL;
#endif // BLK_FILTER
To_CondFil = NULL;
Next = NULL; Next = NULL;
Name = (tdp) ? tdp->GetName() : NULL; Name = (tdp) ? tdp->GetName() : NULL;
To_Table = NULL; To_Table = NULL;
...@@ -72,8 +57,14 @@ TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum) ...@@ -72,8 +57,14 @@ TDB::TDB(PTABDEF tdp) : Tdb_No(++Tnum)
Mode = MODE_READ; Mode = MODE_READ;
} // end of TDB standard constructor } // 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;
#if defined(BLK_INDX)
To_Filter = NULL;
#endif // BLK_FILTER
To_CondFil = NULL;
Next = NULL; Next = NULL;
Name = tdbp->Name; Name = tdbp->Name;
To_Table = tdbp->To_Table; To_Table = tdbp->To_Table;
...@@ -179,7 +170,7 @@ int TDB::RowNumber(PGLOBAL g, bool b) ...@@ -179,7 +170,7 @@ int TDB::RowNumber(PGLOBAL g, bool b)
return 0; return 0;
} // end of RowNumber } // end of RowNumber
PTBX TDB::Copy(PTABS t) PTDB TDB::Copy(PTABS t)
{ {
PTDB tp, tdb1, tdb2 = NULL, outp = NULL; PTDB tp, tdb1, tdb2 = NULL, outp = NULL;
//PGLOBAL g = t->G; // Is this really useful ??? //PGLOBAL g = t->G; // Is this really useful ???
...@@ -398,7 +389,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp) ...@@ -398,7 +389,7 @@ PCOL TDBASE::InsertSpcBlk(PGLOBAL g, PCOLDEF cdp)
/***********************************************************************/ /***********************************************************************/
/* ResetTableOpt: Wrong for this table type. */ /* ResetTableOpt: Wrong for this table type. */
/***********************************************************************/ /***********************************************************************/
int TDBASE::ResetTableOpt(PGLOBAL g, bool dox) int TDBASE::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
{ {
strcpy(g->Message, "This table is not indexable"); strcpy(g->Message, "This table is not indexable");
return RC_INFO; return RC_INFO;
......
...@@ -31,7 +31,7 @@ class DllExport MACDEF : public TABDEF { /* Logical table description */ ...@@ -31,7 +31,7 @@ class DllExport MACDEF : public TABDEF { /* Logical table description */
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g) {return true;} //virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected: protected:
// Members // Members
......
...@@ -38,7 +38,7 @@ class DllExport TDBMUL : public TDBASE { ...@@ -38,7 +38,7 @@ class DllExport TDBMUL : public TDBASE {
// Methods // Methods
virtual void ResetDB(void); virtual void ResetDB(void);
virtual PTDB CopyOne(PTABS t); 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 PSZ GetFile(PGLOBAL g) {return Tdbp->GetFile(g);}
virtual int GetRecpos(void) {return 0;} virtual int GetRecpos(void) {return 0;}
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
......
...@@ -527,8 +527,8 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g) ...@@ -527,8 +527,8 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g)
strcat(strcat(strcat(strcat(Query, " FROM "), tk), Tabname), tk); strcat(strcat(strcat(strcat(Query, " FROM "), tk), Tabname), tk);
if (To_Filter) if (To_CondFil)
strcat(strcat(Query, " WHERE "), To_Filter->Body); strcat(strcat(Query, " WHERE "), To_CondFil->Body);
if (trace) if (trace)
htrc("Query=%s\n", Query); htrc("Query=%s\n", Query);
...@@ -1395,11 +1395,11 @@ PCMD TDBMYEXC::MakeCMD(PGLOBAL g) ...@@ -1395,11 +1395,11 @@ PCMD TDBMYEXC::MakeCMD(PGLOBAL g)
{ {
PCMD xcmd = NULL; PCMD xcmd = NULL;
if (To_Filter) { if (To_CondFil) {
if (Cmdcol) { if (Cmdcol) {
if (!stricmp(Cmdcol, To_Filter->Body) && if (!stricmp(Cmdcol, To_CondFil->Body) &&
(To_Filter->Op == OP_EQ || To_Filter->Op == OP_IN)) { (To_CondFil->Op == OP_EQ || To_CondFil->Op == OP_IN)) {
xcmd = To_Filter->Cmds; xcmd = To_CondFil->Cmds;
} else } else
strcpy(g->Message, "Invalid command specification filter"); strcpy(g->Message, "Invalid command specification filter");
......
...@@ -408,7 +408,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -408,7 +408,7 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
// Below 14 is length of 'select ' + length of ' from ' + 1 // Below 14 is length of 'select ' + length of ' from ' + 1
len = (strlen(colist) + strlen(buf) + 14); 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) if (Catalog && *Catalog)
catp = Catalog; catp = Catalog;
...@@ -441,8 +441,8 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -441,8 +441,8 @@ char *TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
strcat(sql, tabname); strcat(sql, tabname);
if (To_Filter) if (To_CondFil)
strcat(strcat(sql, " WHERE "), To_Filter->Body); strcat(strcat(sql, " WHERE "), To_CondFil->Body);
return sql; return sql;
} // end of MakeSQL } // end of MakeSQL
...@@ -1229,11 +1229,11 @@ PCMD TDBXDBC::MakeCMD(PGLOBAL g) ...@@ -1229,11 +1229,11 @@ PCMD TDBXDBC::MakeCMD(PGLOBAL g)
{ {
PCMD xcmd = NULL; PCMD xcmd = NULL;
if (To_Filter) { if (To_CondFil) {
if (Cmdcol) { if (Cmdcol) {
if (!stricmp(Cmdcol, To_Filter->Body) && if (!stricmp(Cmdcol, To_CondFil->Body) &&
(To_Filter->Op == OP_EQ || To_Filter->Op == OP_IN)) { (To_CondFil->Op == OP_EQ || To_CondFil->Op == OP_IN)) {
xcmd = To_Filter->Cmds; xcmd = To_CondFil->Cmds;
} else } else
strcpy(g->Message, "Invalid command specification filter"); strcpy(g->Message, "Invalid command specification filter");
......
...@@ -113,6 +113,7 @@ PTDB INIDEF::GetTable(PGLOBAL g, MODE m) ...@@ -113,6 +113,7 @@ PTDB INIDEF::GetTable(PGLOBAL g, MODE m)
return tdbp; return tdbp;
} // end of GetTable } // end of GetTable
#if 0
/***********************************************************************/ /***********************************************************************/
/* DeleteTableFile: Delete INI table files using platform API. */ /* DeleteTableFile: Delete INI table files using platform API. */
/***********************************************************************/ /***********************************************************************/
...@@ -134,6 +135,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g) ...@@ -134,6 +135,7 @@ bool INIDEF::DeleteTableFile(PGLOBAL g)
return rc; // Return true if error return rc; // Return true if error
} // end of DeleteTableFile } // end of DeleteTableFile
#endif // 0
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
......
...@@ -32,7 +32,7 @@ class DllExport INIDEF : public TABDEF { /* INI table description */ ...@@ -32,7 +32,7 @@ class DllExport INIDEF : public TABDEF { /* INI table description */
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g); //virtual bool DeleteTableFile(PGLOBAL g);
protected: protected:
// Members // Members
......
/************* TabTbl C++ Program Source Code File (.CPP) **************/ /************* TabTbl C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABTBL */ /* PROGRAM NAME: TABTBL */
/* ------------- */ /* ------------- */
/* Version 1.6 */ /* Version 1.7 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to PlugDB Software Development 2008-2013 */ /* (C) Copyright to PlugDB Software Development 2008-2014 */
/* Author: Olivier BERTRAND */ /* Author: Olivier BERTRAND */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
...@@ -66,7 +66,6 @@ ...@@ -66,7 +66,6 @@
#include "global.h" // global declarations #include "global.h" // global declarations
#include "plgdbsem.h" // DB application declarations #include "plgdbsem.h" // DB application declarations
#include "reldef.h" // DB definition declares #include "reldef.h" // DB definition declares
//#include "filter.h" // FILTER classes dcls
#include "filamtxt.h" #include "filamtxt.h"
#include "tabcol.h" #include "tabcol.h"
#include "tabdos.h" // TDBDOS and DOSCOL class dcls #include "tabdos.h" // TDBDOS and DOSCOL class dcls
...@@ -245,7 +244,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) ...@@ -245,7 +244,7 @@ bool TDBTBL::InitTableList(PGLOBAL g)
// PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); // PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath());
for (n = 0, tp = tdp->Tablep; tp; tp = tp->GetNext()) { 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); tabp = new(g) XTAB(tp);
if (tabp->GetSrc()) { if (tabp->GetSrc()) {
...@@ -286,14 +285,14 @@ bool TDBTBL::InitTableList(PGLOBAL g) ...@@ -286,14 +285,14 @@ bool TDBTBL::InitTableList(PGLOBAL g)
hc->get_table()->s->connect_string.length = sln; hc->get_table()->s->connect_string.length = sln;
//NumTables = n; //NumTables = n;
To_Filter = NULL; // To avoid doing it several times To_CondFil = NULL; // To avoid doing it several times
return FALSE; return FALSE;
} // end of InitTableList } // end of InitTableList
/***********************************************************************/ /***********************************************************************/
/* Test the tablename against the pseudo "local" filter. */ /* 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]; char *body, *fil, op[8], tn[NAME_LEN];
bool neg; bool neg;
...@@ -421,12 +420,12 @@ bool TDBTBL::OpenDB(PGLOBAL g) ...@@ -421,12 +420,12 @@ bool TDBTBL::OpenDB(PGLOBAL g)
} // endif use } // 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; Tablist = NULL;
Nbc = 0; Nbc = 0;
} // endif To_Filter } // endif To_CondFil
/*********************************************************************/ /*********************************************************************/
/* Open the first table of the list. */ /* Open the first table of the list. */
...@@ -661,12 +660,12 @@ bool TDBTBM::OpenDB(PGLOBAL g) ...@@ -661,12 +660,12 @@ bool TDBTBM::OpenDB(PGLOBAL g)
#if 0 #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; Tablist = NULL;
Nbc = 0; Nbc = 0;
} // endif To_Filter } // endif To_CondFil
#endif // 0 #endif // 0
/*********************************************************************/ /*********************************************************************/
......
...@@ -87,7 +87,7 @@ class DllExport TDBTBL : public TDBPRX { ...@@ -87,7 +87,7 @@ class DllExport TDBTBL : public TDBPRX {
protected: protected:
// Internal functions // Internal functions
bool InitTableList(PGLOBAL g); bool InitTableList(PGLOBAL g);
bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp); bool TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp);
// Members // Members
PTABLE Tablist; // Points to the table list PTABLE Tablist; // Points to the table list
...@@ -152,7 +152,7 @@ class DllExport TDBTBM : public TDBTBL { ...@@ -152,7 +152,7 @@ class DllExport TDBTBM : public TDBTBL {
protected: protected:
// Internal functions // Internal functions
//bool InitTableList(PGLOBAL g); //bool InitTableList(PGLOBAL g);
//bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp); //bool TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp);
bool OpenTables(PGLOBAL g); bool OpenTables(PGLOBAL g);
int ReadNextRemote(PGLOBAL g); int ReadNextRemote(PGLOBAL g);
......
/************* TabVct C++ Program Source Code File (.CPP) **************/ /************* TabVct C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABVCT */ /* PROGRAM NAME: TABVCT */
/* ------------- */ /* ------------- */
/* Version 3.7 */ /* Version 3.8 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1999-2012 */ /* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -118,6 +118,7 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -118,6 +118,7 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return false; return false;
} // end of DefineAM } // end of DefineAM
#if 0
/***********************************************************************/ /***********************************************************************/
/* Erase: This was made a separate routine because a strange thing */ /* Erase: This was made a separate routine because a strange thing */
/* happened when DeleteTablefile was defined for the VCTDEF class: */ /* happened when DeleteTablefile was defined for the VCTDEF class: */
...@@ -157,6 +158,7 @@ bool VCTDEF::Erase(char *filename) ...@@ -157,6 +158,7 @@ bool VCTDEF::Erase(char *filename)
return rc; // Return true if error return rc; // Return true if error
} // end of Erase } // end of Erase
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* Prepare the column file name pattern for a split table. */ /* Prepare the column file name pattern for a split table. */
...@@ -231,7 +233,8 @@ PTDB VCTDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -231,7 +233,8 @@ PTDB VCTDEF::GetTable(PGLOBAL g, MODE mode)
/*********************************************************************/ /*********************************************************************/
if (mode != MODE_INSERT) if (mode != MODE_INSERT)
if (tdbp->GetBlockValues(g)) if (tdbp->GetBlockValues(g))
return NULL; PushWarning(g, (PTDBASE)tdbp);
// return NULL; // causes a crash when deleting index
return tdbp; return tdbp;
} // end of GetTable } // end of GetTable
...@@ -298,6 +301,9 @@ bool TDBVCT::OpenDB(PGLOBAL g) ...@@ -298,6 +301,9 @@ bool TDBVCT::OpenDB(PGLOBAL g)
To_Kindex->Reset(); To_Kindex->Reset();
Txfp->Rewind(); Txfp->Rewind();
#if defined(BLK_INDX)
ResetBlockFilter(g);
#endif // BLK_INDX
return false; return false;
} // endif Use } // endif Use
...@@ -319,6 +325,13 @@ bool TDBVCT::OpenDB(PGLOBAL g) ...@@ -319,6 +325,13 @@ bool TDBVCT::OpenDB(PGLOBAL g)
// This was not done in previous version // This was not done in previous version
Use = USE_OPEN; // Do it now in case we are recursively called Use = USE_OPEN; // Do it now in case we are recursively called
#if defined(BLK_INDX)
/*********************************************************************/
/* Allocate the block filter tree if evaluation is possible. */
/*********************************************************************/
To_BlkFil = InitBlockFilter(g, To_Filter);
#endif // BLK_INDX
/*********************************************************************/ /*********************************************************************/
/* Reset buffer access according to indexing and to mode. */ /* Reset buffer access according to indexing and to mode. */
/*********************************************************************/ /*********************************************************************/
......
...@@ -37,7 +37,7 @@ class DllExport VCTDEF : public DOSDEF { /* Logical table description */ ...@@ -37,7 +37,7 @@ class DllExport VCTDEF : public DOSDEF { /* Logical table description */
protected: protected:
// Specific file erase routine for vertical tables // Specific file erase routine for vertical tables
virtual bool Erase(char *filename); //virtual bool Erase(char *filename);
int MakeFnPattern(char *fpat); int MakeFnPattern(char *fpat);
// Members // Members
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "reldef.h" #include "reldef.h"
#include "xtable.h" #include "xtable.h"
#include "colblk.h" #include "colblk.h"
#include "filter.h" //#include "filter.h"
//#include "xindex.h" //#include "xindex.h"
#include "tabwmi.h" #include "tabwmi.h"
#include "valblk.h" #include "valblk.h"
...@@ -480,8 +480,8 @@ bool TDBWMI::Initialize(PGLOBAL g) ...@@ -480,8 +480,8 @@ bool TDBWMI::Initialize(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
void TDBWMI::DoubleSlash(PGLOBAL g) void TDBWMI::DoubleSlash(PGLOBAL g)
{ {
if (To_Filter && strchr(To_Filter->Body, '\\')) { if (To_CondFil && strchr(To_CondFil->Body, '\\')) {
char *body = To_Filter->Body; char *body = To_CondFil->Body;
char *buf = (char*)PlugSubAlloc(g, NULL, strlen(body) * 2); char *buf = (char*)PlugSubAlloc(g, NULL, strlen(body) * 2);
int i = 0, k = 0; int i = 0, k = 0;
...@@ -492,8 +492,8 @@ void TDBWMI::DoubleSlash(PGLOBAL g) ...@@ -492,8 +492,8 @@ void TDBWMI::DoubleSlash(PGLOBAL g)
buf[k++] = body[i]; buf[k++] = body[i];
} while (body[i++]); } while (body[i++]);
To_Filter->Body = buf; To_CondFil->Body = buf;
} // endif To_Filter } // endif To_CondFil
} // end of DoubleSlash } // end of DoubleSlash
...@@ -540,13 +540,13 @@ char *TDBWMI::MakeWQL(PGLOBAL g) ...@@ -540,13 +540,13 @@ char *TDBWMI::MakeWQL(PGLOBAL g)
// Below 14 is length of 'select ' + length of ' from ' + 1 // Below 14 is length of 'select ' + length of ' from ' + 1
len = (strlen(colist) + strlen(Wclass) + 14); 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); wql = (char*)PlugSubAlloc(g, NULL, len);
strcat(strcat(strcpy(wql, "SELECT "), colist), " FROM "); strcat(strcat(strcpy(wql, "SELECT "), colist), " FROM ");
strcat(wql, Wclass); strcat(wql, Wclass);
if (To_Filter) if (To_CondFil)
strcat(strcat(wql, " WHERE "), To_Filter->Body); strcat(strcat(wql, " WHERE "), To_CondFil->Body);
return wql; return wql;
} // end of MakeWQL } // end of MakeWQL
...@@ -659,8 +659,8 @@ bool TDBWMI::OpenDB(PGLOBAL g) ...@@ -659,8 +659,8 @@ bool TDBWMI::OpenDB(PGLOBAL g)
return true; return true;
} // endif Mode } // endif Mode
if (!To_Filter && !stricmp(Wclass, "CIM_Datafile") if (!To_CondFil && !stricmp(Wclass, "CIM_Datafile")
&& !stricmp(Nspace, "root\\cimv2")) { && !stricmp(Nspace, "root\\cimv2")) {
strcpy(g->Message, strcpy(g->Message,
"Would last forever when not filtered, use DIR table instead"); "Would last forever when not filtered, use DIR table instead");
return true; return true;
......
...@@ -48,7 +48,7 @@ class WMIDEF : public TABDEF { /* Logical table description */ ...@@ -48,7 +48,7 @@ class WMIDEF : public TABDEF { /* Logical table description */
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g) {return true;} //virtual bool DeleteTableFile(PGLOBAL g) {return true;}
protected: protected:
// Members // Members
......
...@@ -187,6 +187,7 @@ PTDB XMLDEF::GetTable(PGLOBAL g, MODE m) ...@@ -187,6 +187,7 @@ PTDB XMLDEF::GetTable(PGLOBAL g, MODE m)
return tdbp; return tdbp;
} // end of GetTable } // end of GetTable
#if 0
/***********************************************************************/ /***********************************************************************/
/* DeleteTableFile: Delete XML table files using platform API. */ /* DeleteTableFile: Delete XML table files using platform API. */
/***********************************************************************/ /***********************************************************************/
...@@ -208,6 +209,7 @@ bool XMLDEF::DeleteTableFile(PGLOBAL g) ...@@ -208,6 +209,7 @@ bool XMLDEF::DeleteTableFile(PGLOBAL g)
return rc; // Return true if error return rc; // Return true if error
} // end of DeleteTableFile } // end of DeleteTableFile
#endif // 0
/* ------------------------- TDBXML Class ---------------------------- */ /* ------------------------- TDBXML Class ---------------------------- */
......
...@@ -30,7 +30,7 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */ ...@@ -30,7 +30,7 @@ class DllExport XMLDEF : public TABDEF { /* Logical table description */
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m); virtual PTDB GetTable(PGLOBAL g, MODE m);
virtual bool DeleteTableFile(PGLOBAL g); //virtual bool DeleteTableFile(PGLOBAL g);
protected: protected:
// Members // Members
......
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
#include "plgdbsem.h" #include "plgdbsem.h"
#include "valblk.h" #include "valblk.h"
#define CheckBlanks assert(!Blanks); #define CheckBlanks assert(!Blanks);
#define CheckParms(V, N) ChkIndx(N); ChkTyp(V);
/***********************************************************************/ /***********************************************************************/
/* AllocValBlock: allocate a VALBLK according to type. */ /* AllocValBlock: allocate a VALBLK according to type. */
...@@ -447,6 +448,38 @@ template <> ...@@ -447,6 +448,38 @@ template <>
uchar TYPBLK<uchar>::GetTypedValue(PVBLK blk, int n) uchar TYPBLK<uchar>::GetTypedValue(PVBLK blk, int n)
{return blk->GetUTinyValue(n);} {return blk->GetUTinyValue(n);}
#if defined(BLK_INDX)
/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
template <class TYPE>
void TYPBLK<TYPE>::SetMin(PVAL valp, int n)
{
CheckParms(valp, n)
TYPE tval = GetTypedValue(valp);
TYPE& tmin = Typp[n];
if (tval < tmin)
tmin = tval;
} // end of SetMin
/***********************************************************************/
/* Set one value in a block if val is greater than the current value. */
/***********************************************************************/
template <class TYPE>
void TYPBLK<TYPE>::SetMax(PVAL valp, int n)
{
CheckParms(valp, n)
TYPE tval = GetTypedValue(valp);
TYPE& tmin = Typp[n];
if (tval > tmin)
tmin = tval;
} // end of SetMax
#endif // BLK_INDX
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
/* Set many values in a block from values in another block. */ /* Set many values in a block from values in another block. */
...@@ -779,6 +812,38 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2) ...@@ -779,6 +812,38 @@ void CHRBLK::SetValue(PVBLK pv, int n1, int n2)
SetNull(n1, b); SetNull(n1, b);
} // end of SetValue } // end of SetValue
#if defined(BLK_INDX)
/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
void CHRBLK::SetMin(PVAL valp, int n)
{
CheckParms(valp, n)
CheckBlanks
char *vp = valp->GetCharValue();
char *bp = Chrp + n * Long;
if (((Ci) ? strnicmp(vp, bp, Long) : strncmp(vp, bp, Long)) < 0)
memcpy(bp, vp, Long);
} // end of SetMin
/***********************************************************************/
/* Set one value in a block if val is greater than the current value. */
/***********************************************************************/
void CHRBLK::SetMax(PVAL valp, int n)
{
CheckParms(valp, n)
CheckBlanks
char *vp = valp->GetCharValue();
char *bp = Chrp + n * Long;
if (((Ci) ? strnicmp(vp, bp, Long) : strncmp(vp, bp, Long)) > 0)
memcpy(bp, vp, Long);
} // end of SetMax
#endif // BLK_INDX
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
/* Set many values in a block from values in another block. */ /* Set many values in a block from values in another block. */
...@@ -1101,6 +1166,36 @@ void STRBLK::SetValue(char *sp, uint len, int n) ...@@ -1101,6 +1166,36 @@ void STRBLK::SetValue(char *sp, uint len, int n)
Strp[n] = p; Strp[n] = p;
} // end of SetValue } // end of SetValue
#if defined(BLK_INDX)
/***********************************************************************/
/* Set one value in a block if val is less than the current value. */
/***********************************************************************/
void STRBLK::SetMin(PVAL valp, int n)
{
CheckParms(valp, n)
char *vp = valp->GetCharValue();
char *bp = Strp[n];
if (strcmp(vp, bp) < 0)
SetValue(valp, n);
} // end of SetMin
/***********************************************************************/
/* Set one value in a block if val is greater than the current value. */
/***********************************************************************/
void STRBLK::SetMax(PVAL valp, int n)
{
CheckParms(valp, n)
char *vp = valp->GetCharValue();
char *bp = Strp[n];
if (strcmp(vp, bp) > 0)
SetValue(valp, n);
} // end of SetMax
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* Move one value from i to j. */ /* Move one value from i to j. */
/***********************************************************************/ /***********************************************************************/
...@@ -1240,5 +1335,51 @@ void DATBLK::SetValue(PSZ p, int n) ...@@ -1240,5 +1335,51 @@ void DATBLK::SetValue(PSZ p, int n)
} // end of SetValue } // end of SetValue
#if defined(BLK_INDX)
/* -------------------------- Class MBVALS --------------------------- */
/***********************************************************************/
/* Allocate a value block according to type,len, and nb of values. */
/***********************************************************************/
PVBLK MBVALS::Allocate(PGLOBAL g, int type, int len, int prec,
int n, bool sub)
{
Mblk.Sub = sub;
Mblk.Size = n * GetTypeSize(type, len);
if (!PlgDBalloc(g, NULL, Mblk)) {
sprintf(g->Message, MSG(ALLOC_ERROR), "MBVALS::Allocate");
return NULL;
} else
Vblk = AllocValBlock(g, Mblk.Memp, type, n, len, prec,
TRUE, TRUE, FALSE);
return Vblk;
} // end of Allocate
/***********************************************************************/
/* Reallocate the value block according to the new size. */
/***********************************************************************/
bool MBVALS::ReAllocate(PGLOBAL g, int n)
{
if (!PlgDBrealloc(g, NULL, Mblk, n * Vblk->GetVlen())) {
sprintf(g->Message, MSG(ALLOC_ERROR), "MBVALS::ReAllocate");
return TRUE;
} else
Vblk->ReAlloc(Mblk.Memp, n);
return FALSE;
} // end of ReAllocate
/***********************************************************************/
/* Free the value block. */
/***********************************************************************/
void MBVALS::Free(void)
{
PlgDBfree(Mblk);
Vblk = NULL;
} // end of Free
#endif // BLK_INDX
/* ------------------------- End of Valblk --------------------------- */ /* ------------------------- End of Valblk --------------------------- */
This diff is collapsed.
This diff is collapsed.
...@@ -46,8 +46,10 @@ DllExport char *GetFormatType(int); ...@@ -46,8 +46,10 @@ DllExport char *GetFormatType(int);
DllExport int GetFormatType(char); DllExport int GetFormatType(char);
DllExport bool IsTypeChar(int type); DllExport bool IsTypeChar(int type);
DllExport bool IsTypeNum(int type); DllExport bool IsTypeNum(int type);
//lExport int ConvertType(int, int, CONV, bool match = false); #if defined(BLK_INDX)
//lExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0); DllExport int ConvertType(int, int, CONV, bool match = false);
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
#endif // BLK_INDX
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0, DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
bool uns = false, PSZ fmt = NULL); bool uns = false, PSZ fmt = NULL);
DllExport ulonglong CharToNumber(char *, int, ulonglong, bool, DllExport ulonglong CharToNumber(char *, int, ulonglong, bool,
...@@ -95,6 +97,11 @@ class DllExport VALUE : public BLOCK { ...@@ -95,6 +97,11 @@ class DllExport VALUE : public BLOCK {
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0;
virtual bool SetValue_char(char *p, int n) = 0; virtual bool SetValue_char(char *p, int n) = 0;
virtual void SetValue_psz(PSZ s) = 0; virtual void SetValue_psz(PSZ s) = 0;
#if defined(BLK_INDX)
virtual void SetValue_bool(bool b) {assert(FALSE);}
virtual int CompareValue(PVAL vp) = 0;
virtual BYTE TestValue(PVAL vp);
#endif // BLK_INDX
virtual void SetValue(char c) {assert(false);} virtual void SetValue(char c) {assert(false);}
virtual void SetValue(uchar c) {assert(false);} virtual void SetValue(uchar c) {assert(false);}
virtual void SetValue(short i) {assert(false);} virtual void SetValue(short i) {assert(false);}
...@@ -163,6 +170,10 @@ class DllExport TYPVAL : public VALUE { ...@@ -163,6 +170,10 @@ class DllExport TYPVAL : public VALUE {
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n); virtual bool SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s); virtual void SetValue_psz(PSZ s);
#if defined(BLK_INDX)
virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;}
virtual int CompareValue(PVAL vp);
#endif // BLK_INDX
virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;} virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;}
virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;} virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;}
virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;} virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;}
...@@ -242,6 +253,9 @@ class DllExport TYPVAL<PSZ>: public VALUE { ...@@ -242,6 +253,9 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual void SetValue(ulonglong n); virtual void SetValue(ulonglong n);
virtual void SetValue(double f); virtual void SetValue(double f);
virtual void SetBinValue(void *p); virtual void SetBinValue(void *p);
#if defined(BLK_INDX)
virtual int CompareValue(PVAL vp);
#endif // BLK_INDX
virtual bool GetBinValue(void *buf, int buflen, bool go); virtual bool GetBinValue(void *buf, int buflen, bool go);
virtual char *ShowValue(char *buf, int); virtual char *ShowValue(char *buf, int);
virtual char *GetCharString(char *p); virtual char *GetCharString(char *p);
...@@ -280,6 +294,9 @@ class DllExport DECVAL: public TYPVAL<PSZ> { ...@@ -280,6 +294,9 @@ class DllExport DECVAL: public TYPVAL<PSZ> {
virtual char *ShowValue(char *buf, int); virtual char *ShowValue(char *buf, int);
//virtual char *GetCharString(char *p); //virtual char *GetCharString(char *p);
virtual bool IsEqual(PVAL vp, bool chktype); virtual bool IsEqual(PVAL vp, bool chktype);
#if defined(BLK_INDX)
virtual int CompareValue(PVAL vp);
#endif // BLK_INDX
//virtual bool FormatValue(PVAL vp, char *fmt); //virtual bool FormatValue(PVAL vp, char *fmt);
//virtual bool SetConstFormat(PGLOBAL, FORMAT&); //virtual bool SetConstFormat(PGLOBAL, FORMAT&);
......
...@@ -109,7 +109,7 @@ int CONSTANT::GetLengthEx(void) ...@@ -109,7 +109,7 @@ int CONSTANT::GetLengthEx(void)
return Value->GetValLen(); return Value->GetValLen();
} // end of GetLengthEx } // end of GetLengthEx
#if 0 #if defined(BLK_INDX)
/***********************************************************************/ /***********************************************************************/
/* Convert a constant to the given type. */ /* Convert a constant to the given type. */
/***********************************************************************/ /***********************************************************************/
...@@ -120,7 +120,7 @@ void CONSTANT::Convert(PGLOBAL g, int newtype) ...@@ -120,7 +120,7 @@ void CONSTANT::Convert(PGLOBAL g, int newtype)
longjmp(g->jumper[g->jump_level], TYPE_CONST); longjmp(g->jumper[g->jump_level], TYPE_CONST);
} // end of Convert } // end of Convert
#endif // 0 #endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* Compare: returns true if this object is equivalent to xp. */ /* Compare: returns true if this object is equivalent to xp. */
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment