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

- 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
This commit is contained in:
Olivier Bertrand
2014-03-10 12:21:17 +01:00
parent 126bb34513
commit 85e8aee47d
45 changed files with 3328 additions and 389 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,11 +1,11 @@
/*********** 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)
/*******************************************************************/ /*******************************************************************/
/* Record file position in case of UPDATE or DELETE. */ /* Record file position in case of UPDATE or DELETE. */
/*******************************************************************/ /*******************************************************************/
#if defined(BLK_INDX)
int rc;
next:
#endif // BLK_INDX
Fpos = Mempos; Fpos = Mempos;
CurBlk = (int)Rows++; 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)
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)
/***********************************************************************/ /***********************************************************************/
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)
/*******************************************************************/ /*******************************************************************/
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)
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
/***********************************************************************/ /***********************************************************************/
@@ -658,9 +701,25 @@ int MPXFAM::ReadBuffer(PGLOBAL g)
/*******************************************************************/ /*******************************************************************/
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

View File

@@ -1,11 +1,11 @@
/*********** 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)
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)
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) {

View File

@@ -1,11 +1,11 @@
/*********** 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)
/***********************************************************************/ /***********************************************************************/
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; size += (CurBlk == blm1) ? last : Nrec;
else if (rc == RC_EF)
break;
#else // !BLK_INDX
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)
/*******************************************************************/ /*******************************************************************/
/* 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)
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)
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)
/***********************************************************************/ /***********************************************************************/
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; size += (CurBlk == Block - 1) ? Last : Nrec;
else if (rc == RC_EF)
break;
#else // !BLK_INDX
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)
/***********************************************************************/ /***********************************************************************/
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)
/*******************************************************************/ /*******************************************************************/
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)
// 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
/***********************************************************************/ /***********************************************************************/

View File

@@ -1,11 +1,11 @@
/*********** 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)
/***********************************************************************/ /***********************************************************************/
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; size += (CurBlk == Block - 1) ? Last : Nrec;
else if (rc == RC_EF)
break;
#else // !BLK_INDX
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)
/*******************************************************************/ /*******************************************************************/
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

View File

@@ -306,10 +306,30 @@ int ZIPFAM::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;
CurBlk = Rows++; // Update RowID CurBlk = Rows++; // Update RowID
#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;
@@ -403,7 +423,11 @@ ZBKFAM::ZBKFAM(PDOSDEF tdp) : ZIPFAM(tdp)
CurLine = NULL; CurLine = NULL;
NxtLine = NULL; NxtLine = NULL;
Closing = false; Closing = false;
#if defined(BLK_INDX)
BlkPos = tdp->GetTo_Pos(); BlkPos = tdp->GetTo_Pos();
#else // !BLK_INDX
BlkPos = NULL;
#endif // !BLK_INDX
} // end of ZBKFAM standard constructor } // end of ZBKFAM standard constructor
ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp) ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
@@ -418,13 +442,20 @@ ZBKFAM::ZBKFAM(PZBKFAM txfp) : ZIPFAM(txfp)
/***********************************************************************/ /***********************************************************************/
int ZBKFAM::MaxBlkSize(PGLOBAL g, int s) int ZBKFAM::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; size += (CurBlk == Block - 1) ? Last : Nrec;
else if (rc == RC_EF)
break;
#else // !BLK_INDX
size += (CurBlk == Block - 1) ? Last : Nrec;
#endif // !BLK_INDX
CurBlk = savcur; CurBlk = savcur;
return size; return size;
@@ -509,7 +540,8 @@ int ZBKFAM::SkipRecord(PGLOBAL g, bool header)
/***********************************************************************/ /***********************************************************************/
int ZBKFAM::ReadBuffer(PGLOBAL g) int ZBKFAM::ReadBuffer(PGLOBAL g)
{ {
int n, rc = RC_OK; #if defined(BLK_INDX)
int n, skip, rc = RC_OK;
/*********************************************************************/ /*********************************************************************/
/* Sequential reading when Placed is not true. */ /* Sequential reading when Placed is not true. */
@@ -532,10 +564,34 @@ int ZBKFAM::ReadBuffer(PGLOBAL g)
/* New block. */ /* New block. */
/*********************************************************************/ /*********************************************************************/
CurNum = 0; CurNum = 0;
skip = 0;
next:
if (++CurBlk >= Block) if (++CurBlk >= Block)
return RC_EF; return RC_EF;
/*********************************************************************/
/* Before using the 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:
skip++;
goto next;
} // endswitch rc
if (skip)
// Skip blocks rejected by block optimization
for (int i = CurBlk - skip; i < CurBlk; i++) {
BlkLen = BlkPos[i + 1] - BlkPos[i];
if (gzseek(Zfile, (z_off_t)BlkLen, SEEK_CUR) < 0)
return Zerror(g);
} // endfor i
BlkLen = BlkPos[CurBlk + 1] - BlkPos[CurBlk]; BlkLen = BlkPos[CurBlk + 1] - BlkPos[CurBlk];
if (!(n = gzread(Zfile, To_Buf, BlkLen))) { if (!(n = gzread(Zfile, To_Buf, BlkLen))) {
@@ -559,6 +615,10 @@ int ZBKFAM::ReadBuffer(PGLOBAL g)
rc = Zerror(g); rc = Zerror(g);
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
/***********************************************************************/ /***********************************************************************/
@@ -770,8 +830,33 @@ int ZIXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0; CurNum = 0;
Tdbp->SetLine(To_Buf); Tdbp->SetLine(To_Buf);
//if (++CurBlk >= Block) #if defined(BLK_INDX)
// return RC_EF; int skip = 0;
next:
if (++CurBlk >= Block)
return RC_EF;
/*********************************************************************/
/* Before using the 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:
skip++;
goto next;
} // endswitch rc
if (skip)
// Skip blocks rejected by block optimization
for (int i = 0; i < skip; i++) {
if (gzseek(Zfile, (z_off_t)Buflen, SEEK_CUR) < 0)
return Zerror(g);
} // endfor i
#endif // BLK_INDX
if (!(n = gzread(Zfile, To_Buf, Buflen))) { if (!(n = gzread(Zfile, To_Buf, Buflen))) {
rc = RC_EF; rc = RC_EF;
@@ -818,4 +903,522 @@ int ZIXFAM::WriteBuffer(PGLOBAL g)
return RC_OK; return RC_OK;
} // end of WriteBuffer } // end of WriteBuffer
#if defined(BLK_INDX)
/* --------------------------- Class ZLBFAM -------------------------- */
/***********************************************************************/
/* Constructors. */
/***********************************************************************/
ZLBFAM::ZLBFAM(PDOSDEF tdp) : BLKFAM(tdp)
{
Zstream = NULL;
Zbuffer = NULL;
Zlenp = NULL;
Optimized = tdp->IsOptimized();
} // end of ZLBFAM standard constructor
ZLBFAM::ZLBFAM(PZLBFAM txfp) : BLKFAM(txfp)
{
Zstream = txfp->Zstream;
Zbuffer = txfp->Zbuffer;
Zlenp = txfp->Zlenp;
Optimized = txfp->Optimized;
} // end of ZLBFAM (dummy?) copy constructor
/***********************************************************************/
/* ZLB GetFileLength: returns an estimate of what would be the */
/* uncompressed file size in number of bytes. */
/***********************************************************************/
int ZLBFAM::GetFileLength(PGLOBAL g)
{
int len = (Optimized) ? BlkPos[Block] : BLKFAM::GetFileLength(g);
if (len > 0)
// Estimate size reduction to a max of 5
len *= 5;
return len;
} // end of GetFileLength
/***********************************************************************/
/* Allocate the line buffer. For mode Delete a bigger buffer has to */
/* be allocated because is it also used to move lines into the file. */
/***********************************************************************/
bool ZLBFAM::AllocateBuffer(PGLOBAL g)
{
char *msg;
int n, zrc;
#if 0
if (!Optimized && Tdbp->NeedIndexing(g)) {
strcpy(g->Message, MSG(NOP_ZLIB_INDEX));
return TRUE;
} // endif indexing
#endif // 0
#if defined(NOLIB)
if (!zlib && LoadZlib()) {
sprintf(g->Message, MSG(DLL_LOAD_ERROR), GetLastError(), "zlib.dll");
return TRUE;
} // endif zlib
#endif
BLKFAM::AllocateBuffer(g);
//Buflen = Nrec * (Lrecl + 2);
//Rbuf = Nrec;
// Allocate the compressed buffer
n = Buflen + 16; // ?????????????????????????????????
Zlenp = (int*)PlugSubAlloc(g, NULL, n);
Zbuffer = (Byte*)(Zlenp + 1);
// Allocate and initialize the Z stream
Zstream = (z_streamp)PlugSubAlloc(g, NULL, sizeof(z_stream));
Zstream->zalloc = (alloc_func)0;
Zstream->zfree = (free_func)0;
Zstream->opaque = (voidpf)0;
Zstream->next_in = NULL;
Zstream->avail_in = 0;
if (Tdbp->GetMode() == MODE_READ) {
msg = "inflateInit";
zrc = inflateInit(Zstream);
} else {
msg = "deflateInit";
zrc = deflateInit(Zstream, Z_DEFAULT_COMPRESSION);
} // endif Mode
if (zrc != Z_OK) {
if (Zstream->msg)
sprintf(g->Message, "%s error: %s", msg, Zstream->msg);
else
sprintf(g->Message, "%s error: %d", msg, zrc);
return TRUE;
} // endif zrc
if (Tdbp->GetMode() == MODE_INSERT) {
// Write the file header block
if (Last == Nrec) {
CurBlk = Block;
CurNum = 0;
if (!GetFileLength(g)) {
// Write the zlib header as an extra block
strcpy(To_Buf, "PlugDB");
BlkLen = strlen("PlugDB") + 1;
if (WriteCompressedBuffer(g))
return TRUE;
} // endif void file
} else {
// In mode insert, if Last != Nrec, last block must be updated
CurBlk = Block - 1;
CurNum = Last;
strcpy(g->Message, MSG(NO_PAR_BLK_INS));
return TRUE;
} // endif Last
} else { // MODE_READ
// First thing to do is to read the header block
void *rdbuf;
if (Optimized) {
BlkLen = BlkPos[0];
rdbuf = Zlenp;
} else {
// Get the stored length from the file itself
if (fread(Zlenp, sizeof(int), 1, Stream) != 1)
return FALSE; // Empty file
BlkLen = *Zlenp;
rdbuf = Zbuffer;
} // endif Optimized
switch (ReadCompressedBuffer(g, rdbuf)) {
case RC_EF:
return FALSE;
case RC_FX:
#if defined(UNIX)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#endif
case RC_NF:
return TRUE;
} // endswitch
// Some old tables can have PlugDB in their header
if (strcmp(To_Buf, "PlugDB")) {
sprintf(g->Message, MSG(BAD_HEADER), Tdbp->GetFile(g));
return TRUE;
} // endif strcmp
} // endif Mode
return FALSE;
} // end of AllocateBuffer
/***********************************************************************/
/* GetPos: return the position of last read record. */
/***********************************************************************/
int ZLBFAM::GetPos(void)
{
return (Optimized) ? (CurNum + Nrec * CurBlk) : Fpos;
} // end of GetPos
/***********************************************************************/
/* GetNextPos: should not be called for this class. */
/***********************************************************************/
int ZLBFAM::GetNextPos(void)
{
if (Optimized) {
assert(FALSE);
return 0;
} else
return ftell(Stream);
} // end of GetNextPos
/***********************************************************************/
/* ReadBuffer: Read one line for a text file. */
/***********************************************************************/
int ZLBFAM::ReadBuffer(PGLOBAL g)
{
int n;
void *rdbuf;
/*********************************************************************/
/* Sequential reading when Placed is not true. */
/*********************************************************************/
if (Placed) {
Placed = FALSE;
} else if (++CurNum < Rbuf) {
CurLine = NxtLine;
// Get the position of the next line in the buffer
if (Tdbp->GetFtype() == RECFM_VAR)
while (*NxtLine++ != '\n') ;
else
NxtLine += Lrecl;
// Set caller line buffer
n = NxtLine - CurLine - ((Tdbp->GetFtype() == RECFM_BIN) ? 0 : Ending);
memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0';
return RC_OK;
} else if (Rbuf < Nrec && CurBlk != -1) {
CurNum--; // To have a correct Last value when optimizing
return RC_EF;
} else {
/*******************************************************************/
/* New block. */
/*******************************************************************/
CurNum = 0;
next:
if (++CurBlk >= Block)
return RC_EF;
/*******************************************************************/
/* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */
/*******************************************************************/
if (Optimized) switch (Tdbp->TestBlock(g)) {
case RC_EF:
return RC_EF;
case RC_NF:
goto next;
} // endswitch rc
} // endif's
if (OldBlk == CurBlk)
goto ok; // Block is already there
if (Optimized) {
// Store the position of next block
Fpos = BlkPos[CurBlk];
// fseek is required only in non sequential reading
if (CurBlk != OldBlk + 1)
if (fseek(Stream, Fpos, SEEK_SET)) {
sprintf(g->Message, MSG(FSETPOS_ERROR), Fpos);
return RC_FX;
} // endif fseek
// Calculate the length of block to read
BlkLen = BlkPos[CurBlk + 1] - Fpos;
rdbuf = Zlenp;
} else { // !Optimized
if (CurBlk != OldBlk + 1) {
strcpy(g->Message, MSG(INV_RAND_ACC));
return RC_FX;
} else
Fpos = ftell(Stream); // Used when optimizing
// Get the stored length from the file itself
if (fread(Zlenp, sizeof(int), 1, Stream) != 1) {
if (feof(Stream))
return RC_EF;
goto err;
} // endif fread
BlkLen = *Zlenp;
rdbuf = Zbuffer;
} // endif Optimized
// Read the next block
switch (ReadCompressedBuffer(g, rdbuf)) {
case RC_FX: goto err;
case RC_NF: return RC_FX;
case RC_EF: return RC_EF;
default: Rbuf = (CurBlk == Block - 1) ? Last : Nrec;
} // endswitch ReadCompressedBuffer
ok:
if (Tdbp->GetFtype() == RECFM_VAR) {
int i;
// Get the position of the current line
for (i = 0, CurLine = To_Buf; i < CurNum; i++)
while (*CurLine++ != '\n') ; // What about Unix ???
// Now get the position of the next line
for (NxtLine = CurLine; *NxtLine++ != '\n';) ;
// Set caller line buffer
n = NxtLine - CurLine - Ending;
} else {
CurLine = To_Buf + CurNum * Lrecl;
NxtLine = CurLine + Lrecl;
n = Lrecl - ((Tdbp->GetFtype() == RECFM_BIN) ? 0 : Ending);
} // endif Ftype
memcpy(Tdbp->GetLine(), CurLine, n);
Tdbp->GetLine()[n] = '\0';
OldBlk = CurBlk; // Last block actually read
IsRead = TRUE; // Is read indeed
return RC_OK;
err:
#if defined(UNIX)
sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(errno));
#else
sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#endif
return RC_FX;
} // end of ReadBuffer
/***********************************************************************/
/* Read and decompress a block from the stream. */
/***********************************************************************/
int ZLBFAM::ReadCompressedBuffer(PGLOBAL g, void *rdbuf)
{
if (fread(rdbuf, 1, (size_t)BlkLen, Stream) == (unsigned)BlkLen) {
int zrc;
num_read++;
if (Optimized && BlkLen != signed(*Zlenp + sizeof(int))) {
sprintf(g->Message, MSG(BAD_BLK_SIZE), CurBlk + 1);
return RC_NF;
} // endif BlkLen
// HERE WE MUST INFLATE THE BLOCK
Zstream->next_in = Zbuffer;
Zstream->avail_in = (uInt)(*Zlenp);
Zstream->next_out = (Byte*)To_Buf;
Zstream->avail_out = Buflen;
zrc = inflate(Zstream, Z_SYNC_FLUSH);
if (zrc != Z_OK) {
if (Zstream->msg)
sprintf(g->Message, MSG(FUNC_ERR_S), "inflate", Zstream->msg);
else
sprintf(g->Message, MSG(FUNCTION_ERROR), "inflate", (int)zrc);
return RC_NF;
} // endif zrc
} else if (feof(Stream)) {
return RC_EF;
} else
return RC_FX;
return RC_OK;
} // end of ReadCompressedBuffer
/***********************************************************************/
/* WriteBuffer: File write routine for DOS access method. */
/* Update is directly written back into the file, */
/* with this (fast) method, record size cannot change. */
/***********************************************************************/
int ZLBFAM::WriteBuffer(PGLOBAL g)
{
assert (Tdbp->GetMode() == MODE_INSERT);
/*********************************************************************/
/* Prepare the write buffer. */
/*********************************************************************/
if (!Closing) {
if (Tdbp->GetFtype() == RECFM_BIN)
memcpy(CurLine, Tdbp->GetLine(), Lrecl);
else
strcat(strcpy(CurLine, Tdbp->GetLine()), CrLf);
#if defined(_DEBUG)
if (Tdbp->GetFtype() == RECFM_FIX &&
(signed)strlen(CurLine) != Lrecl + (signed)strlen(CrLf)) {
strcpy(g->Message, MSG(BAD_LINE_LEN));
Closing = TRUE;
return RC_FX;
} // endif Lrecl
#endif // _DEBUG
} // endif Closing
/*********************************************************************/
/* In Insert mode, blocs are added sequentialy to the file end. */
/*********************************************************************/
if (++CurNum != Rbuf) {
if (Tdbp->GetFtype() == RECFM_VAR)
CurLine += strlen(CurLine);
else
CurLine += Lrecl;
return RC_OK; // We write only full blocks
} // endif CurNum
// HERE WE MUST DEFLATE THE BLOCK
if (Tdbp->GetFtype() == RECFM_VAR)
NxtLine = CurLine + strlen(CurLine);
else
NxtLine = CurLine + Lrecl;
BlkLen = NxtLine - To_Buf;
if (WriteCompressedBuffer(g)) {
Closing = TRUE; // To tell CloseDB about a Write error
return RC_FX;
} // endif WriteCompressedBuffer
CurBlk++;
CurNum = 0;
CurLine = To_Buf;
return RC_OK;
} // end of WriteBuffer
/***********************************************************************/
/* Compress the buffer and write the deflated output to stream. */
/***********************************************************************/
bool ZLBFAM::WriteCompressedBuffer(PGLOBAL g)
{
int zrc;
Zstream->next_in = (Byte*)To_Buf;
Zstream->avail_in = (uInt)BlkLen;
Zstream->next_out = Zbuffer;
Zstream->avail_out = Buflen + 16;
Zstream->total_out = 0;
zrc = deflate(Zstream, Z_FULL_FLUSH);
if (zrc != Z_OK) {
if (Zstream->msg)
sprintf(g->Message, MSG(FUNC_ERR_S), "deflate", Zstream->msg);
else
sprintf(g->Message, MSG(FUNCTION_ERROR), "deflate", (int)zrc);
return TRUE;
} else
*Zlenp = Zstream->total_out;
// Now start the writing process.
BlkLen = *Zlenp + sizeof(int);
if (fwrite(Zlenp, 1, BlkLen, Stream) != (size_t)BlkLen) {
sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno));
return TRUE;
} // endif size
return FALSE;
} // end of WriteCompressedBuffer
/***********************************************************************/
/* Table file close routine for DOS access method. */
/***********************************************************************/
void ZLBFAM::CloseTableFile(PGLOBAL g)
{
int rc = RC_OK;
if (Tdbp->GetMode() == MODE_INSERT) {
PCATLG cat = PlgGetCatalog(g);
LPCSTR name = Tdbp->GetName();
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
// Closing is True if last Write was in error
if (CurNum && !Closing) {
// Some more inserted lines remain to be written
Last = (Nrec - Rbuf) + CurNum;
Block = CurBlk + 1;
Rbuf = CurNum--;
Closing = TRUE;
rc = WriteBuffer(g);
} else if (Rbuf == Nrec) {
Last = Nrec;
Block = CurBlk;
} // endif CurNum
if (rc != RC_FX) {
defp->SetBlock(Block);
defp->SetLast(Last);
cat->SetIntCatInfo("Blocks", Block);
cat->SetIntCatInfo("Last", Last);
} // endif
fclose(Stream);
} else
rc = fclose(Stream);
#ifdef DEBTRACE
htrc("ZLB CloseTableFile: closing %s mode=%d rc=%d\n",
To_File, Tdbp->GetMode(), rc);
#endif
Stream = NULL; // So we can know whether table is open
To_Fb->Count = 0; // Avoid double closing by PlugCloseAll
if (Tdbp->GetMode() == MODE_READ)
rc = inflateEnd(Zstream);
else
rc = deflateEnd(Zstream);
} // end of CloseTableFile
/***********************************************************************/
/* Rewind routine for ZLIB access method. */
/***********************************************************************/
void ZLBFAM::Rewind(void)
{
// We must be positioned after the header block
if (CurBlk >= 0) { // Nothing to do if no block read yet
if (!Optimized) { // If optimized, fseek will be done in ReadBuffer
rewind(Stream);
fread(Zlenp, sizeof(int), 1, Stream);
fseek(Stream, *Zlenp + sizeof(int), SEEK_SET);
OldBlk = -1;
} // endif Optimized
CurBlk = -1;
CurNum = Rbuf;
} // endif CurBlk
//OldBlk = -1;
//Rbuf = 0; commented out in case we reuse last read block
} // end of Rewind
#endif // BLK_INDX
/* ------------------------ End of ZipFam ---------------------------- */ /* ------------------------ End of ZipFam ---------------------------- */

View File

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

View File

@@ -252,8 +252,8 @@ ha_create_table_option connect_table_option_list[]=
ha_create_table_option connect_field_option_list[]= ha_create_table_option connect_field_option_list[]=
{ {
HA_FOPTION_NUMBER("FLAG", offset, (ulonglong) -1, 0, INT_MAX32, 1), HA_FOPTION_NUMBER("FLAG", offset, (ulonglong) -1, 0, INT_MAX32, 1),
HA_FOPTION_NUMBER("FREQUENCY", freq, 0, 0, INT_MAX32, 1), // not used HA_FOPTION_NUMBER("MAX_DIST", freq, 0, 0, INT_MAX32, 1), // BLK_INDX
HA_FOPTION_NUMBER("OPT_VALUE", opt, 0, 0, 2, 1), // used for indexing HA_FOPTION_NUMBER("DISTRIB", opt, 0, 0, 2, 1), // used for BLK_INDX
HA_FOPTION_NUMBER("FIELD_LENGTH", fldlen, 0, 0, INT_MAX32, 1), HA_FOPTION_NUMBER("FIELD_LENGTH", fldlen, 0, 0, INT_MAX32, 1),
HA_FOPTION_STRING("DATE_FORMAT", dateformat), HA_FOPTION_STRING("DATE_FORMAT", dateformat),
HA_FOPTION_STRING("FIELD_FORMAT", fieldformat), HA_FOPTION_STRING("FIELD_FORMAT", fieldformat),
@@ -333,9 +333,10 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir)
static const char *ha_connect_exts[]= { static const char *ha_connect_exts[]= {
".dos", ".fix", ".csv", ".bin", ".fmt", ".dbf", ".xml", ".ini", ".vec", ".dos", ".fix", ".csv", ".bin", ".fmt", ".dbf", ".xml", ".ini", ".vec",
".dnx", ".fnx", ".bnx", ".vnx", ".dbx", ".dnx", ".fnx", ".bnx", ".vnx", ".dbx",
NULL #if defined(BLK_INDX)
}; ".dop", ".fop", ".bop", ".vop",
#endif // BLK_INDX
NULL};
/** /**
@brief @brief
@@ -453,7 +454,7 @@ static handler* connect_create_handler(handlerton *hton,
handler *h= new (mem_root) ha_connect(hton, table); handler *h= new (mem_root) ha_connect(hton, table);
if (xtrace) if (xtrace)
printf("New CONNECT %p, table: %s\n", htrc("New CONNECT %p, table: %s\n",
h, table ? table->table_name.str : "<null>"); h, table ? table->table_name.str : "<null>");
return h; return h;
@@ -500,7 +501,7 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
ha_connect::~ha_connect(void) ha_connect::~ha_connect(void)
{ {
if (xtrace) if (xtrace)
printf("Delete CONNECT %p, table: %s, xp=%p count=%d\n", this, htrc("Delete CONNECT %p, table: %s, xp=%p count=%d\n", this,
table ? table->s->table_name.str : "<null>", table ? table->s->table_name.str : "<null>",
xp, xp ? xp->count : 0); xp, xp ? xp->count : 0);
@@ -932,12 +933,12 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
if (fop) { if (fop) {
pcf->Offset= (int)fop->offset; pcf->Offset= (int)fop->offset;
// pcf->Freq= fop->freq; pcf->Freq= (int)fop->freq;
pcf->Datefmt= (char*)fop->dateformat; pcf->Datefmt= (char*)fop->dateformat;
pcf->Fieldfmt= (char*)fop->fieldformat; pcf->Fieldfmt= (char*)fop->fieldformat;
} else { } else {
pcf->Offset= -1; pcf->Offset= -1;
// pcf->Freq= 0; pcf->Freq= 0;
pcf->Datefmt= NULL; pcf->Datefmt= NULL;
pcf->Fieldfmt= NULL; pcf->Fieldfmt= NULL;
} // endif fop } // endif fop
@@ -1046,7 +1047,7 @@ PIXDEF ha_connect::GetIndexInfo(TABLE_SHARE *s)
for (int n= 0; (unsigned)n < s->keynames.count; n++) { for (int n= 0; (unsigned)n < s->keynames.count; n++) {
if (xtrace) if (xtrace)
printf("Getting created index %d info\n", n + 1); htrc("Getting created index %d info\n", n + 1);
// Find the index to describe // Find the index to describe
kp= s->key_info[n]; kp= s->key_info[n];
@@ -1182,7 +1183,7 @@ PTDB ha_connect::GetTDB(PGLOBAL g)
valid_query_id= xp->last_query_id; valid_query_id= xp->last_query_id;
tp->SetMode(xmod); tp->SetMode(xmod);
} else } else
printf("GetTDB: %s\n", g->Message); htrc("GetTDB: %s\n", g->Message);
return tp; return tp;
} // end of GetTDB } // end of GetTDB
@@ -1197,7 +1198,7 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
// Double test to be on the safe side // Double test to be on the safe side
if (!g || !table) { if (!g || !table) {
printf("OpenTable logical error; g=%p table=%p\n", g, table); htrc("OpenTable logical error; g=%p table=%p\n", g, table);
return HA_ERR_INITIALIZATION; return HA_ERR_INITIALIZATION;
} // endif g } // endif g
@@ -1278,9 +1279,8 @@ int ha_connect::OpenTable(PGLOBAL g, bool del)
PIXDEF oldpix= GetIndexInfo(); PIXDEF oldpix= GetIndexInfo();
} // endif xmod } // endif xmod
// tdbp->SetOrig((PTBX)table); // used by CheckCond
} else } else
printf("OpenTable: %s\n", g->Message); htrc("OpenTable: %s\n", g->Message);
if (rc) { if (rc) {
tdbp= NULL; tdbp= NULL;
@@ -1334,7 +1334,7 @@ int ha_connect::MakeRecord(char *buf)
DBUG_ENTER("ha_connect::MakeRecord"); DBUG_ENTER("ha_connect::MakeRecord");
if (xtrace > 1) if (xtrace > 1)
printf("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n", htrc("Maps: read=%08X write=%08X vcol=%08X defr=%08X defw=%08X\n",
*table->read_set->bitmap, *table->write_set->bitmap, *table->read_set->bitmap, *table->write_set->bitmap,
*table->vcol_set->bitmap, *table->vcol_set->bitmap,
*table->def_read_set.bitmap, *table->def_write_set.bitmap); *table->def_read_set.bitmap, *table->def_write_set.bitmap);
@@ -1372,7 +1372,7 @@ int ha_connect::MakeRecord(char *buf)
if (mrr) if (mrr)
continue; continue;
#endif // MRRBKA_SUPPORT #endif // MRRBKA_SUPPORT
printf("Column %s not found\n", fp->field_name); htrc("Column %s not found\n", fp->field_name);
dbug_tmp_restore_column_map(table->write_set, org_bitmap); dbug_tmp_restore_column_map(table->write_set, org_bitmap);
DBUG_RETURN(HA_ERR_WRONG_IN_RECORD); DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
} // endif colp } // endif colp
@@ -1487,7 +1487,7 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
break; break;
if (!colp) { if (!colp) {
printf("Column %s not found\n", fp->field_name); htrc("Column %s not found\n", fp->field_name);
rc= HA_ERR_WRONG_IN_RECORD; rc= HA_ERR_WRONG_IN_RECORD;
goto err; goto err;
} else } else
@@ -1612,16 +1612,16 @@ const char *ha_connect::GetValStr(OPVAL vop, bool neg)
val= (neg) ? " NOT IN (" : " IN ("; val= (neg) ? " NOT IN (" : " IN (";
break; break;
case OP_NULL: case OP_NULL:
val= " IS NULL"; val= (neg) ? " IS NOT NULL" : " IS NULL";
break; break;
case OP_LIKE: case OP_LIKE:
val= " LIKE "; val= " LIKE ";
break; break;
case OP_XX: case OP_XX:
val= " BETWEEN "; val= (neg) ? " NOT BETWEEN " : " BETWEEN ";
break; break;
case OP_EXIST: case OP_EXIST:
val= " EXISTS "; val= (neg) ? " NOT EXISTS " : " EXISTS ";
break; break;
case OP_AND: case OP_AND:
val= " AND "; val= " AND ";
@@ -1656,22 +1656,204 @@ const char *ha_connect::GetValStr(OPVAL vop, bool neg)
} // end of GetValStr } // end of GetValStr
#if defined(BLK_INDX)
/***********************************************************************/ /***********************************************************************/
/* Check the WHERE condition and return an ODBC/WQL filter. */ /* Check the WHERE condition and return a CONNECT filter. */
/***********************************************************************/ /***********************************************************************/
PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond) PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
{
unsigned int i;
bool ismul= false;
OPVAL vop= OP_XX;
PFIL filp= NULL;
if (!cond)
return NULL;
if (xtrace)
htrc("Cond type=%d\n", cond->type());
if (cond->type() == COND::COND_ITEM) {
PFIL fp;
Item_cond *cond_item= (Item_cond *)cond;
if (xtrace)
htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(),
cond_item->func_name());
switch (cond_item->functype()) {
case Item_func::COND_AND_FUNC: vop= OP_AND; break;
case Item_func::COND_OR_FUNC: vop= OP_OR; break;
default: return NULL;
} // endswitch functype
List<Item>* arglist= cond_item->argument_list();
List_iterator<Item> li(*arglist);
Item *subitem;
for (i= 0; i < arglist->elements; i++)
if ((subitem= li++)) {
if (!(fp= CondFilter(g, subitem))) {
if (vop == OP_OR)
return NULL;
} else
filp= (filp) ? MakeFilter(g, filp, vop, fp) : fp;
} else
return NULL;
} else if (cond->type() == COND::FUNC_ITEM) {
unsigned int i;
bool iscol, neg= FALSE;
PCOL colp[2]= {NULL,NULL};
PPARM pfirst= NULL, pprec= NULL;
POPER pop;
Item_func *condf= (Item_func *)cond;
Item* *args= condf->arguments();
if (xtrace)
htrc("Func type=%d argnum=%d\n", condf->functype(),
condf->argument_count());
switch (condf->functype()) {
case Item_func::EQUAL_FUNC:
case Item_func::EQ_FUNC: vop= OP_EQ; break;
case Item_func::NE_FUNC: vop= OP_NE; break;
case Item_func::LT_FUNC: vop= OP_LT; break;
case Item_func::LE_FUNC: vop= OP_LE; break;
case Item_func::GE_FUNC: vop= OP_GE; break;
case Item_func::GT_FUNC: vop= OP_GT; break;
case Item_func::IN_FUNC: vop= OP_IN;
case Item_func::BETWEEN:
ismul= true;
neg= ((Item_func_opt_neg *)condf)->negated;
break;
default: return NULL;
} // endswitch functype
pop= (POPER)PlugSubAlloc(g, NULL, sizeof(OPER));
pop->Name= NULL;
pop->Val=vop;
pop->Mod= 0;
if (condf->argument_count() < 2)
return NULL;
for (i= 0; i < condf->argument_count(); i++) {
if (xtrace)
htrc("Argtype(%d)=%d\n", i, args[i]->type());
if (i >= 2 && !ismul) {
if (xtrace)
htrc("Unexpected arg for vop=%d\n", vop);
continue;
} // endif i
if ((iscol= args[i]->type() == COND::FIELD_ITEM)) {
Item_field *pField= (Item_field *)args[i];
// IN and BETWEEN clauses should be col VOP list
if (i && ismul)
return NULL;
if (pField->field->table != table ||
!(colp[i]= tdbp->ColDB(g, (PSZ)pField->field->field_name, 0)))
return NULL; // Column does not belong to this table
if (xtrace) {
htrc("Field index=%d\n", pField->field->field_index);
htrc("Field name=%s\n", pField->field->field_name);
} // endif xtrace
} else {
char buff[256];
String *res, tmp(buff, sizeof(buff), &my_charset_bin);
Item_basic_constant *pval= (Item_basic_constant *)args[i];
PPARM pp= (PPARM)PlugSubAlloc(g, NULL, sizeof(PARM));
// IN and BETWEEN clauses should be col VOP list
if (!i && (ismul))
return NULL;
if ((res= pval->val_str(&tmp)) == NULL)
return NULL; // To be clarified
switch (args[i]->real_type()) {
case COND::STRING_ITEM:
pp->Type= TYPE_STRING;
pp->Value= PlugSubAlloc(g, NULL, res->length() + 1);
strncpy((char*)pp->Value, res->ptr(), res->length() + 1);
break;
case COND::INT_ITEM:
pp->Type= TYPE_INT;
pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
*((int*)pp->Value)= (int)pval->val_int();
break;
case COND::DATE_ITEM:
pp->Type= TYPE_DATE;
pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
*((int*)pp->Value)= (int)pval->val_int_from_date();
break;
case COND::REAL_ITEM:
pp->Type= TYPE_DOUBLE;
pp->Value= PlugSubAlloc(g, NULL, sizeof(double));
*((double*)pp->Value)= pval->val_real();
break;
case COND::DECIMAL_ITEM:
pp->Type= TYPE_DOUBLE;
pp->Value= PlugSubAlloc(g, NULL, sizeof(double));
*((double*)pp->Value)= pval->val_real_from_decimal();
break;
case COND::CACHE_ITEM: // Possible ???
case COND::NULL_ITEM: // TODO: handle this
default:
return NULL;
} // endswitch type
if (xtrace)
htrc("Value=%.*s\n", res->length(), res->ptr());
// Append the value to the argument list
if (pprec)
pprec->Next= pp;
else
pfirst= pp;
pp->Domain= i;
pp->Next= NULL;
pprec= pp;
} // endif type
} // endfor i
filp= MakeFilter(g, colp, pop, pfirst, neg);
} else {
if (xtrace)
htrc("Unsupported condition\n");
return NULL;
} // endif's type
return filp;
} // end of CondFilter
#endif // BLK_INDX
/***********************************************************************/
/* Check the WHERE condition and return a MYSQL/ODBC/WQL filter. */
/***********************************************************************/
PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, AMT tty, Item *cond)
{ {
char *body= filp->Body; char *body= filp->Body;
unsigned int i; unsigned int i;
bool ismul= false, x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC); bool ismul= false, x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
PPARM pfirst= NULL, pprec= NULL, pp[2]= {NULL, NULL};
OPVAL vop= OP_XX; OPVAL vop= OP_XX;
if (!cond) if (!cond)
return NULL; return NULL;
if (xtrace) if (xtrace)
printf("Cond type=%d\n", cond->type()); htrc("Cond type=%d\n", cond->type());
if (cond->type() == COND::COND_ITEM) { if (cond->type() == COND::COND_ITEM) {
char *p1, *p2; char *p1, *p2;
@@ -1681,7 +1863,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
return NULL; return NULL;
if (xtrace) if (xtrace)
printf("Cond: Ftype=%d name=%s\n", cond_item->functype(), htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(),
cond_item->func_name()); cond_item->func_name());
switch (cond_item->functype()) { switch (cond_item->functype()) {
@@ -1728,7 +1910,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
Item* *args= condf->arguments(); Item* *args= condf->arguments();
if (xtrace) if (xtrace)
printf("Func type=%d argnum=%d\n", condf->functype(), htrc("Func type=%d argnum=%d\n", condf->functype(),
condf->argument_count()); condf->argument_count());
// neg= condf-> // neg= condf->
@@ -1742,8 +1924,10 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
case Item_func::GE_FUNC: vop= OP_GE; break; case Item_func::GE_FUNC: vop= OP_GE; break;
case Item_func::GT_FUNC: vop= OP_GT; break; case Item_func::GT_FUNC: vop= OP_GT; break;
case Item_func::IN_FUNC: vop= OP_IN; case Item_func::IN_FUNC: vop= OP_IN;
case Item_func::BETWEEN:
ismul= true;
neg= ((Item_func_opt_neg *)condf)->negated; neg= ((Item_func_opt_neg *)condf)->negated;
case Item_func::BETWEEN: ismul= true; break; break;
default: return NULL; default: return NULL;
} // endswitch functype } // endswitch functype
@@ -1757,11 +1941,11 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
for (i= 0; i < condf->argument_count(); i++) { for (i= 0; i < condf->argument_count(); i++) {
if (xtrace) if (xtrace)
printf("Argtype(%d)=%d\n", i, args[i]->type()); htrc("Argtype(%d)=%d\n", i, args[i]->type());
if (i >= 2 && !ismul) { if (i >= 2 && !ismul) {
if (xtrace) if (xtrace)
printf("Unexpected arg for vop=%d\n", vop); htrc("Unexpected arg for vop=%d\n", vop);
continue; continue;
} // endif i } // endif i
@@ -1793,8 +1977,8 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
fnm= pField->field->field_name; fnm= pField->field->field_name;
if (xtrace) { if (xtrace) {
printf("Field index=%d\n", pField->field->field_index); htrc("Field index=%d\n", pField->field->field_index);
printf("Field name=%s\n", pField->field->field_name); htrc("Field name=%s\n", pField->field->field_name);
} // endif xtrace } // endif xtrace
// IN and BETWEEN clauses should be col VOP list // IN and BETWEEN clauses should be col VOP list
@@ -1815,7 +1999,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
String *res, tmp(buff, sizeof(buff), &my_charset_bin); String *res, tmp(buff, sizeof(buff), &my_charset_bin);
Item_basic_constant *pval= (Item_basic_constant *)args[i]; Item_basic_constant *pval= (Item_basic_constant *)args[i];
switch (args[i]->type()) { switch (args[i]->real_type()) {
case COND::STRING_ITEM: case COND::STRING_ITEM:
case COND::INT_ITEM: case COND::INT_ITEM:
case COND::REAL_ITEM: case COND::REAL_ITEM:
@@ -1832,7 +2016,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
return NULL; // To be clarified return NULL; // To be clarified
if (xtrace) if (xtrace)
printf("Value=%.*s\n", res->length(), res->ptr()); htrc("Value=%.*s\n", res->length(), res->ptr());
// IN and BETWEEN clauses should be col VOP list // IN and BETWEEN clauses should be col VOP list
if (!i && (x || ismul)) if (!i && (x || ismul))
@@ -1877,7 +2061,7 @@ PFIL ha_connect::CheckCond(PGLOBAL g, PFIL filp, AMT tty, Item *cond)
} else { } else {
if (xtrace) if (xtrace)
printf("Unsupported condition\n"); htrc("Unsupported condition\n");
return NULL; return NULL;
} // endif's type } // endif's type
@@ -1912,12 +2096,20 @@ const COND *ha_connect::cond_push(const COND *cond)
if (tdbp) { if (tdbp) {
AMT tty= tdbp->GetAmType(); AMT tty= tdbp->GetAmType();
bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC); bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
bool b= (tty == TYPE_AM_WMI || tty == TYPE_AM_ODBC ||
if (tty == TYPE_AM_WMI || tty == TYPE_AM_ODBC ||
tty == TYPE_AM_TBL || tty == TYPE_AM_MYSQL || tty == TYPE_AM_TBL || tty == TYPE_AM_MYSQL ||
tty == TYPE_AM_PLG || x) { tty == TYPE_AM_PLG || x);
#if defined(BLK_INDX)
bool go= true;
#else // !BLK_INDX)
bool go= b;
#endif // !BLK_INDX
if (go) {
PGLOBAL& g= xp->g; PGLOBAL& g= xp->g;
PFIL filp= (PFIL)PlugSubAlloc(g, NULL, sizeof(FILTER));
if (b) {
PCFIL filp= (PCFIL)PlugSubAlloc(g, NULL, sizeof(CONDFIL));
filp->Body= (char*)PlugSubAlloc(g, NULL, (x) ? 128 : 0); filp->Body= (char*)PlugSubAlloc(g, NULL, (x) ? 128 : 0);
*filp->Body= 0; *filp->Body= 0;
@@ -1926,18 +2118,23 @@ const COND *ha_connect::cond_push(const COND *cond)
if (CheckCond(g, filp, tty, (Item *)cond)) { if (CheckCond(g, filp, tty, (Item *)cond)) {
if (xtrace) if (xtrace)
printf("cond_push: %s\n", filp->Body); htrc("cond_push: %s\n", filp->Body);
if (!x) if (!x)
PlugSubAlloc(g, NULL, strlen(filp->Body) + 1); PlugSubAlloc(g, NULL, strlen(filp->Body) + 1);
else else
cond= NULL; // Does this work? cond= NULL; // Does this work?
tdbp->SetFilter(filp); tdbp->SetCondFil(filp);
} else if (x && cond) } else if (x && cond)
tdbp->SetFilter(filp); // Wrong filter tdbp->SetCondFil(filp); // Wrong filter
} // endif tty } // endif b
#if defined(BLK_INDX)
else
tdbp->SetFilter(CondFilter(g, (Item *)cond));
#endif // BLK_INDX
} // endif go
} // endif tdbp } // endif tdbp
@@ -2019,7 +2216,7 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked)
DBUG_ENTER("ha_connect::open"); DBUG_ENTER("ha_connect::open");
if (xtrace) if (xtrace)
printf("open: name=%s mode=%d test=%u\n", name, mode, test_if_locked); htrc("open: name=%s mode=%d test=%u\n", name, mode, test_if_locked);
if (!(share= get_share())) if (!(share= get_share()))
DBUG_RETURN(1); DBUG_RETURN(1);
@@ -2063,11 +2260,23 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt)
dup->Check |= CHK_OPT; dup->Check |= CHK_OPT;
if (tdbp || (tdbp= GetTDB(g))) { if (tdbp || (tdbp= GetTDB(g))) {
#if defined(BLK_INDX)
bool b= ((PTDBASE)tdbp)->GetDef()->Indexable();
if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, true, b))) {
if (rc == RC_INFO) {
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc= 0;
} else
rc= HA_ERR_INTERNAL_ERROR;
} // endif rc
#else // !BLK_INDX
if (!((PTDBASE)tdbp)->GetDef()->Indexable()) { if (!((PTDBASE)tdbp)->GetDef()->Indexable()) {
sprintf(g->Message, "optimize: Table %s is not indexable", tdbp->GetName()); sprintf(g->Message, "optimize: Table %s is not indexable", tdbp->GetName());
my_message(ER_INDEX_REBUILD, g->Message, MYF(0)); my_message(ER_INDEX_REBUILD, g->Message, MYF(0));
rc= HA_ERR_UNSUPPORTED; rc= HA_ERR_UNSUPPORTED;
} else if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, true))) { } else if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, false, true))) {
if (rc == RC_INFO) { if (rc == RC_INFO) {
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message);
rc= 0; rc= 0;
@@ -2075,6 +2284,8 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt)
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} // endif's } // endif's
#endif // !BLK_INDX
} else } else
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
@@ -2179,7 +2390,7 @@ int ha_connect::write_row(uchar *buf)
// Return result code from write operation // Return result code from write operation
if (CntWriteRow(g, tdbp)) { if (CntWriteRow(g, tdbp)) {
DBUG_PRINT("write_row", ("%s", g->Message)); DBUG_PRINT("write_row", ("%s", g->Message));
printf("write_row: %s\n", g->Message); htrc("write_row: %s\n", g->Message);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} // endif RC } // endif RC
@@ -2216,7 +2427,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data)
DBUG_ENTER("ha_connect::update_row"); DBUG_ENTER("ha_connect::update_row");
if (xtrace > 1) if (xtrace > 1)
printf("update_row: old=%s new=%s\n", old_data, new_data); htrc("update_row: old=%s new=%s\n", old_data, new_data);
// Check values for possible change in indexed column // Check values for possible change in indexed column
if ((rc= CheckRecord(g, old_data, new_data))) if ((rc= CheckRecord(g, old_data, new_data)))
@@ -2224,7 +2435,7 @@ int ha_connect::update_row(const uchar *old_data, uchar *new_data)
if (CntUpdateRow(g, tdbp)) { if (CntUpdateRow(g, tdbp)) {
DBUG_PRINT("update_row", ("%s", g->Message)); DBUG_PRINT("update_row", ("%s", g->Message));
printf("update_row CONNECT: %s\n", g->Message); htrc("update_row CONNECT: %s\n", g->Message);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} // endif RC } // endif RC
@@ -2258,7 +2469,7 @@ int ha_connect::delete_row(const uchar *buf)
if (CntDeleteRow(xp->g, tdbp, false)) { if (CntDeleteRow(xp->g, tdbp, false)) {
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
printf("delete_row CONNECT: %s\n", xp->g->Message); htrc("delete_row CONNECT: %s\n", xp->g->Message);
} // endif DeleteRow } // endif DeleteRow
DBUG_RETURN(rc); DBUG_RETURN(rc);
@@ -2275,7 +2486,7 @@ int ha_connect::index_init(uint idx, bool sorted)
DBUG_ENTER("index_init"); DBUG_ENTER("index_init");
if (xtrace) if (xtrace)
printf("index_init: this=%p idx=%u sorted=%d\n", this, idx, sorted); htrc("index_init: this=%p idx=%u sorted=%d\n", this, idx, sorted);
if ((rc= rnd_init(0))) if ((rc= rnd_init(0)))
return rc; return rc;
@@ -2291,7 +2502,7 @@ int ha_connect::index_init(uint idx, bool sorted)
if (indexing <= 0) { if (indexing <= 0) {
DBUG_PRINT("index_init", ("%s", g->Message)); DBUG_PRINT("index_init", ("%s", g->Message));
printf("index_init CONNECT: %s\n", g->Message); htrc("index_init CONNECT: %s\n", g->Message);
active_index= MAX_KEY; active_index= MAX_KEY;
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} else { } else {
@@ -2307,7 +2518,7 @@ int ha_connect::index_init(uint idx, bool sorted)
} // endif indexing } // endif indexing
if (xtrace) if (xtrace)
printf("index_init: rc=%d indexing=%d active_index=%d\n", htrc("index_init: rc=%d indexing=%d active_index=%d\n",
rc, indexing, active_index); rc, indexing, active_index);
DBUG_RETURN(rc); DBUG_RETURN(rc);
@@ -2350,13 +2561,13 @@ int ha_connect::ReadIndexed(uchar *buf, OPVAL op, const uchar *key, uint key_len
break; break;
default: // Read error default: // Read error
DBUG_PRINT("ReadIndexed", ("%s", xp->g->Message)); DBUG_PRINT("ReadIndexed", ("%s", xp->g->Message));
printf("ReadIndexed: %s\n", xp->g->Message); htrc("ReadIndexed: %s\n", xp->g->Message);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
break; break;
} // endswitch RC } // endswitch RC
if (xtrace > 1) if (xtrace > 1)
printf("ReadIndexed: op=%d rc=%d\n", op, rc); htrc("ReadIndexed: op=%d rc=%d\n", op, rc);
table->status= (rc == RC_OK) ? 0 : STATUS_NOT_FOUND; table->status= (rc == RC_OK) ? 0 : STATUS_NOT_FOUND;
return rc; return rc;
@@ -2399,7 +2610,7 @@ int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len,
} // endswitch find_flag } // endswitch find_flag
if (xtrace > 1) if (xtrace > 1)
printf("%p index_read: op=%d\n", this, op); htrc("%p index_read: op=%d\n", this, op);
if (indexing > 0) if (indexing > 0)
rc= ReadIndexed(buf, op, key, key_len); rc= ReadIndexed(buf, op, key, key_len);
@@ -2542,7 +2753,7 @@ int ha_connect::rnd_init(bool scan)
} // endif xmod } // endif xmod
if (xtrace) if (xtrace)
printf("rnd_init: this=%p scan=%d xmod=%d alter=%d\n", htrc("rnd_init: this=%p scan=%d xmod=%d alter=%d\n",
this, scan, xmod, alter); this, scan, xmod, alter);
if (!g || !table || xmod == MODE_INSERT) if (!g || !table || xmod == MODE_INSERT)
@@ -2637,22 +2848,23 @@ int ha_connect::rnd_next(uchar *buf)
rc= HA_ERR_RECORD_DELETED; rc= HA_ERR_RECORD_DELETED;
break; break;
default: // Read error default: // Read error
printf("rnd_next CONNECT: %s\n", xp->g->Message); htrc("rnd_next CONNECT: %s\n", xp->g->Message);
rc= (records()) ? HA_ERR_INTERNAL_ERROR : HA_ERR_END_OF_FILE; rc= (records()) ? HA_ERR_INTERNAL_ERROR : HA_ERR_END_OF_FILE;
break; break;
} // endswitch RC } // endswitch RC
#ifndef DBUG_OFF if (xtrace > 1 && (rc || !(xp->nrd++ % 16384))) {
if (rc || !(xp->nrd++ % 16384)) {
ulonglong tb2= my_interval_timer(); ulonglong tb2= my_interval_timer();
double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL; double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL;
DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n", DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
rc, (uint)xp->nrd, (uint)xp->fnd, rc, (uint)xp->nrd, (uint)xp->fnd,
(uint)xp->nfd, elapsed)); (uint)xp->nfd, elapsed));
htrc("rnd_next: rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
rc, (uint)xp->nrd, (uint)xp->fnd,
(uint)xp->nfd, elapsed);
xp->tb1= tb2; xp->tb1= tb2;
xp->fnd= xp->nfd= 0; xp->fnd= xp->nfd= 0;
} // endif nrd } // endif nrd
#endif
table->status= (!rc) ? 0 : STATUS_NOT_FOUND; table->status= (!rc) ? 0 : STATUS_NOT_FOUND;
DBUG_RETURN(rc); DBUG_RETURN(rc);
@@ -2766,7 +2978,7 @@ int ha_connect::info(uint flag)
DBUG_ENTER("ha_connect::info"); DBUG_ENTER("ha_connect::info");
if (xtrace) if (xtrace)
printf("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info); htrc("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info);
if (!valid_info) { if (!valid_info) {
// tdbp must be available to get updated info // tdbp must be available to get updated info
@@ -2879,7 +3091,7 @@ int ha_connect::delete_all_rows()
if (!(rc= OpenTable(g))) { if (!(rc= OpenTable(g))) {
if (CntDeleteRow(g, tdbp, true)) { if (CntDeleteRow(g, tdbp, true)) {
printf("%s\n", g->Message); htrc("%s\n", g->Message);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} // endif } // endif
@@ -2989,8 +3201,8 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
{ {
if (xtrace) { if (xtrace) {
LEX_STRING *query_string= thd_query_string(thd); LEX_STRING *query_string= thd_query_string(thd);
printf("%p check_mode: cmdtype=%d\n", this, thd_sql_command(thd)); htrc("%p check_mode: cmdtype=%d\n", this, thd_sql_command(thd));
printf("Cmd=%.*s\n", (int) query_string->length, query_string->str); htrc("Cmd=%.*s\n", (int) query_string->length, query_string->str);
} // endif xtrace } // endif xtrace
// Next code is temporarily replaced until sql_command is set // Next code is temporarily replaced until sql_command is set
@@ -3040,7 +3252,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
newmode= MODE_ALTER; newmode= MODE_ALTER;
break; break;
default: default:
printf("Unsupported sql_command=%d", thd_sql_command(thd)); htrc("Unsupported sql_command=%d", thd_sql_command(thd));
strcpy(g->Message, "CONNECT Unsupported command"); strcpy(g->Message, "CONNECT Unsupported command");
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0)); my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
newmode= MODE_ERROR; newmode= MODE_ERROR;
@@ -3085,7 +3297,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
newmode= MODE_ALTER; newmode= MODE_ALTER;
break; break;
default: default:
printf("Unsupported sql_command=%d", thd_sql_command(thd)); htrc("Unsupported sql_command=%d", thd_sql_command(thd));
strcpy(g->Message, "CONNECT Unsupported command"); strcpy(g->Message, "CONNECT Unsupported command");
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0)); my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
newmode= MODE_ERROR; newmode= MODE_ERROR;
@@ -3095,7 +3307,7 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
} // endif's newmode } // endif's newmode
if (xtrace) if (xtrace)
printf("New mode=%d\n", newmode); htrc("New mode=%d\n", newmode);
return newmode; return newmode;
} // end of check_mode } // end of check_mode
@@ -3170,7 +3382,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
DBUG_ASSERT(thd == current_thd); DBUG_ASSERT(thd == current_thd);
if (xtrace) if (xtrace)
printf("external_lock: this=%p thd=%p xp=%p g=%p lock_type=%d\n", htrc("external_lock: this=%p thd=%p xp=%p g=%p lock_type=%d\n",
this, thd, xp, g, lock_type); this, thd, xp, g, lock_type);
if (!g) if (!g)
@@ -3309,7 +3521,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
if (check_privileges(thd, options, table->s->db.str)) { if (check_privileges(thd, options, table->s->db.str)) {
strcpy(g->Message, "This operation requires the FILE privilege"); strcpy(g->Message, "This operation requires the FILE privilege");
printf("%s\n", g->Message); htrc("%s\n", g->Message);
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endif check_privileges } // endif check_privileges
@@ -3343,18 +3555,18 @@ int ha_connect::external_lock(THD *thd, int lock_type)
if (xtrace) { if (xtrace) {
#if 0 #if 0
printf("xcheck=%d cras=%d\n", xcheck, cras); htrc("xcheck=%d cras=%d\n", xcheck, cras);
if (xcheck) if (xcheck)
printf("oldsep=%d oldpix=%p\n", htrc("oldsep=%d oldpix=%p\n",
((PCHK)g->Xchk)->oldsep, ((PCHK)g->Xchk)->oldpix); ((PCHK)g->Xchk)->oldsep, ((PCHK)g->Xchk)->oldpix);
#endif // 0 #endif // 0
printf("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras); htrc("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras);
} // endif xtrace } // endif xtrace
// Set or reset the good database environment // Set or reset the good database environment
if (CntCheckDB(g, this, GetDBName(NULL))) { if (CntCheckDB(g, this, GetDBName(NULL))) {
printf("%p external_lock: %s\n", this, g->Message); htrc("%p external_lock: %s\n", this, g->Message);
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
// This can NOT be called without open called first, but // This can NOT be called without open called first, but
// the table can have been closed since then // the table can have been closed since then
@@ -3375,7 +3587,7 @@ int ha_connect::external_lock(THD *thd, int lock_type)
} // endif tdbp } // endif tdbp
if (xtrace) if (xtrace)
printf("external_lock: rc=%d\n", rc); htrc("external_lock: rc=%d\n", rc);
DBUG_RETURN(rc); DBUG_RETURN(rc);
} // end of external_lock } // end of external_lock
@@ -3517,10 +3729,10 @@ int ha_connect::delete_or_rename_table(const char *name, const char *to)
if (xtrace) { if (xtrace) {
if (to) if (to)
printf("rename_table: this=%p thd=%p sqlcom=%d from=%s to=%s\n", htrc("rename_table: this=%p thd=%p sqlcom=%d from=%s to=%s\n",
this, thd, sqlcom, name, to); this, thd, sqlcom, name, to);
else else
printf("delete_table: this=%p thd=%p sqlcom=%d name=%s\n", htrc("delete_table: this=%p thd=%p sqlcom=%d name=%s\n",
this, thd, sqlcom, name); this, thd, sqlcom, name);
} // endif xtrace } // endif xtrace
@@ -3625,7 +3837,7 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
index_init(inx, false); index_init(inx, false);
if (xtrace) if (xtrace)
printf("records_in_range: inx=%d indexing=%d\n", inx, indexing); htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing);
if (indexing > 0) { if (indexing > 0) {
int nval; int nval;
@@ -4626,7 +4838,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
table= table_arg; // Used by called functions table= table_arg; // Used by called functions
if (xtrace) if (xtrace)
printf("create: this=%p thd=%p xp=%p g=%p sqlcom=%d name=%s\n", htrc("create: this=%p thd=%p xp=%p g=%p sqlcom=%d name=%s\n",
this, thd, xp, g, sqlcom, GetTableName()); this, thd, xp, g, sqlcom, GetTableName());
// CONNECT engine specific table options: // CONNECT engine specific table options:
@@ -4954,7 +5166,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} // endif } // endif
if (xtrace) if (xtrace)
printf("xchk=%p createas=%d\n", g->Xchk, g->Createas); htrc("xchk=%p createas=%d\n", g->Xchk, g->Createas);
// To check whether indices have to be made or remade // To check whether indices have to be made or remade
if (!g->Xchk) { if (!g->Xchk) {
@@ -4985,7 +5197,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
cat->SetDataPath(g, table_arg->s->db.str); cat->SetDataPath(g, table_arg->s->db.str);
if ((rc= optimize(table->in_use, NULL))) { if ((rc= optimize(table->in_use, NULL))) {
printf("Create rc=%d %s\n", rc, g->Message); htrc("Create rc=%d %s\n", rc, g->Message);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} else } else
@@ -5025,7 +5237,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
g->Xchk= NULL; g->Xchk= NULL;
if (xtrace && g->Xchk) if (xtrace && g->Xchk)
printf("oldsep=%d newsep=%d oldpix=%p newpix=%p\n", htrc("oldsep=%d newsep=%d oldpix=%p newpix=%p\n",
xcp->oldsep, xcp->newsep, xcp->oldpix, xcp->newpix); xcp->oldsep, xcp->newsep, xcp->oldpix, xcp->newpix);
// if (g->Xchk && // if (g->Xchk &&
@@ -5306,7 +5518,7 @@ ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
tshp= NULL; tshp= NULL;
if (xtrace && g->Xchk) if (xtrace && g->Xchk)
printf( htrc(
"oldsep=%d newsep=%d oldopn=%s newopn=%s oldpix=%p newpix=%p\n", "oldsep=%d newsep=%d oldopn=%s newopn=%s oldpix=%p newpix=%p\n",
xcp->oldsep, xcp->newsep, xcp->oldsep, xcp->newsep,
SVP(xcp->oldopn), SVP(xcp->newopn), SVP(xcp->oldopn), SVP(xcp->newopn),

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/*************** 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 @@
#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 */
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 */
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 */
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 */
#if defined(BLK_INDX)
int *To_Pos; /* To array of block starting positions */ 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 {
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 {
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);
// bool GetDistinctColumnValues(PGLOBAL g, int nrec); #if defined(BLK_INDX)
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 {
// 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

View File

@@ -1,11 +1,11 @@
/************* 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 @@
#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)
/***********************************************************************/ /***********************************************************************/
/* 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 RestoreNrec(); // May have been modified
return TDBDOS::ResetTableOpt(g, dox); 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
return TDBDOS::ResetTableOpt(g, dop, dox);
#endif // !BLK_INDX
} // end of ResetTableOpt } // end of ResetTableOpt
/***********************************************************************/ /***********************************************************************/
@@ -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)
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)
/*********************************************************************/ /*********************************************************************/
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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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)
return rc; // Return true if error return rc; // Return true if error
} // end of DeleteTableFile } // end of DeleteTableFile
#endif // 0
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */

View File

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

View File

@@ -1,11 +1,11 @@
/************* 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 @@
#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)
// 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)
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)
} // 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)
#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
/*********************************************************************/ /*********************************************************************/

View File

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

View File

@@ -1,11 +1,11 @@
/************* 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)
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)
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)
/*********************************************************************/ /*********************************************************************/
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)
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)
// 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. */
/*********************************************************************/ /*********************************************************************/

View File

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

View File

@@ -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)
/***********************************************************************/ /***********************************************************************/
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)
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)
// 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,7 +659,7 @@ 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");

View File

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

View File

@@ -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)
return rc; // Return true if error return rc; // Return true if error
} // end of DeleteTableFile } // end of DeleteTableFile
#endif // 0
/* ------------------------- TDBXML Class ---------------------------- */ /* ------------------------- TDBXML Class ---------------------------- */

View File

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

View File

@@ -41,6 +41,7 @@
#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 <>
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)
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)
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)
} // 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 --------------------------- */

View File

@@ -22,6 +22,38 @@ DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int,
bool, bool, bool); bool, bool, bool);
const char *GetFmt(int type, bool un = false); const char *GetFmt(int type, bool un = false);
#if defined(BLK_INDX)
/***********************************************************************/
/* DB static external variables. */
/***********************************************************************/
extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
/***********************************************************************/
/* Class MBVALS is a utility class for (re)allocating VALBLK's. */
/***********************************************************************/
class MBVALS : public BLOCK {
//friend class LSTBLK;
friend class ARRAY;
public:
// Constructors
MBVALS(void) {Vblk = NULL; Mblk = Nmblk;}
// Methods
void *GetMemp(void) {return Mblk.Memp;}
PVBLK Allocate(PGLOBAL g, int type, int len, int prec,
int n, bool sub = FALSE);
bool ReAllocate(PGLOBAL g, int n);
void Free(void);
protected:
// Members
PVBLK Vblk; // Pointer to VALBLK
MBLOCK Mblk; // The memory block
}; // end of class MBVALS
typedef class MBVALS *PMBV;
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* Class VALBLK represent a base class for variable blocks. */ /* Class VALBLK represent a base class for variable blocks. */
/***********************************************************************/ /***********************************************************************/
@@ -79,9 +111,11 @@ class VALBLK : public BLOCK {
virtual void SetValue(char *sp, uint len, int n) {assert(false);} virtual void SetValue(char *sp, uint len, int n) {assert(false);}
virtual void SetValue(PVAL valp, int n) = 0; virtual void SetValue(PVAL valp, int n) = 0;
virtual void SetValue(PVBLK pv, int n1, int n2) = 0; virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
#if 0 #if defined(BLK_INDX)
virtual void SetMin(PVAL valp, int n) = 0; virtual void SetMin(PVAL valp, int n) = 0;
virtual void SetMax(PVAL valp, int n) = 0; virtual void SetMax(PVAL valp, int n) = 0;
#endif // BLK_INDX
#if 0
virtual void SetValues(PVBLK pv, int i, int n) = 0; virtual void SetValues(PVBLK pv, int i, int n) = 0;
virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);} virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);}
#endif // 0 #endif // 0
@@ -161,6 +195,10 @@ class TYPBLK : public VALBLK {
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
//virtual void SetValues(PVBLK pv, int k, int n); //virtual void SetValues(PVBLK pv, int k, int n);
#if defined(BLK_INDX)
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
#endif // BLK_INDX
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
@@ -212,6 +250,10 @@ class CHRBLK : public VALBLK {
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
//virtual void SetValues(PVBLK pv, int k, int n); //virtual void SetValues(PVBLK pv, int k, int n);
#if defined(BLK_INDX)
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
#endif // BLK_INDX
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);
@@ -264,6 +306,10 @@ class STRBLK : public VALBLK {
virtual void SetValue(PVAL valp, int n); virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); virtual void SetValue(PVBLK pv, int n1, int n2);
//virtual void SetValues(PVBLK pv, int k, int n); //virtual void SetValues(PVBLK pv, int k, int n);
#if defined(BLK_INDX)
virtual void SetMin(PVAL valp, int n);
virtual void SetMax(PVAL valp, int n);
#endif // BLK_INDX
virtual void Move(int i, int j); virtual void Move(int i, int j);
virtual int CompVal(PVAL vp, int n); virtual int CompVal(PVAL vp, int n);
virtual int CompVal(int i1, int i2); virtual int CompVal(int i1, int i2);

View File

@@ -83,6 +83,7 @@ int DTVAL::Shift = 0;
/* Routines called externally. */ /* Routines called externally. */
/***********************************************************************/ /***********************************************************************/
bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool);
#if !defined(WIN32) #if !defined(WIN32)
extern "C" { extern "C" {
PSZ strupr(PSZ s); PSZ strupr(PSZ s);
@@ -90,6 +91,34 @@ PSZ strlwr(PSZ s);
} }
#endif // !WIN32 #endif // !WIN32
#if defined(BLK_INDX)
/***********************************************************************/
/* Returns the bitmap representing the conditions that must not be */
/* met when returning from TestValue for a given operator. */
/* Bit one is EQ, bit 2 is LT, and bit 3 is GT. */
/***********************************************************************/
BYTE OpBmp(PGLOBAL g, OPVAL opc)
{
BYTE bt;
switch (opc) {
case OP_IN:
case OP_EQ: bt = 0x06; break;
case OP_NE: bt = 0x01; break;
case OP_GT: bt = 0x03; break;
case OP_GE: bt = 0x02; break;
case OP_LT: bt = 0x05; break;
case OP_LE: bt = 0x04; break;
case OP_EXIST: bt = 0x00; break;
default:
sprintf(g->Message, MSG(BAD_FILTER_OP), opc);
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
} // endswitch opc
return bt;
} // end of OpBmp
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* Get a long long number from its character representation. */ /* Get a long long number from its character representation. */
/* IN p: Pointer to the numeric string */ /* IN p: Pointer to the numeric string */
@@ -277,7 +306,7 @@ const char *GetFmt(int type, bool un)
return fmt; return fmt;
} // end of GetFmt } // end of GetFmt
#if 0 #if defined(BLK_INDX)
/***********************************************************************/ /***********************************************************************/
/* ConvertType: what this function does is to determine the type to */ /* ConvertType: what this function does is to determine the type to */
/* which should be converted a value so no precision would be lost. */ /* which should be converted a value so no precision would be lost. */
@@ -324,7 +353,7 @@ int ConvertType(int target, int type, CONV kind, bool match)
} // endswitch kind } // endswitch kind
} // end of ConvertType } // end of ConvertType
#endif // 0 #endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* AllocateConstant: allocates a constant Value. */ /* AllocateConstant: allocates a constant Value. */
@@ -422,7 +451,7 @@ PVAL AllocateValue(PGLOBAL g, int type, int len, int prec,
return valp; return valp;
} // end of AllocateValue } // end of AllocateValue
#if 0 #if defined(BLK_INDX)
/***********************************************************************/ /***********************************************************************/
/* Allocate a constant Value converted to newtype. */ /* Allocate a constant Value converted to newtype. */
/* Can also be used to copy a Value eventually converted. */ /* Can also be used to copy a Value eventually converted. */
@@ -490,7 +519,7 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
valp->SetGlobal(g); valp->SetGlobal(g);
return valp; return valp;
} // end of AllocateValue } // end of AllocateValue
#endif // 0 #endif // BLK_INDX
/* -------------------------- Class VALUE ---------------------------- */ /* -------------------------- Class VALUE ---------------------------- */
@@ -527,6 +556,20 @@ const char *VALUE::GetXfmt(void)
return fmt; return fmt;
} // end of GetFmt } // end of GetFmt
#if defined(BLK_INDX)
/***********************************************************************/
/* Returns a BYTE indicating the comparison between two values. */
/* Bit 1 indicates equality, Bit 2 less than, and Bit3 greater than. */
/* More than 1 bit can be set only in the case of TYPE_LIST. */
/***********************************************************************/
BYTE VALUE::TestValue(PVAL vp)
{
int n = CompareValue(vp);
return (n > 0) ? 0x04 : (n < 0) ? 0x02 : 0x01;
} // end of TestValue
#endif // BLK_INDX
/* -------------------------- Class TYPVAL ---------------------------- */ /* -------------------------- Class TYPVAL ---------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -897,6 +940,26 @@ bool TYPVAL<TYPE>::IsEqual(PVAL vp, bool chktype)
} // end of IsEqual } // end of IsEqual
#if defined(BLK_INDX)
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of numeric filters. */
/***********************************************************************/
template <class TYPE>
int TYPVAL<TYPE>::CompareValue(PVAL vp)
{
//assert(vp->GetType() == Type);
// Process filtering on numeric values.
TYPE n = GetTypedValue(vp);
//if (trace)
// htrc(" Comparing: val=%d,%d\n", Tval, n);
return (Tval > n) ? 1 : (Tval < n) ? (-1) : 0;
} // end of CompareValue
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* FormatValue: This function set vp (a STRING value) to the string */ /* FormatValue: This function set vp (a STRING value) to the string */
/* constructed from its own value formated using the fmt format. */ /* constructed from its own value formated using the fmt format. */
@@ -1347,6 +1410,34 @@ bool TYPVAL<PSZ>::IsEqual(PVAL vp, bool chktype)
} // end of IsEqual } // end of IsEqual
#if defined(BLK_INDX)
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of numeric filters. */
/***********************************************************************/
int TYPVAL<PSZ>::CompareValue(PVAL vp)
{
int n;
//assert(vp->GetType() == Type);
if (trace)
htrc(" Comparing: val='%s','%s'\n", Strp, vp->GetCharValue());
// Process filtering on character strings.
if (Ci || vp->IsCi())
n = stricmp(Strp, vp->GetCharValue());
else
n = strcmp(Strp, vp->GetCharValue());
#if defined(WIN32)
if (n == _NLSCMPERROR)
return n; // Here we should raise an error
#endif // WIN32
return (n > 0) ? 1 : (n < 0) ? -1 : 0;
} // end of CompareValue
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* FormatValue: This function set vp (a STRING value) to the string */ /* FormatValue: This function set vp (a STRING value) to the string */
/* constructed from its own value formated using the fmt format. */ /* constructed from its own value formated using the fmt format. */
@@ -1573,6 +1664,25 @@ bool DECVAL::IsEqual(PVAL vp, bool chktype)
return !strcmp(Strp, vp->GetCharString(buf)); return !strcmp(Strp, vp->GetCharString(buf));
} // end of IsEqual } // end of IsEqual
#if defined(BLK_INDX)
/***********************************************************************/
/* Compare values and returns 1, 0 or -1 according to comparison. */
/* This function is used for evaluation of numeric filters. */
/***********************************************************************/
int DECVAL::CompareValue(PVAL vp)
{
//assert(vp->GetType() == Type);
// Process filtering on numeric values.
double f = atof(Strp), n = vp->GetFloatValue();
//if (trace)
// htrc(" Comparing: val=%d,%d\n", f, n);
return (f > n) ? 1 : (f < n) ? (-1) : 0;
} // end of CompareValue
#endif // BLK_INDX
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
/* FormatValue: This function set vp (a STRING value) to the string */ /* FormatValue: This function set vp (a STRING value) to the string */

View File

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

View File

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

View File

@@ -68,7 +68,7 @@ class DllExport XOBJECT : public BLOCK {
virtual bool CheckLocal(PTDB) {return true;} virtual bool CheckLocal(PTDB) {return true;}
virtual int CheckSpcCol(PTDB, int) {return 2;} virtual int CheckSpcCol(PTDB, int) {return 2;}
virtual bool CheckSort(PTDB) {return false;} virtual bool CheckSort(PTDB) {return false;}
virtual bool VerifyColumn(PTBX txp) {return false;} virtual bool VerifyColumn(PTDB txp) {return false;}
virtual bool VerifyTdb(PTDB& tdbp) {return false;} virtual bool VerifyTdb(PTDB& tdbp) {return false;}
virtual bool IsColInside(PCOL colp) {return false;} virtual bool IsColInside(PCOL colp) {return false;}
@@ -123,10 +123,12 @@ class DllExport CONSTANT : public XOBJECT {
virtual bool SetFormat(PGLOBAL g, FORMAT& fmt) virtual bool SetFormat(PGLOBAL g, FORMAT& fmt)
{return Value->SetConstFormat(g, fmt);} {return Value->SetConstFormat(g, fmt);}
virtual int CheckSpcCol(PTDB, int) {return 1;} virtual int CheckSpcCol(PTDB, int) {return 1;}
// void Convert(PGLOBAL g, int newtype); #if defined(BLK_INDX)
void Convert(PGLOBAL g, int newtype);
#endif // BLK_INDX
// bool Rephrase(PGLOBAL g, PSZ work); // bool Rephrase(PGLOBAL g, PSZ work);
void SetValue(PVAL vp) {Value = vp;} void SetValue(PVAL vp) {Value = vp;}
virtual bool VerifyColumn(PTBX txp) {return true;} virtual bool VerifyColumn(PTDB txp) {return true;}
virtual bool VerifyTdb(PTDB& tdbp) {return true;} virtual bool VerifyTdb(PTDB& tdbp) {return true;}
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);

View File

@@ -33,58 +33,20 @@ class CMD : public BLOCK {
char *Cmd; char *Cmd;
}; // end of class CMD }; // end of class CMD
// Filter passed all tables // Condition filter structure
typedef struct _filter { typedef struct _cond_filter {
char *Body; char *Body;
OPVAL Op; OPVAL Op;
PCMD Cmds; PCMD Cmds;
} FILTER, *PFIL; } CONDFIL, *PCFIL;
typedef class TDBCAT *PTDBCAT; typedef class TDBCAT *PTDBCAT;
typedef class CATCOL *PCATCOL; typedef class CATCOL *PCATCOL;
/***********************************************************************/
/* Definition of class TBX (pure virtual class for TDB and OPJOIN) */
/***********************************************************************/
class DllExport TBX: public BLOCK { // Base class for OPJOIN and TDB classes.
public:
// Constructors
TBX(void);
TBX(PTBX txp);
// Implementation
inline PTBX GetOrig(void) {return To_Orig;}
inline TUSE GetUse(void) {return Use;}
inline void SetUse(TUSE n) {Use = n;}
inline PFIL GetFilter(void) {return To_Filter;}
inline void SetOrig(PTBX txp) {To_Orig = txp;}
inline void SetFilter(PFIL fp) {To_Filter = fp;}
// Methods
virtual bool IsSame(PTBX tp) {return tp == this;}
virtual int GetTdb_No(void) = 0; // Convenience during conversion
virtual PTDB GetNext(void) = 0;
virtual int Cardinality(PGLOBAL) = 0;
virtual int GetMaxSize(PGLOBAL) = 0;
virtual int GetProgMax(PGLOBAL) = 0;
virtual int GetProgCur(void) = 0;
virtual int GetBadLines(void) {return 0;}
virtual PTBX Copy(PTABS t) = 0;
protected:
//virtual void PrepareFilters(PGLOBAL g) = 0;
protected:
// Members
PTBX To_Orig; // Pointer to original if it is a copy
PFIL To_Filter;
TUSE Use;
}; // end of class TBX
/***********************************************************************/ /***********************************************************************/
/* Definition of class TDB with all its method functions. */ /* Definition of class TDB with all its method functions. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDB: public TBX { // Table Descriptor Block. class DllExport TDB: public BLOCK { // Table Descriptor Block.
public: public:
// Constructors // Constructors
TDB(PTABDEF tdp = NULL); TDB(PTABDEF tdp = NULL);
@@ -92,11 +54,21 @@ class DllExport TDB: public TBX { // Table Descriptor Block.
// Implementation // Implementation
static void SetTnum(int n) {Tnum = n;} static void SetTnum(int n) {Tnum = n;}
inline PTDB GetOrig(void) {return To_Orig;}
inline TUSE GetUse(void) {return Use;}
inline PCFIL GetCondFil(void) {return To_CondFil;}
inline LPCSTR GetName(void) {return Name;} inline LPCSTR GetName(void) {return Name;}
inline PTABLE GetTable(void) {return To_Table;} inline PTABLE GetTable(void) {return To_Table;}
inline PCOL GetColumns(void) {return Columns;} inline PCOL GetColumns(void) {return Columns;}
inline int GetDegree(void) {return Degree;} inline int GetDegree(void) {return Degree;}
inline MODE GetMode(void) {return Mode;} inline MODE GetMode(void) {return Mode;}
#if defined(BLK_INDX)
inline PFIL GetFilter(void) {return To_Filter;}
inline void SetFilter(PFIL fp) {To_Filter = fp;}
#endif // BLK_INDX
inline void SetOrig(PTDB txp) {To_Orig = txp;}
inline void SetUse(TUSE n) {Use = n;}
inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;}
inline void SetNext(PTDB tdbp) {Next = tdbp;} inline void SetNext(PTDB tdbp) {Next = tdbp;}
inline void SetName(LPCSTR name) {Name = name;} inline void SetName(LPCSTR name) {Name = name;}
inline void SetTable(PTABLE tablep) {To_Table = tablep;} inline void SetTable(PTABLE tablep) {To_Table = tablep;}
@@ -105,25 +77,30 @@ class DllExport TDB: public TBX { // Table Descriptor Block.
inline void SetMode(MODE mode) {Mode = mode;} inline void SetMode(MODE mode) {Mode = mode;}
//Properties //Properties
virtual AMT GetAmType(void) {return TYPE_AM_ERROR;}
virtual int GetTdb_No(void) {return Tdb_No;} virtual int GetTdb_No(void) {return Tdb_No;}
virtual PTDB GetNext(void) {return Next;} virtual PTDB GetNext(void) {return Next;}
virtual PCATLG GetCat(void) {return NULL;} virtual PCATLG GetCat(void) {return NULL;}
// Methods // Methods
virtual AMT GetAmType(void) {return TYPE_AM_ERROR;} virtual bool IsSame(PTDB tp) {return tp == this;}
virtual bool GetBlockValues(PGLOBAL g) {return false;} virtual bool GetBlockValues(PGLOBAL g) {return false;}
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int GetMaxSize(PGLOBAL) = 0;
virtual int GetProgMax(PGLOBAL) = 0;
virtual int GetProgCur(void) = 0;
virtual int RowNumber(PGLOBAL g, bool b = false); virtual int RowNumber(PGLOBAL g, bool b = false);
virtual bool IsReadOnly(void) {return true;} virtual bool IsReadOnly(void) {return true;}
virtual const CHARSET_INFO *data_charset() {return NULL;} virtual const CHARSET_INFO *data_charset() {return NULL;}
virtual PTDB Duplicate(PGLOBAL g) {return NULL;} virtual PTDB Duplicate(PGLOBAL g) {return NULL;}
virtual PTDB CopyOne(PTABS t) {return this;} virtual PTDB CopyOne(PTABS t) {return this;}
virtual PTBX Copy(PTABS t); virtual PTDB Copy(PTABS t);
virtual void PrintAM(FILE *f, char *m) virtual void PrintAM(FILE *f, char *m)
{fprintf(f, "%s AM(%d)\n", m, GetAmType());} {fprintf(f, "%s AM(%d)\n", m, GetAmType());}
virtual void Print(PGLOBAL g, FILE *f, uint n); virtual void Print(PGLOBAL g, FILE *f, uint n);
virtual void Print(PGLOBAL g, char *ps, uint z); virtual void Print(PGLOBAL g, char *ps, uint z);
virtual PSZ GetServer(void) = 0; virtual PSZ GetServer(void) = 0;
virtual int GetBadLines(void) {return 0;}
// Database pure virtual routines // Database pure virtual routines
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num) = 0; virtual PCOL ColDB(PGLOBAL g, PSZ name, int num) = 0;
@@ -141,6 +118,12 @@ class DllExport TDB: public TBX { // Table Descriptor Block.
protected: protected:
// Members // Members
PTDB To_Orig; // Pointer to original if it is a copy
TUSE Use;
#if defined(BLK_INDX)
PFIL To_Filter;
#endif // BLK_INDX
PCFIL To_CondFil; // To condition filter structure
static int Tnum; // Used to generate Tdb_no's static int Tnum; // Used to generate Tdb_no's
const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN
PTDB Next; // Next in linearized queries PTDB Next; // Next in linearized queries
@@ -194,7 +177,7 @@ class DllExport TDBASE : public TDB {
virtual void ResetDB(void) {} virtual void ResetDB(void) {}
virtual void ResetSize(void) {MaxSize = -1;} virtual void ResetSize(void) {MaxSize = -1;}
virtual void RestoreNrec(void) {} virtual void RestoreNrec(void) {}
virtual int ResetTableOpt(PGLOBAL g, bool dox); virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox);
virtual PSZ GetServer(void) {return "Current";} virtual PSZ GetServer(void) {return "Current";}
// Database routines // Database routines