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

- MRR + Block Indexing

modified:
  storage/connect/array.h
  storage/connect/catalog.h
  storage/connect/colblk.cpp
  storage/connect/colblk.h
  storage/connect/connect.cc
  storage/connect/connect.h
  storage/connect/domdoc.h
  storage/connect/filamap.cpp
  storage/connect/filamap.h
  storage/connect/filamdbf.h
  storage/connect/filamfix.cpp
  storage/connect/filamfix.h
  storage/connect/filamtxt.cpp
  storage/connect/filamtxt.h
  storage/connect/filamvct.cpp
  storage/connect/filamvct.h
  storage/connect/filamzip.cpp
  storage/connect/filamzip.h
  storage/connect/filter.cpp
  storage/connect/filter.h
  storage/connect/global.h
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/myconn.h
  storage/connect/plgcnx.h
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
  storage/connect/plugutil.c
  storage/connect/preparse.h
  storage/connect/reldef.cpp
  storage/connect/reldef.h
  storage/connect/tabcol.h
  storage/connect/tabdos.cpp
  storage/connect/tabdos.h
  storage/connect/tabfix.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabfmt.h
  storage/connect/table.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabmysql.h
  storage/connect/taboccur.h
  storage/connect/tabodbc.h
  storage/connect/tabsys.h
  storage/connect/tabtbl.h
  storage/connect/tabutil.h
  storage/connect/tabvct.cpp
  storage/connect/tabvct.h
  storage/connect/tabwmi.h
  storage/connect/tabxml.h
  storage/connect/user_connect.cc
  storage/connect/user_connect.h
  storage/connect/valblk.cpp
  storage/connect/valblk.h
  storage/connect/value.cpp
  storage/connect/value.h
  storage/connect/xindex.cpp
  storage/connect/xindex.h
  storage/connect/xobject.cpp
  storage/connect/xobject.h
  storage/connect/xtable.h
This commit is contained in:
Olivier Bertrand
2014-03-20 12:05:47 +01:00
60 changed files with 32618 additions and 33489 deletions

View File

@@ -51,7 +51,7 @@ class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
virtual int Qcompare(int *, int *); virtual int Qcompare(int *, int *);
virtual bool Compare(PXOB) {assert(FALSE); return FALSE;} virtual bool Compare(PXOB) {assert(FALSE); return FALSE;}
virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(FALSE); return FALSE;} virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(FALSE); return FALSE;}
virtual int CheckSpcCol(PTDB, int) {return 0;} //virtual int CheckSpcCol(PTDB, int) {return 0;}
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);
void Empty(void); void Empty(void);

View File

@@ -1,122 +1,122 @@
/*************** Catalog H Declares Source Code File (.H) **************/ /*************** Catalog H Declares Source Code File (.H) **************/
/* Name: CATALOG.H Version 3.2 */ /* Name: CATALOG.H Version 3.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2012 */
/* */ /* */
/* This file contains the CATALOG PlugDB classes definitions. */ /* This file contains the CATALOG PlugDB classes definitions. */
/***********************************************************************/ /***********************************************************************/
#ifndef __CATALOG__H #ifndef __CATALOG__H
#define __CATALOG__H #define __CATALOG__H
#include "block.h" #include "block.h"
/***********************************************************************/ /***********************************************************************/
/* Defines the length of a buffer to contain entire table section. */ /* Defines the length of a buffer to contain entire table section. */
/***********************************************************************/ /***********************************************************************/
#define PLG_MAX_PATH 144 /* Must be the same across systems */ #define PLG_MAX_PATH 144 /* Must be the same across systems */
#define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */ #define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */
//typedef class INDEXDEF *PIXDEF; //typedef class INDEXDEF *PIXDEF;
/***********************************************************************/ /***********************************************************************/
/* Defines the structure used to enumerate tables or views. */ /* Defines the structure used to enumerate tables or views. */
/***********************************************************************/ /***********************************************************************/
typedef struct _curtab { typedef struct _curtab {
PRELDEF CurTdb; PRELDEF CurTdb;
char *Curp; char *Curp;
char *Tabpat; char *Tabpat;
bool Ispat; bool Ispat;
bool NoView; bool NoView;
int Nt; int Nt;
char *Type[16]; char *Type[16];
} CURTAB, *PCURTAB; } CURTAB, *PCURTAB;
/***********************************************************************/ /***********************************************************************/
/* Defines the structure used to get column catalog info. */ /* Defines the structure used to get column catalog info. */
/***********************************************************************/ /***********************************************************************/
typedef struct _colinfo { typedef struct _colinfo {
char *Name; char *Name;
int Type; int Type;
int Offset; int Offset;
int Length; int Length;
int Key; int Key;
int Precision; int Precision;
int Scale; int Scale;
int Opt; int Opt;
int Freq; int Freq;
char *Remark; char *Remark;
char *Datefmt; char *Datefmt;
char *Fieldfmt; char *Fieldfmt;
ushort Flags; // Used by MariaDB CONNECT handlers ushort Flags; // Used by MariaDB CONNECT handlers
} COLINFO, *PCOLINFO; } COLINFO, *PCOLINFO;
/***********************************************************************/ /***********************************************************************/
/* CATALOG: base class for catalog classes. */ /* CATALOG: base class for catalog classes. */
/***********************************************************************/ /***********************************************************************/
class DllExport CATALOG { class DllExport CATALOG {
friend class RELDEF; friend class RELDEF;
friend class TABDEF; friend class TABDEF;
friend class DIRDEF; friend class DIRDEF;
friend class OEMDEF; friend class OEMDEF;
public: public:
CATALOG(void); // Constructor CATALOG(void); // Constructor
virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy
// Implementation // Implementation
int GetCblen(void) {return Cblen;} int GetCblen(void) {return Cblen;}
bool GetDefHuge(void) {return DefHuge;} bool GetDefHuge(void) {return DefHuge;}
void SetDefHuge(bool b) {DefHuge = b;} void SetDefHuge(bool b) {DefHuge = b;}
char *GetCbuf(void) {return Cbuf;} char *GetCbuf(void) {return Cbuf;}
char *GetDataPath(void) {return (char*)DataPath;} char *GetDataPath(void) {return (char*)DataPath;}
// Methods // Methods
virtual void Reset(void) {} virtual void Reset(void) {}
virtual void SetDataPath(PGLOBAL g, const char *path) {} virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual bool GetBoolCatInfo(PSZ what, bool bdef) {return bdef;} virtual bool GetBoolCatInfo(PSZ what, bool bdef) {return bdef;}
virtual bool SetIntCatInfo(PSZ what, int ival) {return false;} virtual bool SetIntCatInfo(PSZ what, int ival) {return false;}
virtual int GetIntCatInfo(PSZ what, int idef) {return idef;} virtual int GetIntCatInfo(PSZ what, int idef) {return idef;}
virtual int GetSizeCatInfo(PSZ what, PSZ sdef) {return 0;} virtual int GetSizeCatInfo(PSZ what, PSZ sdef) {return 0;}
virtual int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size) virtual int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size)
{strncpy(buf, sdef, size); return size;} {strncpy(buf, sdef, size); return size;}
virtual char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) virtual char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
{return sdef;} {return sdef;}
virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;} virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;}
virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;} virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;}
virtual bool CheckName(PGLOBAL g, char *name) {return true;} virtual bool CheckName(PGLOBAL g, char *name) {return true;}
virtual bool ClearName(PGLOBAL g, PSZ name) {return true;} virtual bool ClearName(PGLOBAL g, PSZ name) {return true;}
virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} virtual PRELDEF MakeOneTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;} virtual PRELDEF GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;}
virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type,
PRELDEF *prp = NULL) {return NULL;} PRELDEF *prp = NULL) {return NULL;}
virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;} virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;}
virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;} virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;}
virtual bool TestCond(PGLOBAL g, const char *name, const char *type) virtual bool TestCond(PGLOBAL g, const char *name, const char *type)
{return true;} {return true;}
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;} virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;}
virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, virtual PTDB GetTable(PGLOBAL g, PTABLE tablep,
MODE mode = MODE_READ, LPCSTR type = NULL) MODE mode = MODE_READ, LPCSTR type = NULL)
{return NULL;} {return NULL;}
virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {} virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {}
virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer, virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {} int maxbuf, int info[]) {}
virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer, virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer,
int maxbuf, int info[]) {} int maxbuf, int info[]) {}
virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname, virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname,
char *buffer, int maxbuf, int info[]) {return NULL;} char *buffer, int maxbuf, int info[]) {return NULL;}
virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;} virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;}
virtual void ClearDB(PGLOBAL g) {} virtual void ClearDB(PGLOBAL g) {}
protected: protected:
virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;} virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;}
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
// Members // Members
char *Cbuf; /* Buffer used for col section */ char *Cbuf; /* Buffer used for col section */
int Cblen; /* Length of suballoc. buffer */ int Cblen; /* Length of suballoc. buffer */
CURTAB Ctb; /* Used to enumerate tables */ CURTAB Ctb; /* Used to enumerate tables */
bool DefHuge; /* true: tables default to huge */ bool DefHuge; /* true: tables default to huge */
LPCSTR DataPath; /* Is the Path of DB data dir */ LPCSTR DataPath; /* Is the Path of DB data dir */
}; // end of class CATALOG }; // end of class CATALOG
#endif // __CATALOG__H #endif // __CATALOG__H

View File

@@ -1,399 +1,382 @@
/************* Colblk C++ Functions Source Code File (.CPP) ************/ /************* Colblk C++ Functions Source Code File (.CPP) ************/
/* Name: COLBLK.CPP Version 2.0 */ /* Name: COLBLK.CPP Version 2.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
/* */ /* */
/* This file contains the COLBLK class functions. */ /* This file contains the COLBLK class functions. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* global.h is header containing all global Plug declarations. */ /* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */ /* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/ /***********************************************************************/
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "tabcol.h" #include "tabcol.h"
#include "colblk.h" #include "colblk.h"
#include "xindex.h" #include "xindex.h"
#include "xtable.h" #include "xtable.h"
/***********************************************************************/ /***********************************************************************/
/* COLBLK protected constructor. */ /* COLBLK protected constructor. */
/***********************************************************************/ /***********************************************************************/
COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i) COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i)
{ {
Next = NULL; Next = NULL;
Index = i; Index = i;
//Number = 0; //Number = 0;
ColUse = 0; ColUse = 0;
if ((Cdp = cdp)) { if ((Cdp = cdp)) {
Name = cdp->Name; Name = cdp->Name;
Format = cdp->F; Format = cdp->F;
Opt = cdp->Opt; Opt = cdp->Opt;
Long = cdp->Long; Long = cdp->Long;
Precision = cdp->Precision; Precision = cdp->Precision;
Freq = cdp->Freq; 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);
Unsigned = !!(cdp->Flags & U_UNSIGNED); Unsigned = !!(cdp->Flags & U_UNSIGNED);
} else { } else {
Name = NULL; Name = NULL;
memset(&Format, 0, sizeof(FORMAT)); memset(&Format, 0, sizeof(FORMAT));
Opt = 0; Opt = 0;
Long = 0; Long = 0;
Precision = 0; Precision = 0;
Freq = 0; Freq = 0;
Buf_Type = TYPE_ERROR; Buf_Type = TYPE_ERROR;
Nullable = false; Nullable = false;
Unsigned = false; Unsigned = false;
} // endif cdp } // endif cdp
To_Tdb = tdbp; To_Tdb = tdbp;
Status = BUF_NO; Status = BUF_NO;
//Value = NULL; done in XOBJECT constructor //Value = NULL; done in XOBJECT constructor
To_Kcol = NULL; To_Kcol = NULL;
} // end of COLBLK constructor } // end of COLBLK constructor
/***********************************************************************/ /***********************************************************************/
/* COLBLK constructor used for copying columns. */ /* COLBLK constructor used for copying columns. */
/* tdbp is the pointer to the new table descriptor. */ /* tdbp is the pointer to the new table descriptor. */
/***********************************************************************/ /***********************************************************************/
COLBLK::COLBLK(PCOL col1, PTDB tdbp) COLBLK::COLBLK(PCOL col1, PTDB tdbp)
{ {
PCOL colp; PCOL colp;
// Copy the old column block to the new one // Copy the old column block to the new one
*this = *col1; *this = *col1;
Next = NULL; Next = NULL;
//To_Orig = col1; //To_Orig = col1;
To_Tdb = tdbp; To_Tdb = tdbp;
#ifdef DEBTRACE #ifdef DEBTRACE
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this);
#endif #endif
if (tdbp) if (tdbp)
// Attach the new column to the table block // Attach the new column to the table block
if (!tdbp->GetColumns()) if (!tdbp->GetColumns())
tdbp->SetColumns(this); tdbp->SetColumns(this);
else { else {
for (colp = tdbp->GetColumns(); colp->Next; colp = colp->Next) ; for (colp = tdbp->GetColumns(); colp->Next; colp = colp->Next) ;
colp->Next = this; colp->Next = this;
} // endelse } // endelse
} // end of COLBLK copy constructor } // end of COLBLK copy constructor
/***********************************************************************/ /***********************************************************************/
/* Reset the column descriptor to non evaluated yet. */ /* Reset the column descriptor to non evaluated yet. */
/***********************************************************************/ /***********************************************************************/
void COLBLK::Reset(void) void COLBLK::Reset(void)
{ {
Status &= ~BUF_READ; Status &= ~BUF_READ;
} // end of Reset } // end of Reset
/***********************************************************************/ /***********************************************************************/
/* Compare: compares itself to an (expression) object and returns */ /* Compare: compares itself to an (expression) object and returns */
/* true if it is equivalent. */ /* true if it is equivalent. */
/***********************************************************************/ /***********************************************************************/
bool COLBLK::Compare(PXOB xp) bool COLBLK::Compare(PXOB xp)
{ {
return (this == xp); return (this == xp);
} // end of Compare } // end of Compare
/***********************************************************************/ /***********************************************************************/
/* SetFormat: function used to set SELECT output format. */ /* SetFormat: function used to set SELECT output format. */
/***********************************************************************/ /***********************************************************************/
bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt)
{ {
fmt = Format; fmt = Format;
#ifdef DEBTRACE #ifdef DEBTRACE
htrc("COLBLK: %p format=%c(%d,%d)\n", htrc("COLBLK: %p format=%c(%d,%d)\n",
this, *fmt.Type, fmt.Length, fmt.Prec); this, *fmt.Type, fmt.Length, fmt.Prec);
#endif #endif
return false; return false;
} // end of SetFormat } // end of SetFormat
/***********************************************************************/ /***********************************************************************/
/* CheckColumn: a column descriptor is found, say it by returning 1. */ /* Eval: get the column value from the last read record or from a */
/***********************************************************************/ /* matching Index column if there is one. */
int COLBLK::CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &p, int &ag) /***********************************************************************/
{ bool COLBLK::Eval(PGLOBAL g)
return 1; {
} // end of CheckColumn #ifdef DEBTRACE
htrc("Col Eval: %s status=%.4X\n", Name, Status);
/***********************************************************************/ #endif
/* Eval: get the column value from the last read record or from a */
/* matching Index column if there is one. */ if (!GetStatus(BUF_READ)) {
/***********************************************************************/ // if (To_Tdb->IsNull())
bool COLBLK::Eval(PGLOBAL g) // Value->Reset();
{ if (To_Kcol)
#ifdef DEBTRACE To_Kcol->FillValue(Value);
htrc("Col Eval: %s status=%.4X\n", Name, Status); else
#endif ReadColumn(g);
if (!GetStatus(BUF_READ)) { AddStatus(BUF_READ);
// if (To_Tdb->IsNull()) } // endif
// Value->Reset();
if (To_Kcol) return false;
To_Kcol->FillValue(Value); } // end of Eval
else
ReadColumn(g); /***********************************************************************/
/* InitValue: prepare a column block for read operation. */
AddStatus(BUF_READ); /* Now we use Format.Length for the len parameter to avoid strings */
} // endif /* to be truncated when converting from string to coded string. */
/* Added in version 1.5 is the arguments GetScale() and Domain */
return false; /* in calling AllocateValue. Domain is used for TYPE_DATE only. */
} // end of Eval /***********************************************************************/
bool COLBLK::InitValue(PGLOBAL g)
/***********************************************************************/ {
/* CheckSort: */ if (Value)
/* Used to check that a table is involved in the sort list items. */ return false; // Already done
/***********************************************************************/
bool COLBLK::CheckSort(PTDB tdbp) // Allocate a Value object
{ if (!(Value = AllocateValue(g, Buf_Type, Precision,
return (tdbp == To_Tdb); GetScale(), Unsigned, GetDomain())))
} // end of CheckSort return true;
/***********************************************************************/ AddStatus(BUF_READY);
/* InitValue: prepare a column block for read operation. */ Value->SetNullable(Nullable);
/* Now we use Format.Length for the len parameter to avoid strings */
/* to be truncated when converting from string to coded string. */ #ifdef DEBTRACE
/* Added in version 1.5 is the arguments GetScale() and Domain */ htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n",
/* in calling AllocateValue. Domain is used for TYPE_DATE only. */ this, Buf_Type, Value, ColUse, Status);
/***********************************************************************/ #endif
bool COLBLK::InitValue(PGLOBAL g)
{ return false;
if (Value) } // end of InitValue
return false; // Already done
/***********************************************************************/
// Allocate a Value object /* SetBuffer: prepare a column block for write operation. */
if (!(Value = AllocateValue(g, Buf_Type, Precision, /***********************************************************************/
GetScale(), Unsigned, GetDomain()))) bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check)
return true; {
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer");
AddStatus(BUF_READY); return true;
Value->SetNullable(Nullable); } // end of SetBuffer
#ifdef DEBTRACE /***********************************************************************/
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n", /* GetLength: returns an evaluation of the column string length. */
this, Buf_Type, Value, ColUse, Status); /***********************************************************************/
#endif int COLBLK::GetLengthEx(void)
{
return false; return Long;
} // end of InitValue } // end of GetLengthEx
/***********************************************************************/ /***********************************************************************/
/* SetBuffer: prepare a column block for write operation. */ /* ReadColumn: what this routine does is to access the last line */
/***********************************************************************/ /* read from the corresponding table, extract from it the field */
bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) /* corresponding to this column and convert it to buffer type. */
{ /***********************************************************************/
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer"); void COLBLK::ReadColumn(PGLOBAL g)
return true; {
} // end of SetBuffer sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
/***********************************************************************/ } // end of ReadColumn
/* GetLength: returns an evaluation of the column string length. */
/***********************************************************************/ /***********************************************************************/
int COLBLK::GetLengthEx(void) /* WriteColumn: what this routine does is to access the last line */
{ /* read from the corresponding table, and rewrite the field */
return Long; /* corresponding to this column from the column buffer and type. */
} // end of GetLengthEx /***********************************************************************/
void COLBLK::WriteColumn(PGLOBAL g)
/***********************************************************************/ {
/* ReadColumn: what this routine does is to access the last line */ sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
/* read from the corresponding table, extract from it the field */ longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
/* corresponding to this column and convert it to buffer type. */ } // end of WriteColumn
/***********************************************************************/
void COLBLK::ReadColumn(PGLOBAL g) /***********************************************************************/
{ /* Make file output of a column descriptor block. */
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); /***********************************************************************/
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); void COLBLK::Print(PGLOBAL g, FILE *f, uint n)
} // end of ReadColumn {
char m[64];
/***********************************************************************/ int i;
/* WriteColumn: what this routine does is to access the last line */ PCOL colp;
/* read from the corresponding table, and rewrite the field */
/* corresponding to this column from the column buffer and type. */ memset(m, ' ', n); // Make margin string
/***********************************************************************/ m[n] = '\0';
void COLBLK::WriteColumn(PGLOBAL g)
{ for (colp = To_Tdb->GetColumns(), i = 1; colp; colp = colp->Next, i++)
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); if (colp == this)
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); break;
} // end of WriteColumn
fprintf(f, "%sR%dC%d type=%d F=%.2s(%d,%d)", m, To_Tdb->GetTdb_No(),
/***********************************************************************/ i, GetAmType(), Format.Type, Format.Length, Format.Prec);
/* Make file output of a column descriptor block. */ fprintf(f,
/***********************************************************************/ " coluse=%04X status=%04X buftyp=%d value=%p name=%s\n",
void COLBLK::Print(PGLOBAL g, FILE *f, uint n) ColUse, Status, Buf_Type, Value, Name);
{ } // end of Print
char m[64];
int i; /***********************************************************************/
PCOL colp; /* Make string output of a column descriptor block. */
/***********************************************************************/
memset(m, ' ', n); // Make margin string void COLBLK::Print(PGLOBAL g, char *ps, uint z)
m[n] = '\0'; {
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name);
for (colp = To_Tdb->GetColumns(), i = 1; colp; colp = colp->Next, i++) } // end of Print
if (colp == this)
break;
/***********************************************************************/
fprintf(f, "%sR%dC%d type=%d F=%.2s(%d,%d)", m, To_Tdb->GetTdb_No(), /* SPCBLK constructor. */
i, GetAmType(), Format.Type, Format.Length, Format.Prec); /***********************************************************************/
fprintf(f, SPCBLK::SPCBLK(PCOLUMN cp)
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n", : COLBLK((PCOLDEF)NULL, cp->GetTo_Table()->GetTo_Tdb(), 0)
ColUse, Status, Buf_Type, Value, Name); {
} // end of Print Name = (char*)cp->GetName();
Precision = Long = 0;
/***********************************************************************/ Buf_Type = TYPE_ERROR;
/* Make string output of a column descriptor block. */ } // end of SPCBLK constructor
/***********************************************************************/
void COLBLK::Print(PGLOBAL g, char *ps, uint z) /***********************************************************************/
{ /* WriteColumn: what this routine does is to access the last line */
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name); /* read from the corresponding table, and rewrite the field */
} // end of Print /* corresponding to this column from the column buffer and type. */
/***********************************************************************/
void SPCBLK::WriteColumn(PGLOBAL g)
/***********************************************************************/ {
/* SPCBLK constructor. */ sprintf(g->Message, MSG(SPCOL_READONLY), Name);
/***********************************************************************/ longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
SPCBLK::SPCBLK(PCOLUMN cp) } // end of WriteColumn
: COLBLK((PCOLDEF)NULL, cp->GetTo_Table()->GetTo_Tdb(), 0)
{ /***********************************************************************/
Name = (char*)cp->GetName(); /* RIDBLK constructor for the ROWID special column. */
Precision = Long = 0; /***********************************************************************/
Buf_Type = TYPE_ERROR; RIDBLK::RIDBLK(PCOLUMN cp, bool rnm) : SPCBLK(cp)
} // end of SPCBLK constructor {
Precision = Long = 10;
/***********************************************************************/ Buf_Type = TYPE_INT;
/* WriteColumn: what this routine does is to access the last line */ Rnm = rnm;
/* read from the corresponding table, and rewrite the field */ *Format.Type = 'N';
/* corresponding to this column from the column buffer and type. */ Format.Length = 10;
/***********************************************************************/ } // end of RIDBLK constructor
void SPCBLK::WriteColumn(PGLOBAL g)
{ /***********************************************************************/
sprintf(g->Message, MSG(SPCOL_READONLY), Name); /* ReadColumn: what this routine does is to return the ordinal */
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); /* number of the current row in the table (if Rnm is true) or in the */
} // end of WriteColumn /* current file (if Rnm is false) the same except for multiple tables.*/
/***********************************************************************/
/***********************************************************************/ void RIDBLK::ReadColumn(PGLOBAL g)
/* RIDBLK constructor for the ROWID special column. */ {
/***********************************************************************/ Value->SetValue(To_Tdb->RowNumber(g, Rnm));
RIDBLK::RIDBLK(PCOLUMN cp, bool rnm) : SPCBLK(cp) } // end of ReadColumn
{
Precision = Long = 10; /***********************************************************************/
Buf_Type = TYPE_INT; /* FIDBLK constructor for the FILEID special column. */
Rnm = rnm; /***********************************************************************/
*Format.Type = 'N'; FIDBLK::FIDBLK(PCOLUMN cp) : SPCBLK(cp)
Format.Length = 10; {
} // end of RIDBLK constructor //Is_Key = 2; for when the MUL table indexed reading will be implemented.
Precision = Long = _MAX_PATH;
/***********************************************************************/ Buf_Type = TYPE_STRING;
/* ReadColumn: what this routine does is to return the ordinal */ *Format.Type = 'C';
/* number of the current row in the table (if Rnm is true) or in the */ Format.Length = Long;
/* current file (if Rnm is false) the same except for multiple tables.*/ #if defined(WIN32)
/***********************************************************************/ Format.Prec = 1; // Case insensitive
void RIDBLK::ReadColumn(PGLOBAL g) #endif // WIN32
{ Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() &&
Value->SetValue(To_Tdb->RowNumber(g, Rnm)); To_Tdb->GetAmType() != TYPE_AM_PLG &&
} // end of ReadColumn To_Tdb->GetAmType() != TYPE_AM_PLM);
Fn = NULL;
/***********************************************************************/ } // end of FIDBLK constructor
/* FIDBLK constructor for the FILEID special column. */
/***********************************************************************/ /***********************************************************************/
FIDBLK::FIDBLK(PCOLUMN cp) : SPCBLK(cp) /* ReadColumn: what this routine does is to return the current */
{ /* file ID of the table (can change for Multiple tables). */
//Is_Key = 2; for when the MUL table indexed reading will be implemented. /***********************************************************************/
Precision = Long = _MAX_PATH; void FIDBLK::ReadColumn(PGLOBAL g)
Buf_Type = TYPE_STRING; {
*Format.Type = 'C'; if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) {
Format.Length = Long; char filename[_MAX_PATH];
#if defined(WIN32)
Format.Prec = 1; // Case insensitive Fn = ((PTDBASE)To_Tdb)->GetFile(g);
#endif // WIN32 PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath());
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() && Value->SetValue_psz(filename);
To_Tdb->GetAmType() != TYPE_AM_PLG && } // endif Fn
To_Tdb->GetAmType() != TYPE_AM_PLM);
Fn = NULL; } // end of ReadColumn
} // end of FIDBLK constructor
/***********************************************************************/
/***********************************************************************/ /* TIDBLK constructor for the TABID special column. */
/* ReadColumn: what this routine does is to return the current */ /***********************************************************************/
/* file ID of the table (can change for Multiple tables). */ TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp)
/***********************************************************************/ {
void FIDBLK::ReadColumn(PGLOBAL g) //Is_Key = 2; for when the MUL table indexed reading will be implemented.
{ Precision = Long = 64;
if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) { Buf_Type = TYPE_STRING;
char filename[_MAX_PATH]; *Format.Type = 'C';
Format.Length = Long;
Fn = ((PTDBASE)To_Tdb)->GetFile(g); Format.Prec = 1; // Case insensitive
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath()); Constant = (To_Tdb->GetAmType() != TYPE_AM_TBL);
Value->SetValue_psz(filename); Tname = NULL;
} // endif Fn } // end of TIDBLK constructor
} // end of ReadColumn /***********************************************************************/
/* ReadColumn: what this routine does is to return the table ID. */
/***********************************************************************/ /***********************************************************************/
/* TIDBLK constructor for the TABID special column. */ void TIDBLK::ReadColumn(PGLOBAL g)
/***********************************************************************/ {
TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp) if (Tname == NULL) {
{ Tname = (char*)To_Tdb->GetName();
//Is_Key = 2; for when the MUL table indexed reading will be implemented. Value->SetValue_psz(Tname);
Precision = Long = 64; } // endif Tname
Buf_Type = TYPE_STRING;
*Format.Type = 'C'; } // end of ReadColumn
Format.Length = Long;
Format.Prec = 1; // Case insensitive /***********************************************************************/
Constant = (To_Tdb->GetAmType() != TYPE_AM_TBL); /* SIDBLK constructor for the SERVID special column. */
Tname = NULL; /***********************************************************************/
} // end of TIDBLK constructor SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp)
{
/***********************************************************************/ //Is_Key = 2; for when the MUL table indexed reading will be implemented.
/* ReadColumn: what this routine does is to return the table ID. */ Precision = Long = 64;
/***********************************************************************/ Buf_Type = TYPE_STRING;
void TIDBLK::ReadColumn(PGLOBAL g) *Format.Type = 'C';
{ Format.Length = Long;
if (Tname == NULL) { Format.Prec = 1; // Case insensitive
Tname = (char*)To_Tdb->GetName(); Constant = (To_Tdb->GetAmType() != TYPE_AM_TBL);
Value->SetValue_psz(Tname); Sname = NULL;
} // endif Tname } // end of TIDBLK constructor
} // end of ReadColumn /***********************************************************************/
/* ReadColumn: what this routine does is to return the server ID. */
/***********************************************************************/ /***********************************************************************/
/* SIDBLK constructor for the SERVID special column. */ void SIDBLK::ReadColumn(PGLOBAL g)
/***********************************************************************/ {
SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp) //if (Sname == NULL) {
{ Sname = (char*)To_Tdb->GetServer();
//Is_Key = 2; for when the MUL table indexed reading will be implemented. Value->SetValue_psz(Sname);
Precision = Long = 64; // } // endif Sname
Buf_Type = TYPE_STRING;
*Format.Type = 'C'; } // end of ReadColumn
Format.Length = Long;
Format.Prec = 1; // Case insensitive
Constant = (To_Tdb->GetAmType() != TYPE_AM_TBL);
Sname = NULL;
} // end of TIDBLK constructor
/***********************************************************************/
/* ReadColumn: what this routine does is to return the server ID. */
/***********************************************************************/
void SIDBLK::ReadColumn(PGLOBAL g)
{
//if (Sname == NULL) {
Sname = (char*)To_Tdb->GetServer();
Value->SetValue_psz(Sname);
// } // endif Sname
} // end of ReadColumn

View File

@@ -1,221 +1,205 @@
/*************** Colblk H Declares Source Code File (.H) ***************/ /*************** Colblk H Declares Source Code File (.H) ***************/
/* Name: COLBLK.H Version 1.7 */ /* Name: COLBLK.H Version 1.7 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* This file contains the COLBLK and derived classes declares. */ /* This file contains the COLBLK and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __COLBLK__H #ifndef __COLBLK__H
#define __COLBLK__H #define __COLBLK__H
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/***********************************************************************/ /***********************************************************************/
#include "xobject.h" #include "xobject.h"
#include "reldef.h" #include "reldef.h"
/***********************************************************************/ /***********************************************************************/
/* Class COLBLK: Base class for table column descriptors. */ /* Class COLBLK: Base class for table column descriptors. */
/***********************************************************************/ /***********************************************************************/
class DllExport COLBLK : public XOBJECT { class DllExport COLBLK : public XOBJECT {
friend class TDBPIVOT; friend class TDBPIVOT;
protected: protected:
// Default constructors used by derived classes // Default constructors used by derived classes
COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0); COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0);
COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process
COLBLK(int n) {} // Used when changing a column class in TDBXML COLBLK(int n) {} // Used when changing a column class in TDBXML
public: public:
// Implementation // Implementation
virtual int GetType(void) {return TYPE_COLBLK;} virtual int GetType(void) {return TYPE_COLBLK;}
virtual int GetResultType(void) {return Buf_Type;} virtual int GetResultType(void) {return Buf_Type;}
virtual int GetScale(void) {return Format.Prec;} virtual int GetScale(void) {return Format.Prec;}
virtual int GetPrecision(void) {return Precision;} virtual int GetPrecision(void) {return Precision;}
virtual int GetLength(void) {return Long;} virtual int GetLength(void) {return Long;}
virtual int GetLengthEx(void); virtual int GetLengthEx(void);
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 GetClustered(void) {return 0;} virtual int IsClustered(void) {return FALSE;}
virtual int IsClustered(void) {return FALSE;} PCOL GetNext(void) {return Next;}
#endif // BLK_INDX PSZ GetName(void) {return Name;}
PCOL GetNext(void) {return Next;} int GetIndex(void) {return Index;}
PSZ GetName(void) {return Name;} ushort GetColUse(void) {return ColUse;}
int GetIndex(void) {return Index;} int GetOpt(void) {return Opt;}
int GetOpt(void) {return Opt;} ushort GetColUse(ushort u) {return (ColUse & u);}
ushort GetColUse(void) {return ColUse;} ushort GetStatus(void) {return Status;}
ushort GetColUse(ushort u) {return (ColUse & u);} ushort GetStatus(ushort u) {return (Status & u);}
ushort GetStatus(void) {return Status;} void SetColUse(ushort u) {ColUse = u;}
ushort GetStatus(ushort u) {return (Status & u);} void SetStatus(ushort u) {Status = u;}
void SetColUse(ushort u) {ColUse = u;} void AddColUse(ushort u) {ColUse |= u;}
void SetStatus(ushort u) {Status = u;} void AddStatus(ushort u) {Status |= u;}
void AddColUse(ushort u) {ColUse |= u;} void SetNext(PCOL cp) {Next = cp;}
void AddStatus(ushort u) {Status |= u;} PXCOL GetKcol(void) {return To_Kcol;}
void SetNext(PCOL cp) {Next = cp;} void SetKcol(PXCOL kcp) {To_Kcol = kcp;}
#if defined(MRRBKA_SUPPORT) PCOLDEF GetCdp(void) {return Cdp;}
PXCOL GetKcol(void) {return To_Kcol;} PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;}
#endif // MRRBKA_SUPPORT PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;}
void SetKcol(PXCOL kcp) {To_Kcol = kcp;} PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;}
PCOLDEF GetCdp(void) {return Cdp;} bool IsUnsigned(void) {return Unsigned;}
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;} bool IsNullable(void) {return Nullable;}
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;} void SetNullable(bool b) {Nullable = b;}
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;}
bool IsUnsigned(void) {return Unsigned;} // Methods
bool IsNullable(void) {return Nullable;} virtual void Reset(void);
void SetNullable(bool b) {Nullable = b;} virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL, FORMAT&);
// Methods virtual bool IsSpecial(void) {return false;}
virtual void Reset(void); virtual bool Eval(PGLOBAL g);
virtual bool Compare(PXOB xp); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual bool SetFormat(PGLOBAL, FORMAT&); virtual void SetTo_Val(PVAL valp) {}
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag); virtual void ReadColumn(PGLOBAL g);
virtual bool IsSpecial(void) {return false;} virtual void WriteColumn(PGLOBAL g);
virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;} virtual void Print(PGLOBAL g, FILE *, uint);
virtual bool CheckSort(PTDB tdbp); virtual void Print(PGLOBAL g, char *, uint);
virtual bool Eval(PGLOBAL g); virtual bool VarSize(void) {return false;}
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); bool InitValue(PGLOBAL g);
virtual void SetTo_Val(PVAL valp) {}
virtual void ReadColumn(PGLOBAL g); protected:
virtual void WriteColumn(PGLOBAL g); // Members
virtual void Print(PGLOBAL g, FILE *, uint); PCOL Next; // Next column in table
virtual void Print(PGLOBAL g, char *, uint); PSZ Name; // Column name
#if defined(BLK_INDX) PCOLDEF Cdp; // To column definition block
virtual bool VarSize(void) {return false;} PTDB To_Tdb; // Points to Table Descriptor Block
#endif // BLK_INDX PXCOL To_Kcol; // Points to Xindex matching column
virtual bool IsColInside(PCOL colp) {return this == colp;} bool Nullable; // True if nullable
bool InitValue(PGLOBAL g); bool Unsigned; // True if unsigned
int Index; // Column number in table
protected: int Opt; // Cluster/sort information
// Members int Buf_Type; // Data type
PCOL Next; // Next column in table int Long; // Internal length in table
PSZ Name; // Column name int Precision; // Column length (as for ODBC)
PCOLDEF Cdp; // To column definition block int Freq; // Evaluated ceiling of distinct values
PTDB To_Tdb; // Points to Table Descriptor Block FORMAT Format; // Output format
PXCOL To_Kcol; // Points to Xindex matching column ushort ColUse; // Column usage
bool Nullable; // True if nullable ushort Status; // Column read status
bool Unsigned; // True if unsigned }; // end of class COLBLK
int Index; // Column number in table
int Opt; // Cluster/sort information /***********************************************************************/
int Buf_Type; // Data type /* Class SPCBLK: Base class for special column descriptors. */
int Long; // Internal length in table /***********************************************************************/
int Precision; // Column length (as for ODBC) class DllExport SPCBLK : public COLBLK {
int Freq; // Evaluated ceiling of distinct values public:
FORMAT Format; // Output format // Constructor
ushort ColUse; // Column usage SPCBLK(PCOLUMN cp);
ushort Status; // Column read status
}; // end of class COLBLK // Implementation
virtual int GetAmType(void) = 0;
/***********************************************************************/ virtual bool GetRnm(void) {return false;}
/* Class SPCBLK: Base class for special column descriptors. */
/***********************************************************************/ // Methods
class DllExport SPCBLK : public COLBLK { virtual bool IsSpecial(void) {return true;}
public: virtual void ReadColumn(PGLOBAL g) = 0;
// Constructor virtual void WriteColumn(PGLOBAL g);
SPCBLK(PCOLUMN cp);
protected:
// Implementation // Default constructor not to be used
virtual int GetAmType(void) = 0; SPCBLK(void) : COLBLK(1) {}
virtual bool GetRnm(void) {return false;} }; // end of class SPCBLK
// Methods /***********************************************************************/
virtual bool IsSpecial(void) {return true;} /* Class RIDBLK: ROWID special column descriptor. */
virtual void ReadColumn(PGLOBAL g) = 0; /***********************************************************************/
virtual void WriteColumn(PGLOBAL g); class DllExport RIDBLK : public SPCBLK {
public:
protected: // Constructor
// Default constructor not to be used RIDBLK(PCOLUMN cp, bool rnm);
SPCBLK(void) : COLBLK(1) {}
}; // end of class SPCBLK // Implementation
virtual int GetAmType(void) {return TYPE_AM_ROWID;}
/***********************************************************************/ virtual bool GetRnm(void) {return Rnm;}
/* Class RIDBLK: ROWID special column descriptor. */
/***********************************************************************/ // Methods
class DllExport RIDBLK : public SPCBLK { virtual void ReadColumn(PGLOBAL g);
public:
// Constructor protected:
RIDBLK(PCOLUMN cp, bool rnm); bool Rnm; // False for RowID, True for RowNum
}; // end of class RIDBLK
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ROWID;} /***********************************************************************/
virtual bool GetRnm(void) {return Rnm;} /* Class FIDBLK: FILEID special column descriptor. */
/***********************************************************************/
// Methods class DllExport FIDBLK : public SPCBLK {
virtual void ReadColumn(PGLOBAL g); public:
// Constructor
protected: FIDBLK(PCOLUMN cp);
bool Rnm; // False for RowID, True for RowNum
}; // end of class RIDBLK // Implementation
virtual int GetAmType(void) {return TYPE_AM_FILID;}
/***********************************************************************/
/* Class FIDBLK: FILEID special column descriptor. */ // Methods
/***********************************************************************/ virtual void Reset(void) {} // This is a pseudo constant column
class DllExport FIDBLK : public SPCBLK { virtual void ReadColumn(PGLOBAL g);
public:
// Constructor protected:
FIDBLK(PCOLUMN cp); PSZ Fn; // The current To_File of the table
}; // end of class FIDBLK
// Implementation
virtual int GetAmType(void) {return TYPE_AM_FILID;} /***********************************************************************/
/* Class TIDBLK: TABID special column descriptor. */
// Methods /***********************************************************************/
virtual void Reset(void) {} // This is a pseudo constant column class DllExport TIDBLK : public SPCBLK {
virtual int CheckSpcCol(PTDB tdbp, int n) public:
{return (n == 2 && tdbp == To_Tdb) ? 1 : 2;} // Constructor
virtual void ReadColumn(PGLOBAL g); TIDBLK(PCOLUMN cp);
protected: // Implementation
PSZ Fn; // The current To_File of the table virtual int GetAmType(void) {return TYPE_AM_TABID;}
}; // end of class FIDBLK
// Methods
/***********************************************************************/ virtual void Reset(void) {} // This is a pseudo constant column
/* Class TIDBLK: TABID special column descriptor. */ virtual void ReadColumn(PGLOBAL g);
/***********************************************************************/
class DllExport TIDBLK : public SPCBLK { protected:
public: // Default constructor not to be used
// Constructor TIDBLK(void) {}
TIDBLK(PCOLUMN cp);
// Members
// Implementation PSZ Tname; // The current table name
virtual int GetAmType(void) {return TYPE_AM_TABID;} }; // end of class TIDBLK
// Methods /***********************************************************************/
virtual void Reset(void) {} // This is a pseudo constant column /* Class SIDBLK: SERVID special column descriptor. */
virtual int CheckSpcCol(PTDB tdbp, int n) /***********************************************************************/
{return (n == 3 && tdbp == To_Tdb) ? 1 : 2;} class DllExport SIDBLK : public SPCBLK {
virtual void ReadColumn(PGLOBAL g); public:
// Constructor
protected: SIDBLK(PCOLUMN cp);
// Default constructor not to be used
TIDBLK(void) {} // Implementation
virtual int GetAmType(void) {return TYPE_AM_SRVID;}
// Members
PSZ Tname; // The current table name // Methods
}; // end of class TIDBLK virtual void Reset(void) {} // This is a pseudo constant column
virtual void ReadColumn(PGLOBAL g);
/***********************************************************************/
/* Class SIDBLK: SERVID special column descriptor. */ protected:
/***********************************************************************/ // Default constructor not to be used
class DllExport SIDBLK : public SPCBLK { SIDBLK(void) {}
public:
// Constructor // Members
SIDBLK(PCOLUMN cp); PSZ Sname; // The current server name
}; // end of class SIDBLK
// Implementation
virtual int GetAmType(void) {return TYPE_AM_SRVID;} #endif // __COLBLK__H
// Methods
virtual void Reset(void) {} // This is a pseudo constant column
virtual int CheckSpcCol(PTDB tdbp, int n)
{return (n == 3 && tdbp == To_Tdb) ? 1 : 2;}
virtual void ReadColumn(PGLOBAL g);
protected:
// Default constructor not to be used
SIDBLK(void) {}
// Members
PSZ Sname; // The current server name
}; // end of class SIDBLK
#endif // __COLBLK__H

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,6 @@
/* Name: CONNECT.H Version 2.4 */ /* Name: CONNECT.H Version 2.4 */
/* This file contains the some based classes declares. */ /* This file contains the some based classes declares. */
/***********************************************************************/ /***********************************************************************/
//#include "xtable.h" // Base class declares
#include "filamtxt.h" #include "filamtxt.h"
#include "tabdos.h" #include "tabdos.h"
@@ -52,8 +51,6 @@ PGLOBAL CntExit(PGLOBAL g);
/* These classes purpose is chiefly to access protected items! */ /* These classes purpose is chiefly to access protected items! */
/***********************************************************************/ /***********************************************************************/
class DOXDEF: public DOSDEF { class DOXDEF: public DOSDEF {
//friend class TDBDOX;
//friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int); friend int CntIndexInit(PGLOBAL, PTDB, int);
}; // end of class DOXDEF }; // end of class DOXDEF
@@ -74,10 +71,7 @@ class TDBDOX: public TDBDOS {
class XKPDEF: public KPARTDEF { class XKPDEF: public KPARTDEF {
friend class TDBDOX; friend class TDBDOX;
friend class ha_connect; friend class ha_connect;
//friend int CntMakeIndex(PGLOBAL, const char *, PIXDEF);
friend int CntIndexInit(PGLOBAL, PTDB, int); friend int CntIndexInit(PGLOBAL, PTDB, int);
public: public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {} XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {}
}; // end of class XKPDEF }; // end of class XKPDEF
//RCODE CheckRecord(PGLOBAL g, PTDB tdbp, char *oldbuf, char *newbuf);

View File

@@ -20,7 +20,6 @@ typedef struct _xblock { /* Loaded XML file block */
short Type; /* TYPE_FB_XML */ short Type; /* TYPE_FB_XML */
int Retcode; /* Return code from Load */ int Retcode; /* Return code from Load */
MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */ MSXML2::IXMLDOMDocumentPtr Docp;/* Document interface pointer */
//IXMLDOMNodeListPtr Nlist;
} XBLOCK, *PXBLOCK; } XBLOCK, *PXBLOCK;
/******************************************************************/ /******************************************************************/
@@ -123,9 +122,6 @@ class DOMATTR : public XMLATTRIBUTE {
friend class DOMDOC; friend class DOMDOC;
friend class DOMNODE; friend class DOMNODE;
public: public:
// Properties
//virtual char *GetText(void);
// Methods // Methods
virtual bool SetText(PGLOBAL g, char *txtp, int len); virtual bool SetText(PGLOBAL g, char *txtp, int len);

File diff suppressed because it is too large Load Diff

View File

@@ -1,114 +1,113 @@
/*************** FilAMap H Declares Source Code File (.H) **************/ /*************** FilAMap H Declares Source Code File (.H) **************/
/* Name: FILAMAP.H Version 1.2 */ /* Name: FILAMAP.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the MAP file access method classes declares. */ /* This file contains the MAP file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMAP_H #ifndef __FILAMAP_H
#define __FILAMAP_H #define __FILAMAP_H
#include "block.h" #include "block.h"
#include "filamtxt.h" #include "filamtxt.h"
typedef class MAPFAM *PMAPFAM; typedef class MAPFAM *PMAPFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the variable file access method using file mapping. */ /* This is the variable file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MAPFAM : public TXTFAM { class DllExport MAPFAM : public TXTFAM {
public: public:
// Constructor // Constructor
MAPFAM(PDOSDEF tdp); MAPFAM(PDOSDEF tdp);
MAPFAM(PMAPFAM tmfp); MAPFAM(PMAPFAM tmfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_MAP;} virtual AMT GetAmType(void) {return TYPE_AM_MAP;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MAPFAM(this);} {return (PTXF)new(g) MAPFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual bool DeferReading(void) {return false;} virtual bool DeferReading(void) {return false;}
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
char *Memory; // Pointer on file mapping view. char *Memory; // Pointer on file mapping view.
char *Mempos; // Position of next data to read char *Mempos; // Position of next data to read
char *Fpos; // Position of last read record char *Fpos; // Position of last read record
char *Tpos; // Target Position for delete move char *Tpos; // Target Position for delete move
char *Spos; // Start position for delete move char *Spos; // Start position for delete move
char *Top; // Mark end of file mapping view char *Top; // Mark end of file mapping view
}; // end of class MAPFAM }; // end of class MAPFAM
/***********************************************************************/ /***********************************************************************/
/* This is the blocked file access method using file mapping. */ /* This is the blocked file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MBKFAM : public MAPFAM { class DllExport MBKFAM : public MAPFAM {
public: public:
// Constructor // Constructor
MBKFAM(PDOSDEF tdp); MBKFAM(PDOSDEF tdp);
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {} MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {}
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MBKFAM(this);} {return (PTXF)new(g) MBKFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
virtual int GetRowID(void); virtual int GetRowID(void);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// No additional members // No additional members
}; // end of class MBKFAM }; // end of class MBKFAM
/***********************************************************************/ /***********************************************************************/
/* This is the fixed file access method using file mapping. */ /* This is the fixed file access method using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport MPXFAM : public MBKFAM { class DllExport MPXFAM : public MBKFAM {
public: public:
// Constructor // Constructor
MPXFAM(PDOSDEF tdp); MPXFAM(PDOSDEF tdp);
MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {} MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {}
// Implementation // Implementation
virtual int GetPos(void); virtual int GetPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) MPXFAM(this);} {return (PTXF)new(g) MPXFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
//virtual int GetRowID(void); virtual bool SetPos(PGLOBAL g, int recpos);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool DeferReading(void) {return false;}
virtual bool DeferReading(void) {return false;} virtual int ReadBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g);
protected:
protected: // No additional members
// No additional members }; // end of class MPXFAM
}; // end of class MPXFAM
#endif // __FILAMAP_H
#endif // __FILAMAP_H

View File

@@ -43,7 +43,6 @@ class DllExport DBFBASE {
int Nerr; /* Number of bad records */ int Nerr; /* Number of bad records */
int Maxerr; /* Maximum number of bad records */ int Maxerr; /* Maximum number of bad records */
int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */ int ReadMode; /* 1: ALL 2: DEL 0: NOT DEL */
//PSZ Defpath; /* Default data path */
}; // end of class DBFBASE }; // end of class DBFBASE
/****************************************************************************/ /****************************************************************************/
@@ -63,22 +62,18 @@ class DllExport DBFFAM : public FIXFAM, public DBFBASE {
// Methods // Methods
virtual int GetNerr(void) {return Nerr;} virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members
virtual bool CopyHeader(PGLOBAL g); virtual bool CopyHeader(PGLOBAL g);
//int Records; in TXTFAM // Members
//int Headlen; in TXTFAM
}; // end of class DBFFAM }; // end of class DBFFAM
/****************************************************************************/ /****************************************************************************/
@@ -100,17 +95,13 @@ class DllExport DBMFAM : public MPXFAM, public DBFBASE {
// Methods // Methods
virtual int GetNerr(void) {return Nerr;} virtual int GetNerr(void) {return Nerr;}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
//virtual int GetRowID(void); // Temporarily suppressed
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
//virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
//int Records; in TXTFAM
//int Headlen; in TXTFAM
}; // end of class DBFFAM }; // end of class DBFFAM
#endif // __FILAMDBF_H #endif // __FILAMDBF_H

View File

@@ -168,13 +168,10 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0; CurNum = 0;
Tdbp->SetLine(To_Buf); Tdbp->SetLine(To_Buf);
#if defined(BLK_INDX)
next: 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 */ /* Before reading a new block, check whether block indexing */
/* can be done, as well as for join as for local filtering. */ /* can be done, as well as for join as for local filtering. */
@@ -185,7 +182,6 @@ int FIXFAM::ReadBuffer(PGLOBAL g)
case RC_NF: case RC_NF:
goto next; goto next;
} // endswitch rc } // endswitch rc
#endif // BLK_INDX
} // endif's } // endif's
if (OldBlk == CurBlk) { if (OldBlk == CurBlk) {
@@ -1043,13 +1039,10 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
CurNum = 0; CurNum = 0;
Tdbp->SetLine(To_Buf); Tdbp->SetLine(To_Buf);
#if defined(BLK_INDX)
next: 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 */ /* Before reading a new block, check whether block optimization */
/* can be done, as well as for join as for local filtering. */ /* can be done, as well as for join as for local filtering. */
@@ -1060,7 +1053,7 @@ int BGXFAM::ReadBuffer(PGLOBAL g)
case RC_NF: case RC_NF:
goto next; goto next;
} // endswitch rc } // endswitch rc
#endif // BLK_INDX
} // endif's } // endif's
if (OldBlk == CurBlk) { if (OldBlk == CurBlk) {

View File

@@ -1,90 +1,88 @@
/************** FilAMFix H Declares Source Code File (.H) **************/ /************** FilAMFix H Declares Source Code File (.H) **************/
/* Name: FILAMFIX.H Version 1.2 */ /* Name: FILAMFIX.H Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005 - 2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005 - 2014 */
/* */ /* */
/* This file contains the FIX file access method classes declares. */ /* This file contains the FIX file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMFIX_H #ifndef __FILAMFIX_H
#define __FILAMFIX_H #define __FILAMFIX_H
#include "filamtxt.h" #include "filamtxt.h"
typedef class FIXFAM *PFIXFAM; typedef class FIXFAM *PFIXFAM;
typedef class BGXFAM *PBGXFAM; typedef class BGXFAM *PBGXFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */ /* This is the DOS/UNIX Access Method class declaration for standard */
/* files with fixed record format (FIX, BIN) */ /* files with fixed record format (FIX, BIN) */
/***********************************************************************/ /***********************************************************************/
class DllExport FIXFAM : public BLKFAM { class DllExport FIXFAM : public BLKFAM {
public: public:
// Constructor // Constructor
FIXFAM(PDOSDEF tdp); FIXFAM(PDOSDEF tdp);
FIXFAM(PFIXFAM txfp); FIXFAM(PFIXFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FIX;} virtual AMT GetAmType(void) {return TYPE_AM_FIX;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) FIXFAM(this);} {return (PTXF)new(g) FIXFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);}
virtual int MaxBlkSize(PGLOBAL g, int s) virtual int MaxBlkSize(PGLOBAL g, int s)
{return TXTFAM::MaxBlkSize(g, s);} {return TXTFAM::MaxBlkSize(g, s);}
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
protected: protected:
virtual bool CopyHeader(PGLOBAL g) {return false;} virtual bool CopyHeader(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
// No additional members // No additional members
}; // end of class FIXFAM }; // end of class FIXFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* that are standard files with columns starting at fixed offset */ /* that are standard files with columns starting at fixed offset */
/* This class is for fixed formatted files of more than 2 gigabytes. */ /* This class is for fixed formatted files of more than 2 gigabytes. */
/***********************************************************************/ /***********************************************************************/
class BGXFAM : public FIXFAM { class BGXFAM : public FIXFAM {
public: public:
// Constructor // Constructor
BGXFAM(PDOSDEF tdp); BGXFAM(PDOSDEF tdp);
BGXFAM(PBGXFAM txfp); BGXFAM(PBGXFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGXFAM(this);} {return (PTXF)new(g) BGXFAM(this);}
// Methods // Methods
//virtual void Reset(void); virtual int Cardinality(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual bool OpenTableFile(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g); virtual void Rewind(void);
virtual void Rewind(void);
protected:
protected: bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos , int org = FILE_BEGIN);
, int org = FILE_BEGIN); int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); virtual bool OpenTempFile(PGLOBAL g);
virtual bool OpenTempFile(PGLOBAL g); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
// Members
// Members HANDLE Hfile; // Handle(descriptor) to big file
HANDLE Hfile; // Handle(descriptor) to big file HANDLE Tfile; // Handle(descriptor) to big temp file
HANDLE Tfile; // Handle(descriptor) to big temp file }; // end of class BGXFAM
//BIGINT Xpos; // Current file position
}; // end of class BGXFAM #endif // __FILAMFIX_H
#endif // __FILAMFIX_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,196 +1,196 @@
/************** FilAMTxt H Declares Source Code File (.H) **************/ /************** FilAMTxt H Declares Source Code File (.H) **************/
/* Name: FILAMTXT.H Version 1.2 */ /* Name: FILAMTXT.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the file access method classes declares. */ /* This file contains the file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMTXT_H #ifndef __FILAMTXT_H
#define __FILAMTXT_H #define __FILAMTXT_H
#include "block.h" #include "block.h"
typedef class TXTFAM *PTXF; typedef class TXTFAM *PTXF;
typedef class DOSFAM *PDOSFAM; typedef class DOSFAM *PDOSFAM;
typedef class BLKFAM *PBLKFAM; typedef class BLKFAM *PBLKFAM;
typedef class DOSDEF *PDOSDEF; typedef class DOSDEF *PDOSDEF;
typedef class TDBDOS *PTDBDOS; typedef class TDBDOS *PTDBDOS;
/***********************************************************************/ /***********************************************************************/
/* This is the base class for all file access method classes. */ /* This is the base class for all file access method classes. */
/***********************************************************************/ /***********************************************************************/
class DllExport TXTFAM : public BLOCK { class DllExport TXTFAM : public BLOCK {
friend class TDBDOS; friend class TDBDOS;
friend class TDBCSV; friend class TDBCSV;
friend class TDBFIX; friend class TDBFIX;
friend class TDBVCT; friend class TDBVCT;
friend class DOSCOL; friend class DOSCOL;
friend class BINCOL; friend class BINCOL;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
TXTFAM(PDOSDEF tdp); TXTFAM(PDOSDEF tdp);
TXTFAM(PTXF txfp); TXTFAM(PTXF txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) = 0; virtual AMT GetAmType(void) = 0;
virtual int GetPos(void) = 0; virtual int GetPos(void) = 0;
virtual int GetNextPos(void) = 0; virtual int GetNextPos(void) = 0;
virtual PTXF Duplicate(PGLOBAL g) = 0; virtual PTXF Duplicate(PGLOBAL g) = 0;
virtual bool GetUseTemp(void) {return false;} virtual bool GetUseTemp(void) {return false;}
virtual int GetDelRows(void) {return DelRows;} virtual int GetDelRows(void) {return DelRows;}
int GetCurBlk(void) {return CurBlk;} int GetCurBlk(void) {return CurBlk;}
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;} void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;}
int GetBlock(void) {return Block;} int GetBlock(void) {return Block;}
void SetBlkPos(int *bkp) {BlkPos = bkp;} void SetBlkPos(int *bkp) {BlkPos = bkp;}
void SetNrec(int n) {Nrec = n;} void SetNrec(int n) {Nrec = n;}
char *GetBuf(void) {return To_Buf;} char *GetBuf(void) {return To_Buf;}
int GetRows(void) {return Rows;} int GetRows(void) {return Rows;}
bool IsBlocked(void) {return Blocked;} bool IsBlocked(void) {return Blocked;}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g) {return false;} virtual bool AllocateBuffer(PGLOBAL g) {return false;}
virtual void ResetBuffer(PGLOBAL g) {} virtual void ResetBuffer(PGLOBAL g) {}
virtual int GetNerr(void) {return 0;} virtual int GetNerr(void) {return 0;}
virtual int GetRowID(void) = 0; virtual int GetRowID(void) = 0;
virtual bool RecordPos(PGLOBAL g) = 0; virtual bool RecordPos(PGLOBAL g) = 0;
virtual bool SetPos(PGLOBAL g, int recpos) = 0; virtual bool SetPos(PGLOBAL g, int recpos) = 0;
virtual int SkipRecord(PGLOBAL g, bool header) = 0; virtual int SkipRecord(PGLOBAL g, bool header) = 0;
virtual bool OpenTableFile(PGLOBAL g) = 0; virtual bool OpenTableFile(PGLOBAL g) = 0;
virtual bool DeferReading(void) {IsRead = false; return true;} virtual bool DeferReading(void) {IsRead = false; return true;}
virtual int ReadBuffer(PGLOBAL g) = 0; virtual int ReadBuffer(PGLOBAL g) = 0;
virtual int WriteBuffer(PGLOBAL g) = 0; virtual int WriteBuffer(PGLOBAL g) = 0;
virtual int DeleteRecords(PGLOBAL g, int irc) = 0; virtual int DeleteRecords(PGLOBAL g, int irc) = 0;
virtual void CloseTableFile(PGLOBAL g) = 0; virtual void CloseTableFile(PGLOBAL g) = 0;
virtual void Rewind(void) = 0; virtual void Rewind(void) = 0;
protected: protected:
// Members // Members
PTDBDOS Tdbp; // To table class PTDBDOS Tdbp; // To table class
PSZ To_File; // Points to table file name PSZ To_File; // Points to table file name
PFBLOCK To_Fb; // Pointer to file block PFBLOCK To_Fb; // Pointer to file block
bool Placed; // true if Recpos was externally set bool Placed; // true if Recpos was externally set
bool IsRead; // false for deferred reading bool IsRead; // false for deferred reading
bool Blocked; // true if using blocked I/O bool Blocked; // true if using blocked I/O
char *To_Buf; // Points to I/O buffer char *To_Buf; // Points to I/O buffer
void *DelBuf; // Buffer used to move lines in Delete void *DelBuf; // Buffer used to move lines in Delete
int *BlkPos; // To array of block positions int *BlkPos; // To array of block positions
int BlkLen; // Current block length int BlkLen; // Current block length
int Buflen; // Buffer length int Buflen; // Buffer length
int Dbflen; // Delete buffer length int Dbflen; // Delete buffer length
int Rows; // Number of rows read so far int Rows; // Number of rows read so far
int DelRows; // Number of deleted rows int DelRows; // Number of deleted rows
int Headlen; // Number of bytes in header int Headlen; // Number of bytes in header
int Lrecl; // Logical Record Length int Lrecl; // Logical Record Length
int Block; // Number of blocks in table int Block; // Number of blocks in table
int Last; // Number of elements of last block int Last; // Number of elements of last block
int Nrec; // Number of records in buffer int Nrec; // Number of records in buffer
int OldBlk; // Index of last read block int OldBlk; // Index of last read block
int CurBlk; // Index of current block int CurBlk; // Index of current block
int CurNum; // Current buffer line number int CurNum; // Current buffer line number
int ReadBlks; // Number of blocks read (selected) int ReadBlks; // Number of blocks read (selected)
int Rbuf; // Number of lines read in buffer int Rbuf; // Number of lines read in buffer
int Modif; // Number of modified lines in block int Modif; // Number of modified lines in block
int Blksize; // Size of padded blocks int Blksize; // Size of padded blocks
int Ending; // Length of line end int Ending; // Length of line end
bool Padded; // true if fixed size blocks are padded bool Padded; // true if fixed size blocks are padded
bool Eof; // true if an EOF (0xA) character exists bool Eof; // true if an EOF (0xA) character exists
char *CrLf; // End of line character(s) char *CrLf; // End of line character(s)
}; // end of class TXTFAM }; // end of class TXTFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */ /* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */ /* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/ /***********************************************************************/
class DllExport DOSFAM : public TXTFAM { class DllExport DOSFAM : public TXTFAM {
public: public:
// Constructor // Constructor
DOSFAM(PDOSDEF tdp); DOSFAM(PDOSDEF tdp);
DOSFAM(PDOSFAM txfp); DOSFAM(PDOSFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_DOS;} virtual AMT GetAmType(void) {return TYPE_AM_DOS;}
virtual bool GetUseTemp(void) {return UseTemp;} virtual bool GetUseTemp(void) {return UseTemp;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) DOSFAM(this);} {return (PTXF)new(g) DOSFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b);
virtual int RenameTempFile(PGLOBAL g); virtual int RenameTempFile(PGLOBAL g);
// Members // Members
FILE *Stream; // Points to Dos file structure FILE *Stream; // Points to Dos file structure
FILE *T_Stream; // Points to temporary file structure FILE *T_Stream; // Points to temporary file structure
PFBLOCK To_Fbt; // Pointer to temp file block PFBLOCK To_Fbt; // Pointer to temp file block
int Fpos; // Position of last read record int Fpos; // Position of last read record
int Tpos; // Target Position for delete move int Tpos; // Target Position for delete move
int Spos; // Start position for delete move int Spos; // Start position for delete move
bool UseTemp; // True to use a temporary file in Delete bool UseTemp; // True to use a temporary file in Delete
bool Bin; // True to force binary mode bool Bin; // True to force binary mode
}; // end of class DOSFAM }; // end of class DOSFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for standard */ /* This is the DOS/UNIX Access Method class declaration for standard */
/* text files with variable record format (DOS, CSV, FMT) */ /* text files with variable record format (DOS, CSV, FMT) */
/***********************************************************************/ /***********************************************************************/
class DllExport BLKFAM : public DOSFAM { class DllExport BLKFAM : public DOSFAM {
public: public:
// Constructor // Constructor
BLKFAM(PDOSDEF tdp); BLKFAM(PDOSDEF tdp);
BLKFAM(PBLKFAM txfp); BLKFAM(PBLKFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_BLK;} virtual AMT GetAmType(void) {return TYPE_AM_BLK;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BLKFAM(this);} {return (PTXF)new(g) BLKFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
char *CurLine; // Position of current line in buffer char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer char *NxtLine; // Position of Next line in buffer
char *OutBuf; // Buffer to write in temporary file char *OutBuf; // Buffer to write in temporary file
bool Closing; // True when closing on Update bool Closing; // True when closing on Update
}; // end of class BLKFAM }; // end of class BLKFAM
#endif // __FILAMTXT_H #endif // __FILAMTXT_H

File diff suppressed because it is too large Load Diff

View File

@@ -1,249 +1,249 @@
/************** FilAMVct H Declares Source Code File (.H) **************/ /************** FilAMVct H Declares Source Code File (.H) **************/
/* Name: FILAMVCT.H Version 1.5 */ /* Name: FILAMVCT.H Version 1.5 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2012 */
/* */ /* */
/* This file contains the VCT file access method classes declares. */ /* This file contains the VCT file access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMVCT__ #ifndef __FILAMVCT__
#define __FILAMVCT__ #define __FILAMVCT__
#include "filamfix.h" #include "filamfix.h"
typedef class VCTFAM *PVCTFAM; typedef class VCTFAM *PVCTFAM;
typedef class VCTCOL *PVCTCOL; typedef class VCTCOL *PVCTCOL;
typedef class VCMFAM *PVCMFAM; typedef class VCMFAM *PVCMFAM;
typedef class VECFAM *PVECFAM; typedef class VECFAM *PVECFAM;
typedef class VMPFAM *PVMPFAM; typedef class VMPFAM *PVMPFAM;
typedef class BGVFAM *PBGVFAM; typedef class BGVFAM *PBGVFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format. If MaxBlk=0, each block containing "Elements" */ /* in vector format. If MaxBlk=0, each block containing "Elements" */
/* records, values of each columns are consecutively stored (vector). */ /* records, values of each columns are consecutively stored (vector). */
/* Otherwise, data is arranged by column in the file and MaxBlk is */ /* Otherwise, data is arranged by column in the file and MaxBlk is */
/* used to set the maximum number of blocks. This leave some white */ /* used to set the maximum number of blocks. This leave some white */
/* space allowing to insert new values up to this maximum size. */ /* space allowing to insert new values up to this maximum size. */
/***********************************************************************/ /***********************************************************************/
class DllExport VCTFAM : public FIXFAM { class DllExport VCTFAM : public FIXFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VCTFAM(PVCTDEF tdp); VCTFAM(PVCTDEF tdp);
VCTFAM(PVCTFAM txfp); VCTFAM(PVCTFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCTFAM(this);} {return (PTXF)new(g) VCTFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g); virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g) {} virtual void ResetBuffer(PGLOBAL g) {}
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected: protected:
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g) {return false;} virtual bool MoveLines(PGLOBAL g) {return false;}
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g); virtual bool CleanUnusedSpace(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g); virtual int GetBlockInfo(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g); virtual bool SetBlockInfo(PGLOBAL g);
bool ResetTableSize(PGLOBAL g, int block, int last); bool ResetTableSize(PGLOBAL g, int block, int last);
// Members // Members
char *NewBlock; // To block written on Insert char *NewBlock; // To block written on Insert
char *Colfn; // Pattern for column file names (VER) char *Colfn; // Pattern for column file names (VER)
char *Tempat; // Pattern for temp file names (VER) char *Tempat; // Pattern for temp file names (VER)
int *Clens; // Pointer to col size array int *Clens; // Pointer to col size array
int *Deplac; // Pointer to col start position array int *Deplac; // Pointer to col start position array
bool *Isnum; // Pointer to buffer type isnum result bool *Isnum; // Pointer to buffer type isnum result
bool AddBlock; // True when adding new blocks on Insert bool AddBlock; // True when adding new blocks on Insert
bool Split; // true: split column file vector format bool Split; // true: split column file vector format
int Header; // 0: no, 1: separate, 2: in data file int Header; // 0: no, 1: separate, 2: in data file
int MaxBlk; // Max number of blocks (True vector format) int MaxBlk; // Max number of blocks (True vector format)
int Bsize; // Because Nrec can be modified int Bsize; // Because Nrec can be modified
int Ncol; // The number of columns; int Ncol; // The number of columns;
}; // end of class VCTFAM }; // end of class VCTFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in vector format accessed using file mapping. */ /* in vector format accessed using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport VCMFAM : public VCTFAM { class DllExport VCMFAM : public VCTFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VCMFAM(PVCTDEF tdp); VCMFAM(PVCTDEF tdp);
VCMFAM(PVCMFAM txfp); VCMFAM(PVCMFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VMP;} virtual AMT GetAmType(void) {return TYPE_AM_VMP;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VCMFAM(this);} {return (PTXF)new(g) VCMFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g); virtual bool InitInsert(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
// Members // Members
char* Memory; // Pointer on file mapping view. char* Memory; // Pointer on file mapping view.
char* *Memcol; // Pointer on column start. char* *Memcol; // Pointer on column start.
}; // end of class VCMFAM }; // end of class VCMFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format. Each column is contained in a separate */ /* in full vertical format. Each column is contained in a separate */
/* file whose name is the table name followed by the column number. */ /* file whose name is the table name followed by the column number. */
/***********************************************************************/ /***********************************************************************/
class DllExport VECFAM : public VCTFAM { class DllExport VECFAM : public VCTFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VECFAM(PVCTDEF tdp); VECFAM(PVCTDEF tdp);
VECFAM(PVECFAM txfp); VECFAM(PVECFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VECFAM(this);} {return (PTXF)new(g) VECFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool InitInsert(PGLOBAL g); virtual bool InitInsert(PGLOBAL g);
virtual void ResetBuffer(PGLOBAL g); virtual void ResetBuffer(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected: protected:
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveLines(PGLOBAL g); virtual bool MoveLines(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual int RenameTempFile(PGLOBAL g); virtual int RenameTempFile(PGLOBAL g);
bool OpenColumnFile(PGLOBAL g, char *opmode, int i); bool OpenColumnFile(PGLOBAL g, char *opmode, int i);
// Members // Members
FILE* *Streams; // Points to Dos file structure array FILE* *Streams; // Points to Dos file structure array
FILE* *T_Streams; // Points to temp file structure array FILE* *T_Streams; // Points to temp file structure array
PFBLOCK *To_Fbs; // Pointer to file block array PFBLOCK *To_Fbs; // Pointer to file block array
PFBLOCK *T_Fbs; // Pointer to temp file block array PFBLOCK *T_Fbs; // Pointer to temp file block array
void* *To_Bufs; // Pointer to col val block array void* *To_Bufs; // Pointer to col val block array
bool InitUpdate; // Used to initialize updating bool InitUpdate; // Used to initialize updating
}; // end of class VECFAM }; // end of class VECFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in full vertical format accessed using file mapping. */ /* in full vertical format accessed using file mapping. */
/***********************************************************************/ /***********************************************************************/
class DllExport VMPFAM : public VCMFAM { class DllExport VMPFAM : public VCMFAM {
friend class TDBVCT; friend class TDBVCT;
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructor // Constructor
VMPFAM(PVCTDEF tdp); VMPFAM(PVCTDEF tdp);
VMPFAM(PVMPFAM txfp); VMPFAM(PVMPFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) VMPFAM(this);} {return (PTXF)new(g) VMPFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
protected: protected:
bool MapColumnFile(PGLOBAL g, MODE mode, int i); bool MapColumnFile(PGLOBAL g, MODE mode, int i);
// Members // Members
PFBLOCK *To_Fbs; // Pointer to file block array PFBLOCK *To_Fbs; // Pointer to file block array
}; // end of class VMPFAM }; // end of class VMPFAM
/***********************************************************************/ /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */ /* This is the DOS/UNIX Access Method class declaration for files */
/* in (possibly blocked) vector format that can be larger than 2GB. */ /* in (possibly blocked) vector format that can be larger than 2GB. */
/***********************************************************************/ /***********************************************************************/
class BGVFAM : public VCTFAM { class BGVFAM : public VCTFAM {
friend class VCTCOL; friend class VCTCOL;
public: public:
// Constructors // Constructors
BGVFAM(PVCTDEF tdp); BGVFAM(PVCTDEF tdp);
BGVFAM(PBGVFAM txfp); BGVFAM(PBGVFAM txfp);
// Implementation // Implementation
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) BGVFAM(this);} {return (PTXF)new(g) BGVFAM(this);}
// Methods // Methods
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
// Database routines // Database routines
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
// Specific functions // Specific functions
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp);
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp);
protected: protected:
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false); bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false);
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req);
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req);
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); virtual bool MakeEmptyFile(PGLOBAL g, char *fn);
virtual bool OpenTempFile(PGLOBAL g); virtual bool OpenTempFile(PGLOBAL g);
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL);
virtual bool CleanUnusedSpace(PGLOBAL g); virtual bool CleanUnusedSpace(PGLOBAL g);
virtual bool SetBlockInfo(PGLOBAL g); virtual bool SetBlockInfo(PGLOBAL g);
virtual int GetBlockInfo(PGLOBAL g); virtual int GetBlockInfo(PGLOBAL g);
// Members // Members
HANDLE Hfile; // Handle to big file HANDLE Hfile; // Handle to big file
HANDLE Tfile; // Handle to temporary file HANDLE Tfile; // Handle to temporary file
BIGINT *BigDep; // Pointer to col start position array BIGINT *BigDep; // Pointer to col start position array
}; // end of class BGVFAM }; // end of class BGVFAM
#endif // __FILAMVCT__ #endif // __FILAMVCT__

File diff suppressed because it is too large Load Diff

View File

@@ -1,171 +1,169 @@
/************** FilAmZip H Declares Source Code File (.H) **************/ /************** FilAmZip H Declares Source Code File (.H) **************/
/* Name: FILAMZIP.H Version 1.1 */ /* Name: FILAMZIP.H Version 1.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* This file contains the GZIP access method classes declares. */ /* This file contains the GZIP access method classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __FILAMZIP_H #ifndef __FILAMZIP_H
#define __FILAMZIP_H #define __FILAMZIP_H
#include "zlib.h" #include "zlib.h"
typedef class ZIPFAM *PZIPFAM; typedef class ZIPFAM *PZIPFAM;
typedef class ZBKFAM *PZBKFAM; typedef class ZBKFAM *PZBKFAM;
typedef class ZIXFAM *PZIXFAM; typedef class ZIXFAM *PZIXFAM;
typedef class ZLBFAM *PZLBFAM; typedef class ZLBFAM *PZLBFAM;
/***********************************************************************/ /***********************************************************************/
/* This is the access method class declaration for not optimized */ /* This is the access method class declaration for not optimized */
/* variable record length files compressed using the gzip library */ /* variable record length files compressed using the gzip library */
/* functions. File is accessed record by record (row). */ /* functions. File is accessed record by record (row). */
/***********************************************************************/ /***********************************************************************/
class DllExport ZIPFAM : public TXTFAM { class DllExport ZIPFAM : public TXTFAM {
// friend class DOSCOL; // friend class DOSCOL;
public: public:
// Constructor // Constructor
ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;} ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;}
ZIPFAM(PZIPFAM txfp); ZIPFAM(PZIPFAM txfp);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;} virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void); virtual int GetNextPos(void);
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIPFAM(this);} {return (PTXF)new(g) ZIPFAM(this);}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
virtual int GetFileLength(PGLOBAL g); virtual int GetFileLength(PGLOBAL g);
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual bool SetPos(PGLOBAL g, int recpos); virtual bool SetPos(PGLOBAL g, int recpos);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual bool OpenTableFile(PGLOBAL g); virtual bool OpenTableFile(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
int Zerror(PGLOBAL g); // GZ error function int Zerror(PGLOBAL g); // GZ error function
// Members // Members
gzFile Zfile; // Points to GZ file structure gzFile Zfile; // Points to GZ file structure
z_off_t Zpos; // Uncompressed file position z_off_t Zpos; // Uncompressed file position
}; // end of class ZIPFAM }; // end of class ZIPFAM
/***********************************************************************/ /***********************************************************************/
/* This is the access method class declaration for optimized variable */ /* This is the access method class declaration for optimized variable */
/* record length files compressed using the gzip library functions. */ /* record length files compressed using the gzip library functions. */
/* The File is accessed by block (requires an opt file). */ /* The File is accessed by block (requires an opt file). */
/***********************************************************************/ /***********************************************************************/
class DllExport ZBKFAM : public ZIPFAM { class DllExport ZBKFAM : public ZIPFAM {
public: public:
// Constructor // Constructor
ZBKFAM(PDOSDEF tdp); ZBKFAM(PDOSDEF tdp);
ZBKFAM(PZBKFAM txfp); ZBKFAM(PZBKFAM txfp);
// Implementation // Implementation
virtual int GetPos(void); virtual int GetPos(void);
virtual int GetNextPos(void) {return 0;} virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZBKFAM(this);} {return (PTXF)new(g) ZBKFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual int MaxBlkSize(PGLOBAL g, int s); virtual int MaxBlkSize(PGLOBAL g, int s);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int GetRowID(void); virtual int GetRowID(void);
virtual bool RecordPos(PGLOBAL g); virtual bool RecordPos(PGLOBAL g);
virtual int SkipRecord(PGLOBAL g, bool header); virtual int SkipRecord(PGLOBAL g, bool header);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int DeleteRecords(PGLOBAL g, int irc); virtual int DeleteRecords(PGLOBAL g, int irc);
virtual void CloseTableFile(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void Rewind(void); virtual void Rewind(void);
protected: protected:
// Members // Members
char *CurLine; // Position of current line in buffer char *CurLine; // Position of current line in buffer
char *NxtLine; // Position of Next line in buffer char *NxtLine; // Position of Next line in buffer
bool Closing; // True when closing on Insert bool Closing; // True when closing on Insert
}; // end of class ZBKFAM }; // end of class ZBKFAM
/***********************************************************************/ /***********************************************************************/
/* This is the access method class declaration for fixed record */ /* This is the access method class declaration for fixed record */
/* length files compressed using the gzip library functions. */ /* length files compressed using the gzip library functions. */
/* The file is always accessed by block. */ /* The file is always accessed by block. */
/***********************************************************************/ /***********************************************************************/
class DllExport ZIXFAM : public ZBKFAM { class DllExport ZIXFAM : public ZBKFAM {
public: public:
// Constructor // Constructor
ZIXFAM(PDOSDEF tdp); ZIXFAM(PDOSDEF tdp);
ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {} ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {}
// Implementation // Implementation
virtual int GetNextPos(void) {return 0;} virtual int GetNextPos(void) {return 0;}
virtual PTXF Duplicate(PGLOBAL g) virtual PTXF Duplicate(PGLOBAL g)
{return (PTXF)new(g) ZIXFAM(this);} {return (PTXF)new(g) ZIXFAM(this);}
// Methods // Methods
virtual int Cardinality(PGLOBAL g); virtual int Cardinality(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
protected: protected:
// No additional Members // No additional Members
}; // end of class ZIXFAM }; // end of class ZIXFAM
#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. */ /* Physically these are written and read using the same technique */
/* Physically these are written and read using the same technique */ /* than blocked variable files, only the contain of each block is */
/* than blocked variable files, only the contain of each block is */ /* compressed using the deflate zlib function. The purpose of this */
/* compressed using the deflate zlib function. The purpose of this */ /* specific format is to have a fast mechanism for direct access of */
/* specific format is to have a fast mechanism for direct access of */ /* records so blocked optimization is fast and direct access (joins) */
/* records so blocked optimization is fast and direct access (joins) */ /* is allowed. Note that the block length is written ahead of each */
/* is allowed. Note that the block length is written ahead of each */ /* block to enable reading when optimization file is not available. */
/* block to enable reading when optimization file is not available. */ /***********************************************************************/
/***********************************************************************/ class DllExport ZLBFAM : public BLKFAM {
class DllExport ZLBFAM : public BLKFAM { public:
public: // Constructor
// Constructor ZLBFAM(PDOSDEF tdp);
ZLBFAM(PDOSDEF tdp); ZLBFAM(PZLBFAM txfp);
ZLBFAM(PZLBFAM txfp);
// Implementation
// Implementation virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;}
virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;} virtual int GetPos(void);
virtual int GetPos(void); virtual int GetNextPos(void);
virtual int GetNextPos(void); virtual PTXF Duplicate(PGLOBAL g)
virtual PTXF Duplicate(PGLOBAL g) {return (PTXF)new(g) ZLBFAM(this);}
{return (PTXF)new(g) ZLBFAM(this);} inline void SetOptimized(bool b) {Optimized = b;}
inline void SetOptimized(bool b) {Optimized = b;}
// Methods
// Methods virtual int GetFileLength(PGLOBAL g);
virtual int GetFileLength(PGLOBAL g); virtual bool AllocateBuffer(PGLOBAL g);
virtual bool AllocateBuffer(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); virtual int WriteBuffer(PGLOBAL g);
virtual int WriteBuffer(PGLOBAL g); virtual void CloseTableFile(PGLOBAL g);
virtual void CloseTableFile(PGLOBAL g); virtual void Rewind(void);
virtual void Rewind(void);
protected:
protected: bool WriteCompressedBuffer(PGLOBAL g);
bool WriteCompressedBuffer(PGLOBAL g); int ReadCompressedBuffer(PGLOBAL g, void *rdbuf);
int ReadCompressedBuffer(PGLOBAL g, void *rdbuf);
// Members
// Members z_streamp Zstream; // Compression/decompression stream
z_streamp Zstream; // Compression/decompression stream Byte *Zbuffer; // Compressed block buffer
Byte *Zbuffer; // Compressed block buffer 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 // BLK_INDX #endif // __FILAMZIP_H
#endif // __FILAMZIP_H

View File

@@ -68,7 +68,7 @@ PPARM MakeParm(PGLOBAL g, PXOB xp)
bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool); bool PlugEvalLike(PGLOBAL, LPCSTR, LPCSTR, bool);
//bool ReadSubQuery(PGLOBAL, PSUBQ); //bool ReadSubQuery(PGLOBAL, PSUBQ);
//PSUBQ OpenSubQuery(PGLOBAL, PSQL); //PSUBQ OpenSubQuery(PGLOBAL, PSQL);
void PlugCloseDB(PGLOBAL, PSQL); //void PlugCloseDB(PGLOBAL, PSQL);
BYTE OpBmp(PGLOBAL g, OPVAL opc); BYTE OpBmp(PGLOBAL g, OPVAL opc);
PARRAY MakeValueArray(PGLOBAL g, PPARM pp); PARRAY MakeValueArray(PGLOBAL g, PPARM pp);
@@ -201,6 +201,7 @@ FILTER::FILTER(PFIL fil1)
Test[1] = fil1->Test[1]; Test[1] = fil1->Test[1];
} // end of FILTER copy constructor } // end of FILTER copy constructor
#if 0
/***********************************************************************/ /***********************************************************************/
/* Linearize: Does the linearization of the filter tree: */ /* Linearize: Does the linearization of the filter tree: */
/* Independent filters (not implied in OR/NOT) will be separated */ /* Independent filters (not implied in OR/NOT) will be separated */
@@ -388,7 +389,6 @@ int FILTER::RefNum(PSQL sqlp)
return n; return n;
} // end of RefNum } // end of RefNum
#if 0
/***********************************************************************/ /***********************************************************************/
/* CheckSubQuery: see SUBQUERY::CheckSubQuery for comment. */ /* CheckSubQuery: see SUBQUERY::CheckSubQuery for comment. */
/***********************************************************************/ /***********************************************************************/
@@ -747,7 +747,6 @@ bool FILTER::CheckHaving(PGLOBAL g, PSQL sqlp)
sqlp->SetOk(FALSE); sqlp->SetOk(FALSE);
return FALSE; return FALSE;
} // end of CheckHaving } // end of CheckHaving
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* Used while building a table index. This function split the filter */ /* Used while building a table index. This function split the filter */
@@ -924,6 +923,7 @@ int FILTER::CheckSpcCol(PTDB tdbp, int n)
return max(n1, n2); return max(n1, n2);
} // end of CheckSpcCol } // end of CheckSpcCol
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* Reset the filter arguments to non evaluated yet. */ /* Reset the filter arguments to non evaluated yet. */

View File

@@ -53,25 +53,25 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
virtual bool Init(PGLOBAL); virtual bool Init(PGLOBAL);
virtual bool Eval(PGLOBAL); virtual bool Eval(PGLOBAL);
virtual bool SetFormat(PGLOBAL, FORMAT&) {return TRUE;} // NUY virtual bool SetFormat(PGLOBAL, FORMAT&) {return TRUE;} // NUY
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag); //virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag);
virtual int RefNum(PSQL); //virtual int RefNum(PSQL);
virtual PXOB SetSelect(PGLOBAL, PSQL, bool) {return NULL;} // NUY //virtual PXOB SetSelect(PGLOBAL, PSQL, bool) {return NULL;} // NUY
//virtual PXOB CheckSubQuery(PGLOBAL, PSQL); //virtual PXOB CheckSubQuery(PGLOBAL, PSQL);
virtual bool CheckLocal(PTDB); //virtual bool CheckLocal(PTDB);
virtual int CheckSpcCol(PTDB tdbp, int n); //virtual int CheckSpcCol(PTDB tdbp, int n);
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);
PFIL Linearize(bool nosep); // PFIL Linearize(bool nosep);
PFIL Link(PGLOBAL g, PFIL fil2); // PFIL Link(PGLOBAL g, PFIL fil2);
PFIL RemoveLastSep(void); // PFIL RemoveLastSep(void);
// PFIL SortJoin(PGLOBAL g); // PFIL SortJoin(PGLOBAL g);
// bool FindJoinFilter(POPJOIN opj, PFIL fprec, bool teq, // bool FindJoinFilter(POPJOIN opj, PFIL fprec, bool teq,
// bool tek, bool tk2, bool tc2, bool tix, bool thx); // bool tek, bool tk2, bool tc2, bool tix, bool thx);
// bool CheckHaving(PGLOBAL g, PSQL sqlp); // bool CheckHaving(PGLOBAL g, PSQL sqlp);
bool Convert(PGLOBAL g, bool having); bool Convert(PGLOBAL g, bool having);
int SplitFilter(PFIL *fp); // int SplitFilter(PFIL *fp);
int SplitFilter(PFIL *fp, PTDB tp, int n); // int SplitFilter(PFIL *fp, PTDB tp, int n);
PFIL LinkFilter(PGLOBAL g, PFIL fp2); // PFIL LinkFilter(PGLOBAL g, PFIL fp2);
// PFIL Copy(PTABS t); // PFIL Copy(PTABS t);
protected: protected:

View File

@@ -1,260 +1,258 @@
/***********************************************************************/ /***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright Olivier Bertrand 1993-2012 */ /* (C) Copyright Olivier Bertrand 1993-2012 */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Included C-definition files common to all Plug routines */ /* Included C-definition files common to all Plug routines */
/***********************************************************************/ /***********************************************************************/
#include <string.h> /* String manipulation declares */ #include <string.h> /* String manipulation declares */
#include <stdlib.h> /* C standard library */ #include <stdlib.h> /* C standard library */
#include <ctype.h> /* C language specific types */ #include <ctype.h> /* C language specific types */
#include <stdio.h> /* FOPEN_MAX declaration */ #include <stdio.h> /* FOPEN_MAX declaration */
#include <time.h> /* time_t type declaration */ #include <time.h> /* time_t type declaration */
#include <setjmp.h> /* Long jump declarations */ #include <setjmp.h> /* Long jump declarations */
#if defined(WIN32) && !defined(NOEX) #if defined(WIN32) && !defined(NOEX)
#define DllExport __declspec( dllexport ) #define DllExport __declspec( dllexport )
#else // !WIN32 #else // !WIN32
#define DllExport #define DllExport
#endif // !WIN32 #endif // !WIN32
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) #if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT)
#define XML_SUPPORT 1 #define XML_SUPPORT 1
#endif #endif
#if defined(XMSG) #if defined(XMSG)
// Definition used to read messages from message file. // Definition used to read messages from message file.
#include "msgid.h" #include "msgid.h"
#define MSG(I) PlugReadMessage(NULL, MSG_##I, #I) #define MSG(I) PlugReadMessage(NULL, MSG_##I, #I)
#define STEP(I) PlugReadMessage(g, MSG_##I, #I) #define STEP(I) PlugReadMessage(g, MSG_##I, #I)
#elif defined(NEWMSG) #elif defined(NEWMSG)
// Definition used to get messages from resource. // Definition used to get messages from resource.
#include "msgid.h" #include "msgid.h"
#define MSG(I) PlugGetMessage(NULL, MSG_##I) #define MSG(I) PlugGetMessage(NULL, MSG_##I)
#define STEP(I) PlugGetMessage(g, MSG_##I) #define STEP(I) PlugGetMessage(g, MSG_##I)
#else // !XMSG and !NEWMSG #else // !XMSG and !NEWMSG
// Definition used to replace messages ID's by their definition. // Definition used to replace messages ID's by their definition.
#include "messages.h" #include "messages.h"
#define MSG(I) MSG_##I #define MSG(I) MSG_##I
#define STEP(I) MSG_##I #define STEP(I) MSG_##I
#endif // !XMSG and !NEWMSG #endif // !XMSG and !NEWMSG
#if defined(WIN32) #if defined(WIN32)
#define CRLF 2 #define CRLF 2
#else // !WIN32 #else // !WIN32
#define CRLF 1 #define CRLF 1
#endif // !WIN32 #endif // !WIN32
/***********************************************************************/ /***********************************************************************/
/* Miscellaneous Constants */ /* Miscellaneous Constants */
/***********************************************************************/ /***********************************************************************/
#define NO_IVAL -95684275 /* Used by GetIntegerOption */ #define NO_IVAL -95684275 /* Used by GetIntegerOption */
#define VMLANG 370 /* Size of olf VM lang blocks */ #define VMLANG 370 /* Size of olf VM lang blocks */
#define MAX_JUMP 24 /* Maximum jump level number */ #define MAX_JUMP 24 /* Maximum jump level number */
#define MAX_STR 1024 /* Maximum string length */ #define MAX_STR 1024 /* Maximum string length */
#define STR_SIZE 501 /* Length of char strings. */ #define STR_SIZE 501 /* Length of char strings. */
#define STD_INPUT 0 /* Standard language input */ #define STD_INPUT 0 /* Standard language input */
#define STD_OUTPUT 1 /* Standard language output */ #define STD_OUTPUT 1 /* Standard language output */
#define ERROR_OUTPUT 2 /* Error message output */ #define ERROR_OUTPUT 2 /* Error message output */
#define DEBUG_OUTPUT 3 /* Debug info output */ #define DEBUG_OUTPUT 3 /* Debug info output */
#define PROMPT_OUTPUT 4 /* Prompt message output */ #define PROMPT_OUTPUT 4 /* Prompt message output */
#define COPY_OUTPUT 5 /* Copy of language input */ #define COPY_OUTPUT 5 /* Copy of language input */
#define STD_MSG 6 /* System message file */ #define STD_MSG 6 /* System message file */
#define DEBUG_MSG 7 /* Debug message file */ #define DEBUG_MSG 7 /* Debug message file */
#define DUMMY 0 /* Dummy file index in Ldm block */ #define DUMMY 0 /* Dummy file index in Ldm block */
#define STDIN 1 /* stdin file index in Ldm block */ #define STDIN 1 /* stdin file index in Ldm block */
#define STDOUT 2 /* stdout file index in Ldm block */ #define STDOUT 2 /* stdout file index in Ldm block */
#define STDERR 3 /* stderr file index in Ldm block */ #define STDERR 3 /* stderr file index in Ldm block */
#define STDEBUG 4 /* debug file index in Ldm block */ #define STDEBUG 4 /* debug file index in Ldm block */
#define STDPRN 5 /* stdprn file index in Ldm block */ #define STDPRN 5 /* stdprn file index in Ldm block */
#define STDFREE 6 /* Free file index in Ldm block */ #define STDFREE 6 /* Free file index in Ldm block */
#define TYPE_SEM -2 /* Returned semantic function */ #define TYPE_SEM -2 /* Returned semantic function */
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */ #define TYPE_DFONC -2 /* Indirect sem ref in FPARM */
#define TYPE_VOID -1 #define TYPE_VOID -1
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */ #define TYPE_SBPAR -1 /* Phrase reference in FPARM */
#define TYPE_SEMX 0 /* Initial semantic function type? */ #define TYPE_SEMX 0 /* Initial semantic function type? */
#define TYPE_ERROR 0 #define TYPE_ERROR 0
#define TYPE_STRING 1 #define TYPE_STRING 1
#define TYPE_DOUBLE 2 #define TYPE_DOUBLE 2
#define TYPE_SHORT 3 #define TYPE_SHORT 3
#define TYPE_TINY 4 #define TYPE_TINY 4
#define TYPE_BIGINT 5 #define TYPE_BIGINT 5
#define TYPE_LIST 6 #define TYPE_LIST 6
#define TYPE_INT 7 #define TYPE_INT 7
#define TYPE_DECIM 9 #define TYPE_DECIM 9
#if defined(OS32) #if defined(OS32)
#define SYS_STAMP "OS32" #define SYS_STAMP "OS32"
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) #elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
#define SYS_STAMP "UNIX" #define SYS_STAMP "UNIX"
#elif defined(OS16) #elif defined(OS16)
#define SYS_STAMP "OS16" #define SYS_STAMP "OS16"
#elif defined(DOSR) #elif defined(DOSR)
#define SYS_STAMP "DOSR" #define SYS_STAMP "DOSR"
#elif defined(WIN) #elif defined(WIN)
#define SYS_STAMP "WIN1" #define SYS_STAMP "WIN1"
#elif defined(WIN32) #elif defined(WIN32)
#define SYS_STAMP "WIN2" #define SYS_STAMP "WIN2"
#else #else
#define SYS_STAMP "XXXX" #define SYS_STAMP "XXXX"
#endif #endif
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
/***********************************************************************/ /***********************************************************************/
/* Static variables */ /* Static variables */
/***********************************************************************/ /***********************************************************************/
#if defined(STORAGE) #if defined(STORAGE)
char sys_stamp[4] = SYS_STAMP; char sys_stamp[4] = SYS_STAMP;
#else #else
extern char sys_stamp[]; extern char sys_stamp[];
#endif #endif
/***********************************************************************/ /***********************************************************************/
/* File-Selection Indicators */ /* File-Selection Indicators */
/***********************************************************************/ /***********************************************************************/
#define PAT_LOG "log" #define PAT_LOG "log"
#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) #if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
/*********************************************************************/ /*********************************************************************/
/* printf does not accept null pointer for %s target. */ /* printf does not accept null pointer for %s target. */
/*********************************************************************/ /*********************************************************************/
#define SVP(S) ((S) ? S : "<null>") #define SVP(S) ((S) ? S : "<null>")
#else #else
/*********************************************************************/ /*********************************************************************/
/* printf accepts null pointer for %s target. */ /* printf accepts null pointer for %s target. */
/*********************************************************************/ /*********************************************************************/
#define SVP(S) S #define SVP(S) S
#endif #endif
#if defined(STORAGE) #if defined(STORAGE)
FILE *debug; FILE *debug;
#else #else
extern FILE *debug; extern FILE *debug;
#endif #endif
/***********************************************************************/ /***********************************************************************/
/* General purpose type definitions. */ /* General purpose type definitions. */
/***********************************************************************/ /***********************************************************************/
#include "os.h" #include "os.h"
typedef uint OFFSET; typedef uint OFFSET;
typedef char NAME[9]; typedef char NAME[9];
typedef struct { typedef struct {
ushort Length; ushort Length;
char String[2]; char String[2];
} VARSTR; } VARSTR;
#if !defined(PGLOBAL_DEFINED) #if !defined(PGLOBAL_DEFINED)
typedef struct _global *PGLOBAL; typedef struct _global *PGLOBAL;
#define PGLOBAL_DEFINED #define PGLOBAL_DEFINED
#endif #endif
typedef struct _globplg *PGS; typedef struct _globplg *PGS;
typedef struct _activity *PACTIVITY; typedef struct _activity *PACTIVITY;
typedef struct _parm *PPARM; typedef struct _parm *PPARM;
/***********************************************************************/ /***********************************************************************/
/* Segment Sub-Allocation block structure declares. */ /* Segment Sub-Allocation block structure declares. */
/* Next block is an implementation dependent segment suballoc save */ /* Next block is an implementation dependent segment suballoc save */
/* structure used to keep the suballocation system offsets and to */ /* structure used to keep the suballocation system offsets and to */
/* restore them if needed. This scheme implies that no SubFree be used */ /* restore them if needed. This scheme implies that no SubFree be used */
/***********************************************************************/ /***********************************************************************/
typedef struct { /* Plug Area SubAlloc header */ typedef struct { /* Plug Area SubAlloc header */
OFFSET To_Free; /* Offset of next free block */ OFFSET To_Free; /* Offset of next free block */
uint FreeBlk; /* Size of remaining free memory */ uint FreeBlk; /* Size of remaining free memory */
} POOLHEADER, *PPOOLHEADER; } POOLHEADER, *PPOOLHEADER;
/***********************************************************************/ /***********************************************************************/
/* Language block. Containing all global information for the language */ /* Language block. Containing all global information for the language */
/* this block is saved and retrieved with the language. Information */ /* this block is saved and retrieved with the language. Information */
/* in this block can be set and modified under Grammar editing. */ /* in this block can be set and modified under Grammar editing. */
/***********************************************************************/ /***********************************************************************/
#if defined(BIT64) #if defined(BIT64)
typedef int TIME_T; /* Lang block size must not change */ typedef int TIME_T; /* Lang block size must not change */
#else // BIT32 #else // BIT32
typedef time_t TIME_T; /* time_t */ typedef time_t TIME_T; /* time_t */
#endif // BIT32 #endif // BIT32
typedef struct { typedef struct {
uint Memsize; uint Memsize;
uint Size; uint Size;
} AREADEF; } AREADEF;
typedef struct Lang_block { typedef struct Lang_block {
NAME LangName; /* Language name */ NAME LangName; /* Language name */
NAME Application; /* Application name */ NAME Application; /* Application name */
} LANG, *PLANG; } LANG, *PLANG;
/***********************************************************************/ /***********************************************************************/
/* Application block. It contains all global information for the */ /* Application block. It contains all global information for the */
/* current parse and execution using the corresponding language. */ /* current parse and execution using the corresponding language. */
/* This block is dynamically allocated and set at language init. */ /* This block is dynamically allocated and set at language init. */
/***********************************************************************/ /***********************************************************************/
typedef struct _activity { /* Describes activity and language */ typedef struct _activity { /* Describes activity and language */
void *Aptr; /* Points to user work area(s) */ void *Aptr; /* Points to user work area(s) */
NAME Ap_Name; /* Current application name */ NAME Ap_Name; /* Current application name */
} ACTIVITY; } ACTIVITY;
/*---------------- UNIT ?????????? VERSION ? ----------------------*/ /*---------------- UNIT ?????????? VERSION ? ----------------------*/
typedef struct _parm { typedef struct _parm {
void *Value; void *Value;
short Type, Domain; short Type, Domain;
PPARM Next; PPARM Next;
} PARM; } PARM;
/***********************************************************************/ /***********************************************************************/
/* Global Structure Block. This block contains, or points to, all */ /* Global Structure Block. This block contains, or points to, all */
/* information used by CONNECT tables. Passed as an argument */ /* information used by CONNECT tables. Passed as an argument */
/* to any routine allows it to have access to the entire information */ /* to any routine allows it to have access to the entire information */
/* currently available for the whole set of loaded languages. */ /* currently available for the whole set of loaded languages. */
/***********************************************************************/ /***********************************************************************/
typedef struct _global { /* Global structure */ typedef struct _global { /* Global structure */
void *Sarea; /* Points to work area */ void *Sarea; /* Points to work area */
uint Sarea_Size; /* Work area size */ uint Sarea_Size; /* Work area size */
PACTIVITY Activityp, ActivityStart; PACTIVITY Activityp, ActivityStart;
char Message[MAX_STR]; char Message[MAX_STR];
int Createas; /* To pass info to created table */ int Createas; /* To pass info to created table */
void *Xchk; /* indexes in create/alter */ void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */ short Alchecked; /* Checked for ALTER */
#if defined(MRRBKA_SUPPORT) short Mrr; /* True when doing mrr */
short Mrr; /* True when doing mrr */ short Trace;
#endif // MRRBKA_SUPPORT int jump_level;
short Trace; jmp_buf jumper[MAX_JUMP + 2];
int jump_level; } GLOBAL;
jmp_buf jumper[MAX_JUMP + 2];
} GLOBAL; /***********************************************************************/
/* Exported routine declarations. */
/***********************************************************************/ /***********************************************************************/
/* Exported routine declarations. */ #if defined(XMSG)
/***********************************************************************/ DllExport char *PlugReadMessage(PGLOBAL, int, char *);
#if defined(XMSG) #elif defined(NEWMSG)
DllExport char *PlugReadMessage(PGLOBAL, int, char *); DllExport char *PlugGetMessage(PGLOBAL, int);
#elif defined(NEWMSG) #endif // XMSG || NEWMSG
DllExport char *PlugGetMessage(PGLOBAL, int); #if defined(WIN32)
#endif // XMSG || NEWMSG DllExport short GetLineLength(PGLOBAL); // Console line length
#if defined(WIN32) #endif // WIN32
DllExport short GetLineLength(PGLOBAL); // Console line length DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization
#endif // WIN32 DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
DllExport int PlugExit(PGLOBAL); // Plug global termination DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir);
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir); DllExport void *PlugAllocMem(PGLOBAL, uint);
DllExport BOOL PlugIsAbsolutePath(LPCSTR path); DllExport BOOL PlugSubSet(PGLOBAL, void *, uint);
DllExport void *PlugAllocMem(PGLOBAL, uint); DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); DllExport char *PlugDup(PGLOBAL g, const char *str);
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); DllExport void *MakePtr(void *, OFFSET);
DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport void htrc(char const *fmt, ...);
DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...); #if defined(__cplusplus)
} // extern "C"
#if defined(__cplusplus) #endif
} // extern "C"
#endif /*-------------------------- End of Global.H --------------------------*/
/*-------------------------- End of Global.H --------------------------*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -63,15 +63,10 @@ class DllItem MYSQLC {
bool Connected(void); bool Connected(void);
// Methods // Methods
// int GetCurPos(void) {return (m_Res) ? N : 0;}
// int GetProgCur(void) {return N;}
int GetResultSize(PGLOBAL g, PSZ sql); int GetResultSize(PGLOBAL g, PSZ sql);
int Open(PGLOBAL g, const char *host, const char *db, int Open(PGLOBAL g, const char *host, const char *db,
const char *user= "root", const char *pwd= "*", const char *user= "root", const char *pwd= "*",
int pt= 0); int pt= 0);
//ulong GetThreadID(void);
//ulong ServerVersion(void);
//const char *ServerInfo(void);
int KillQuery(ulong id); int KillQuery(ulong id);
int ExecSQL(PGLOBAL g, const char *query, int *w = NULL); int ExecSQL(PGLOBAL g, const char *query, int *w = NULL);
int ExecSQLcmd(PGLOBAL g, const char *query, int *w); int ExecSQLcmd(PGLOBAL g, const char *query, int *w);
@@ -87,7 +82,6 @@ class DllItem MYSQLC {
void Rewind(void); void Rewind(void);
void FreeResult(void); void FreeResult(void);
void Close(void); void Close(void);
//void DiscardResults(void);
protected: protected:
MYSQL_FIELD *GetNextField(void); MYSQL_FIELD *GetNextField(void);

View File

@@ -62,146 +62,6 @@ enum INFO {INDX_RC, /* Index of PlugDB return code field */
INDX_SIZE, /* Index of returned data size field */ INDX_SIZE, /* Index of returned data size field */
INDX_MAX}; /* Size of info array */ INDX_MAX}; /* Size of info array */
#ifdef NOT_USED
/**************************************************************************/
/* Internal message types. */
/**************************************************************************/
enum MSGTYP {MST_OPEN = 10, /* Code for old connecting message */
MST_COMMAND = 11, /* Code for send command message */
MST_RESULT = 12, /* Code for get result message */
MST_CLOSE = 13, /* Code for disconnecting message */
MST_PROGRESS = 14, /* Code for progress message */
MST_CANCEL = 15, /* Code for cancel message */
MST_PROCESSED = 16, /* Code for already processed msg */
MST_ERROR = 17, /* Code for get error message */
MST_CHAR = 18, /* Code for get char value message */
MST_LONG = 19, /* Code for get int value message */
MST_COLUMN = 20, /* Code for get col value message */
MST_MESSAGE = 21, /* Code for get message message */
MST_HEADER = 22, /* Code for get header message */
MST_SOCKET = 23, /* Code for socket error message */
MST_SHUTDOWN = 24, /* Code for shutdown message */
MST_SOCKPROG = 25, /* Code for socket progress message */
MST_POST = 26, /* Code for post command message */
MST_NEW_OPEN = 27, /* Code for new connecting message */
MST_PROG_NUM = 5}; /* Num of integers in progress msg */
/**************************************************************************/
/* Vendors. */
/**************************************************************************/
enum VENDOR {VDR_UNKNOWN = -2, /* Not known or not connected */
VDR_PlugDB = -1, /* PlugDB */
VDR_OTHER = 0}; /* OEM */
/**************************************************************************/
/* Attribute keys of Result Description structure (arranged by type). */
/**************************************************************************/
enum CKEYS {K_ProgMsg, K_Lang, K_ActiveDB, K_Cmax};
enum LKEYS {K_NBcol, K_NBlin, K_CurPos, K_RC, K_Result, K_Elapsed,
K_Continued, K_Maxsize, K_Affrows, K_Lmax, K_Maxcol,
K_Maxres, K_Maxlin, K_NBparm};
enum NKEYS {K_Type, K_Length, K_Prec, K_DataLen, K_Unsigned, K_Nmax};
/**************************************************************************/
/* Result description structures. */
/**************************************************************************/
typedef struct _MsgTagAttr {
bool fSupplied;
char Attr[MAXMESSAGE];
} MTAG, *PMTAG;
typedef struct _CharTagAttr {
bool fSupplied;
char Attr[MAXDBNAME];
} CTAG, *PCTAG;
typedef struct _LongTagAttr {
bool fSupplied;
int Attr;
} LTAG, *PLTAG;
typedef struct _ColVar {
LTAG Lat[K_Nmax];
CTAG Cat;
} COLVAR, *LPCOLVAR;
typedef struct _ResDesc {
int Maxcol; /* Max number of columns */
int Colnum; /* Number of columns */
MTAG Mat; /* Message */
CTAG Cat[K_Cmax]; /* Character attributes */
LTAG Lat[K_Lmax]; /* Long int attributes */
COLVAR Col[1]; /* Column attributes */
} RDESC, *PRDESC;
/**************************************************************************/
/* Exported PlugDB client functions in Plgcnx DLL. */
/**************************************************************************/
#if !defined(CNXFUNC)
#if defined(UNIX) || defined(UNIV_LINUX)
#undef __stdcall
#define __stdcall
#endif
#if defined(NOLIB) /* Dynamic link of plgcnx.dll */
#define CNXFUNC(f) (__stdcall *f)
#else /* LIB */ /* Static link with plgcnx.lib */
#define CNXFUNC(f) __stdcall f
#endif
#endif
#if !defined(CNXKEY)
#define CNXKEY uint
#endif
#if !defined(XTRN)
#define XTRN
#endif
//#if !defined(NO_FUNC)
#ifdef __cplusplus
extern "C" {
#endif
XTRN int CNXFUNC(PLGConnect) (CNXKEY *, const char *, bool);
XTRN int CNXFUNC(PLGSendCommand) (CNXKEY, const char *, void *, int, int *);
XTRN int CNXFUNC(PLGGetResult) (CNXKEY, void *, int, int *, bool);
XTRN int CNXFUNC(PLGDisconnect) (CNXKEY);
XTRN int CNXFUNC(PLGGetErrorMsg) (CNXKEY, char *, int, int *);
XTRN bool CNXFUNC(PLGGetCharValue)(CNXKEY, char *, int, int);
XTRN bool CNXFUNC(PLGGetIntValue)(CNXKEY, int *, int);
XTRN bool CNXFUNC(PLGGetColValue) (CNXKEY, int *, int, int);
XTRN bool CNXFUNC(PLGGetMessage) (CNXKEY, char *, int);
XTRN bool CNXFUNC(PLGGetHeader) (CNXKEY, char *, int, int, int);
#ifdef __cplusplus
}
#endif
//#endif /* !NO_FUNC */
/**************************************************************************/
/* Convenience function Definitions */
/**************************************************************************/
#define PLGPostCommand(T,C) PLGSendCommand(T,C,NULL,0,NULL)
#if defined(FNCMAC)
#define PLGGetProgMsg(T,C,S) PLGGetCharValue(T,C,S,K_ProgMsg)
#define PLGGetLangID(T,C,S) PLGGetCharValue(T,C,S,K_Lang)
#define PLGGetActiveDB(T,C,S) PLGGetCharValue(T,C,S,K_ActiveDB)
#define PLGGetCursorPos(T,L) PLGGetIntValue(T,L,K_CurPos)
#define PLGGetResultType(T,L) PLGGetIntValue(T,L,K_Result)
#define PLGGetNBcol(T,L) PLGGetIntValue(T,L,K_NBcol)
#define PLGGetNBlin(T,L) PLGGetIntValue(T,L,K_NBlin)
#define PLGGetRetCode(T,L) PLGGetIntValue(T,L,K_RC)
#define PLGGetElapsed(T,L) PLGGetIntValue(T,L,K_Elapsed)
#define PLGGetContinued(T,L) PLGGetIntValue(T,L,K_Continued)
#define PLGGetMaxSize(T,L) PLGGetIntValue(T,L,K_Maxsize)
#define PLGGetLength(T,L,C) PLGGetColValue(T,L,K_Length,C)
#define PLGGetDataSize(T,L,C) PLGGetColValue(T,L,K_DataLen,C)
#define PLGGetDecimal(T,L,C) PLGGetColValue(T,L,K_Prec,C)
#define PLGGetType(T,L,C) PLGGetColValue(T,L,K_Type,C)
#endif /* FNCMAC */
#endif // NOT_USED
#endif /* !_PLGCNX_H */ #endif /* !_PLGCNX_H */
/* ------------------------- End of Plgcnx.h ---------------------------- */ /* ------------------------- End of Plgcnx.h ---------------------------- */

File diff suppressed because it is too large Load Diff

View File

@@ -374,18 +374,7 @@ PDBUSER PlgMakeUser(PGLOBAL g)
} // endif dbuserp } // endif dbuserp
memset(dbuserp, 0, sizeof(DBUSERBLK)); memset(dbuserp, 0, sizeof(DBUSERBLK));
//dbuserp->Act2 = g->Activityp;
//#if defined(UNIX)
// dbuserp->LineLen = 160;
//#else
// dbuserp->LineLen = 78;
//#endif
//dbuserp->Maxres = MAXRES;
//dbuserp->Maxlin = MAXLIN;
#if defined(BLK_INDX)
dbuserp->Maxbmp = MAXBMP; dbuserp->Maxbmp = MAXBMP;
#endif // BLK_INDX
//dbuserp->AlgChoice = AMOD_AUTO;
dbuserp->UseTemp = TMP_AUTO; dbuserp->UseTemp = TMP_AUTO;
dbuserp->Check = CHK_ALL; dbuserp->Check = CHK_ALL;
strcpy(dbuserp->Server, "CONNECT"); strcpy(dbuserp->Server, "CONNECT");

File diff suppressed because it is too large Load Diff

View File

@@ -3,31 +3,6 @@
#include "checklvl.h" #include "checklvl.h"
/***********************************************************************/
/* Struct of variables used by the SQL pre-parsers. */
/***********************************************************************/
typedef struct _prepar {
struct _prepar *Next;
char *Debinp; // Start of input buffer
char *Endinp; // End of input buffer
char *Pluginp; // Points on current parsing position
char *Plugbuf; // Start of output buffer
char *Plugptr; // Current output position
char *Debchar; // Next/current start of command
char *Debselp; // Beginning of selection
char *Debline; // Start of current line
char *Plugpar[32]; // Parameters
int Numparms; // Number of defined parameters
int Nprms; // Number of ODBC parameters
int Lines; // Line number
int Chars; // Index of selection start in line
int Endchars; // Index of selection end in line
int Frinp, Frbuf; // 0: no, 1: free, 2: delete Debinp/Plugbuf
int Outsize; // Size of output buffer
FILE *Argfile; // File containing arguments
int Addargs; // 1 if arguments are added to the list
} PREPAR, *PPREP;
/***********************************************************************/ /***********************************************************************/
/* Struct of variables used by the date format pre-parser. */ /* Struct of variables used by the date format pre-parser. */
/***********************************************************************/ /***********************************************************************/
@@ -49,8 +24,6 @@ typedef struct _datpar {
extern "C" { extern "C" {
#endif #endif
int sqlflex(PPREP pp);
int sqpflex(PPREP pp);
int fmdflex(PDTP pp); int fmdflex(PDTP pp);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -1,444 +1,436 @@
/************* RelDef CPP Program Source Code File (.CPP) **************/ /************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: REFDEF */ /* PROGRAM NAME: REFDEF */
/* ------------- */ /* ------------- */
/* Version 1.3 */ /* Version 1.4 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
/* This program are the DB definition related routines. */ /* This program are the DB definition related routines. */
/* */ /* */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Include relevant MariaDB header file. */ /* Include relevant MariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
#if defined(WIN32) #if defined(WIN32)
#include <sqlext.h> #include <sqlext.h>
#else #else
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ... #include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
#include "osutil.h" #include "osutil.h"
//#include "sqlext.h" //#include "sqlext.h"
#endif #endif
/***********************************************************************/ /***********************************************************************/
/* Include application header files */ /* Include application header files */
/* */ /* */
/* global.h is header containing all global declarations. */ /* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing DB application declarations. */ /* plgdbsem.h is header containing DB application declarations. */
/* catalog.h is header containing DB description declarations. */ /* catalog.h is header containing DB description declarations. */
/***********************************************************************/ /***********************************************************************/
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "mycat.h" #include "mycat.h"
#include "reldef.h" #include "reldef.h"
#include "colblk.h" #include "colblk.h"
#include "filamap.h" #include "filamap.h"
#include "filamfix.h" #include "filamfix.h"
#include "filamvct.h" #include "filamvct.h"
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
#include "filamzip.h" #include "filamzip.h"
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
#include "tabdos.h" #include "tabdos.h"
#include "valblk.h" #include "valblk.h"
#include "tabmul.h" #include "tabmul.h"
/***********************************************************************/ /***********************************************************************/
/* External static variables. */ /* External static variables. */
/***********************************************************************/ /***********************************************************************/
//extern "C" char plgini[]; //extern "C" char plgini[];
/* --------------------------- Class RELDEF -------------------------- */ /* --------------------------- Class RELDEF -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* RELDEF Constructor. */ /* RELDEF Constructor. */
/***********************************************************************/ /***********************************************************************/
RELDEF::RELDEF(void) RELDEF::RELDEF(void)
{ {
Next = NULL; Next = NULL;
To_Cols = NULL; To_Cols = NULL;
Name = NULL; Name = NULL;
Database = NULL; Database = NULL;
Cat = NULL; Cat = NULL;
} // end of RELDEF constructor } // end of RELDEF constructor
/* --------------------------- Class TABDEF -------------------------- */ /* --------------------------- Class TABDEF -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* TABDEF Constructor. */ /* TABDEF Constructor. */
/***********************************************************************/ /***********************************************************************/
TABDEF::TABDEF(void) TABDEF::TABDEF(void)
{ {
Schema = NULL; Schema = NULL;
Desc = NULL; Desc = NULL;
Catfunc = FNC_NO; Catfunc = FNC_NO;
Card = 0; Card = 0;
Elemt = 0; Elemt = 0;
Sort = 0; Sort = 0;
Multiple = 0; Multiple = 0;
Degree = 0; Degree = 0;
Pseudo = 0; Pseudo = 0;
Read_Only = false; Read_Only = false;
} // end of TABDEF constructor } // end of TABDEF constructor
/***********************************************************************/ /***********************************************************************/
/* Define: initialize the table definition block from XDB file. */ /* Define: initialize the table definition block from XDB file. */
/***********************************************************************/ /***********************************************************************/
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
{ {
int poff = 0; int poff = 0;
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1);
strcpy(Name, name); strcpy(Name, name);
Cat = cat; Cat = cat;
Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL)); Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL));
Elemt = cat->GetIntCatInfo("Elements", 0); Elemt = cat->GetIntCatInfo("Elements", 0);
Multiple = cat->GetIntCatInfo("Multiple", 0); Multiple = cat->GetIntCatInfo("Multiple", 0);
Degree = cat->GetIntCatInfo("Degree", 0); Degree = cat->GetIntCatInfo("Degree", 0);
Read_Only = cat->GetBoolCatInfo("ReadOnly", false); Read_Only = cat->GetBoolCatInfo("ReadOnly", false);
const char *data_charset_name= cat->GetStringCatInfo(g, "Data_charset", NULL); const char *data_charset_name= cat->GetStringCatInfo(g, "Data_charset", NULL);
m_data_charset= data_charset_name ? m_data_charset= data_charset_name ?
get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0): get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0):
NULL; NULL;
// Get The column definitions // Get The column definitions
if ((poff = cat->GetColCatInfo(g, this)) < 0) if ((poff = cat->GetColCatInfo(g, this)) < 0)
return true; return true;
// Do the definition of AM specific fields // Do the definition of AM specific fields
return DefineAM(g, am, poff); return DefineAM(g, am, poff);
} // end of Define } // end of Define
/* --------------------------- Class OEMDEF -------------------------- */ /* --------------------------- Class OEMDEF -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* GetXdef: get the external TABDEF from OEM module. */ /* GetXdef: get the external TABDEF from OEM module. */
/***********************************************************************/ /***********************************************************************/
PTABDEF OEMDEF::GetXdef(PGLOBAL g) PTABDEF OEMDEF::GetXdef(PGLOBAL g)
{ {
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *); typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *);
char c, getname[40] = "Get"; char c, getname[40] = "Get";
PTABDEF xdefp; PTABDEF xdefp;
XGETDEF getdef = NULL; XGETDEF getdef = NULL;
PCATLG cat = Cat; PCATLG cat = Cat;
#if defined(WIN32) #if defined(WIN32)
// Is the DLL already loaded? // Is the DLL already loaded?
if (!Hdll && !(Hdll = GetModuleHandle(Module))) if (!Hdll && !(Hdll = GetModuleHandle(Module)))
// No, load the Dll implementing the function // No, load the Dll implementing the function
if (!(Hdll = LoadLibrary(Module))) { if (!(Hdll = LoadLibrary(Module))) {
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module); sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
strcat(strcat(g->Message, ": "), buf); strcat(strcat(g->Message, ": "), buf);
return NULL; return NULL;
} // endif hDll } // endif hDll
// The exported name is always in uppercase // The exported name is always in uppercase
for (int i = 0; ; i++) { for (int i = 0; ; i++) {
c = Subtype[i]; c = Subtype[i];
getname[i + 3] = toupper(c); getname[i + 3] = toupper(c);
if (!c) break; if (!c) break;
} // endfor i } // endfor i
// Get the function returning an instance of the external DEF class // Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) { if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname); sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname);
FreeLibrary((HMODULE)Hdll); FreeLibrary((HMODULE)Hdll);
return NULL; return NULL;
} // endif getdef } // endif getdef
#else // !WIN32 #else // !WIN32
const char *error = NULL; const char *error = NULL;
// Is the library already loaded? // Is the library already loaded?
// if (!Hdll && !(Hdll = ???)) // if (!Hdll && !(Hdll = ???))
// Load the desired shared library // Load the desired shared library
if (!(Hdll = dlopen(Module, RTLD_LAZY))) { if (!(Hdll = dlopen(Module, RTLD_LAZY))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error)); sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error));
return NULL; return NULL;
} // endif Hdll } // endif Hdll
// The exported name is always in uppercase // The exported name is always in uppercase
for (int i = 0; ; i++) { for (int i = 0; ; i++) {
c = Subtype[i]; c = Subtype[i];
getname[i + 3] = toupper(c); getname[i + 3] = toupper(c);
if (!c) break; if (!c) break;
} // endfor i } // endfor i
// Get the function returning an instance of the external DEF class // Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) { if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) {
error = dlerror(); error = dlerror();
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error)); sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error));
dlclose(Hdll); dlclose(Hdll);
return NULL; return NULL;
} // endif getdef } // endif getdef
#endif // !WIN32 #endif // !WIN32
// Just in case the external Get function does not set error messages // Just in case the external Get function does not set error messages
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype);
// Get the table definition block // Get the table definition block
if (!(xdefp = getdef(g, NULL))) if (!(xdefp = getdef(g, NULL)))
return NULL; return NULL;
// Have the external class do its complete definition // Have the external class do its complete definition
if (!cat->Cbuf) { if (!cat->Cbuf) {
// Suballocate a temporary buffer for the entire column section // Suballocate a temporary buffer for the entire column section
cat->Cblen = cat->GetSizeCatInfo("Colsize", "8K"); cat->Cblen = cat->GetSizeCatInfo("Colsize", "8K");
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen); cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen);
} // endif Cbuf } // endif Cbuf
// Here "OEM" should be replace by a more useful value // Here "OEM" should be replace by a more useful value
if (xdefp->Define(g, cat, Name, "OEM")) if (xdefp->Define(g, cat, Name, "OEM"))
return NULL; return NULL;
// Ok, return external block // Ok, return external block
return xdefp; return xdefp;
} // end of GetXdef } // end of GetXdef
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
/* DeleteTableFile: Delete an OEM table file if applicable. */ /* DeleteTableFile: Delete an OEM table file if applicable. */
/***********************************************************************/ /***********************************************************************/
bool OEMDEF::DeleteTableFile(PGLOBAL g) bool OEMDEF::DeleteTableFile(PGLOBAL g)
{ {
if (!Pxdef) if (!Pxdef)
Pxdef = GetXdef(g); Pxdef = GetXdef(g);
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true; return (Pxdef) ? Pxdef->DeleteTableFile(g) : true;
} // end of DeleteTableFile } // end of DeleteTableFile
#endif // 0 #endif // 0
/***********************************************************************/ /***********************************************************************/
/* Define: initialize the table definition block from XDB file. */ /* Define: initialize the table definition block from XDB file. */
/***********************************************************************/ /***********************************************************************/
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
Module = Cat->GetStringCatInfo(g, "Module", ""); Module = Cat->GetStringCatInfo(g, "Module", "");
Subtype = Cat->GetStringCatInfo(g, "Subtype", Module); Subtype = Cat->GetStringCatInfo(g, "Subtype", Module);
if (!*Module) if (!*Module)
Module = Subtype; Module = Subtype;
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module) Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
+ strlen(Subtype) + 3); + strlen(Subtype) + 3);
sprintf(Desc, "%s(%s)", Module, Subtype); sprintf(Desc, "%s(%s)", Module, Subtype);
return false; return false;
} // end of DefineAM } // end of DefineAM
/***********************************************************************/ /***********************************************************************/
/* GetTable: makes a new Table Description Block. */ /* GetTable: makes a new Table Description Block. */
/***********************************************************************/ /***********************************************************************/
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode) PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
{ {
RECFM rfm; RECFM rfm;
PTDBASE tdbp = NULL; PTDBASE tdbp = NULL;
// If define block not here yet, get it now // If define block not here yet, get it now
if (!Pxdef && !(Pxdef = GetXdef(g))) if (!Pxdef && !(Pxdef = GetXdef(g)))
return NULL; // Error return NULL; // Error
/*********************************************************************/ /*********************************************************************/
/* Allocate a TDB of the proper type. */ /* Allocate a TDB of the proper type. */
/* Column blocks will be allocated only when needed. */ /* Column blocks will be allocated only when needed. */
/*********************************************************************/ /*********************************************************************/
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode))) if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode)))
return NULL; return NULL;
else else
rfm = tdbp->GetFtype(); rfm = tdbp->GetFtype();
if (rfm == RECFM_NAF) if (rfm == RECFM_NAF)
return tdbp; return tdbp;
else if (rfm == RECFM_OEM) { else if (rfm == RECFM_OEM) {
if (Multiple) if (Multiple)
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
return tdbp; return tdbp;
} // endif OEM } // endif OEM
/*********************************************************************/ /*********************************************************************/
/* The OEM table is based on a file type (currently DOS+ only) */ /* The OEM table is based on a file type (currently DOS+ only) */
/*********************************************************************/ /*********************************************************************/
assert (rfm == RECFM_VAR || rfm == RECFM_FIX || assert (rfm == RECFM_VAR || rfm == RECFM_FIX ||
rfm == RECFM_BIN || rfm == RECFM_VCT); rfm == RECFM_BIN || rfm == RECFM_VCT);
PTXF txfp = NULL; PTXF txfp = NULL;
PDOSDEF defp = (PDOSDEF)Pxdef; PDOSDEF defp = (PDOSDEF)Pxdef;
bool map = defp->Mapped && mode != MODE_INSERT && bool map = defp->Mapped && mode != MODE_INSERT &&
!(PlgGetUser(g)->UseTemp == TMP_FORCE && !(PlgGetUser(g)->UseTemp == TMP_FORCE &&
(mode == MODE_UPDATE || mode == MODE_DELETE)); (mode == MODE_UPDATE || mode == MODE_DELETE));
int cmpr = defp->Compressed; int cmpr = defp->Compressed;
/*********************************************************************/ /*********************************************************************/
/* Allocate table and file processing class of the proper type. */ /* Allocate table and file processing class of the proper type. */
/* Column blocks will be allocated only when needed. */ /* Column blocks will be allocated only when needed. */
/*********************************************************************/ /*********************************************************************/
if (!((PTDBDOS)tdbp)->GetTxfp()) { if (!((PTDBDOS)tdbp)->GetTxfp()) {
if (cmpr) { if (cmpr) {
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
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);
txfp = new(g) ZLBFAM(defp); #else // !ZIP_SUPPORT
#else // !BLK_INDX strcpy(g->Message, "Compress not supported");
strcpy(g->Message, "Compress 2 not supported yet"); return NULL;
#endif // !BLK_INDX #endif // !ZIP_SUPPORT
return NULL; } else if (rfm == RECFM_VAR) {
} // endelse if (map)
#else // !ZIP_SUPPORT txfp = new(g) MAPFAM(defp);
strcpy(g->Message, "Compress not supported"); else
return NULL; txfp = new(g) DOSFAM(defp);
#endif // !ZIP_SUPPORT
} else if (rfm == RECFM_VAR) { } else if (rfm == RECFM_FIX || rfm == RECFM_BIN) {
if (map) if (map)
txfp = new(g) MAPFAM(defp); txfp = new(g) MPXFAM(defp);
else else
txfp = new(g) DOSFAM(defp); txfp = new(g) FIXFAM(defp);
} else if (rfm == RECFM_FIX || rfm == RECFM_BIN) { } else if (rfm == RECFM_VCT) {
if (map) assert (Pxdef->GetDefType() == TYPE_AM_VCT);
txfp = new(g) MPXFAM(defp);
else if (map)
txfp = new(g) FIXFAM(defp); txfp = new(g) VCMFAM((PVCTDEF)defp);
else
} else if (rfm == RECFM_VCT) { txfp = new(g) VCTFAM((PVCTDEF)defp);
assert (Pxdef->GetDefType() == TYPE_AM_VCT);
} // endif's
if (map)
txfp = new(g) VCMFAM((PVCTDEF)defp); ((PTDBDOS)tdbp)->SetTxfp(txfp);
else } // endif Txfp
txfp = new(g) VCTFAM((PVCTDEF)defp);
if (Multiple)
} // endif's tdbp = new(g) TDBMUL(tdbp);
((PTDBDOS)tdbp)->SetTxfp(txfp); return tdbp;
} // endif Txfp } // end of GetTable
if (Multiple) /* --------------------------- Class COLCRT -------------------------- */
tdbp = new(g) TDBMUL(tdbp);
/***********************************************************************/
return tdbp; /* COLCRT Constructors. */
} // end of GetTable /***********************************************************************/
COLCRT::COLCRT(PSZ name)
/* --------------------------- Class COLCRT -------------------------- */ {
Next = NULL;
/***********************************************************************/ Name = name;
/* COLCRT Constructors. */ Desc = NULL;
/***********************************************************************/ Decode = NULL;
COLCRT::COLCRT(PSZ name) Fmt = NULL;
{ Offset = -1;
Next = NULL; Long = -1;
Name = name; Precision = -1;
Desc = NULL; Freq = -1;
Decode = NULL; Key = -1;
Fmt = NULL; Scale = -1;
Offset = -1; Opt = -1;
Long = -1; DataType = '*';
Precision = -1; } // end of COLCRT constructor for table creation
Freq = -1;
Key = -1; COLCRT::COLCRT(void)
Scale = -1; {
Opt = -1; Next = NULL;
DataType = '*'; Name = NULL;
} // end of COLCRT constructor for table creation Desc = NULL;
Decode = NULL;
COLCRT::COLCRT(void) Fmt = NULL;
{ Offset = 0;
Next = NULL; Long = 0;
Name = NULL; Precision = 0;
Desc = NULL; Freq = 0;
Decode = NULL; Key = 0;
Fmt = NULL; Scale = 0;
Offset = 0; Opt = 0;
Long = 0; DataType = '*';
Precision = 0; } // end of COLCRT constructor for table & view definition
Freq = 0;
Key = 0; /* --------------------------- Class COLDEF -------------------------- */
Scale = 0;
Opt = 0; /***********************************************************************/
DataType = '*'; /* COLDEF Constructor. */
} // end of COLCRT constructor for table & view definition /***********************************************************************/
COLDEF::COLDEF(void) : COLCRT()
/* --------------------------- Class COLDEF -------------------------- */ {
To_Min = NULL;
/***********************************************************************/ To_Max = NULL;
/* COLDEF Constructor. */ To_Pos = NULL;
/***********************************************************************/ Xdb2 = FALSE;
COLDEF::COLDEF(void) : COLCRT() To_Bmap = NULL;
{ To_Dval = NULL;
#if defined(BLK_INDX) Ndv = 0;
To_Min = NULL; Nbm = 0;
To_Max = NULL; Buf_Type = TYPE_ERROR;
To_Pos = NULL; Clen = 0;
Xdb2 = FALSE; Poff = 0;
To_Bmap = NULL; memset(&F, 0, sizeof(FORMAT));
To_Dval = NULL; Flags = 0;
Ndv = 0; } // end of COLDEF constructor
Nbm = 0;
#endif // BLK_INDX /***********************************************************************/
Buf_Type = TYPE_ERROR; /* Define: initialize a column definition from a COLINFO structure. */
Clen = 0; /***********************************************************************/
Poff = 0; int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
memset(&F, 0, sizeof(FORMAT)); {
Flags = 0; Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1);
} // end of COLDEF constructor strcpy(Name, cfp->Name);
/***********************************************************************/ if (!(cfp->Flags & U_SPECIAL)) {
/* Define: initialize a column definition from a COLINFO structure. */ Poff = poff;
/***********************************************************************/ Buf_Type = cfp->Type;
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff)
{ if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) {
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1); sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name);
strcpy(Name, cfp->Name); return -1;
} // endswitch
if (!(cfp->Flags & U_SPECIAL)) {
Poff = poff; strcpy(F.Type, GetFormatType(Buf_Type));
Buf_Type = cfp->Type; F.Length = cfp->Length;
F.Prec = cfp->Scale;
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) { Offset = (cfp->Offset < 0) ? poff : cfp->Offset;
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name); Precision = cfp->Precision;
return -1; Scale = cfp->Scale;
} // endswitch Long = cfp->Length;
Opt = cfp->Opt;
strcpy(F.Type, GetFormatType(Buf_Type)); Key = cfp->Key;
F.Length = cfp->Length; Freq = cfp->Freq;
F.Prec = cfp->Scale;
Offset = (cfp->Offset < 0) ? poff : cfp->Offset; if (cfp->Remark && *cfp->Remark) {
Precision = cfp->Precision; Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
Scale = cfp->Scale; strcpy(Desc, cfp->Remark);
Long = cfp->Length; } // endif Remark
Opt = cfp->Opt;
Key = cfp->Key; if (cfp->Datefmt) {
Freq = cfp->Freq; Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1);
strcpy(Decode, cfp->Datefmt);
if (cfp->Remark && *cfp->Remark) { } // endif Datefmt
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1);
strcpy(Desc, cfp->Remark); } // endif special
} // endif Remark
if (cfp->Fieldfmt) {
if (cfp->Datefmt) { Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1);
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1); strcpy(Fmt, cfp->Fieldfmt);
strcpy(Decode, cfp->Datefmt); } // endif Fieldfmt
} // endif Datefmt
Flags = cfp->Flags;
} // endif special return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long;
} // end of Define
if (cfp->Fieldfmt) {
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1); /* ------------------------- End of RelDef --------------------------- */
strcpy(Fmt, cfp->Fieldfmt);
} // endif Fieldfmt
Flags = cfp->Flags;
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long;
} // end of Define
/* ------------------------- End of RelDef --------------------------- */

View File

@@ -1,231 +1,225 @@
/*************** RelDef H Declares Source Code File (.H) ***************/ /*************** RelDef H Declares Source Code File (.H) ***************/
/* Name: RELDEF.H Version 1.3 */ /* Name: RELDEF.H Version 1.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2014 */
/* */ /* */
/* This file contains the DEF classes definitions. */ /* This file contains the DEF classes definitions. */
/***********************************************************************/ /***********************************************************************/
#ifndef __RELDEF_H #ifndef __RELDEF_H
#define __RELDEF_H #define __RELDEF_H
#include "block.h" #include "block.h"
#include "catalog.h" #include "catalog.h"
#include "my_sys.h" #include "my_sys.h"
typedef class INDEXDEF *PIXDEF; typedef class INDEXDEF *PIXDEF;
/***********************************************************************/ /***********************************************************************/
/* Table or View (relation) definition block. */ /* Table or View (relation) definition block. */
/***********************************************************************/ /***********************************************************************/
class DllExport RELDEF : public BLOCK { // Relation definition block class DllExport RELDEF : public BLOCK { // Relation definition block
friend class CATALOG; friend class CATALOG;
friend class PLUGCAT; friend class PLUGCAT;
friend class MYCAT; friend class MYCAT;
public: public:
RELDEF(void); // Constructor RELDEF(void); // Constructor
// Implementation // Implementation
PRELDEF GetNext(void) {return Next;} PRELDEF GetNext(void) {return Next;}
PSZ GetName(void) {return Name;} PSZ GetName(void) {return Name;}
PSZ GetDB(void) {return (PSZ)Database;} PSZ GetDB(void) {return (PSZ)Database;}
PCOLDEF GetCols(void) {return To_Cols;} PCOLDEF GetCols(void) {return To_Cols;}
void SetCols(PCOLDEF pcd) {To_Cols = pcd;} void SetCols(PCOLDEF pcd) {To_Cols = pcd;}
PCATLG GetCat(void) {return Cat;} PCATLG GetCat(void) {return Cat;}
virtual const char *GetType(void) = 0; virtual const char *GetType(void) = 0;
virtual AMT GetDefType(void) = 0; virtual AMT GetDefType(void) = 0;
void SetName(const char *str) { Name=(char*)str; } void SetName(const char *str) { Name=(char*)str; }
void SetCat(PCATLG cat) { Cat=cat; } void SetCat(PCATLG cat) { Cat=cat; }
// Methods // Methods
//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;
protected:
protected: PRELDEF Next; /* To next definition block */
PRELDEF Next; /* To next definition block */ PSZ Name; /* Name of the view */
PSZ Name; /* Name of the view */ LPCSTR Database; /* Table database */
LPCSTR Database; /* Table database */ PCOLDEF To_Cols; /* To a list of column desc */
PCOLDEF To_Cols; /* To a list of column desc */ PCATLG Cat; /* To DB catalog info */
PCATLG Cat; /* To DB catalog info */ }; // end of RELDEF
}; // end of RELDEF
/***********************************************************************/
/***********************************************************************/ /* These classes correspond to the data base description contained in */
/* These classes correspond to the data base description contained in */ /* a .XDB file the A.M. DOS, FIX, CSV, MAP, BIN, VCT, PLG, ODBC, DOM. */
/* a .XDB file the A.M. DOS, FIX, CSV, MAP, BIN, VCT, PLG, ODBC, DOM. */ /***********************************************************************/
/***********************************************************************/ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */ friend class CATALOG;
friend class CATALOG; friend class PLUGCAT;
friend class PLUGCAT; friend class MYCAT;
friend class MYCAT; public:
public: // Constructor
// Constructor TABDEF(void); // Constructor
TABDEF(void); // Constructor
// Implementation
// Implementation int GetDegree(void) {return Degree;}
int GetDegree(void) {return Degree;} void SetDegree(int d) {Degree = d;}
void SetDegree(int d) {Degree = d;} int GetElemt(void) {return Elemt;}
int GetElemt(void) {return Elemt;} void SetNext(PTABDEF tdfp) {Next = tdfp;}
void SetNext(PTABDEF tdfp) {Next = tdfp;} int GetMultiple(void) {return Multiple;}
int GetMultiple(void) {return Multiple;} int GetPseudo(void) {return Pseudo;}
int GetPseudo(void) {return Pseudo;} PSZ GetPath(void)
PSZ GetPath(void) {return (Database) ? (PSZ)Database : Cat->GetDataPath();}
{return (Database) ? (PSZ)Database : Cat->GetDataPath();} bool SepIndex(void) {return Cat->GetBoolCatInfo("SepIndex", false);}
bool SepIndex(void) {return Cat->GetBoolCatInfo("SepIndex", false);} bool IsReadOnly(void) {return Read_Only;}
bool IsReadOnly(void) {return Read_Only;} virtual AMT GetDefType(void) {return TYPE_AM_TAB;}
virtual AMT GetDefType(void) {return TYPE_AM_TAB;} virtual PIXDEF GetIndx(void) {return NULL;}
virtual PIXDEF GetIndx(void) {return NULL;} virtual void SetIndx(PIXDEF xp) {}
virtual void SetIndx(PIXDEF xp) {} virtual bool IsHuge(void) {return false;}
virtual bool IsHuge(void) {return false;} const CHARSET_INFO *data_charset() {return m_data_charset;}
const CHARSET_INFO *data_charset() {return m_data_charset;}
// Methods
// Methods bool DropTable(PGLOBAL g, PSZ name);
bool DropTable(PGLOBAL g, PSZ name); virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am);
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am); virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
protected:
protected: // Members
// Members PSZ Schema; /* Table schema (for ODBC) */
PSZ Schema; /* Table schema (for ODBC) */ PSZ Desc; /* Table description */
PSZ Desc; /* Table description */ uint Catfunc; /* Catalog function ID */
uint Catfunc; /* Catalog function ID */ int Card; /* (max) number of rows in table */
int Card; /* (max) number of rows in table */ int Elemt; /* Number of rows in blocks or rowset */
int Elemt; /* Number of rows in blocks or rowset */ int Sort; /* Table already sorted ??? */
int Sort; /* Table already sorted ??? */ int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */ int Degree; /* Number of columns in the table */
int Degree; /* Number of columns in the table */ int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */
int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */ bool Read_Only; /* true for read only tables */
bool Read_Only; /* true for read only tables */ const CHARSET_INFO *m_data_charset;
const CHARSET_INFO *m_data_charset; }; // end of TABDEF
}; // end of TABDEF
/***********************************************************************/
/***********************************************************************/ /* Externally defined OEM tables. */
/* Externally defined OEM tables. */ /***********************************************************************/
/***********************************************************************/ class DllExport OEMDEF : public TABDEF { /* OEM table */
class DllExport OEMDEF : public TABDEF { /* OEM table */ friend class CATALOG;
friend class CATALOG; friend class PLUGCAT;
friend class PLUGCAT; friend class MYCAT;
friend class MYCAT; public:
public: // Constructor
// Constructor OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;}
OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;}
// Implementation
// Implementation virtual const char *GetType(void) {return "OEM";}
virtual const char *GetType(void) {return "OEM";} virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
virtual AMT GetDefType(void) {return TYPE_AM_OEM;}
// Methods
// Methods virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
//virtual bool DeleteTableFile(PGLOBAL g); virtual PTDB GetTable(PGLOBAL g, MODE mode);
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE mode); protected:
PTABDEF GetXdef(PGLOBAL g);
protected:
PTABDEF GetXdef(PGLOBAL g); // Members
#if defined(WIN32)
// Members HANDLE Hdll; /* Handle to the external DLL */
#if defined(WIN32) #else // !WIN32
HANDLE Hdll; /* Handle to the external DLL */ void *Hdll; /* Handle for the loaded shared library */
#else // !WIN32 #endif // !WIN32
void *Hdll; /* Handle for the loaded shared library */ PTABDEF Pxdef; /* Pointer to the external TABDEF class */
#endif // !WIN32 char *Module; /* Path/Name of the DLL implenting it */
PTABDEF Pxdef; /* Pointer to the external TABDEF class */ char *Subtype; /* The name of the OEM table sub type */
char *Module; /* Path/Name of the DLL implenting it */ }; // end of OEMDEF
char *Subtype; /* The name of the OEM table sub type */
}; // end of OEMDEF /***********************************************************************/
/* Column definition block used during creation. */
/***********************************************************************/ /***********************************************************************/
/* Column definition block used during creation. */ class DllExport COLCRT : public BLOCK { /* Column description block */
/***********************************************************************/ friend class TABDEF;
class DllExport COLCRT : public BLOCK { /* Column description block */ public:
friend class TABDEF; COLCRT(PSZ name); // Constructor
public: COLCRT(void); // Constructor (for views)
COLCRT(PSZ name); // Constructor
COLCRT(void); // Constructor (for views) // Implementation
PSZ GetName(void) {return Name;}
// Implementation PSZ GetDecode(void) {return Decode;}
PSZ GetName(void) {return Name;} PSZ GetFmt(void) {return Fmt;}
PSZ GetDecode(void) {return Decode;} int GetOpt(void) {return Opt;}
PSZ GetFmt(void) {return Fmt;} int GetFreq(void) {return Freq;}
int GetOpt(void) {return Opt;} int GetLong(void) {return Long;}
int GetFreq(void) {return Freq;} int GetPrecision(void) {return Precision;}
int GetLong(void) {return Long;} int GetOffset(void) {return Offset;}
int GetPrecision(void) {return Precision;} void SetOffset(int offset) {Offset = offset;}
int GetOffset(void) {return Offset;}
void SetOffset(int offset) {Offset = offset;} protected:
PCOLCRT Next; /* To next block */
protected: PSZ Name; /* Column name */
PCOLCRT Next; /* To next block */ PSZ Desc; /* Column description */
PSZ Name; /* Column name */ PSZ Decode; /* Date format */
PSZ Desc; /* Column description */ PSZ Fmt; /* Input format for formatted files */
PSZ Decode; /* Date format */ int Offset; /* Offset of field within record */
PSZ Fmt; /* Input format for formatted files */ int Long; /* Length of field in file record (!BIN) */
int Offset; /* Offset of field within record */ int Key; /* Key (greater than 1 if multiple) */
int Long; /* Length of field in file record (!BIN) */ int Precision; /* Logical column length */
int Key; /* Key (greater than 1 if multiple) */ int Scale; /* Decimals for float/decimal values */
int Precision; /* Logical column length */ int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */
int Scale; /* Decimals for float/decimal values */ int Freq; /* Estimated number of different values */
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */ char DataType; /* Internal data type (C, N, F, T) */
int Freq; /* Estimated number of different values */ }; // end of COLCRT
char DataType; /* Internal data type (C, N, F, T) */
}; // end of COLCRT /***********************************************************************/
/* Column definition block. */
/***********************************************************************/ /***********************************************************************/
/* Column definition block. */ class DllExport COLDEF : public COLCRT { /* Column description block */
/***********************************************************************/ friend class CATALOG;
class DllExport COLDEF : public COLCRT { /* Column description block */ friend class PLUGCAT;
friend class CATALOG; friend class MYCAT;
friend class PLUGCAT; friend class COLBLK;
friend class MYCAT; friend class DBFFAM;
friend class COLBLK; friend class TDBASE;
friend class DBFFAM; public:
friend class TDBASE; COLDEF(void); // Constructor
public:
COLDEF(void); // Constructor // Implementation
PCOLDEF GetNext(void) {return (PCOLDEF)Next;}
// Implementation void SetNext(PCOLDEF pcdf) {Next = pcdf;}
PCOLDEF GetNext(void) {return (PCOLDEF)Next;} int GetLength(void) {return (int)F.Length;}
void SetNext(PCOLDEF pcdf) {Next = pcdf;} int GetClen(void) {return Clen;}
int GetLength(void) {return (int)F.Length;} int GetType(void) {return Buf_Type;}
int GetClen(void) {return Clen;} int GetPoff(void) {return Poff;}
int GetType(void) {return Buf_Type;} void *GetMin(void) {return To_Min;}
int GetPoff(void) {return Poff;} void SetMin(void *minp) {To_Min = minp;}
#if defined(BLK_INDX) void *GetMax(void) {return To_Max;}
void *GetMin(void) {return To_Min;} void SetMax(void *maxp) {To_Max = maxp;}
void SetMin(void *minp) {To_Min = minp;} bool GetXdb2(void) {return Xdb2;}
void *GetMax(void) {return To_Max;} void SetXdb2(bool b) {Xdb2 = b;}
void SetMax(void *maxp) {To_Max = maxp;} void *GetBmap(void) {return To_Bmap;}
bool GetXdb2(void) {return Xdb2;} void SetBmap(void *bmp) {To_Bmap = bmp;}
void SetXdb2(bool b) {Xdb2 = b;} void *GetDval(void) {return To_Dval;}
void *GetBmap(void) {return To_Bmap;} void SetDval(void *dvp) {To_Dval = dvp;}
void SetBmap(void *bmp) {To_Bmap = bmp;} int GetNdv(void) {return Ndv;}
void *GetDval(void) {return To_Dval;} void SetNdv(int ndv) {Ndv = ndv;}
void SetDval(void *dvp) {To_Dval = dvp;} int GetNbm(void) {return Nbm;}
int GetNdv(void) {return Ndv;} void SetNbm(int nbm) {Nbm = nbm;}
void SetNdv(int ndv) {Ndv = ndv;} int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff);
int GetNbm(void) {return Nbm;} void Define(PGLOBAL g, PCOL colp);
void SetNbm(int nbm) {Nbm = nbm;}
#endif // BLK_INDX protected:
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff); void *To_Min; /* Point to array of block min values */
void Define(PGLOBAL g, PCOL colp); void *To_Max; /* Point to array of block max values */
int *To_Pos; /* Point to array of block positions */
protected: bool Xdb2; /* TRUE if to be optimized by XDB2 */
#if defined(BLK_INDX) void *To_Bmap; /* To array of block bitmap values */
void *To_Min; /* Point to array of block min values */ void *To_Dval; /* To array of column distinct values */
void *To_Max; /* Point to array of block max values */ int Ndv; /* Number of distinct values */
int *To_Pos; /* Point to array of block positions */ int Nbm; /* Number of ULONG in bitmap (XDB2) */
bool Xdb2; /* TRUE if to be optimized by XDB2 */ int Buf_Type; /* Internal data type */
void *To_Bmap; /* To array of block bitmap values */ int Clen; /* Internal data size in chars (bytes) */
void *To_Dval; /* To array of column distinct values */ int Poff; /* Calculated offset for Packed tables */
int Ndv; /* Number of distinct values */ FORMAT F; /* Output format (should be in COLCRT) */
int Nbm; /* Number of ULONG in bitmap (XDB2) */ ushort Flags; /* Used by MariaDB CONNECT handler */
#endif // BLK_INDX }; // end of COLDEF
int Buf_Type; /* Internal data type */
int Clen; /* Internal data size in chars (bytes) */ #endif // __RELDEF_H
int Poff; /* Calculated offset for Packed tables */
FORMAT F; /* Output format (should be in COLCRT) */
ushort Flags; /* Used by MariaDB CONNECT handler */
}; // end of COLDEF
#endif // __RELDEF_H

View File

@@ -85,8 +85,6 @@ class DllExport COLUMN: public XOBJECT { // Column Name/Qualifier block.
virtual bool Compare(PXOB) {assert(false); return false;} virtual bool Compare(PXOB) {assert(false); return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&); virtual bool SetFormat(PGLOBAL, FORMAT&);
virtual bool Eval(PGLOBAL) {assert(false); return true;} virtual bool Eval(PGLOBAL) {assert(false); return true;}
virtual int CheckSpcCol(PTDB, int) {assert(false); return 2;}
virtual bool CheckSort(PTDB) {assert(false); return false;}
private: private:
// Members // Members

File diff suppressed because it is too large Load Diff

View File

@@ -1,286 +1,253 @@
/*************** TabDos H Declares Source Code File (.H) ***************/ /*************** TabDos H Declares Source Code File (.H) ***************/
/* Name: TABDOS.H Version 3.3 */ /* Name: TABDOS.H Version 3.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
/* */ /* */
/* This file contains the DOS classes declares. */ /* This file contains the DOS classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __TABDOS_H #ifndef __TABDOS_H
#define __TABDOS_H #define __TABDOS_H
#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"
#include "filter.h"
#endif // BLK_INDX //pedef struct _tabdesc *PTABD; // For friend setting
typedef class TXTFAM *PTXF;
//pedef struct _tabdesc *PTABD; // For friend setting typedef class BLOCKFILTER *PBF;
typedef class TXTFAM *PTXF; typedef class BLOCKINDEX *PBX;
#if defined(BLK_INDX)
typedef class BLOCKFILTER *PBF; /***********************************************************************/
typedef class BLOCKINDEX *PBX; /* DOS table. */
#endif // BLK_INDX /***********************************************************************/
class DllExport DOSDEF : public TABDEF { /* Logical table description */
/***********************************************************************/ friend class OEMDEF;
/* DOS table. */ friend class TDBDOS;
/***********************************************************************/ friend class TDBFIX;
class DllExport DOSDEF : public TABDEF { /* Logical table description */ friend class TXTFAM;
friend class OEMDEF; friend class DBFBASE;
friend class TDBDOS; public:
friend class TDBFIX; // Constructor
friend class TXTFAM; DOSDEF(void);
friend class DBFBASE;
public: // Implementation
// Constructor virtual AMT GetDefType(void) {return TYPE_AM_DOS;}
DOSDEF(void); virtual const char *GetType(void) {return "DOS";}
virtual PIXDEF GetIndx(void) {return To_Indx;}
// Implementation virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;}
virtual AMT GetDefType(void) {return TYPE_AM_DOS;} virtual bool IsHuge(void) {return Huge;}
virtual const char *GetType(void) {return "DOS";} PSZ GetFn(void) {return Fn;}
virtual PIXDEF GetIndx(void) {return To_Indx;} PSZ GetOfn(void) {return Ofn;}
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;} void SetBlock(int block) {Block = block;}
virtual bool IsHuge(void) {return Huge;} int GetBlock(void) {return Block;}
PSZ GetFn(void) {return Fn;} int GetLast(void) {return Last;}
PSZ GetOfn(void) {return Ofn;} void SetLast(int last) {Last = last;}
void SetBlock(int block) {Block = block;} int GetLrecl(void) {return Lrecl;}
int GetBlock(void) {return Block;} void SetLrecl(int lrecl) {Lrecl = lrecl;}
int GetLast(void) {return Last;} bool GetPadded(void) {return Padded;}
void SetLast(int last) {Last = last;} bool GetEof(void) {return Eof;}
int GetLrecl(void) {return Lrecl;} int GetBlksize(void) {return Blksize;}
void SetLrecl(int lrecl) {Lrecl = lrecl;} int GetEnding(void) {return Ending;}
bool GetPadded(void) {return Padded;} bool IsOptimized(void) {return (Optimized == 1);}
bool GetEof(void) {return Eof;} void SetOptimized(int opt) {Optimized = opt;}
int GetBlksize(void) {return Blksize;} void SetAllocBlks(int blks) {AllocBlks = blks;}
int GetEnding(void) {return Ending;} int GetAllocBlks(void) {return AllocBlks;}
#if defined(BLK_INDX) int *GetTo_Pos(void) {return To_Pos;}
bool IsOptimized(void) {return (Optimized == 1);}
void SetOptimized(int opt) {Optimized = opt;} // Methods
void SetAllocBlks(int blks) {AllocBlks = blks;} virtual bool Indexable(void) {return Compressed != 1;}
int GetAllocBlks(void) {return AllocBlks;} virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf);
int *GetTo_Pos(void) {return To_Pos;} virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
#endif // BLK_INDX virtual PTDB GetTable(PGLOBAL g, MODE mode);
bool InvalidateIndex(PGLOBAL g);
// Methods bool GetOptFileName(PGLOBAL g, char *filename);
//virtual bool DeleteTableFile(PGLOBAL g); void RemoveOptValues(PGLOBAL g);
virtual bool Indexable(void) {return Compressed != 1;}
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf); protected:
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); //virtual bool Erase(char *filename);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
bool InvalidateIndex(PGLOBAL g); // Members
#if defined(BLK_INDX) PSZ Fn; /* Path/Name of corresponding file */
bool GetOptFileName(PGLOBAL g, char *filename); PSZ Ofn; /* Base Path/Name of matching index files*/
void RemoveOptValues(PGLOBAL g); PIXDEF To_Indx; /* To index definitions blocks */
#endif // BLK_INDX RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
bool Mapped; /* 0: disk file, 1: memory mapped file */
protected: bool Padded; /* true for padded table file */
//virtual bool Erase(char *filename); bool Huge; /* true for files larger than 2GB */
bool Accept; /* true if wrong lines are accepted (DBF)*/
// Members bool Eof; /* true if an EOF (0xA) character exists */
PSZ Fn; /* Path/Name of corresponding file */ int *To_Pos; /* To array of block starting positions */
PSZ Ofn; /* Base Path/Name of matching index files*/ int Optimized; /* 0: No, 1:Yes, 2:Redo optimization */
PIXDEF To_Indx; /* To index definitions blocks */ int AllocBlks; /* Number of suballocated opt blocks */
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */ int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */
bool Mapped; /* 0: disk file, 1: memory mapped file */ int Lrecl; /* Size of biggest record */
bool Padded; /* true for padded table file */ int AvgLen; /* Average size of records */
bool Huge; /* true for files larger than 2GB */ int Block; /* Number de blocks of FIX/VCT tables */
bool Accept; /* true if wrong lines are accepted (DBF)*/ int Last; /* Number of elements of last block */
bool Eof; /* true if an EOF (0xA) character exists */ int Blksize; /* Size of padded blocks */
#if defined(BLK_INDX) int Maxerr; /* Maximum number of bad records (DBF) */
int *To_Pos; /* To array of block starting positions */ int ReadMode; /* Specific to DBF */
int Optimized; /* 0: No, 1:Yes, 2:Redo optimization */ int Ending; /* Length of end of lines */
int AllocBlks; /* Number of suballocated opt blocks */ }; // end of DOSDEF
#endif // BLK_INDX
int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */ /***********************************************************************/
int Lrecl; /* Size of biggest record */ /* This is the DOS/UNIX Access Method class declaration for files */
int AvgLen; /* Average size of records */ /* that are standard files with columns starting at fixed offset. */
int Block; /* Number de blocks of FIX/VCT tables */ /* The last column (and record) is of variable length. */
int Last; /* Number of elements of last block */ /***********************************************************************/
int Blksize; /* Size of padded blocks */ class DllExport TDBDOS : public TDBASE {
int Maxerr; /* Maximum number of bad records (DBF) */ friend class XINDEX;
int ReadMode; /* Specific to DBF */ friend class DOSCOL;
int Ending; /* Length of end of lines */ friend class MAPCOL;
}; // end of DOSDEF friend class TXTFAM;
friend class DOSFAM;
/***********************************************************************/ friend class VCTCOL;
/* This is the DOS/UNIX Access Method class declaration for files */ friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
/* that are standard files with columns starting at fixed offset. */ public:
/* The last column (and record) is of variable length. */ // Constructors
/***********************************************************************/ TDBDOS(PDOSDEF tdp, PTXF txfp);
class DllExport TDBDOS : public TDBASE { TDBDOS(PGLOBAL g, PTDBDOS tdbp);
//friend class KINDEX;
friend class XINDEX; // Inline functions
friend class DOSCOL; inline void SetTxfp(PTXF txfp) {Txfp = txfp; Txfp->SetTdbp(this);}
friend class MAPCOL; inline PTXF GetTxfp(void) {return Txfp;}
friend class TXTFAM; inline char *GetLine(void) {return To_Line;}
friend class DOSFAM; inline int GetCurBlk(void) {return Txfp->GetCurBlk();}
friend class VCTCOL; inline void SetLine(char *toline) {To_Line = toline;}
//friend class TDBMUL; inline void IncLine(int inc) {To_Line += inc;}
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool); inline bool IsRead(void) {return Txfp->IsRead;}
public: inline PXOB *GetLink(void) {return To_Link;}
// Constructors
TDBDOS(PDOSDEF tdp, PTXF txfp); // Implementation
TDBDOS(PGLOBAL g, PTDBDOS tdbp); virtual AMT GetAmType(void) {return Txfp->GetAmType();}
virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;}
// Inline functions virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;}
inline void SetTxfp(PTXF txfp) {Txfp = txfp; Txfp->SetTdbp(this);} virtual RECFM GetFtype(void) {return Ftype;}
inline PTXF GetTxfp(void) {return Txfp;} virtual bool SkipHeader(PGLOBAL g) {return false;}
inline char *GetLine(void) {return To_Line;} virtual void RestoreNrec(void) {Txfp->SetNrec(1);}
inline int GetCurBlk(void) {return Txfp->GetCurBlk();} virtual PTDB Duplicate(PGLOBAL g)
inline void SetLine(char *toline) {To_Line = toline;} {return (PTDB)new(g) TDBDOS(g, this);}
inline void IncLine(int inc) {To_Line += inc;}
inline bool IsRead(void) {return Txfp->IsRead;} // Methods
inline PXOB *GetLink(void) {return To_Link;} virtual PTDB CopyOne(PTABS t);
//inline PCOL *GetKeyCol(void) {return To_Key_Col;} virtual void ResetDB(void) {Txfp->Reset();}
virtual bool IsUsingTemp(PGLOBAL g);
// Implementation virtual void ResetSize(void) {MaxSize = Cardinal = -1;}
virtual AMT GetAmType(void) {return Txfp->GetAmType();} virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox);
virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;} virtual int MakeBlockValues(PGLOBAL g);
virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;} virtual bool SaveBlockValues(PGLOBAL g);
virtual RECFM GetFtype(void) {return Ftype;} virtual bool GetBlockValues(PGLOBAL g);
virtual bool SkipHeader(PGLOBAL g) {return false;} virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp);
virtual void RestoreNrec(void) {Txfp->SetNrec(1);} //virtual PBX InitBlockIndex(PGLOBAL g);
virtual PTDB Duplicate(PGLOBAL g) virtual int TestBlock(PGLOBAL g);
{return (PTDB)new(g) TDBDOS(g, this);} virtual void PrintAM(FILE *f, char *m);
// Methods // Database routines
virtual PTDB CopyOne(PTABS t); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual void ResetDB(void) {Txfp->Reset();} virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;}
virtual bool IsUsingTemp(PGLOBAL g); virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);}
//virtual bool NeedIndexing(PGLOBAL g); virtual int GetProgMax(PGLOBAL g);
virtual void ResetSize(void) {MaxSize = Cardinal = -1;} virtual int GetProgCur(void);
virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox); virtual int GetAffectedRows(void) {return Txfp->GetDelRows();}
#if defined(BLK_INDX) virtual int GetRecpos(void) {return Txfp->GetPos();}
virtual int MakeBlockValues(PGLOBAL g); virtual bool SetRecpos(PGLOBAL g, int recpos)
virtual bool SaveBlockValues(PGLOBAL g); {return Txfp->SetPos(g, recpos);}
virtual bool GetBlockValues(PGLOBAL g); virtual int RowNumber(PGLOBAL g, bool b = false);
virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp); virtual int Cardinality(PGLOBAL g);
//virtual PBX InitBlockIndex(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual int TestBlock(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
#endif // BLK_INDX virtual int ReadDB(PGLOBAL g);
virtual void PrintAM(FILE *f, char *m); virtual int WriteDB(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
// Database routines virtual void CloseDB(PGLOBAL g);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);}
virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;}
virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);} // Specific routine
virtual int GetProgMax(PGLOBAL g); virtual int EstimatedLength(PGLOBAL g);
virtual int GetProgCur(void);
virtual int GetAffectedRows(void) {return Txfp->GetDelRows();} // Optimization routines
virtual int GetRecpos(void) {return Txfp->GetPos();} int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add);
virtual bool SetRecpos(PGLOBAL g, int recpos) void ResetBlockFilter(PGLOBAL g);
{return Txfp->SetPos(g, recpos);} bool GetDistinctColumnValues(PGLOBAL g, int nrec);
virtual int RowNumber(PGLOBAL g, bool b = false);
virtual int Cardinality(PGLOBAL g); protected:
virtual int GetMaxSize(PGLOBAL g); PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); // Members
virtual int WriteDB(PGLOBAL g); PTXF Txfp; // To the File access method class
virtual int DeleteDB(PGLOBAL g, int irc); //PBX To_BlkIdx; // To index test block
virtual void CloseDB(PGLOBAL g); PBF To_BlkFil; // To evaluation block filter
virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);} PFIL SavFil; // Saved hidden filter
char *To_Line; // Points to current processed line
// Specific routine int Cardinal; // Table Cardinality
virtual int EstimatedLength(PGLOBAL g); RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT)
int Lrecl; // Logical Record Length
// Optimization routines int AvgLen; // Logical Record Average Length
int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); //int Xeval; // BlockTest return value
#if defined(BLK_INDX) int Beval; // BlockEval return value
void ResetBlockFilter(PGLOBAL g); }; // end of class TDBDOS
bool GetDistinctColumnValues(PGLOBAL g, int nrec);
/***********************************************************************/
protected: /* Class DOSCOL: DOS access method column descriptor. */
PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv); /* This A.M. is used for text file tables under operating systems */
#endif // BLK_INDX /* DOS, OS2, UNIX, WIN16 and WIN32. */
/***********************************************************************/
// Members class DllExport DOSCOL : public COLBLK {
PTXF Txfp; // To the File access method class friend class TDBDOS;
#if defined(BLK_INDX) friend class TDBFIX;
//PBX To_BlkIdx; // To index test block public:
PBF To_BlkFil; // To evaluation block filter // Constructors
PFIL SavFil; // Saved hidden filter DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "DOS");
#endif // BLK_INDX DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process
char *To_Line; // Points to current processed line
int Cardinal; // Table Cardinality // Implementation
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT) virtual int GetAmType(void) {return TYPE_AM_DOS;}
int Lrecl; // Logical Record Length virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
int AvgLen; // Logical Record Average Length virtual int GetClustered(void) {return Clustered;}
#if defined(BLK_INDX) virtual int IsClustered(void) {return (Clustered &&
//int Xeval; // BlockTest return value ((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());}
int Beval; // BlockEval return value virtual int IsSorted(void) {return Sorted;}
#endif // BLK_INDX virtual PVBLK GetMin(void) {return Min;}
}; // end of class TDBDOS virtual PVBLK GetMax(void) {return Max;}
virtual int GetNdv(void) {return Ndv;}
/***********************************************************************/ virtual int GetNbm(void) {return Nbm;}
/* Class DOSCOL: DOS access method column descriptor. */ virtual PVBLK GetBmap(void) {return Bmap;}
/* This A.M. is used for text file tables under operating systems */ virtual PVBLK GetDval(void) {return Dval;}
/* DOS, OS2, UNIX, WIN16 and WIN32. */
/***********************************************************************/ // Methods
class DllExport DOSCOL : public COLBLK { virtual bool VarSize(void);
friend class TDBDOS; virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
friend class TDBFIX; virtual void ReadColumn(PGLOBAL g);
public: virtual void WriteColumn(PGLOBAL g);
// Constructors virtual void Print(PGLOBAL g, FILE *, uint);
DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "DOS");
DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process protected:
virtual bool SetMinMax(PGLOBAL g);
// Implementation virtual bool SetBitMap(PGLOBAL g);
virtual int GetAmType(void) {return TYPE_AM_DOS;} bool CheckSorted(PGLOBAL g);
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} bool AddDistinctValue(PGLOBAL g);
#if defined(BLK_INDX)
virtual int GetClustered(void) {return Clustered;} // Default constructor not to be used
virtual int IsClustered(void) {return (Clustered && DOSCOL(void) {}
((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());}
virtual int IsSorted(void) {return Sorted;} // Members
virtual PVBLK GetMin(void) {return Min;} PVBLK Min; // Array of block min values
virtual PVBLK GetMax(void) {return Max;} PVBLK Max; // Array of block max values
virtual int GetNdv(void) {return Ndv;} PVBLK Bmap; // Array of block bitmap values
virtual int GetNbm(void) {return Nbm;} PVBLK Dval; // Array of column distinct values
virtual PVBLK GetBmap(void) {return Bmap;} PVAL To_Val; // To value used for Update/Insert
virtual PVBLK GetDval(void) {return Dval;} PVAL OldVal; // The previous value of the object.
#endif // BLK_INDX char *Buf; // Buffer used in write operations
bool Ldz; // True if field contains leading zeros
// Methods bool Nod; // True if no decimal point
#if defined(BLK_INDX) int Dcm; // Last Dcm digits are decimals
virtual bool VarSize(void); int Deplac; // Offset in dos_buf
#endif // BLK_INDX int Clustered; // 0:No 1:Yes
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); int Sorted; // 0:No 1:Asc (2:Desc - NIY)
virtual void ReadColumn(PGLOBAL g); int Ndv; // Number of distinct values
virtual void WriteColumn(PGLOBAL g); int Nbm; // Number of uint in bitmap
virtual void Print(PGLOBAL g, FILE *, uint); }; // end of class DOSCOL
protected: #endif // __TABDOS_H
#if defined(BLK_INDX)
virtual bool SetMinMax(PGLOBAL g);
virtual bool SetBitMap(PGLOBAL g);
bool CheckSorted(PGLOBAL g);
bool AddDistinctValue(PGLOBAL g);
#endif // BLK_INDX
// Default constructor not to be used
DOSCOL(void) {}
// Members
#if defined(BLK_INDX)
PVBLK Min; // Array of block min values
PVBLK Max; // Array of block max values
PVBLK Bmap; // Array of block bitmap values
PVBLK Dval; // Array of column distinct values
#endif // BLK_INDX
PVAL To_Val; // To value used for Update/Insert
PVAL OldVal; // The previous value of the object.
char *Buf; // Buffer used in write operations
bool Ldz; // True if field contains leading zeros
bool Nod; // True if no decimal point
int Dcm; // Last Dcm digits are decimals
int Deplac; // Offset in dos_buf
#if defined(BLK_INDX)
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
#endif // __TABDOS_H

View File

@@ -45,10 +45,8 @@
#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 "array.h"
#include "blkfil.h" #include "blkfil.h"
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* DB static variables. */ /* DB static variables. */
@@ -129,7 +127,6 @@ PCOL TDBFIX::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
/***********************************************************************/ /***********************************************************************/
int TDBFIX::ResetTableOpt(PGLOBAL g, bool dop, bool dox) int TDBFIX::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
{ {
#if defined(BLK_INDX)
int prc, rc = RC_OK; int prc, rc = RC_OK;
To_Filter = NULL; // Disable filtering To_Filter = NULL; // Disable filtering
@@ -169,10 +166,6 @@ int TDBFIX::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
} // endif dox } // endif dox
return rc; 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
/***********************************************************************/ /***********************************************************************/
@@ -211,14 +204,14 @@ 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)) if (MaxSize > 0 && (To_BlkFil = InitBlockFilter(g, To_Filter))
&& !To_BlkFil->Correlated()) { && !To_BlkFil->Correlated()) {
// Use BlockTest to reduce the estimated size // Use BlockTest to reduce the estimated size
MaxSize = Txfp->MaxBlkSize(g, MaxSize); MaxSize = Txfp->MaxBlkSize(g, MaxSize);
ResetBlockFilter(g); ResetBlockFilter(g);
} // endif To_BlkFil } // endif To_BlkFil
#endif // BLK_INDX
} // endif MaxSize } // endif MaxSize
return MaxSize; return MaxSize;
@@ -301,9 +294,7 @@ 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); ResetBlockFilter(g);
#endif // BLK_INDX
return false; return false;
} // endif use } // endif use
@@ -335,12 +326,10 @@ 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. */ /* Allocate the block filter tree if evaluation is possible. */
/*********************************************************************/ /*********************************************************************/
To_BlkFil = InitBlockFilter(g, To_Filter); 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);

File diff suppressed because it is too large Load Diff

View File

@@ -1,192 +1,188 @@
/*************** TabFmt H Declares Source Code File (.H) ***************/ /*************** TabFmt H Declares Source Code File (.H) ***************/
/* Name: TABFMT.H Version 2.3 */ /* Name: TABFMT.H Version 2.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2014 */
/* */ /* */
/* This file contains the CSV and FMT classes declares. */ /* This file contains the CSV and FMT classes declares. */
/***********************************************************************/ /***********************************************************************/
#include "xtable.h" // Base class declares #include "xtable.h" // Base class declares
#include "tabdos.h" #include "tabdos.h"
//pedef struct _tabdesc *PTABD; // For friend setting typedef class TDBFMT *PTDBFMT;
typedef class TDBFMT *PTDBFMT;
/***********************************************************************/
/***********************************************************************/ /* Functions used externally. */
/* Functions used externally. */ /***********************************************************************/
/***********************************************************************/ PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q,
PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q, int hdr, int mxr, bool info);
int hdr, int mxr, bool info);
/***********************************************************************/
/***********************************************************************/ /* CSV table. */
/* CSV table. */ /***********************************************************************/
/***********************************************************************/ class DllExport CSVDEF : public DOSDEF { /* Logical table description */
class DllExport CSVDEF : public DOSDEF { /* Logical table description */ friend class TDBCSV;
friend class TDBCSV; friend class TDBCCL;
friend class TDBCCL; public:
public: // Constructor
// Constructor CSVDEF(void);
CSVDEF(void);
// Implementation
// Implementation virtual const char *GetType(void) {return "CSV";}
virtual const char *GetType(void) {return "CSV";} char GetSep(void) {return Sep;}
char GetSep(void) {return Sep;} char GetQot(void) {return Qot;}
char GetQot(void) {return Qot;}
// 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 mode);
virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected:
protected: // Members
// Members bool Fmtd; /* true for formatted files */
bool Fmtd; /* true for formatted files */ //bool Accept; /* true if wrong lines are accepted */
//bool Accept; /* true if wrong lines are accepted */ bool Header; /* true if first line contains headers */
bool Header; /* true if first line contains headers */ //int Maxerr; /* Maximum number of bad records */
//int Maxerr; /* Maximum number of bad records */ int Quoted; /* Quoting level for quoted fields */
int Quoted; /* Quoting level for quoted fields */ char Sep; /* Separator for standard CSV files */
char Sep; /* Separator for standard CSV files */ char Qot; /* Character for quoted strings */
char Qot; /* Character for quoted strings */ }; // end of CSVDEF
}; // end of CSVDEF
/***********************************************************************/
/***********************************************************************/ /* This is the DOS/UNIX Access Method class declaration for files */
/* This is the DOS/UNIX Access Method class declaration for files */ /* that are CSV files with columns separated by the Sep character. */
/* that are CSV files with columns separated by the Sep character. */ /***********************************************************************/
/***********************************************************************/ class TDBCSV : public TDBDOS {
class TDBCSV : public TDBDOS { friend class CSVCOL;
friend class CSVCOL; public:
public: // Constructor
// Constructor TDBCSV(PCSVDEF tdp, PTXF txfp);
TDBCSV(PCSVDEF tdp, PTXF txfp); TDBCSV(PGLOBAL g, PTDBCSV tdbp);
TDBCSV(PGLOBAL g, PTDBCSV tdbp);
// Implementation
// Implementation virtual AMT GetAmType(void) {return TYPE_AM_CSV;}
virtual AMT GetAmType(void) {return TYPE_AM_CSV;} virtual PTDB Duplicate(PGLOBAL g)
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBCSV(g, this);}
{return (PTDB)new(g) TDBCSV(g, this);}
// Methods
// Methods virtual PTDB CopyOne(PTABS t);
virtual PTDB CopyOne(PTABS t); //virtual bool IsUsingTemp(PGLOBAL g);
//virtual bool IsUsingTemp(PGLOBAL g); virtual int GetBadLines(void) {return (int)Nerr;}
virtual int GetBadLines(void) {return (int)Nerr;}
// Database routines
// Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual bool OpenDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int CheckWrite(PGLOBAL g);
virtual int CheckWrite(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g); // Physical file read
virtual int ReadBuffer(PGLOBAL g); // Physical file read
// Specific routines
// Specific routines virtual int EstimatedLength(PGLOBAL g);
virtual int EstimatedLength(PGLOBAL g); virtual bool SkipHeader(PGLOBAL g);
virtual bool SkipHeader(PGLOBAL g); virtual bool CheckErr(void);
virtual bool CheckErr(void);
protected:
protected: // Members
// Members PSZ *Field; // Field to write to current line
PSZ *Field; // Field to write to current line int *Offset; // Column offsets for current record
int *Offset; // Column offsets for current record int *Fldlen; // Column field length for current record
int *Fldlen; // Column field length for current record bool *Fldtyp; // true for numeric fields
bool *Fldtyp; // true for numeric fields int Fields; // Number of fields to handle
int Fields; // Number of fields to handle int Nerr; // Number of bad records
int Nerr; // Number of bad records int Maxerr; // Maximum number of bad records
int Maxerr; // Maximum number of bad records int Quoted; // Quoting level for quoted fields
int Quoted; // Quoting level for quoted fields bool Accept; // true if bad lines are accepted
bool Accept; // true if bad lines are accepted bool Header; // true if first line contains column headers
bool Header; // true if first line contains column headers char Sep; // Separator
char Sep; // Separator char Qot; // Quoting character
char Qot; // Quoting character }; // end of class TDBCSV
}; // end of class TDBCSV
/***********************************************************************/
/***********************************************************************/ /* Class CSVCOL: CSV access method column descriptor. */
/* Class CSVCOL: CSV access method column descriptor. */ /* This A.M. is used for Comma Separated V(?) files. */
/* This A.M. is used for Comma Separated V(?) files. */ /***********************************************************************/
/***********************************************************************/ class CSVCOL : public DOSCOL {
class CSVCOL : public DOSCOL { friend class TDBCSV;
friend class TDBCSV; friend class TDBFMT;
friend class TDBFMT; public:
public: // Constructors
// Constructors CSVCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
CSVCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); CSVCOL(CSVCOL *colp, PTDB tdbp); // Constructor used in copy process
CSVCOL(CSVCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
// Implementation virtual int GetAmType() {return TYPE_AM_CSV;}
virtual int GetAmType() {return TYPE_AM_CSV;}
// Methods
// Methods virtual bool VarSize(void);
#if defined(BLK_INDX) virtual void ReadColumn(PGLOBAL g);
virtual bool VarSize(void); virtual void WriteColumn(PGLOBAL g);
#endif // BLK_INDX
virtual void ReadColumn(PGLOBAL g); protected:
virtual void WriteColumn(PGLOBAL g); // Default constructor not to be used
// void Print(FILE *, uint); CSVCOL(void) {}
protected: // Members
// Default constructor not to be used int Fldnum; // Field ordinal number (0 based)
CSVCOL(void) {} }; // end of class CSVCOL
// Members /***********************************************************************/
int Fldnum; // Field ordinal number (0 based) /* This is the DOS/UNIX Access Method class declaration for files */
}; // end of class CSVCOL /* whose record format is described by a Format keyword. */
/***********************************************************************/
/***********************************************************************/ class TDBFMT : public TDBCSV {
/* This is the DOS/UNIX Access Method class declaration for files */ friend class CSVCOL;
/* whose record format is described by a Format keyword. */ //friend class FMTCOL;
/***********************************************************************/ public:
class TDBFMT : public TDBCSV { // Standard constructor
friend class CSVCOL; TDBFMT(PCSVDEF tdp, PTXF txfp) : TDBCSV(tdp, txfp)
//friend class FMTCOL; {FldFormat = NULL; To_Fld = NULL; FmtTest = NULL; Linenum = 0;}
public:
// Standard constructor // Copy constructor
TDBFMT(PCSVDEF tdp, PTXF txfp) : TDBCSV(tdp, txfp) TDBFMT(PGLOBAL g, PTDBFMT tdbp);
{FldFormat = NULL; To_Fld = NULL; FmtTest = NULL; Linenum = 0;}
// Implementation
// Copy constructor virtual AMT GetAmType(void) {return TYPE_AM_FMT;}
TDBFMT(PGLOBAL g, PTDBFMT tdbp); virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBFMT(g, this);}
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_FMT;} // Methods
virtual PTDB Duplicate(PGLOBAL g) virtual PTDB CopyOne(PTABS t);
{return (PTDB)new(g) TDBFMT(g, this);}
// Database routines
// Methods virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PTDB CopyOne(PTABS t); //virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
// Database routines virtual int WriteDB(PGLOBAL g);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); //virtual int CheckWrite(PGLOBAL g);
//virtual int GetMaxSize(PGLOBAL g); virtual int ReadBuffer(PGLOBAL g); // Physical file read
virtual bool OpenDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); // Specific routines
//virtual int CheckWrite(PGLOBAL g); virtual int EstimatedLength(PGLOBAL g);
virtual int ReadBuffer(PGLOBAL g); // Physical file read
protected:
// Specific routines // Members
virtual int EstimatedLength(PGLOBAL g); PSZ *FldFormat; // Field read format
void *To_Fld; // To field test buffer
protected: int *FmtTest; // Test on ending by %n or %m
// Members int Linenum; // Last read line
PSZ *FldFormat; // Field read format }; // end of class TDBFMT
void *To_Fld; // To field test buffer
int *FmtTest; // Test on ending by %n or %m /***********************************************************************/
int Linenum; // Last read line /* This is the class declaration for the CSV catalog table. */
}; // end of class TDBFMT /***********************************************************************/
class TDBCCL : public TDBCAT {
/***********************************************************************/ public:
/* This is the class declaration for the CSV catalog table. */ // Constructor
/***********************************************************************/ TDBCCL(PCSVDEF tdp);
class TDBCCL : public TDBCAT {
public: protected:
// Constructor // Specific routines
TDBCCL(PCSVDEF tdp); virtual PQRYRES GetResult(PGLOBAL g);
protected: // Members
// Specific routines char *Fn; // The CSV file (path) name
virtual PQRYRES GetResult(PGLOBAL g); bool Hdr; // true if first line contains headers
int Mxr; // Maximum number of bad records
// Members int Qtd; // Quoting level for quoted fields
char *Fn; // The CSV file (path) name char Sep; // Separator for standard CSV files
bool Hdr; // true if first line contains headers }; // end of class TDBCCL
int Mxr; // Maximum number of bad records
int Qtd; // Quoting level for quoted fields /* ------------------------- End of TabFmt.H ------------------------- */
char Sep; // Separator for standard CSV files
}; // end of class TDBCCL
/* ------------------------- End of TabFmt.H ------------------------- */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -185,14 +185,7 @@ class TDBMYEXC : public TDBMYSQL {
// Methods // Methods
virtual PTDB CopyOne(PTABS t); virtual PTDB CopyOne(PTABS t);
//virtual int GetAffectedRows(void) {return AftRows;}
//virtual int GetRecpos(void) {return N;}
//virtual int GetProgMax(PGLOBAL g);
//virtual void ResetDB(void) {N = 0;}
//virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual bool IsView(void) {return Isview;} virtual bool IsView(void) {return Isview;}
//virtual PSZ GetServer(void) {return Server;}
// void SetDatabase(LPCSTR db) {Database = (char*)db;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
@@ -200,20 +193,10 @@ class TDBMYEXC : public TDBMYSQL {
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
//virtual int DeleteDB(PGLOBAL g, int irc);
//virtual void CloseDB(PGLOBAL g);
// Specific routines
// bool SetColumnRanks(PGLOBAL g);
// PCOL MakeFieldColumn(PGLOBAL g, char *name);
// PSZ FindFieldColumn(char *name);
protected: protected:
// Internal functions // Internal functions
PCMD MakeCMD(PGLOBAL g); PCMD MakeCMD(PGLOBAL g);
//bool MakeSelect(PGLOBAL g);
//bool MakeInsert(PGLOBAL g);
//int BindColumns(PGLOBAL g);
// Members // Members
PCMD Cmdlist; // The commands to execute PCMD Cmdlist; // The commands to execute
@@ -237,15 +220,9 @@ class MYXCOL : public MYSQLCOL {
MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am = "MYSQL"); MYXCOL(MYSQL_FIELD *fld, PTDB tdbp, int i, PSZ am = "MYSQL");
MYXCOL(MYXCOL *colp, PTDB tdbp); // Constructor used in copy process MYXCOL(MYXCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
//virtual int GetAmType(void) {return TYPE_AM_MYSQL;}
// void InitBind(PGLOBAL g);
// Methods // Methods
//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);
// bool FindRank(PGLOBAL g);
protected: protected:
// Default constructor not to be used // Default constructor not to be used

View File

@@ -68,7 +68,6 @@ class TDBOCCUR : public TDBPRX {
protected: protected:
// Members // Members
//PTDBASE Tdbp; // To the source table or view
LPCSTR Tabname; // Name of source table LPCSTR Tabname; // Name of source table
char *Colist; // Source column list char *Colist; // Source column list
char *Xcolumn; // Occurence column name char *Xcolumn; // Occurence column name

View File

@@ -158,7 +158,6 @@ class ODBCCOL : public COLBLK {
// PVBLK GetBlkp(void) {return Blkp;} // PVBLK GetBlkp(void) {return Blkp;}
// Methods // Methods
//virtual bool CheckLocal(PTDB tdbp);
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);

View File

@@ -1,182 +1,181 @@
/*************** TabSys H Declares Source Code File (.H) ***************/ /*************** TabSys H Declares Source Code File (.H) ***************/
/* Name: TABSYS.H Version 2.2 */ /* Name: TABSYS.H Version 2.2 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2004-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2004-2013 */
/* */ /* */
/* This file contains the XDB system tables classes declares. */ /* This file contains the XDB system tables classes declares. */
/***********************************************************************/ /***********************************************************************/
typedef class INIDEF *PINIDEF; typedef class INIDEF *PINIDEF;
typedef class TDBINI *PTDBINI; typedef class TDBINI *PTDBINI;
typedef class INICOL *PINICOL; typedef class INICOL *PINICOL;
typedef class TDBXIN *PTDBXIN; typedef class TDBXIN *PTDBXIN;
typedef class XINCOL *PXINCOL; typedef class XINCOL *PXINCOL;
/* --------------------------- INI classes --------------------------- */ /* --------------------------- INI classes --------------------------- */
/***********************************************************************/ /***********************************************************************/
/* INI, XDB and XCL tables. */ /* INI, XDB and XCL tables. */
/***********************************************************************/ /***********************************************************************/
class DllExport INIDEF : public TABDEF { /* INI table description */ class DllExport INIDEF : public TABDEF { /* INI table description */
friend class TDBINI; friend class TDBINI;
friend class TDBXIN; friend class TDBXIN;
friend class TDBXTB; friend class TDBXTB;
friend class TDBRTB; friend class TDBRTB;
friend class TDBXCL; friend class TDBXCL;
public: public:
// Constructor // Constructor
INIDEF(void); INIDEF(void);
// Implementation // Implementation
virtual const char *GetType(void) {return "INI";} virtual const char *GetType(void) {return "INI";}
// 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);
protected:
protected: // Members
// Members char *Fn; /* Path/Name of corresponding file */
char *Fn; /* Path/Name of corresponding file */ char *Xname; /* The eventual table name */
char *Xname; /* The eventual table name */ char Layout; /* R: Row, C: Column */
char Layout; /* R: Row, C: Column */ int Ln; /* Length of section list buffer */
int Ln; /* Length of section list buffer */ }; // end of INIDEF
}; // end of INIDEF
/***********************************************************************/
/***********************************************************************/ /* This is the class declaration for the INI tables. */
/* This is the class declaration for the INI tables. */ /* These are tables represented by a INI like file. */
/* These are tables represented by a INI like file. */ /***********************************************************************/
/***********************************************************************/ class TDBINI : public TDBASE {
class TDBINI : public TDBASE { friend class INICOL;
friend class INICOL; public:
public: // Constructor
// Constructor TDBINI(PINIDEF tdp);
TDBINI(PINIDEF tdp); TDBINI(PTDBINI tdbp);
TDBINI(PTDBINI tdbp);
// Implementation
// Implementation virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual AMT GetAmType(void) {return TYPE_AM_INI;} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);}
// Methods
// Methods virtual PTDB CopyOne(PTABS t);
virtual PTDB CopyOne(PTABS t); virtual int GetRecpos(void) {return N;}
virtual int GetRecpos(void) {return N;} virtual int GetProgCur(void) {return N;}
virtual int GetProgCur(void) {return N;} virtual int GetAffectedRows(void) {return 0;}
virtual int GetAffectedRows(void) {return 0;} virtual PSZ GetFile(PGLOBAL g) {return Ifile;}
virtual PSZ GetFile(PGLOBAL g) {return Ifile;} virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;}
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;} virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;}
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;} virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;}
virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;} virtual int RowNumber(PGLOBAL g, bool b = false) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;} char *GetSeclist(PGLOBAL g);
char *GetSeclist(PGLOBAL g);
// Database routines
// Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int GetMaxSize(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc);
virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g);
virtual void CloseDB(PGLOBAL g);
protected:
protected: // Members
// Members char *Ifile; // The INI file
char *Ifile; // The INI file char *Seclist; // The section list
char *Seclist; // The section list char *Section; // The current section
char *Section; // The current section int Seclen; // Length of seclist buffer
int Seclen; // Length of seclist buffer int N; // The current section index
int N; // The current section index }; // end of class TDBINI
}; // end of class TDBINI
/***********************************************************************/
/***********************************************************************/ /* Class INICOL: XDB table access method column descriptor. */
/* Class INICOL: XDB table access method column descriptor. */ /***********************************************************************/
/***********************************************************************/ class INICOL : public COLBLK {
class INICOL : public COLBLK { public:
public: // Constructors
// Constructors INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
// Implementation virtual int GetAmType(void) {return TYPE_AM_INI;}
virtual int GetAmType(void) {return TYPE_AM_INI;} virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
// Methods
// Methods 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 AllocBuf(PGLOBAL g);
virtual void AllocBuf(PGLOBAL g);
protected:
protected: // Default constructor not to be used
// Default constructor not to be used INICOL(void) {}
INICOL(void) {}
// Members
// Members char *Valbuf; // To the key value buffer
char *Valbuf; // To the key value buffer int Flag; // Tells what set in value
int Flag; // Tells what set in value int Long; // Buffer length
int Long; // Buffer length PVAL To_Val; // To value used for Update/Insert
PVAL To_Val; // To value used for Update/Insert }; // end of class INICOL
}; // end of class INICOL
/* --------------------------- XINI class ---------------------------- */
/* --------------------------- XINI class ---------------------------- */
/***********************************************************************/
/***********************************************************************/ /* This is the class declaration for the XINI tables. */
/* This is the class declaration for the XINI tables. */ /* These are tables represented by a INI like file */
/* These are tables represented by a INI like file */ /* having 3 columns Section, Key, and Value. */
/* having 3 columns Section, Key, and Value. */ /***********************************************************************/
/***********************************************************************/ class TDBXIN : public TDBINI {
class TDBXIN : public TDBINI { friend class XINCOL;
friend class XINCOL; public:
public: // Constructor
// Constructor TDBXIN(PINIDEF tdp);
TDBXIN(PINIDEF tdp); TDBXIN(PTDBXIN tdbp);
TDBXIN(PTDBXIN tdbp);
// Implementation
// Implementation virtual AMT GetAmType(void) {return TYPE_AM_INI;}
virtual AMT GetAmType(void) {return TYPE_AM_INI;} virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);}
// Methods
// Methods virtual PTDB CopyOne(PTABS t);
virtual PTDB CopyOne(PTABS t); virtual int GetRecpos(void);
virtual int GetRecpos(void); virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual bool SetRecpos(PGLOBAL g, int recpos); virtual void ResetDB(void)
virtual void ResetDB(void) {Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;}
{Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;} char *GetKeylist(PGLOBAL g, char *sec);
char *GetKeylist(PGLOBAL g, char *sec);
// Database routines
// Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int GetMaxSize(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc);
virtual int DeleteDB(PGLOBAL g, int irc);
protected:
protected: // Members
// Members char *Keylist; // The key list
char *Keylist; // The key list char *Keycur; // The current key
char *Keycur; // The current key int Keylen; // Length of keylist buffer
int Keylen; // Length of keylist buffer short Oldsec; // Last current section
short Oldsec; // Last current section }; // end of class TDBXIN
}; // end of class TDBXIN
/***********************************************************************/
/***********************************************************************/ /* Class XINCOL: XIN table access method column descriptor. */
/* Class XINCOL: XIN table access method column descriptor. */ /***********************************************************************/
/***********************************************************************/ class XINCOL : public INICOL {
class XINCOL : public INICOL { public:
public: // Constructors
// Constructors XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI");
XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
// Implementation
// Methods
// Methods virtual void ReadColumn(PGLOBAL g);
virtual void ReadColumn(PGLOBAL g); virtual void WriteColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
protected:
protected: // Default constructor not to be used
// Default constructor not to be used XINCOL(void) {}
XINCOL(void) {}
// Members
// Members }; // end of class XINICOL
}; // end of class XINICOL

View File

@@ -1,169 +1,159 @@
/*************** TabTbl H Declares Source Code File (.H) ***************/ /*************** TabTbl H Declares Source Code File (.H) ***************/
/* Name: TABTBL.H Version 1.3 */ /* Name: TABTBL.H Version 1.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2008-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2008-2013 */
/* */ /* */
/* This file contains the TDBTBL classes declares. */ /* This file contains the TDBTBL classes declares. */
/***********************************************************************/ /***********************************************************************/
#include "block.h" #include "block.h"
#include "colblk.h" #include "colblk.h"
#include "tabutil.h" #include "tabutil.h"
typedef class TBLDEF *PTBLDEF; typedef class TBLDEF *PTBLDEF;
typedef class TDBTBL *PTDBTBL; typedef class TDBTBL *PTDBTBL;
typedef class TDBTBM *PTDBTBM; typedef class TDBTBM *PTDBTBM;
typedef class MYSQLC *PMYC; typedef class MYSQLC *PMYC;
/***********************************************************************/ /***********************************************************************/
/* Defines the structures used for distributed TBM tables. */ /* Defines the structures used for distributed TBM tables. */
/***********************************************************************/ /***********************************************************************/
typedef struct _TBMtable *PTBMT; typedef struct _TBMtable *PTBMT;
typedef struct _TBMtable { typedef struct _TBMtable {
PTBMT Next; // Points to next data table struct PTBMT Next; // Points to next data table struct
PTABLE Tap; // Points to the sub table PTABLE Tap; // Points to the sub table
PGLOBAL G; // Needed in thread routine PGLOBAL G; // Needed in thread routine
bool Complete; // TRUE when all results are read bool Complete; // TRUE when all results are read
bool Ready; // TRUE when results are there bool Ready; // TRUE when results are there
int Rows; // Total number of rows read so far int Rows; // Total number of rows read so far
int ProgCur; // Current pos int ProgCur; // Current pos
int ProgMax; // Max pos int ProgMax; // Max pos
int Rc; // Return code int Rc; // Return code
THD *Thd; THD *Thd;
pthread_attr_t attr; // ??? pthread_attr_t attr; // ???
pthread_t Tid; // CheckOpen thread ID pthread_t Tid; // CheckOpen thread ID
} TBMT; } TBMT;
/***********************************************************************/ /***********************************************************************/
/* TBL table. */ /* TBL table. */
/***********************************************************************/ /***********************************************************************/
class DllExport TBLDEF : public PRXDEF { /* Logical table description */ class DllExport TBLDEF : public PRXDEF { /* Logical table description */
friend class TDBTBL; friend class TDBTBL;
friend class TDBTBC; friend class TDBTBC;
public: public:
// Constructor // Constructor
TBLDEF(void); TBLDEF(void);
// Implementation // Implementation
virtual const char *GetType(void) {return "TBL";} virtual const char *GetType(void) {return "TBL";}
// 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);
protected: protected:
// Members // Members
bool Accept; /* TRUE if bad tables are accepted */ bool Accept; /* TRUE if bad tables are accepted */
bool Thread; /* Use thread for remote tables */ bool Thread; /* Use thread for remote tables */
int Maxerr; /* Maximum number of bad tables */ int Maxerr; /* Maximum number of bad tables */
int Ntables; /* Number of tables */ int Ntables; /* Number of tables */
}; // end of TBLDEF }; // end of TBLDEF
/***********************************************************************/ /***********************************************************************/
/* This is the TBL Access Method class declaration. */ /* This is the TBL Access Method class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBTBL : public TDBPRX { class DllExport TDBTBL : public TDBPRX {
friend class TBTBLK; friend class TBTBLK;
public: public:
// Constructor // Constructor
TDBTBL(PTBLDEF tdp = NULL); TDBTBL(PTBLDEF tdp = NULL);
// Implementation // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_TBL;} virtual AMT GetAmType(void) {return TYPE_AM_TBL;}
// Methods // Methods
virtual void ResetDB(void); virtual void ResetDB(void);
virtual int GetRecpos(void) {return Rows;} virtual int GetRecpos(void) {return Rows;}
virtual int GetBadLines(void) {return (int)Nbc;} virtual int GetBadLines(void) {return (int)Nbc;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
protected: protected:
// Internal functions // Internal functions
bool InitTableList(PGLOBAL g); bool InitTableList(PGLOBAL g);
bool TestFil(PGLOBAL g, PCFIL 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
PTABLE CurTable; // Points to the current table PTABLE CurTable; // Points to the current table
bool Accept; // TRUE if bad tables are accepted bool Accept; // TRUE if bad tables are accepted
int Maxerr; // Maximum number of bad tables int Maxerr; // Maximum number of bad tables
int Nbc; // Number of bad connections int Nbc; // Number of bad connections
int Rows; // Used for RowID int Rows; // Used for RowID
int Crp; // Used for CurPos int Crp; // Used for CurPos
}; // end of class TDBTBL }; // end of class TDBTBL
/***********************************************************************/ /***********************************************************************/
/* Class TBTBLK: TDBPLG TABID special column descriptor. */ /* Class TBTBLK: TDBPLG TABID special column descriptor. */
/***********************************************************************/ /***********************************************************************/
class TBTBLK : public TIDBLK { class TBTBLK : public TIDBLK {
public: public:
// The constructor must restore Value because XOBJECT has a void // The constructor must restore Value because XOBJECT has a void
// constructor called by default that set Value to NULL // constructor called by default that set Value to NULL
TBTBLK(PVAL valp) {Value = valp;} TBTBLK(PVAL valp) {Value = valp;}
// Methods // Methods
virtual void ReadColumn(PGLOBAL g); virtual void ReadColumn(PGLOBAL g);
// Fake operator new used to change TIDBLK into SDTBLK // Fake operator new used to change TIDBLK into SDTBLK
void * operator new(size_t size, TIDBLK *sp) {return sp;} void * operator new(size_t size, TIDBLK *sp) {return sp;}
#if !defined(__BORLANDC__) #if !defined(__BORLANDC__)
// Avoid warning C4291 by defining a matching dummy delete operator // Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, TIDBLK*) {} void operator delete(void *, TIDBLK*) {}
void operator delete(void *, size_t size) {} void operator delete(void *, size_t size) {}
#endif #endif
protected: protected:
// Must not have additional members // Must not have additional members
}; // end of class TBTBLK }; // end of class TBTBLK
/***********************************************************************/ /***********************************************************************/
/* This is the TBM Access Method class declaration. */ /* This is the TBM Access Method class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBTBM : public TDBTBL { class DllExport TDBTBM : public TDBTBL {
friend class TBTBLK; friend class TBTBLK;
public: public:
// Constructor // Constructor
TDBTBM(PTBLDEF tdp = NULL); TDBTBM(PTBLDEF tdp = NULL);
// Implementation // Methods
//virtual AMT GetAmType(void) {return TYPE_AM_TBL;} virtual void ResetDB(void);
// Methods // Database routines
virtual void ResetDB(void); virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary
//virtual int GetRecpos(void) {return Rows;} virtual int RowNumber(PGLOBAL g, bool b = FALSE);
//virtual int GetBadLines(void) {return (int)Nbc;} virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
// Database routines
//virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); protected:
virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary // Internal functions
virtual int RowNumber(PGLOBAL g, bool b = FALSE); bool OpenTables(PGLOBAL g);
//virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); int ReadNextRemote(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); // Members
PTBMT Tmp; // To data table TBMT structures
protected: PTBMT Cmp; // Current data table PLGF (to move to TDBTBL)
// Internal functions PTBMT Bmp; // To bad (unconnected) PLGF structures
//bool InitTableList(PGLOBAL g); bool Done; // TRUE after first GetAllResults
//bool TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp); int Nrc; // Number of remote connections
bool OpenTables(PGLOBAL g); int Nlc; // Number of local connections
int ReadNextRemote(PGLOBAL g); }; // end of class TDBTBM
// Members pthread_handler_t ThreadOpen(void *p);
PTBMT Tmp; // To data table TBMT structures
PTBMT Cmp; // Current data table PLGF (to move to TDBTBL)
PTBMT Bmp; // To bad (unconnected) PLGF structures
bool Done; // TRUE after first GetAllResults
int Nrc; // Number of remote connections
int Nlc; // Number of local connections
}; // end of class TDBTBM
pthread_handler_t ThreadOpen(void *p);

View File

@@ -54,7 +54,6 @@ class DllExport PRXDEF : public TABDEF { /* Logical table description */
/* This is the class declaration for the XCSV table. */ /* This is the class declaration for the XCSV table. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBPRX : public TDBASE { class DllExport TDBPRX : public TDBASE {
//friend class MULINDX;
friend class PRXDEF; friend class PRXDEF;
friend class PRXCOL; friend class PRXCOL;
public: public:
@@ -126,8 +125,6 @@ class TDBTBC : public TDBCAT {
public: public:
// Constructors // Constructors
TDBTBC(PPRXDEF tdp); TDBTBC(PPRXDEF tdp);
//TDBTBC(PTBLDEF tdp);
//TDBTBC(PXCLDEF tdp);
protected: protected:
// Specific routines // Specific routines

View File

@@ -301,9 +301,7 @@ bool TDBVCT::OpenDB(PGLOBAL g)
To_Kindex->Reset(); To_Kindex->Reset();
Txfp->Rewind(); Txfp->Rewind();
#if defined(BLK_INDX)
ResetBlockFilter(g); ResetBlockFilter(g);
#endif // BLK_INDX
return false; return false;
} // endif Use } // endif Use
@@ -325,12 +323,10 @@ 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. */ /* Allocate the block filter tree if evaluation is possible. */
/*********************************************************************/ /*********************************************************************/
To_BlkFil = InitBlockFilter(g, To_Filter); 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

@@ -1,123 +1,121 @@
/*************** TabVct H Declares Source Code File (.H) ***************/ /*************** TabVct H Declares Source Code File (.H) ***************/
/* Name: TABVCT.H Version 3.4 */ /* Name: TABVCT.H Version 3.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */ /* (C) Copyright to the author Olivier BERTRAND 1999-2011 */
/* */ /* */
/* This file contains the TDBVCT class declares. */ /* This file contains the TDBVCT class declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __TABVCT__ #ifndef __TABVCT__
#define __TABVCT__ #define __TABVCT__
#include "tabfix.h" #include "tabfix.h"
#if defined(UNIX) #if defined(UNIX)
//#include <string.h.SUNWCCh> //#include <string.h.SUNWCCh>
#endif #endif
typedef class TDBVCT *PTDBVCT; typedef class TDBVCT *PTDBVCT;
typedef class VCTCOL *PVCTCOL; typedef class VCTCOL *PVCTCOL;
/***********************************************************************/ /***********************************************************************/
/* VCT table. */ /* VCT table. */
/***********************************************************************/ /***********************************************************************/
class DllExport VCTDEF : public DOSDEF { /* Logical table description */ class DllExport VCTDEF : public DOSDEF { /* Logical table description */
friend class VCTFAM; friend class VCTFAM;
friend class VECFAM; friend class VECFAM;
friend class VMPFAM; friend class VMPFAM;
public: public:
// Constructor // Constructor
VCTDEF(void) {Split = Estimate = Header = 0;} VCTDEF(void) {Split = Estimate = Header = 0;}
// Implementation // Implementation
virtual const char *GetType(void) {return "VCT";} virtual const char *GetType(void) {return "VCT";}
int GetEstimate(void) {return Estimate;} int GetEstimate(void) {return Estimate;}
// 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 mode); virtual PTDB GetTable(PGLOBAL g, MODE mode);
protected: protected:
// Specific file erase routine for vertical tables int MakeFnPattern(char *fpat);
//virtual bool Erase(char *filename);
int MakeFnPattern(char *fpat); // Members
int Split; /* Columns in separate files */
// Members int Estimate; /* Estimated maximum size of table */
int Split; /* Columns in separate files */ int Header; /* 0: no, 1: separate, 2: in data file */
int Estimate; /* Estimated maximum size of table */ }; // end of VCTDEF
int Header; /* 0: no, 1: separate, 2: in data file */
}; // end of VCTDEF /***********************************************************************/
/* This is the DOS/UNIX Access Method class declaration for files */
/***********************************************************************/ /* in blocked vector format. In each block containing "Elements" */
/* This is the DOS/UNIX Access Method class declaration for files */ /* records, values of each columns are consecutively stored (vector). */
/* in blocked vector format. In each block containing "Elements" */ /***********************************************************************/
/* records, values of each columns are consecutively stored (vector). */ class DllExport TDBVCT : public TDBFIX {
/***********************************************************************/ friend class VCTCOL;
class DllExport TDBVCT : public TDBFIX { friend class VCTFAM;
friend class VCTCOL; friend class VCMFAM;
friend class VCTFAM; friend class VECFAM;
friend class VCMFAM; friend class VMPFAM;
friend class VECFAM; public:
friend class VMPFAM; // Constructors
public: TDBVCT(PVCTDEF tdp, PTXF txfp);
// Constructors TDBVCT(PGLOBAL g, PTDBVCT tdbp);
TDBVCT(PVCTDEF tdp, PTXF txfp);
TDBVCT(PGLOBAL g, PTDBVCT tdbp); // Implementation
virtual AMT GetAmType(void) {return TYPE_AM_VCT;}
// Implementation virtual PTDB Duplicate(PGLOBAL g)
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} {return (PTDB)new(g) TDBVCT(g, this);}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBVCT(g, this);} // Methods
virtual PTDB CopyOne(PTABS t);
// Methods
virtual PTDB CopyOne(PTABS t); // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
// Database routines virtual bool OpenDB(PGLOBAL g);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int ReadDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual void CloseDB(PGLOBAL g); protected:
// Members
protected: }; // end of class TDBVCT
// Members
}; // end of class TDBVCT /***********************************************************************/
/* Class VCTCOL: VCT access method column descriptor. */
/***********************************************************************/ /* This A.M. is used for file having column wise organization. */
/* Class VCTCOL: VCT access method column descriptor. */ /***********************************************************************/
/* This A.M. is used for file having column wise organization. */ class DllExport VCTCOL : public DOSCOL {
/***********************************************************************/ friend class TDBVCT;
class DllExport VCTCOL : public DOSCOL { friend class VCTFAM;
friend class TDBVCT; friend class VCMFAM;
friend class VCTFAM; friend class VECFAM;
friend class VCMFAM; friend class VMPFAM;
friend class VECFAM; friend class BGVFAM;
friend class VMPFAM; public:
friend class BGVFAM; // Constructors
public: VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
// Constructors VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process
VCTCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i);
VCTCOL(VCTCOL *colp, PTDB tdbp); // Constructor used in copy process // Implementation
virtual int GetAmType(void) {return TYPE_AM_VCT;}
// Implementation
virtual int GetAmType(void) {return TYPE_AM_VCT;} // Methods
virtual void ReadColumn(PGLOBAL g);
// Methods virtual void WriteColumn(PGLOBAL g);
virtual void ReadColumn(PGLOBAL g); virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void WriteColumn(PGLOBAL g); virtual void SetOk(void);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetOk(void); protected:
virtual void ReadBlock(PGLOBAL g);
protected: virtual void WriteBlock(PGLOBAL g);
virtual void ReadBlock(PGLOBAL g);
virtual void WriteBlock(PGLOBAL g); VCTCOL(void) {} // Default constructor not to be used
VCTCOL(void) {} // Default constructor not to be used // Members
PVBLK Blk; // Block buffer
// Members int Clen; // Internal length in table
PVBLK Blk; // Block buffer int ColBlk; // Block pointed by column
int Clen; // Internal length in table int ColPos; // Last position read
int ColBlk; // Block pointed by column int Modif; // Number of modified lines in block
int ColPos; // Last position read }; // end of class VCTCOL
int Modif; // Number of modified lines in block
}; // end of class VCTCOL #endif // __TABVCT__
#endif // __TABVCT__

View File

@@ -1,151 +1,150 @@
// TABWMI.H Olivier Bertrand 2012 // TABWMI.H Olivier Bertrand 2012
// WMI: Virtual table to Get WMI information // WMI: Virtual table to Get WMI information
#define _WIN32_DCOM #define _WIN32_DCOM
#include <wbemidl.h> #include <wbemidl.h>
# pragma comment(lib, "wbemuuid.lib") # pragma comment(lib, "wbemuuid.lib")
#include <iostream> #include <iostream>
using namespace std; using namespace std;
#include <comdef.h> #include <comdef.h>
/***********************************************************************/ /***********************************************************************/
/* Definitions. */ /* Definitions. */
/***********************************************************************/ /***********************************************************************/
typedef class WMIDEF *PWMIDEF; typedef class WMIDEF *PWMIDEF;
typedef class TDBWMI *PTDBWMI; typedef class TDBWMI *PTDBWMI;
typedef class WMICOL *PWMICOL; typedef class WMICOL *PWMICOL;
typedef class TDBWCL *PTDBWCL; typedef class TDBWCL *PTDBWCL;
typedef class WCLCOL *PWCLCOL; typedef class WCLCOL *PWCLCOL;
/***********************************************************************/ /***********************************************************************/
/* Structure used by WMI column info functions. */ /* Structure used by WMI column info functions. */
/***********************************************************************/ /***********************************************************************/
typedef struct _WMIutil { typedef struct _WMIutil {
IWbemServices *Svc; IWbemServices *Svc;
IWbemClassObject *Cobj; IWbemClassObject *Cobj;
} WMIUTIL, *PWMIUT; } WMIUTIL, *PWMIUT;
/***********************************************************************/ /***********************************************************************/
/* Functions used externally. */ /* Functions used externally. */
/***********************************************************************/ /***********************************************************************/
PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info); PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info);
/* -------------------------- WMI classes ---------------------------- */ /* -------------------------- WMI classes ---------------------------- */
/***********************************************************************/ /***********************************************************************/
/* WMI: Virtual table to get the WMI information. */ /* WMI: Virtual table to get the WMI information. */
/***********************************************************************/ /***********************************************************************/
class WMIDEF : public TABDEF { /* Logical table description */ class WMIDEF : public TABDEF { /* Logical table description */
friend class TDBWMI; friend class TDBWMI;
friend class TDBWCL; friend class TDBWCL;
friend class TDBWCX; friend class TDBWCX;
public: public:
// Constructor // Constructor
WMIDEF(void) {Pseudo = 3; Nspace = NULL; Wclass = NULL; Ems = 0;} WMIDEF(void) {Pseudo = 3; Nspace = NULL; Wclass = NULL; Ems = 0;}
// Implementation // Implementation
virtual const char *GetType(void) {return "WMI";} virtual const char *GetType(void) {return "WMI";}
// 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;}
protected:
protected: // Members
// Members char *Nspace;
char *Nspace; char *Wclass;
char *Wclass; int Ems;
int Ems; }; // end of WMIDEF
}; // end of WMIDEF
/***********************************************************************/
/***********************************************************************/ /* This is the class declaration for the WMI table. */
/* This is the class declaration for the WMI table. */ /***********************************************************************/
/***********************************************************************/ class TDBWMI : public TDBASE {
class TDBWMI : public TDBASE { friend class WMICOL;
friend class WMICOL; public:
public: // Constructor
// Constructor TDBWMI(PWMIDEF tdp);
TDBWMI(PWMIDEF tdp);
// Implementation
// Implementation virtual AMT GetAmType(void) {return TYPE_AM_WMI;}
virtual AMT GetAmType(void) {return TYPE_AM_WMI;}
// Methods
// Methods virtual int GetRecpos(void);
virtual int GetRecpos(void); virtual int GetProgCur(void) {return N;}
virtual int GetProgCur(void) {return N;} virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
// Database routines
// Database routines virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual int GetMaxSize(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc);
virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g);
virtual void CloseDB(PGLOBAL g);
protected:
protected: // Specific routines
// Specific routines bool Initialize(PGLOBAL g);
bool Initialize(PGLOBAL g); char *MakeWQL(PGLOBAL g);
char *MakeWQL(PGLOBAL g); void DoubleSlash(PGLOBAL g);
void DoubleSlash(PGLOBAL g); bool GetWMIInfo(PGLOBAL g);
bool GetWMIInfo(PGLOBAL g);
// Members
// Members IWbemServices *Svc; // IWbemServices pointer
IWbemServices *Svc; // IWbemServices pointer IEnumWbemClassObject *Enumerator;
IEnumWbemClassObject *Enumerator; IWbemClassObject *ClsObj;
IWbemClassObject *ClsObj; char *Nspace; // Namespace
char *Nspace; // Namespace char *Wclass; // Class name
char *Wclass; // Class name char *ObjPath; // Used for direct access
char *ObjPath; // Used for direct access char *Kvp; // Itou
char *Kvp; // Itou int Ems; // Estimated max size
int Ems; // Estimated max size PCOL Kcol; // Key column
PCOL Kcol; // Key column HRESULT Res;
HRESULT Res; PVBLK Vbp;
PVBLK Vbp; bool Init;
bool Init; bool Done;
bool Done; ULONG Rc;
ULONG Rc; int N; // Row number
int N; // Row number }; // end of class TDBWMI
}; // end of class TDBWMI
/***********************************************************************/
/***********************************************************************/ /* Class WMICOL: WMI Address column. */
/* Class WMICOL: WMI Address column. */ /***********************************************************************/
/***********************************************************************/ class WMICOL : public COLBLK {
class WMICOL : public COLBLK { friend class TDBWMI;
friend class TDBWMI; public:
public: // Constructors
// Constructors WMICOL(PCOLDEF cdp, PTDB tdbp, int n);
WMICOL(PCOLDEF cdp, PTDB tdbp, int n);
// Implementation
// Implementation virtual int GetAmType(void) {return TYPE_AM_WMI;}
virtual int GetAmType(void) {return TYPE_AM_WMI;}
// Methods
// Methods virtual void ReadColumn(PGLOBAL g);
virtual void ReadColumn(PGLOBAL g);
protected:
protected: WMICOL(void) {} // Default constructor not to be used
WMICOL(void) {} // Default constructor not to be used
// Members
// Members PTDBWMI Tdbp; // Points to WMI table block
PTDBWMI Tdbp; // Points to WMI table block VARIANT Prop; // Property value
VARIANT Prop; // Property value CIMTYPE Ctype; // CIM Type
CIMTYPE Ctype; // CIM Type HRESULT Res;
HRESULT Res; }; // end of class WMICOL
}; // end of class WMICOL
/***********************************************************************/
/***********************************************************************/ /* This is the class declaration for the WMI catalog table. */
/* This is the class declaration for the WMI catalog table. */ /***********************************************************************/
/***********************************************************************/ class TDBWCL : public TDBCAT {
class TDBWCL : public TDBCAT { public:
public: // Constructor
// Constructor TDBWCL(PWMIDEF tdp);
TDBWCL(PWMIDEF tdp);
protected:
protected: // Specific routines
// Specific routines virtual PQRYRES GetResult(PGLOBAL g);
virtual PQRYRES GetResult(PGLOBAL g);
// Members
// Members char *Nsp; // Name space
char *Nsp; // Name space char *Cls; // Class
char *Cls; // Class }; // end of class TDBWCL
}; // end of class TDBWCL

View File

@@ -1,246 +1,240 @@
/*************** Tabxml H Declares Source Code File (.H) ***************/ /*************** Tabxml H Declares Source Code File (.H) ***************/
/* Name: TABXML.H Version 1.6 */ /* Name: TABXML.H Version 1.6 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2007-2013 */
/* */ /* */
/* This file contains the XML table classes declares. */ /* This file contains the XML table classes declares. */
/***********************************************************************/ /***********************************************************************/
typedef class XMLDEF *PXMLDEF; typedef class XMLDEF *PXMLDEF;
typedef class TDBXML *PTDBXML; typedef class TDBXML *PTDBXML;
typedef class XMLCOL *PXMLCOL; typedef class XMLCOL *PXMLCOL;
// These functions are exported from the Extended.dll /* --------------------------- XML classes --------------------------- */
//PTABDEF __stdcall GetXML(PGLOBAL g, void *memp);
/***********************************************************************/
/* --------------------------- XML classes --------------------------- */ /* XML table. */
/***********************************************************************/
/***********************************************************************/ class DllExport XMLDEF : public TABDEF { /* Logical table description */
/* XML table. */ friend class TDBXML;
/***********************************************************************/ public:
class DllExport XMLDEF : public TABDEF { /* Logical table description */ // Constructor
friend class TDBXML; XMLDEF(void);
public:
// Constructor // Implementation
XMLDEF(void); virtual const char *GetType(void) {return "XML";}
// Implementation // Methods
virtual const char *GetType(void) {return "XML";} virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); protected:
virtual PTDB GetTable(PGLOBAL g, MODE m); // Members
//virtual bool DeleteTableFile(PGLOBAL g); char *Fn; /* Path/Name of corresponding file */
char *Encoding; /* New XML table file encoding */
protected: char *Tabname; /* Name of Table node */
// Members char *Rowname; /* Name of first level nodes */
char *Fn; /* Path/Name of corresponding file */ char *Colname; /* Name of second level nodes */
char *Encoding; /* New XML table file encoding */ char *Mulnode; /* Name of multiple node */
char *Tabname; /* Name of Table node */ char *XmlDB; /* Name of XML DB node */
char *Rowname; /* Name of first level nodes */ char *Nslist; /* List of namespaces to register */
char *Colname; /* Name of second level nodes */ char *DefNs; /* Dummy name of default namespace */
char *Mulnode; /* Name of multiple node */ char *Attrib; /* Table node attributes */
char *XmlDB; /* Name of XML DB node */ char *Hdattr; /* Header node attributes */
char *Nslist; /* List of namespaces to register */ int Coltype; /* Default column type */
char *DefNs; /* Dummy name of default namespace */ int Limit; /* Limit of multiple values */
char *Attrib; /* Table node attributes */ int Header; /* n first rows are header rows */
char *Hdattr; /* Header node attributes */ bool Xpand; /* Put multiple tags in several rows */
int Coltype; /* Default column type */ bool Usedom; /* True: DOM, False: libxml2 */
int Limit; /* Limit of multiple values */ }; // end of XMLDEF
int Header; /* n first rows are header rows */
bool Xpand; /* Put multiple tags in several rows */ #if defined(INCLUDE_TDBXML)
bool Usedom; /* True: DOM, False: libxml2 */ /***********************************************************************/
}; // end of XMLDEF /* This is the class declaration for the simple XML tables. */
/***********************************************************************/
#if defined(INCLUDE_TDBXML) class DllExport TDBXML : public TDBASE {
friend class XMLCOL;
/***********************************************************************/ friend class XMULCOL;
/* This is the class declaration for the simple XML tables. */ friend class XPOSCOL;
/***********************************************************************/ public:
class DllExport TDBXML : public TDBASE { // Constructor
friend class XMLCOL; TDBXML(PXMLDEF tdp);
friend class XMULCOL; TDBXML(PTDBXML tdbp);
friend class XPOSCOL;
public: // Implementation
// Constructor virtual AMT GetAmType(void) {return TYPE_AM_XML;}
TDBXML(PXMLDEF tdp); virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXML(this);}
TDBXML(PTDBXML tdbp);
// Methods
// Implementation virtual PTDB CopyOne(PTABS t);
virtual AMT GetAmType(void) {return TYPE_AM_XML;} virtual int GetRecpos(void);
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXML(this);} virtual int GetProgCur(void) {return N;}
virtual PSZ GetFile(PGLOBAL g) {return Xfile;}
// Methods virtual void SetFile(PGLOBAL g, PSZ fn) {Xfile = fn;}
virtual PTDB CopyOne(PTABS t); virtual void ResetDB(void) {N = 0;}
virtual int GetRecpos(void); virtual void ResetSize(void) {MaxSize = -1;}
virtual int GetProgCur(void) {return N;} virtual int RowNumber(PGLOBAL g, bool b = false);
virtual PSZ GetFile(PGLOBAL g) {return Xfile;} int LoadTableFile(PGLOBAL g, char *filename);
virtual void SetFile(PGLOBAL g, PSZ fn) {Xfile = fn;} bool Initialize(PGLOBAL g);
virtual void ResetDB(void) {N = 0;} bool SetTabNode(PGLOBAL g);
virtual void ResetSize(void) {MaxSize = -1;} void SetNodeAttr(PGLOBAL g, char *attr, PXNODE node);
virtual int RowNumber(PGLOBAL g, bool b = false); bool CheckRow(PGLOBAL g, bool b);
int LoadTableFile(PGLOBAL g, char *filename);
bool Initialize(PGLOBAL g); // Database routines
bool SetTabNode(PGLOBAL g); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
void SetNodeAttr(PGLOBAL g, char *attr, PXNODE node); virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
bool CheckRow(PGLOBAL g, bool b); //virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;}
virtual int Cardinality(PGLOBAL g);
// Database routines virtual int GetMaxSize(PGLOBAL g);
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); //virtual bool NeedIndexing(PGLOBAL g);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); virtual bool OpenDB(PGLOBAL g);
//virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;} virtual int ReadDB(PGLOBAL g);
virtual int Cardinality(PGLOBAL g); virtual int WriteDB(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual int DeleteDB(PGLOBAL g, int irc);
//virtual bool NeedIndexing(PGLOBAL g); virtual void CloseDB(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;}
virtual int ReadDB(PGLOBAL g); virtual const CHARSET_INFO *data_charset()
virtual int WriteDB(PGLOBAL g); {return &my_charset_utf8_general_ci;}
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); protected:
virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;} // Members
virtual const CHARSET_INFO *data_charset() PXDOC Docp;
{return &my_charset_utf8_general_ci;} PXNODE Root;
PXNODE Curp;
protected: PXNODE DBnode;
// Members PXNODE TabNode;
PXDOC Docp; PXNODE RowNode;
PXNODE Root; PXNODE ColNode;
PXNODE Curp; PXLIST Nlist;
PXNODE DBnode; PXLIST Clist;
PXNODE TabNode; PFBLOCK To_Xb; // Pointer to XML file block
PXNODE RowNode; PCOL Colp; // The multiple column
PXNODE ColNode; bool Changed; // After Update, Insert or Delete
PXLIST Nlist; bool Checked; // After Update check pass
PXLIST Clist; bool NextSame; // Same next row
PFBLOCK To_Xb; // Pointer to XML file block bool Xpand; // Put multiple tags in several rows
PCOL Colp; // The multiple column bool NewRow; // True when inserting a new row
bool Changed; // After Update, Insert or Delete bool Hasnod; // True if rows have subnodes
bool Checked; // After Update check pass bool Write; // True for Insert and Update
bool NextSame; // Same next row bool Usedom; // True for DOM, False for libxml2
bool Xpand; // Put multiple tags in several rows bool Bufdone; // True when column buffers allocated
bool NewRow; // True when inserting a new row bool Nodedone; // True when column nodes allocated
bool Hasnod; // True if rows have subnodes bool Void; // True if the file does not exist
bool Write; // True for Insert and Update char *Xfile; // The XML file
bool Usedom; // True for DOM, False for libxml2 char *Enc; // New XML table file encoding
bool Bufdone; // True when column buffers allocated char *Tabname; // Name of Table node
bool Nodedone; // True when column nodes allocated char *Rowname; // Name of first level nodes
bool Void; // True if the file does not exist char *Colname; // Name of second level nodes
char *Xfile; // The XML file char *Mulnode; // Name of multiple node
char *Enc; // New XML table file encoding char *XmlDB; // Name of XML DB node
char *Tabname; // Name of Table node char *Nslist; // List of namespaces to register
char *Rowname; // Name of first level nodes char *DefNs; // Dummy name of default namespace
char *Colname; // Name of second level nodes char *Attrib; // Table node attribut(s)
char *Mulnode; // Name of multiple node char *Hdattr; // Header node attribut(s)
char *XmlDB; // Name of XML DB node int Coltype; // Default column type
char *Nslist; // List of namespaces to register int Limit; // Limit of multiple values
char *DefNs; // Dummy name of default namespace int Header; // n first rows are header rows
char *Attrib; // Table node attribut(s) int Multiple; // If multiple files
char *Hdattr; // Header node attribut(s) int Nrow; // The table cardinality
int Coltype; // Default column type int Irow; // The current row index
int Limit; // Limit of multiple values int Nsub; // The current subrow index
int Header; // n first rows are header rows int N; // The current Rowid
int Multiple; // If multiple files }; // end of class TDBXML
int Nrow; // The table cardinality
int Irow; // The current row index /***********************************************************************/
int Nsub; // The current subrow index /* Class XMLCOL: XDB table access method column descriptor. */
int N; // The current Rowid /***********************************************************************/
}; // end of class TDBXML class XMLCOL : public COLBLK {
public:
/***********************************************************************/ // Constructors
/* Class XMLCOL: XDB table access method column descriptor. */ XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "XML");
/***********************************************************************/ XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process
class XMLCOL : public COLBLK {
public: // Implementation
// Constructors virtual int GetAmType(void) {return TYPE_AM_XML;}
XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "XML"); virtual void SetTo_Val(PVAL valp) {To_Val = valp;}
XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process bool ParseXpath(PGLOBAL g, bool mode);
// Implementation // Methods
virtual int GetAmType(void) {return TYPE_AM_XML;} virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} virtual void ReadColumn(PGLOBAL g);
bool ParseXpath(PGLOBAL g, bool mode); virtual void WriteColumn(PGLOBAL g);
bool AllocBuf(PGLOBAL g, bool mode);
// Methods void AllocNodes(PGLOBAL g, PXDOC dp);
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check);
virtual void ReadColumn(PGLOBAL g); protected:
virtual void WriteColumn(PGLOBAL g); //xmlNodePtr SelectSingleNode(xmlNodePtr node, char *name);
bool AllocBuf(PGLOBAL g, bool mode);
void AllocNodes(PGLOBAL g, PXDOC dp); // Default constructor not to be used
XMLCOL(void) : COLBLK(1) {}
protected:
//xmlNodePtr SelectSingleNode(xmlNodePtr node, char *name); // Members
PXLIST Nl;
// Default constructor not to be used PXLIST Nlx;
XMLCOL(void) : COLBLK(1) {} PXNODE ColNode;
PXNODE ValNode;
// Members PXNODE Cxnp;
PXLIST Nl; PXNODE Vxnp;
PXLIST Nlx; PXATTR Vxap;
PXNODE ColNode; PXATTR AttNode;
PXNODE ValNode; PTDBXML Tdbp;
PXNODE Cxnp; char *Valbuf; // To the node value buffer
PXNODE Vxnp; char *Xname; // The node or attribute name
PXATTR Vxap; char* *Nodes; // The intermediate nodes
PXATTR AttNode; int Type; // 0: Attribute, 1: Tag, 2: position
PTDBXML Tdbp; int Nod; // The number of intermediate nodes
char *Valbuf; // To the node value buffer int Inod; // Index of multiple node
char *Xname; // The node or attribute name int Rank; // Position
char* *Nodes; // The intermediate nodes bool Mul; // true for multiple column
int Type; // 0: Attribute, 1: Tag, 2: position bool Checked; // Was checked while Updating
int Nod; // The number of intermediate nodes int Long; // Buffer length
int Inod; // Index of multiple node int Nx; // The last read row
int Rank; // Position int Sx; // The last read sub-row
bool Mul; // true for multiple column PVAL To_Val; // To value used for Update/Insert
bool Checked; // Was checked while Updating }; // end of class XMLCOL
int Long; // Buffer length
int Nx; // The last read row /***********************************************************************/
int Sx; // The last read sub-row /* Derived class XMLCOLX: used to replace a multiple XMLCOL by the */
PVAL To_Val; // To value used for Update/Insert /* derived class XMULCOL that has specialize read and write functions.*/
}; // end of class XMLCOL /* Note: this works only if the members of the derived class are the */
/* same than the ones of the original class (NO added members). */
/***********************************************************************/ /***********************************************************************/
/* Derived class XMLCOLX: used to replace a multiple XMLCOL by the */ class XMLCOLX : public XMLCOL {
/* derived class XMULCOL that has specialize read and write functions.*/ public:
/* Note: this works only if the members of the derived class are the */ // Fake operator new used to change a filter into a derived filter
/* same than the ones of the original class (NO added members). */ void * operator new(size_t size, PXMLCOL colp) {return colp;}
/***********************************************************************/ #if !defined(__BORLANDC__)
class XMLCOLX : public XMLCOL { // Avoid warning C4291 by defining a matching dummy delete operator
public: void operator delete(void *, size_t size) {}
// Fake operator new used to change a filter into a derived filter void operator delete(void *, PXMLCOL) {}
void * operator new(size_t size, PXMLCOL colp) {return colp;} #endif
#if !defined(__BORLANDC__) }; // end of class XMLCOLX
// Avoid warning C4291 by defining a matching dummy delete operator
void operator delete(void *, size_t size) {} /***********************************************************************/
void operator delete(void *, PXMLCOL) {} /* Class XMULCOL: XML table access method multiple column descriptor. */
#endif /***********************************************************************/
}; // end of class XMLCOLX class XMULCOL : public XMLCOLX {
public:
/***********************************************************************/ // The constructor must restore Value because XOBJECT has a void
/* Class XMULCOL: XML table access method multiple column descriptor. */ // constructor called by default that set Value to NULL
/***********************************************************************/ XMULCOL(PVAL valp) {Value = valp; Mul = true;}
class XMULCOL : public XMLCOLX {
public: // Methods
// The constructor must restore Value because XOBJECT has a void virtual void ReadColumn(PGLOBAL g);
// constructor called by default that set Value to NULL virtual void WriteColumn(PGLOBAL g);
XMULCOL(PVAL valp) {Value = valp; Mul = true;} }; // end of class XMULCOL
// Methods /***********************************************************************/
virtual void ReadColumn(PGLOBAL g); /* Class XPOSCOL: XML table column accessed by position. */
virtual void WriteColumn(PGLOBAL g); /***********************************************************************/
}; // end of class XMULCOL class XPOSCOL : public XMLCOLX {
public:
/***********************************************************************/ // The constructor must restore Value because XOBJECT has a void
/* Class XPOSCOL: XML table column accessed by position. */ // constructor called by default that set Value to NULL
/***********************************************************************/ XPOSCOL(PVAL valp) {Value = valp;}
class XPOSCOL : public XMLCOLX {
public: // Methods
// The constructor must restore Value because XOBJECT has a void virtual void ReadColumn(PGLOBAL g);
// constructor called by default that set Value to NULL virtual void WriteColumn(PGLOBAL g);
XPOSCOL(PVAL valp) {Value = valp;} }; // end of class XPOSCOL
#endif // INCLUDE_TDBXML
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
}; // end of class XPOSCOL
#endif // INCLUDE_TDBXML

View File

@@ -1,163 +1,161 @@
/* Copyright (C) Olivier Bertrand 2004 - 2012 /* Copyright (C) Olivier Bertrand 2004 - 2012
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/** /**
@file user_connect.cc @file user_connect.cc
@brief @brief
Implements the user_connect class. Implements the user_connect class.
@details @details
To support multi_threading, each query creates and use a PlugDB "user" To support multi_threading, each query creates and use a PlugDB "user"
that is a connection with its personnal memory allocation. that is a connection with its personnal memory allocation.
@note @note
*/ */
/****************************************************************************/ /****************************************************************************/
/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2012 */ /* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2012 */
/****************************************************************************/ /****************************************************************************/
#ifdef USE_PRAGMA_IMPLEMENTATION #ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation #pragma implementation // gcc: Class implementation
#endif #endif
#define DONT_DEFINE_VOID #define DONT_DEFINE_VOID
#define MYSQL_SERVER #define MYSQL_SERVER
#include "sql_class.h" #include "sql_class.h"
#undef OFFSET #undef OFFSET
#define NOPARSE #define NOPARSE
#include "osutil.h" #include "osutil.h"
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "connect.h" #include "connect.h"
#include "user_connect.h" #include "user_connect.h"
#include "mycat.h" #include "mycat.h"
extern "C" char plgxini[]; extern "C" char plgxini[];
extern int xtrace; extern int xtrace;
/****************************************************************************/ /****************************************************************************/
/* Initialize the user_connect static member. */ /* Initialize the user_connect static member. */
/****************************************************************************/ /****************************************************************************/
PCONNECT user_connect::to_users= NULL; PCONNECT user_connect::to_users= NULL;
/* -------------------------- class user_connect -------------------------- */ /* -------------------------- class user_connect -------------------------- */
/****************************************************************************/ /****************************************************************************/
/* Constructor. */ /* Constructor. */
/****************************************************************************/ /****************************************************************************/
user_connect::user_connect(THD *thd, const char *dbn) user_connect::user_connect(THD *thd, const char *dbn)
{ {
thdp= thd; thdp= thd;
next= NULL; next= NULL;
previous= NULL; previous= NULL;
g= NULL; g= NULL;
last_query_id= 0; last_query_id= 0;
count= 0; count= 0;
// Statistics // Statistics
nrd= fnd= nfd= 0; nrd= fnd= nfd= 0;
tb1= 0; tb1= 0;
} // end of user_connect constructor } // end of user_connect constructor
/****************************************************************************/ /****************************************************************************/
/* Destructor. */ /* Destructor. */
/****************************************************************************/ /****************************************************************************/
user_connect::~user_connect() user_connect::~user_connect()
{ {
// Terminate CONNECT and Plug-like environment, should return NULL // Terminate CONNECT and Plug-like environment, should return NULL
g= CntExit(g); g= CntExit(g);
} // end of user_connect destructor } // end of user_connect destructor
/****************************************************************************/ /****************************************************************************/
/* Initialization. */ /* Initialization. */
/****************************************************************************/ /****************************************************************************/
bool user_connect::user_init() bool user_connect::user_init()
{ {
// Initialize Plug-like environment // Initialize Plug-like environment
PACTIVITY ap= NULL; PACTIVITY ap= NULL;
PDBUSER dup= NULL; PDBUSER dup= NULL;
// Areasize= 64M because of VEC tables. Should be parameterisable // Areasize= 64M because of VEC tables. Should be parameterisable
g= PlugInit(NULL, 67108864); g= PlugInit(NULL, 67108864);
//g= PlugInit(NULL, 134217728); // 128M was because of old embedded tests //g= PlugInit(NULL, 134217728); // 128M was because of old embedded tests
// Check whether the initialization is complete // Check whether the initialization is complete
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size) if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size)
|| !(dup= PlgMakeUser(g))) { || !(dup= PlgMakeUser(g))) {
if (g) if (g)
printf("%s\n", g->Message); printf("%s\n", g->Message);
int rc= PlugExit(g); int rc= PlugExit(g);
g= NULL; g= NULL;
free(dup); free(dup);
return true; return true;
} // endif g-> } // endif g->
dup->Catalog= new MYCAT(NULL); dup->Catalog= new MYCAT(NULL);
ap= new ACTIVITY; ap= new ACTIVITY;
memset(ap, 0, sizeof(ACTIVITY)); memset(ap, 0, sizeof(ACTIVITY));
strcpy(ap->Ap_Name, "CONNECT"); strcpy(ap->Ap_Name, "CONNECT");
g->Activityp= ap; g->Activityp= ap;
g->Activityp->Aptr= dup; g->Activityp->Aptr= dup;
next= to_users; next= to_users;
to_users= this; to_users= this;
if (next) if (next)
next->previous= this; next->previous= this;
last_query_id= thdp->query_id; last_query_id= thdp->query_id;
count= 1; count= 1;
return false; return false;
} // end of user_init } // end of user_init
void user_connect::SetHandler(ha_connect *hc) void user_connect::SetHandler(ha_connect *hc)
{ {
PDBUSER dup= (PDBUSER)g->Activityp->Aptr; PDBUSER dup= (PDBUSER)g->Activityp->Aptr;
MYCAT *mc= (MYCAT*)dup->Catalog; MYCAT *mc= (MYCAT*)dup->Catalog;
mc->SetHandler(hc); mc->SetHandler(hc);
} }
/****************************************************************************/ /****************************************************************************/
/* Check whether we begin a new query and if so cleanup the previous one. */ /* Check whether we begin a new query and if so cleanup the previous one. */
/****************************************************************************/ /****************************************************************************/
bool user_connect::CheckCleanup(void) bool user_connect::CheckCleanup(void)
{ {
if (thdp->query_id > last_query_id) { if (thdp->query_id > last_query_id) {
PlugCleanup(g, true); PlugCleanup(g, true);
PlugSubSet(g, g->Sarea, g->Sarea_Size); PlugSubSet(g, g->Sarea, g->Sarea_Size);
g->Xchk = NULL; g->Xchk = NULL;
g->Createas = 0; g->Createas = 0;
g->Alchecked = 0; g->Alchecked = 0;
#if defined(MRRBKA_SUPPORT) g->Mrr = 0;
g->Mrr = 0; last_query_id= thdp->query_id;
#endif // MRRBKA_SUPPORT
last_query_id= thdp->query_id; if (xtrace)
printf("=====> Begin new query %llu\n", last_query_id);
if (xtrace)
printf("=====> Begin new query %llu\n", last_query_id); return true;
} // endif query_id
return true;
} // endif query_id return false;
} // end of CheckCleanup
return false;
} // end of CheckCleanup

View File

@@ -63,11 +63,10 @@ public:
PCONNECT next; // Next user in chain PCONNECT next; // Next user in chain
PCONNECT previous; // Previous user in chain PCONNECT previous; // Previous user in chain
PGLOBAL g; // The common handle to CONNECT PGLOBAL g; // The common handle to CONNECT
//char dbname[32]; // The DBCONNECT database
query_id_t last_query_id; // the latest user query id query_id_t last_query_id; // the latest user query id
int count; // if used by several handlers int count; // if used by several handlers
// Statistics // Statistics
ulong nrd, fnd, nfd; ulong nrd, fnd, nfd;
ulonglong tb1; ulonglong tb1;
}; // end of user_connect class definition }; // end of user_connect class definition

View File

@@ -448,7 +448,6 @@ 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. */ /* Set one value in a block if val is less than the current value. */
/***********************************************************************/ /***********************************************************************/
@@ -478,7 +477,6 @@ void TYPBLK<TYPE>::SetMax(PVAL valp, int n)
tmin = tval; tmin = tval;
} // end of SetMax } // end of SetMax
#endif // BLK_INDX
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
@@ -812,7 +810,6 @@ 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. */ /* Set one value in a block if val is less than the current value. */
/***********************************************************************/ /***********************************************************************/
@@ -842,7 +839,6 @@ void CHRBLK::SetMax(PVAL valp, int n)
memcpy(bp, vp, Long); memcpy(bp, vp, Long);
} // end of SetMax } // end of SetMax
#endif // BLK_INDX
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
@@ -1166,7 +1162,6 @@ 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. */ /* Set one value in a block if val is less than the current value. */
/***********************************************************************/ /***********************************************************************/
@@ -1194,7 +1189,6 @@ void STRBLK::SetMax(PVAL valp, int n)
SetValue(valp, n); SetValue(valp, n);
} // end of SetMax } // end of SetMax
#endif // BLK_INDX
/***********************************************************************/ /***********************************************************************/
/* Move one value from i to j. */ /* Move one value from i to j. */
@@ -1335,7 +1329,6 @@ void DATBLK::SetValue(PSZ p, int n)
} // end of SetValue } // end of SetValue
#if defined(BLK_INDX)
/* -------------------------- Class MBVALS --------------------------- */ /* -------------------------- Class MBVALS --------------------------- */
/***********************************************************************/ /***********************************************************************/
@@ -1379,7 +1372,6 @@ void MBVALS::Free(void)
PlgDBfree(Mblk); PlgDBfree(Mblk);
Vblk = NULL; Vblk = NULL;
} // end of Free } // end of Free
#endif // BLK_INDX
/* ------------------------- End of Valblk --------------------------- */ /* ------------------------- End of Valblk --------------------------- */

View File

@@ -1,351 +1,331 @@
/*************** Valblk H Declares Source Code File (.H) ***************/ /*************** Valblk H Declares Source Code File (.H) ***************/
/* Name: VALBLK.H Version 2.1 */ /* Name: VALBLK.H Version 2.1 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */
/* */ /* */
/* This file contains the VALBLK and derived classes declares. */ /* This file contains the VALBLK and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* assert.h is header required when using the assert function. */ /* assert.h is header required when using the assert function. */
/* block.h is header containing Block global declarations. */ /* block.h is header containing Block global declarations. */
/***********************************************************************/ /***********************************************************************/
#ifndef __VALBLK__H__ #ifndef __VALBLK__H__
#define __VALBLK__H__ #define __VALBLK__H__
#include "value.h" #include "value.h"
/***********************************************************************/ /***********************************************************************/
/* Utility used to allocate value blocks. */ /* Utility used to allocate value blocks. */
/***********************************************************************/ /***********************************************************************/
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, 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. */
/* DB static external variables. */ /***********************************************************************/
/***********************************************************************/ extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
/***********************************************************************/
/***********************************************************************/ /* Class MBVALS is a utility class for (re)allocating VALBLK's. */
/* Class MBVALS is a utility class for (re)allocating VALBLK's. */ /***********************************************************************/
/***********************************************************************/ class MBVALS : public BLOCK {
class MBVALS : public BLOCK { //friend class LSTBLK;
//friend class LSTBLK; friend class ARRAY;
friend class ARRAY; public:
public: // Constructors
// Constructors MBVALS(void) {Vblk = NULL; Mblk = Nmblk;}
MBVALS(void) {Vblk = NULL; Mblk = Nmblk;}
// Methods
// Methods void *GetMemp(void) {return Mblk.Memp;}
void *GetMemp(void) {return Mblk.Memp;} PVBLK Allocate(PGLOBAL g, int type, int len, int prec,
PVBLK Allocate(PGLOBAL g, int type, int len, int prec, int n, bool sub = FALSE);
int n, bool sub = FALSE); bool ReAllocate(PGLOBAL g, int n);
bool ReAllocate(PGLOBAL g, int n); void Free(void);
void Free(void);
protected:
protected: // Members
// Members PVBLK Vblk; // Pointer to VALBLK
PVBLK Vblk; // Pointer to VALBLK MBLOCK Mblk; // The memory block
MBLOCK Mblk; // The memory block }; // end of class MBVALS
}; // end of class MBVALS
typedef class MBVALS *PMBV;
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. */ class VALBLK : public BLOCK {
/***********************************************************************/ public:
class VALBLK : public BLOCK { // Constructors
//friend void SemColData(PGLOBAL g, PSEM semp); VALBLK(void *mp, int type, int nval, bool un = false);
public:
// Constructors // Implementation
VALBLK(void *mp, int type, int nval, bool un = false); int GetNval(void) {return Nval;}
void SetNval(int n) {Nval = n;}
// Implementation void *GetValPointer(void) {return Blkp;}
int GetNval(void) {return Nval;} void SetValPointer(void *mp) {Blkp = mp;}
void SetNval(int n) {Nval = n;} int GetType(void) {return Type;}
void *GetValPointer(void) {return Blkp;} int GetPrec(void) {return Prec;}
void SetValPointer(void *mp) {Blkp = mp;} void SetCheck(bool b) {Check = b;}
int GetType(void) {return Type;} void MoveNull(int i, int j)
int GetPrec(void) {return Prec;} {if (To_Nulls) To_Nulls[j] = To_Nulls[j];}
void SetCheck(bool b) {Check = b;} virtual void SetNull(int n, bool b)
void MoveNull(int i, int j) {if (To_Nulls) {To_Nulls[n] = (b) ? '*' : 0;}}
{if (To_Nulls) To_Nulls[j] = To_Nulls[j];} virtual bool IsNull(int n) {return To_Nulls && To_Nulls[n];}
virtual void SetNull(int n, bool b) virtual void SetNullable(bool b);
{if (To_Nulls) {To_Nulls[n] = (b) ? '*' : 0;}} virtual bool IsUnsigned(void) {return Unsigned;}
virtual bool IsNull(int n) {return To_Nulls && To_Nulls[n];} virtual void Init(PGLOBAL g, bool check) = 0;
virtual void SetNullable(bool b); virtual int GetVlen(void) = 0;
virtual bool IsUnsigned(void) {return Unsigned;} virtual PSZ GetCharValue(int n);
virtual void Init(PGLOBAL g, bool check) = 0; virtual char GetTinyValue(int n) = 0;
virtual int GetVlen(void) = 0; virtual uchar GetUTinyValue(int n) = 0;
virtual PSZ GetCharValue(int n); virtual short GetShortValue(int n) = 0;
virtual char GetTinyValue(int n) = 0; virtual ushort GetUShortValue(int n) = 0;
virtual uchar GetUTinyValue(int n) = 0; virtual int GetIntValue(int n) = 0;
virtual short GetShortValue(int n) = 0; virtual uint GetUIntValue(int n) = 0;
virtual ushort GetUShortValue(int n) = 0; virtual longlong GetBigintValue(int n) = 0;
virtual int GetIntValue(int n) = 0; virtual ulonglong GetUBigintValue(int n) = 0;
virtual uint GetUIntValue(int n) = 0; virtual double GetFloatValue(int n) = 0;
virtual longlong GetBigintValue(int n) = 0; virtual char *GetCharString(char *p, int n) = 0;
virtual ulonglong GetUBigintValue(int n) = 0; virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;}
virtual double GetFloatValue(int n) = 0; virtual void Reset(int n) = 0;
virtual char *GetCharString(char *p, int n) = 0; virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;} virtual void SetPrec(int p) {}
virtual void Reset(int n) = 0; virtual bool IsCi(void) {return false;}
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
virtual void SetPrec(int p) {} // Methods
virtual bool IsCi(void) {return false;} virtual void SetValue(short sval, int n) {assert(false);}
virtual void SetValue(ushort sval, int n) {assert(false);}
// Methods virtual void SetValue(int lval, int n) {assert(false);}
virtual void SetValue(short sval, int n) {assert(false);} virtual void SetValue(uint lval, int n) {assert(false);}
virtual void SetValue(ushort sval, int n) {assert(false);} virtual void SetValue(longlong lval, int n) {assert(false);}
virtual void SetValue(int lval, int n) {assert(false);} virtual void SetValue(ulonglong lval, int n) {assert(false);}
virtual void SetValue(uint lval, int n) {assert(false);} virtual void SetValue(double fval, int n) {assert(false);}
virtual void SetValue(longlong lval, int n) {assert(false);} virtual void SetValue(char cval, int n) {assert(false);}
virtual void SetValue(ulonglong lval, int n) {assert(false);} virtual void SetValue(uchar cval, int n) {assert(false);}
virtual void SetValue(double fval, int n) {assert(false);} virtual void SetValue(PSZ sp, int n) {assert(false);}
virtual void SetValue(char cval, int n) {assert(false);} virtual void SetValue(char *sp, uint len, int n) {assert(false);}
virtual void SetValue(uchar cval, int n) {assert(false);} virtual void SetValue(PVAL valp, int n) = 0;
virtual void SetValue(PSZ sp, int n) {assert(false);} virtual void SetValue(PVBLK pv, int n1, int n2) = 0;
virtual void SetValue(char *sp, uint len, int n) {assert(false);} virtual void SetMin(PVAL valp, int n) = 0;
virtual void SetValue(PVAL valp, int n) = 0; virtual void SetMax(PVAL valp, int n) = 0;
virtual void SetValue(PVBLK pv, int n1, int n2) = 0; virtual void Move(int i, int j) = 0;
#if defined(BLK_INDX) virtual int CompVal(PVAL vp, int n) = 0;
virtual void SetMin(PVAL valp, int n) = 0; virtual int CompVal(int i1, int i2) = 0;
virtual void SetMax(PVAL valp, int n) = 0; virtual void *GetValPtr(int n) = 0;
#endif // BLK_INDX virtual void *GetValPtrEx(int n) = 0;
#if 0 virtual int Find(PVAL vp) = 0;
virtual void SetValues(PVBLK pv, int i, int n) = 0; virtual int GetMaxLength(void) = 0;
virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);} bool Locate(PVAL vp, int& i);
#endif // 0
virtual void Move(int i, int j) = 0; protected:
virtual int CompVal(PVAL vp, int n) = 0; void ChkIndx(int n);
virtual int CompVal(int i1, int i2) = 0; void ChkTyp(PVAL v);
virtual void *GetValPtr(int n) = 0; void ChkTyp(PVBLK vb);
virtual void *GetValPtrEx(int n) = 0;
virtual int Find(PVAL vp) = 0; // Members
virtual int GetMaxLength(void) = 0; PGLOBAL Global; // Used for messages and allocation
bool Locate(PVAL vp, int& i); char *To_Nulls; // Null values array
void *Blkp; // To value block
protected: bool Check; // If true SetValue types must match
void ChkIndx(int n); bool Nullable; // True if values can be null
void ChkTyp(PVAL v); bool Unsigned; // True if values are unsigned
void ChkTyp(PVBLK vb); int Type; // Type of individual values
int Nval; // Max number of values in block
// Members int Prec; // Precision of float values
PGLOBAL Global; // Used for messages and allocation }; // end of class VALBLK
char *To_Nulls; // Null values array
void *Blkp; // To value block /***********************************************************************/
bool Check; // If true SetValue types must match /* Class TYPBLK: represents a block of typed values. */
bool Nullable; // True if values can be null /***********************************************************************/
bool Unsigned; // True if values are unsigned template <class TYPE>
int Type; // Type of individual values class TYPBLK : public VALBLK {
int Nval; // Max number of values in block public:
int Prec; // Precision of float values // Constructors
}; // end of class VALBLK TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false);
/***********************************************************************/ // Implementation
/* Class TYPBLK: represents a block of typed values. */ virtual void Init(PGLOBAL g, bool check);
/***********************************************************************/ virtual int GetVlen(void) {return sizeof(TYPE);}
template <class TYPE> virtual char GetTinyValue(int n) {return (char)Typp[n];}
class TYPBLK : public VALBLK { virtual uchar GetUTinyValue(int n) {return (uchar)Typp[n];}
public: virtual short GetShortValue(int n) {return (short)Typp[n];}
// Constructors virtual ushort GetUShortValue(int n) {return (ushort)Typp[n];}
TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false); virtual int GetIntValue(int n) {return (int)Typp[n];}
//TYPBLK(void *mp, int size, int prec, int type); virtual uint GetUIntValue(int n) {return (uint)Typp[n];}
virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];}
// Implementation virtual ulonglong GetUBigintValue(int n) {return (ulonglong)Typp[n];}
virtual void Init(PGLOBAL g, bool check); virtual double GetFloatValue(int n) {return (double)Typp[n];}
virtual int GetVlen(void) {return sizeof(TYPE);} virtual char *GetCharString(char *p, int n);
//virtual PSZ GetCharValue(int n); virtual void Reset(int n) {Typp[n] = 0;}
virtual char GetTinyValue(int n) {return (char)Typp[n];}
virtual uchar GetUTinyValue(int n) {return (uchar)Typp[n];} // Methods
virtual short GetShortValue(int n) {return (short)Typp[n];} virtual void SetValue(PSZ sp, int n);
virtual ushort GetUShortValue(int n) {return (ushort)Typp[n];} virtual void SetValue(char *sp, uint len, int n);
virtual int GetIntValue(int n) {return (int)Typp[n];} virtual void SetValue(short sval, int n)
virtual uint GetUIntValue(int n) {return (uint)Typp[n];} {Typp[n] = (TYPE)sval; SetNull(n, false);}
virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];} virtual void SetValue(ushort sval, int n)
virtual ulonglong GetUBigintValue(int n) {return (ulonglong)Typp[n];} {Typp[n] = (TYPE)sval; SetNull(n, false);}
virtual double GetFloatValue(int n) {return (double)Typp[n];} virtual void SetValue(int lval, int n)
virtual char *GetCharString(char *p, int n); {Typp[n] = (TYPE)lval; SetNull(n, false);}
virtual void Reset(int n) {Typp[n] = 0;} virtual void SetValue(uint lval, int n)
{Typp[n] = (TYPE)lval; SetNull(n, false);}
// Methods virtual void SetValue(longlong lval, int n)
virtual void SetValue(PSZ sp, int n); {Typp[n] = (TYPE)lval; SetNull(n, false);}
virtual void SetValue(char *sp, uint len, int n); virtual void SetValue(ulonglong lval, int n)
virtual void SetValue(short sval, int n) {Typp[n] = (TYPE)lval; SetNull(n, false);}
{Typp[n] = (TYPE)sval; SetNull(n, false);} virtual void SetValue(double fval, int n)
virtual void SetValue(ushort sval, int n) {Typp[n] = (TYPE)fval; SetNull(n, false);}
{Typp[n] = (TYPE)sval; SetNull(n, false);} virtual void SetValue(char cval, int n)
virtual void SetValue(int lval, int n) {Typp[n] = (TYPE)cval; SetNull(n, false);}
{Typp[n] = (TYPE)lval; SetNull(n, false);} virtual void SetValue(uchar cval, int n)
virtual void SetValue(uint lval, int n) {Typp[n] = (TYPE)cval; SetNull(n, false);}
{Typp[n] = (TYPE)lval; SetNull(n, false);} virtual void SetValue(PVAL valp, int n);
virtual void SetValue(longlong lval, int n) virtual void SetValue(PVBLK pv, int n1, int n2);
{Typp[n] = (TYPE)lval; SetNull(n, false);} virtual void SetMin(PVAL valp, int n);
virtual void SetValue(ulonglong lval, int n) virtual void SetMax(PVAL valp, int n);
{Typp[n] = (TYPE)lval; SetNull(n, false);} virtual void Move(int i, int j);
virtual void SetValue(double fval, int n) virtual int CompVal(PVAL vp, int n);
{Typp[n] = (TYPE)fval; SetNull(n, false);} virtual int CompVal(int i1, int i2);
virtual void SetValue(char cval, int n) virtual void *GetValPtr(int n);
{Typp[n] = (TYPE)cval; SetNull(n, false);} virtual void *GetValPtrEx(int n);
virtual void SetValue(uchar cval, int n) virtual int Find(PVAL vp);
{Typp[n] = (TYPE)cval; SetNull(n, false);} virtual int GetMaxLength(void);
virtual void SetValue(PVAL valp, int n);
virtual void SetValue(PVBLK pv, int n1, int n2); protected:
//virtual void SetValues(PVBLK pv, int k, int n); // Specialized functions
#if defined(BLK_INDX) static ulonglong MaxVal(void);
virtual void SetMin(PVAL valp, int n); TYPE GetTypedValue(PVAL vp);
virtual void SetMax(PVAL valp, int n); TYPE GetTypedValue(PVBLK blk, int n);
#endif // BLK_INDX
virtual void Move(int i, int j); // Members
virtual int CompVal(PVAL vp, int n); TYPE* const &Typp;
virtual int CompVal(int i1, int i2); const char *Fmt;
virtual void *GetValPtr(int n); }; // end of class TYPBLK
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); /***********************************************************************/
virtual int GetMaxLength(void); /* Class CHRBLK: represent a block of fixed length strings. */
/***********************************************************************/
protected: class CHRBLK : public VALBLK {
// Specialized functions public:
static ulonglong MaxVal(void); // Constructors
TYPE GetTypedValue(PVAL vp); CHRBLK(void *mp, int size, int len, int prec, bool b);
TYPE GetTypedValue(PVBLK blk, int n);
// Implementation
// Members virtual void Init(PGLOBAL g, bool check);
TYPE* const &Typp; virtual int GetVlen(void) {return Long;}
const char *Fmt; virtual PSZ GetCharValue(int n);
}; // end of class TYPBLK virtual char GetTinyValue(int n);
virtual uchar GetUTinyValue(int n);
/***********************************************************************/ virtual short GetShortValue(int n);
/* Class CHRBLK: represent a block of fixed length strings. */ virtual ushort GetUShortValue(int n);
/***********************************************************************/ virtual int GetIntValue(int n);
class CHRBLK : public VALBLK { virtual uint GetUIntValue(int n);
public: virtual longlong GetBigintValue(int n);
// Constructors virtual ulonglong GetUBigintValue(int n);
CHRBLK(void *mp, int size, int len, int prec, bool b); virtual double GetFloatValue(int n);
virtual char *GetCharString(char *p, int n);
// Implementation virtual void Reset(int n);
virtual void Init(PGLOBAL g, bool check); virtual void SetPrec(int p) {Ci = (p != 0);}
virtual int GetVlen(void) {return Long;} virtual bool IsCi(void) {return Ci;}
virtual PSZ GetCharValue(int n);
virtual char GetTinyValue(int n); // Methods
virtual uchar GetUTinyValue(int n); virtual void SetValue(PSZ sp, int n);
virtual short GetShortValue(int n); virtual void SetValue(char *sp, uint len, int n);
virtual ushort GetUShortValue(int n); virtual void SetValue(PVAL valp, int n);
virtual int GetIntValue(int n); virtual void SetValue(PVBLK pv, int n1, int n2);
virtual uint GetUIntValue(int n); virtual void SetMin(PVAL valp, int n);
virtual longlong GetBigintValue(int n); virtual void SetMax(PVAL valp, int n);
virtual ulonglong GetUBigintValue(int n); virtual void Move(int i, int j);
virtual double GetFloatValue(int n); virtual int CompVal(PVAL vp, int n);
virtual char *GetCharString(char *p, int n); virtual int CompVal(int i1, int i2);
virtual void Reset(int n); virtual void *GetValPtr(int n);
virtual void SetPrec(int p) {Ci = (p != 0);} virtual void *GetValPtrEx(int n);
virtual bool IsCi(void) {return Ci;} virtual int Find(PVAL vp);
virtual int GetMaxLength(void);
// Methods
virtual void SetValue(PSZ sp, int n); protected:
virtual void SetValue(char *sp, uint len, int n); // Members
virtual void SetValue(PVAL valp, int n); char* const &Chrp; // Pointer to char buffer
virtual void SetValue(PVBLK pv, int n1, int n2); PSZ Valp; // Used to make a zero ended value
//virtual void SetValues(PVBLK pv, int k, int n); bool Blanks; // True for right filling with blanks
#if defined(BLK_INDX) bool Ci; // True if case insensitive
virtual void SetMin(PVAL valp, int n); int Long; // Length of each string
virtual void SetMax(PVAL valp, int n); }; // end of class CHRBLK
#endif // BLK_INDX
virtual void Move(int i, int j); /***********************************************************************/
virtual int CompVal(PVAL vp, int n); /* Class STRBLK: represent a block of string pointers. */
virtual int CompVal(int i1, int i2); /* Currently this class is used only by the DECODE scalar function */
virtual void *GetValPtr(int n); /* and by the MyColumn function to store date formats. */
virtual void *GetValPtrEx(int n); /***********************************************************************/
virtual int Find(PVAL vp); class STRBLK : public VALBLK {
virtual int GetMaxLength(void); public:
// Constructors
protected: STRBLK(PGLOBAL g, void *mp, int size);
// Members
char* const &Chrp; // Pointer to char buffer // Implementation
PSZ Valp; // Used to make a zero ended value virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}}
bool Blanks; // True for right filling with blanks virtual bool IsNull(int n) {return Strp[n] == NULL;}
bool Ci; // True if case insensitive virtual void SetNullable(bool b) {} // Always nullable
int Long; // Length of each string virtual void Init(PGLOBAL g, bool check);
}; // end of class CHRBLK virtual int GetVlen(void) {return sizeof(PSZ);}
virtual PSZ GetCharValue(int n) {return Strp[n];}
/***********************************************************************/ virtual char GetTinyValue(int n);
/* Class STRBLK: represent a block of string pointers. */ virtual uchar GetUTinyValue(int n);
/* Currently this class is used only by the DECODE scalar function */ virtual short GetShortValue(int n);
/* and by the MyColumn function to store date formats. */ virtual ushort GetUShortValue(int n);
/***********************************************************************/ virtual int GetIntValue(int n);
class STRBLK : public VALBLK { virtual uint GetUIntValue(int n);
public: virtual longlong GetBigintValue(int n);
// Constructors virtual ulonglong GetUBigintValue(int n);
STRBLK(PGLOBAL g, void *mp, int size); virtual double GetFloatValue(int n) {return atof(Strp[n]);}
virtual char *GetCharString(char *p, int n) {return Strp[n];}
// Implementation virtual void Reset(int n) {Strp[n] = NULL;}
virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}}
virtual bool IsNull(int n) {return Strp[n] == NULL;} // Methods
virtual void SetNullable(bool b) {} // Always nullable virtual void SetValue(PSZ sp, int n);
virtual void Init(PGLOBAL g, bool check); virtual void SetValue(char *sp, uint len, int n);
virtual int GetVlen(void) {return sizeof(PSZ);} virtual void SetValue(PVAL valp, int n);
virtual PSZ GetCharValue(int n) {return Strp[n];} virtual void SetValue(PVBLK pv, int n1, int n2);
virtual char GetTinyValue(int n); virtual void SetMin(PVAL valp, int n);
virtual uchar GetUTinyValue(int n); virtual void SetMax(PVAL valp, int n);
virtual short GetShortValue(int n); virtual void Move(int i, int j);
virtual ushort GetUShortValue(int n); virtual int CompVal(PVAL vp, int n);
virtual int GetIntValue(int n); virtual int CompVal(int i1, int i2);
virtual uint GetUIntValue(int n); virtual void *GetValPtr(int n);
virtual longlong GetBigintValue(int n); virtual void *GetValPtrEx(int n);
virtual ulonglong GetUBigintValue(int n); virtual int Find(PVAL vp);
virtual double GetFloatValue(int n) {return atof(Strp[n]);} virtual int GetMaxLength(void);
virtual char *GetCharString(char *p, int n) {return Strp[n];}
virtual void Reset(int n) {Strp[n] = NULL;} // Specific
void SetSorted(bool b) {Sorted = b;}
// Methods
virtual void SetValue(PSZ sp, int n); protected:
virtual void SetValue(char *sp, uint len, int n); // Members
virtual void SetValue(PVAL valp, int n); PSZ* const &Strp; // Pointer to PSZ buffer
virtual void SetValue(PVBLK pv, int n1, int n2); bool Sorted; // Values are (semi?) sorted
//virtual void SetValues(PVBLK pv, int k, int n); }; // end of class STRBLK
#if defined(BLK_INDX)
virtual void SetMin(PVAL valp, int n); /***********************************************************************/
virtual void SetMax(PVAL valp, int n); /* Class DATBLK: represents a block of time stamp values. */
#endif // BLK_INDX /***********************************************************************/
virtual void Move(int i, int j); class DATBLK : public TYPBLK<int> {
virtual int CompVal(PVAL vp, int n); public:
virtual int CompVal(int i1, int i2); // Constructor
virtual void *GetValPtr(int n); DATBLK(void *mp, int size);
virtual void *GetValPtrEx(int n);
virtual int Find(PVAL vp); // Implementation
virtual int GetMaxLength(void); virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
virtual char *GetCharString(char *p, int n);
// Specific
void SetSorted(bool b) {Sorted = b;} // Methods
virtual void SetValue(PSZ sp, int n);
protected:
// Members protected:
PSZ* const &Strp; // Pointer to PSZ buffer // Members
bool Sorted; // Values are (semi?) sorted PVAL Dvalp; // Date value used to convert string
}; // end of class STRBLK }; // end of class DATBLK
/***********************************************************************/ #endif // __VALBLK__H__
/* Class DATBLK: represents a block of time stamp values. */
/***********************************************************************/
class DATBLK : public TYPBLK<int> {
public:
// Constructor
DATBLK(void *mp, int size);
// Implementation
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
virtual char *GetCharString(char *p, int n);
// Methods
virtual void SetValue(PSZ sp, int n);
protected:
// Members
PVAL Dvalp; // Date value used to convert string
}; // end of class DATBLK
#endif // __VALBLK__H__

File diff suppressed because it is too large Load Diff

View File

@@ -1,354 +1,333 @@
/**************** Value H Declares Source Code File (.H) ***************/ /**************** Value H Declares Source Code File (.H) ***************/
/* Name: VALUE.H Version 2.0 */ /* Name: VALUE.H Version 2.0 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2001-2013 */
/* */ /* */
/* This file contains the VALUE and derived classes declares. */ /* This file contains the VALUE and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __VALUE__H__ #ifndef __VALUE__H__
#define __VALUE__H__ #define __VALUE__H__
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* assert.h is header required when using the assert function. */ /* assert.h is header required when using the assert function. */
/* block.h is header containing Block global declarations. */ /* block.h is header containing Block global declarations. */
/***********************************************************************/ /***********************************************************************/
#include "assert.h" #include "assert.h"
#include "block.h" #include "block.h"
/***********************************************************************/ /***********************************************************************/
/* Types used in some class definitions. */ /* Types used in some class definitions. */
/***********************************************************************/ /***********************************************************************/
enum CONV {CNV_ANY = 0, /* Convert to any type */ enum CONV {CNV_ANY = 0, /* Convert to any type */
CNV_CHAR = 1, /* Convert to character type */ CNV_CHAR = 1, /* Convert to character type */
CNV_NUM = 2}; /* Convert to numeric type */ CNV_NUM = 2}; /* Convert to numeric type */
/***********************************************************************/ /***********************************************************************/
/* Types used in some class definitions. */ /* Types used in some class definitions. */
/***********************************************************************/ /***********************************************************************/
class CONSTANT; // For friend setting class CONSTANT; // For friend setting
typedef struct _datpar *PDTP; // For DTVAL typedef struct _datpar *PDTP; // For DTVAL
/***********************************************************************/ /***********************************************************************/
/* Utilities used to test types and to allocated values. */ /* Utilities used to test types and to allocated values. */
/***********************************************************************/ /***********************************************************************/
PVAL AllocateValue(PGLOBAL, void *, short); PVAL AllocateValue(PGLOBAL, void *, short);
// Exported functions // Exported functions
DllExport PSZ GetTypeName(int); DllExport PSZ GetTypeName(int);
DllExport int GetTypeSize(int, int); DllExport int GetTypeSize(int, int);
#ifdef ODBC_SUPPORT #ifdef ODBC_SUPPORT
/* This function is exported for use in EOM table type DLLs */ /* This function is exported for use in EOM table type DLLs */
DllExport int TranslateSQLType(int stp, int prec, int& len, char& v); DllExport int TranslateSQLType(int stp, int prec, int& len, char& v);
#endif #endif
DllExport char *GetFormatType(int); 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);
#if defined(BLK_INDX) DllExport int ConvertType(int, int, CONV, bool match = false);
DllExport int ConvertType(int, int, CONV, bool match = false); DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0);
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0); DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0,
#endif // BLK_INDX bool uns = false, PSZ fmt = NULL);
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0, DllExport ulonglong CharToNumber(char *, int, ulonglong, bool,
bool uns = false, PSZ fmt = NULL); bool *minus = NULL, bool *rc = NULL);
DllExport ulonglong CharToNumber(char *, int, ulonglong, bool,
bool *minus = NULL, bool *rc = NULL); /***********************************************************************/
/* Class VALUE represents a constant or variable of any valid type. */
/***********************************************************************/ /***********************************************************************/
/* Class VALUE represents a constant or variable of any valid type. */ class DllExport VALUE : public BLOCK {
/***********************************************************************/ friend class CONSTANT; // The only object allowed to use SetConstFormat
class DllExport VALUE : public BLOCK { public:
friend class CONSTANT; // The only object allowed to use SetConstFormat // Constructors
public:
// Constructors // Implementation
virtual bool IsTypeNum(void) = 0;
// Implementation virtual bool IsZero(void) = 0;
virtual bool IsTypeNum(void) = 0; virtual bool IsCi(void) {return false;}
virtual bool IsZero(void) = 0; virtual bool IsUnsigned(void) {return Unsigned;}
virtual bool IsCi(void) {return false;} virtual void Reset(void) = 0;
virtual bool IsUnsigned(void) {return Unsigned;} virtual int GetSize(void) = 0;
virtual void Reset(void) = 0; virtual int GetValLen(void) = 0;
virtual int GetSize(void) = 0; virtual int GetValPrec(void) = 0;
virtual int GetValLen(void) = 0; virtual int GetLength(void) {return 1;}
virtual int GetValPrec(void) = 0; virtual PSZ GetCharValue(void) {assert(false); return NULL;}
virtual int GetLength(void) {return 1;} virtual char GetTinyValue(void) {assert(false); return 0;}
virtual PSZ GetCharValue(void) {assert(false); return NULL;} virtual uchar GetUTinyValue(void) {assert(false); return 0;}
virtual char GetTinyValue(void) {assert(false); return 0;} virtual short GetShortValue(void) {assert(false); return 0;}
virtual uchar GetUTinyValue(void) {assert(false); return 0;} virtual ushort GetUShortValue(void) {assert(false); return 0;}
virtual short GetShortValue(void) {assert(false); return 0;} virtual int GetIntValue(void) = 0;
virtual ushort GetUShortValue(void) {assert(false); return 0;} virtual uint GetUIntValue(void) = 0;
virtual int GetIntValue(void) = 0; virtual longlong GetBigintValue(void) = 0;
virtual uint GetUIntValue(void) = 0; virtual ulonglong GetUBigintValue(void) = 0;
virtual longlong GetBigintValue(void) = 0; virtual double GetFloatValue(void) = 0;
virtual ulonglong GetUBigintValue(void) = 0; virtual void *GetTo_Val(void) = 0;
virtual double GetFloatValue(void) = 0; virtual void SetPrec(int prec) {Prec = prec;}
virtual void *GetTo_Val(void) = 0; bool IsNull(void) {return Null;}
virtual void SetPrec(int prec) {Prec = prec;} void SetNull(bool b) {Null = b;}
bool IsNull(void) {return Null;} bool GetNullable(void) {return Nullable;}
void SetNull(bool b) {Null = b;} void SetNullable(bool b) {Nullable = b;}
bool GetNullable(void) {return Nullable;} int GetType(void) {return Type;}
void SetNullable(bool b) {Nullable = b;} int GetClen(void) {return Clen;}
int GetType(void) {return Type;} void SetGlobal(PGLOBAL g) {Global = g;}
int GetClen(void) {return Clen;}
void SetGlobal(PGLOBAL g) {Global = g;} // Methods
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0;
// Methods virtual bool SetValue_char(char *p, int n) = 0;
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; virtual void SetValue_psz(PSZ s) = 0;
virtual bool SetValue_char(char *p, int n) = 0; virtual void SetValue_bool(bool b) {assert(FALSE);}
virtual void SetValue_psz(PSZ s) = 0; virtual int CompareValue(PVAL vp) = 0;
#if defined(BLK_INDX) virtual BYTE TestValue(PVAL vp);
virtual void SetValue_bool(bool b) {assert(FALSE);} virtual void SetValue(char c) {assert(false);}
virtual int CompareValue(PVAL vp) = 0; virtual void SetValue(uchar c) {assert(false);}
virtual BYTE TestValue(PVAL vp); virtual void SetValue(short i) {assert(false);}
#endif // BLK_INDX virtual void SetValue(ushort i) {assert(false);}
virtual void SetValue(char c) {assert(false);} virtual void SetValue(int n) {assert(false);}
virtual void SetValue(uchar c) {assert(false);} virtual void SetValue(uint n) {assert(false);}
virtual void SetValue(short i) {assert(false);} virtual void SetValue(longlong n) {assert(false);}
virtual void SetValue(ushort i) {assert(false);} virtual void SetValue(ulonglong n) {assert(false);}
virtual void SetValue(int n) {assert(false);} virtual void SetValue(double f) {assert(false);}
virtual void SetValue(uint n) {assert(false);} virtual void SetValue_pvblk(PVBLK blk, int n) = 0;
virtual void SetValue(longlong n) {assert(false);} virtual void SetBinValue(void *p) = 0;
virtual void SetValue(ulonglong n) {assert(false);} virtual bool GetBinValue(void *buf, int buflen, bool go) = 0;
virtual void SetValue(double f) {assert(false);} virtual char *ShowValue(char *buf, int len = 0) = 0;
virtual void SetValue_pvblk(PVBLK blk, int n) = 0; virtual char *GetCharString(char *p) = 0;
virtual void SetBinValue(void *p) = 0; virtual bool IsEqual(PVAL vp, bool chktype) = 0;
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0; virtual bool FormatValue(PVAL vp, char *fmt) = 0;
virtual char *ShowValue(char *buf, int len = 0) = 0;
virtual char *GetCharString(char *p) = 0; protected:
virtual bool IsEqual(PVAL vp, bool chktype) = 0; virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
virtual bool FormatValue(PVAL vp, char *fmt) = 0; const char *GetXfmt(void);
protected: // Constructor used by derived classes
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0; VALUE(int type, bool un = false);
const char *GetXfmt(void);
// Members
// Constructor used by derived classes PGLOBAL Global; // To reduce arglist
VALUE(int type, bool un = false); const char *Fmt;
const char *Xfmt;
// Members bool Nullable; // True if value can be null
PGLOBAL Global; // To reduce arglist bool Null; // True if value is null
const char *Fmt; bool Unsigned; // True if unsigned
const char *Xfmt; int Type; // The value type
bool Nullable; // True if value can be null int Clen; // Internal value length
bool Null; // True if value is null int Prec;
bool Unsigned; // True if unsigned }; // end of class VALUE
int Type; // The value type
int Clen; // Internal value length /***********************************************************************/
int Prec; /* Class TYPVAL: represents a typed value. */
}; // end of class VALUE /***********************************************************************/
template <class TYPE>
/***********************************************************************/ class DllExport TYPVAL : public VALUE {
/* Class TYPVAL: represents a typed value. */ public:
/***********************************************************************/ // Constructor
template <class TYPE> TYPVAL(TYPE n, int type, int prec = 0, bool un = false);
class DllExport TYPVAL : public VALUE {
public: // Implementation
// Constructor virtual bool IsTypeNum(void) {return true;}
TYPVAL(TYPE n, int type, int prec = 0, bool un = false); virtual bool IsZero(void) {return Tval == 0;}
virtual void Reset(void) {Tval = 0;}
// Implementation virtual int GetValLen(void);
virtual bool IsTypeNum(void) {return true;} virtual int GetValPrec() {return 0;}
virtual bool IsZero(void) {return Tval == 0;} virtual int GetSize(void) {return sizeof(TYPE);}
virtual void Reset(void) {Tval = 0;} virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();}
virtual int GetValLen(void); virtual char GetTinyValue(void) {return (char)Tval;}
virtual int GetValPrec() {return 0;} virtual uchar GetUTinyValue(void) {return (uchar)Tval;}
virtual int GetSize(void) {return sizeof(TYPE);} virtual short GetShortValue(void) {return (short)Tval;}
virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();} virtual ushort GetUShortValue(void) {return (ushort)Tval;}
virtual char GetTinyValue(void) {return (char)Tval;} virtual int GetIntValue(void) {return (int)Tval;}
virtual uchar GetUTinyValue(void) {return (uchar)Tval;} virtual uint GetUIntValue(void) {return (uint)Tval;}
virtual short GetShortValue(void) {return (short)Tval;} virtual longlong GetBigintValue(void) {return (longlong)Tval;}
virtual ushort GetUShortValue(void) {return (ushort)Tval;} virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;}
virtual int GetIntValue(void) {return (int)Tval;} virtual double GetFloatValue(void) {return (double)Tval;}
virtual uint GetUIntValue(void) {return (uint)Tval;} virtual void *GetTo_Val(void) {return &Tval;}
virtual longlong GetBigintValue(void) {return (longlong)Tval;}
virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;} // Methods
virtual double GetFloatValue(void) {return (double)Tval;} virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual void *GetTo_Val(void) {return &Tval;} virtual bool SetValue_char(char *p, int n);
virtual void SetValue_psz(PSZ s);
// Methods virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;}
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual int CompareValue(PVAL vp);
virtual bool SetValue_char(char *p, int n); virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;}
virtual void SetValue_psz(PSZ s); virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;}
#if defined(BLK_INDX) virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;}
virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;} virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;}
virtual int CompareValue(PVAL vp); virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;}
#endif // BLK_INDX virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;}
virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;} virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;}
virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;} virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;}
virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;} virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;}
virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;} virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;} virtual void SetBinValue(void *p);
virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;} virtual bool GetBinValue(void *buf, int buflen, bool go);
virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;} virtual char *ShowValue(char *buf, int);
virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;} virtual char *GetCharString(char *p);
virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;} virtual bool IsEqual(PVAL vp, bool chktype);
virtual void SetValue_pvblk(PVBLK blk, int n); virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual void SetBinValue(void *p); virtual bool FormatValue(PVAL vp, char *fmt);
virtual bool GetBinValue(void *buf, int buflen, bool go); virtual void Print(PGLOBAL g, FILE *, uint);
virtual char *ShowValue(char *buf, int); virtual void Print(PGLOBAL g, char *, uint);
virtual char *GetCharString(char *p);
virtual bool IsEqual(PVAL vp, bool chktype); protected:
virtual bool SetConstFormat(PGLOBAL, FORMAT&); // Default constructor not to be used
virtual bool FormatValue(PVAL vp, char *fmt); TYPVAL(void) : VALUE(TYPE_ERROR) {}
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint); // Specialized functions
static ulonglong MaxVal(void);
protected: TYPE GetTypedValue(PVAL vp);
// Default constructor not to be used TYPE GetTypedValue(PVBLK blk, int n);
TYPVAL(void) : VALUE(TYPE_ERROR) {} // TYPE GetTypedValue(PSZ s);
// Specialized functions // Members
static ulonglong MaxVal(void); TYPE Tval;
TYPE GetTypedValue(PVAL vp); }; // end of class TYPVAL
TYPE GetTypedValue(PVBLK blk, int n);
// TYPE GetTypedValue(PSZ s); /***********************************************************************/
/* Specific STRING class. */
// Members /***********************************************************************/
TYPE Tval; template <>
}; // end of class TYPVAL class DllExport TYPVAL<PSZ>: public VALUE {
public:
/***********************************************************************/ // Constructors
/* Specific STRING class. */ TYPVAL(PSZ s);
/***********************************************************************/ TYPVAL(PGLOBAL g, PSZ s, int n, int c);
template <>
class DllExport TYPVAL<PSZ>: public VALUE { // Implementation
public: virtual bool IsTypeNum(void) {return false;}
// Constructors virtual bool IsZero(void) {return *Strp == 0;}
TYPVAL(PSZ s); virtual void Reset(void) {*Strp = 0;}
TYPVAL(PGLOBAL g, PSZ s, int n, int c); virtual int GetValLen(void) {return Len;};
virtual int GetValPrec() {return (Ci) ? 1 : 0;}
// Implementation virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;}
virtual bool IsTypeNum(void) {return false;} virtual PSZ GetCharValue(void) {return Strp;}
virtual bool IsZero(void) {return *Strp == 0;} virtual char GetTinyValue(void);
virtual void Reset(void) {*Strp = 0;} virtual uchar GetUTinyValue(void);
virtual int GetValLen(void) {return Len;}; virtual short GetShortValue(void);
virtual int GetValPrec() {return (Ci) ? 1 : 0;} virtual ushort GetUShortValue(void);
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;} virtual int GetIntValue(void);
virtual PSZ GetCharValue(void) {return Strp;} virtual uint GetUIntValue(void);
virtual char GetTinyValue(void); virtual longlong GetBigintValue(void);
virtual uchar GetUTinyValue(void); virtual ulonglong GetUBigintValue(void);
virtual short GetShortValue(void); virtual double GetFloatValue(void) {return atof(Strp);}
virtual ushort GetUShortValue(void); virtual void *GetTo_Val(void) {return Strp;}
virtual int GetIntValue(void); virtual void SetPrec(int prec) {Ci = prec != 0;}
virtual uint GetUIntValue(void);
virtual longlong GetBigintValue(void); // Methods
virtual ulonglong GetUBigintValue(void); virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual double GetFloatValue(void) {return atof(Strp);} virtual bool SetValue_char(char *p, int n);
virtual void *GetTo_Val(void) {return Strp;} virtual void SetValue_psz(PSZ s);
virtual void SetPrec(int prec) {Ci = prec != 0;} virtual void SetValue_pvblk(PVBLK blk, int n);
virtual void SetValue(char c);
// Methods virtual void SetValue(uchar c);
virtual bool SetValue_pval(PVAL valp, bool chktype); virtual void SetValue(short i);
virtual bool SetValue_char(char *p, int n); virtual void SetValue(ushort i);
virtual void SetValue_psz(PSZ s); virtual void SetValue(int n);
virtual void SetValue_pvblk(PVBLK blk, int n); virtual void SetValue(uint n);
virtual void SetValue(char c); virtual void SetValue(longlong n);
virtual void SetValue(uchar c); virtual void SetValue(ulonglong n);
virtual void SetValue(short i); virtual void SetValue(double f);
virtual void SetValue(ushort i); virtual void SetBinValue(void *p);
virtual void SetValue(int n); virtual int CompareValue(PVAL vp);
virtual void SetValue(uint n); virtual bool GetBinValue(void *buf, int buflen, bool go);
virtual void SetValue(longlong n); virtual char *ShowValue(char *buf, int);
virtual void SetValue(ulonglong n); virtual char *GetCharString(char *p);
virtual void SetValue(double f); virtual bool IsEqual(PVAL vp, bool chktype);
virtual void SetBinValue(void *p); virtual bool FormatValue(PVAL vp, char *fmt);
#if defined(BLK_INDX) virtual bool SetConstFormat(PGLOBAL, FORMAT&);
virtual int CompareValue(PVAL vp);
#endif // BLK_INDX // Members
virtual bool GetBinValue(void *buf, int buflen, bool go); PSZ Strp;
virtual char *ShowValue(char *buf, int); bool Ci; // true if case insensitive
virtual char *GetCharString(char *p); int Len;
virtual bool IsEqual(PVAL vp, bool chktype); }; // end of class TYPVAL<PSZ>
virtual bool FormatValue(PVAL vp, char *fmt);
virtual bool SetConstFormat(PGLOBAL, FORMAT&); /***********************************************************************/
/* Specific DECIMAL class. */
// Members /***********************************************************************/
PSZ Strp; class DllExport DECVAL: public TYPVAL<PSZ> {
bool Ci; // true if case insensitive public:
int Len; // Constructors
}; // end of class TYPVAL<PSZ> DECVAL(PSZ s);
DECVAL(PGLOBAL g, PSZ s, int n, int prec, bool uns);
/***********************************************************************/
/* Specific DECIMAL class. */ // Implementation
/***********************************************************************/ virtual bool IsTypeNum(void) {return true;}
class DllExport DECVAL: public TYPVAL<PSZ> { virtual bool IsZero(void);
public: virtual void Reset(void);
// Constructors virtual int GetValPrec() {return Prec;}
DECVAL(PSZ s);
DECVAL(PGLOBAL g, PSZ s, int n, int prec, bool uns); // Methods
virtual bool GetBinValue(void *buf, int buflen, bool go);
// Implementation virtual char *ShowValue(char *buf, int);
virtual bool IsTypeNum(void) {return true;} virtual bool IsEqual(PVAL vp, bool chktype);
virtual bool IsZero(void); virtual int CompareValue(PVAL vp);
virtual void Reset(void);
virtual int GetValPrec() {return Prec;} // Members
}; // end of class DECVAL
// Methods
//virtual bool SetValue_pval(PVAL valp, bool chktype); /***********************************************************************/
//virtual bool SetValue_char(char *p, int n); /* Class DTVAL: represents a time stamp value. */
//virtual void SetValue_psz(PSZ s); /***********************************************************************/
//virtual void SetValue_pvblk(PVBLK blk, int n); class DllExport DTVAL : public TYPVAL<int> {
//virtual void SetBinValue(void *p); public:
virtual bool GetBinValue(void *buf, int buflen, bool go); // Constructors
virtual char *ShowValue(char *buf, int); DTVAL(PGLOBAL g, int n, int p, PSZ fmt);
//virtual char *GetCharString(char *p); DTVAL(PGLOBAL g, PSZ s, int n);
virtual bool IsEqual(PVAL vp, bool chktype); DTVAL(PGLOBAL g, short i);
#if defined(BLK_INDX) DTVAL(PGLOBAL g, int n);
virtual int CompareValue(PVAL vp); DTVAL(PGLOBAL g, longlong n);
#endif // BLK_INDX DTVAL(PGLOBAL g, double f);
//virtual bool FormatValue(PVAL vp, char *fmt);
//virtual bool SetConstFormat(PGLOBAL, FORMAT&); // Implementation
virtual bool SetValue_pval(PVAL valp, bool chktype);
// Members virtual bool SetValue_char(char *p, int n);
}; // end of class DECVAL virtual void SetValue_psz(PSZ s);
virtual void SetValue_pvblk(PVBLK blk, int n);
/***********************************************************************/ virtual char *GetCharString(char *p);
/* Class DTVAL: represents a time stamp value. */ virtual char *ShowValue(char *buf, int);
/***********************************************************************/ virtual bool FormatValue(PVAL vp, char *fmt);
class DllExport DTVAL : public TYPVAL<int> { bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0);
public: bool SetFormat(PGLOBAL g, PVAL valp);
// Constructors bool IsFormatted(void) {return Pdtp != NULL;}
DTVAL(PGLOBAL g, int n, int p, PSZ fmt); bool MakeTime(struct tm *ptm);
DTVAL(PGLOBAL g, PSZ s, int n); static void SetTimeShift(void);
DTVAL(PGLOBAL g, short i); static int GetShift(void) {return Shift;}
DTVAL(PGLOBAL g, int n);
DTVAL(PGLOBAL g, longlong n); // Methods
DTVAL(PGLOBAL g, double f); bool MakeDate(PGLOBAL g, int *val, int nval);
// Implementation struct tm *GetGmTime(struct tm *);
virtual bool SetValue_pval(PVAL valp, bool chktype);
virtual bool SetValue_char(char *p, int n); protected:
virtual void SetValue_psz(PSZ s); // Default constructor not to be used
virtual void SetValue_pvblk(PVBLK blk, int n); DTVAL(void) : TYPVAL<int>() {}
virtual char *GetCharString(char *p);
virtual char *ShowValue(char *buf, int); // Members
virtual bool FormatValue(PVAL vp, char *fmt); static int Shift; // Time zone shift in seconds
bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); PDTP Pdtp; // To the DATPAR structure
bool SetFormat(PGLOBAL g, PVAL valp); char *Sdate; // Utility char buffer
bool IsFormatted(void) {return Pdtp != NULL;} int DefYear; // Used by ExtractDate
// bool GetTmMember(OPVAL op, int& mval); int Len; // Used by CHAR scalar function
// bool DateDiff(DTVAL *dtp, OPVAL op, int& tdif); }; // end of class DTVAL
bool MakeTime(struct tm *ptm);
static void SetTimeShift(void); #endif // __VALUE__H__
static int GetShift(void) {return Shift;}
// Methods
bool MakeDate(PGLOBAL g, int *val, int nval);
// bool WeekNum(PGLOBAL g, int& nval);
struct tm *GetGmTime(struct tm *);
protected:
// Default constructor not to be used
DTVAL(void) : TYPVAL<int>() {}
// Members
static int Shift; // Time zone shift in seconds
PDTP Pdtp; // To the DATPAR structure
char *Sdate; // Utility char buffer
int DefYear; // Used by ExtractDate
int Len; // Used by CHAR scalar function
}; // end of class DTVAL
#endif // __VALUE__H__

File diff suppressed because it is too large Load Diff

View File

@@ -98,12 +98,6 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */
void SetNParts(uint np) {Nparts = (signed)np;} void SetNParts(uint np) {Nparts = (signed)np;}
void SetMaxSame(int mxs) {MaxSame = mxs;} void SetMaxSame(int mxs) {MaxSame = mxs;}
void SetMxsame(PXINDEX x); void SetMxsame(PXINDEX x);
//int GetOffset(void) {return Offset;}
//void SetOffset(int off) {Offset = off;}
//int GetOffhigh(void) {return Offhigh;}
//void SetOffhigh(int hof) {Offhigh = hof;}
//int GetSize(void) {return Size;}
//void SetSize(int size) {Size = size;}
int GetMaxSame(void) {return MaxSame;} int GetMaxSame(void) {return MaxSame;}
bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p); bool Define(PGLOBAL g, void *memp, PTABDEF dfp, LPCSTR p);
PIXDEF GetIndexOf(PCOL colp, bool hd = false); PIXDEF GetIndexOf(PCOL colp, bool hd = false);
@@ -123,9 +117,6 @@ class DllExport INDEXDEF : public BLOCK { /* Index description block */
bool AutoInc; /* true if unique key in auto increment */ bool AutoInc; /* true if unique key in auto increment */
int Nparts; /* Number of key parts */ int Nparts; /* Number of key parts */
int ID; /* Index ID number */ int ID; /* Index ID number */
//int Offset; /* Offset in index file */
//int Offhigh; /* Offset high in big index file */
//int Size; /* Size of index file */
int MaxSame; /* Max number of same values */ int MaxSame; /* Max number of same values */
}; // end of INDEXDEF }; // end of INDEXDEF
@@ -253,9 +244,6 @@ class DllExport XINDEX : public XXBASE {
virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;} virtual int GetCurPos(void) {return (Pex) ? Pex[Cur_K] : Cur_K;}
virtual void SetNval(int n) {Nval = n;} virtual void SetNval(int n) {Nval = n;}
int GetMaxSame(void) {return MaxSame;} int GetMaxSame(void) {return MaxSame;}
// int GetDefoff(void) {return Defoff;}
// int GetDefhigh(void) {return Defhigh;}
// int GetSize(void) {return Size;}
// Methods // Methods
virtual void Reset(void); virtual void Reset(void);
@@ -288,9 +276,6 @@ class DllExport XINDEX : public XXBASE {
int Nk; // The number of indexed columns int Nk; // The number of indexed columns
int Nval; // The number of used columns int Nval; // The number of used columns
int Incr; // Increment of record position int Incr; // Increment of record position
//int Defoff; // Offset of definition in index file
//int Defhigh; // High order of offset big value
//int Size; // Size of definition in index file
int MaxSame; // Max number of same values int MaxSame; // Max number of same values
}; // end of class XINDEX }; // end of class XINDEX

View File

@@ -1,188 +1,186 @@
/************ Xobject C++ Functions Source Code File (.CPP) ************/ /************ Xobject C++ Functions Source Code File (.CPP) ************/
/* Name: XOBJECT.CPP Version 2.2 */ /* Name: XOBJECT.CPP Version 2.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
/* */ /* */
/* This file contains base XOBJECT class functions. */ /* This file contains base XOBJECT class functions. */
/* Also here is the implementation of the CONSTANT class. */ /* Also here is the implementation of the CONSTANT class. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
/* Include mariaDB header file. */ /* Include mariaDB header file. */
/***********************************************************************/ /***********************************************************************/
#include "my_global.h" #include "my_global.h"
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* global.h is header containing all global Plug declarations. */ /* global.h is header containing all global Plug declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */ /* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/ /***********************************************************************/
#include "global.h" #include "global.h"
#include "plgdbsem.h" #include "plgdbsem.h"
#include "xobject.h" #include "xobject.h"
/***********************************************************************/ /***********************************************************************/
/* Macro definitions. */ /* Macro definitions. */
/***********************************************************************/ /***********************************************************************/
#if defined(_DEBUG) || defined(DEBTRACE) #if defined(_DEBUG) || defined(DEBTRACE)
#define ASSERT(B) assert(B); #define ASSERT(B) assert(B);
#else #else
#define ASSERT(B) #define ASSERT(B)
#endif #endif
/***********************************************************************/ /***********************************************************************/
/* The one and only needed void object. */ /* The one and only needed void object. */
/***********************************************************************/ /***********************************************************************/
XVOID Xvoid; XVOID Xvoid;
PXOB const pXVOID = &Xvoid; // Pointer used by other classes PXOB const pXVOID = &Xvoid; // Pointer used by other classes
/* ------------------------- Class XOBJECT --------------------------- */ /* ------------------------- Class XOBJECT --------------------------- */
/***********************************************************************/ /***********************************************************************/
/* GetCharValue: returns the Result value as a char string. */ /* GetCharValue: returns the Result value as a char string. */
/* Using GetCharValue provides no conversion from numeric types. */ /* Using GetCharValue provides no conversion from numeric types. */
/***********************************************************************/ /***********************************************************************/
PSZ XOBJECT::GetCharValue(void) PSZ XOBJECT::GetCharValue(void)
{ {
ASSERT(Value) ASSERT(Value)
return Value->GetCharValue(); return Value->GetCharValue();
} // end of GetCharValue() } // end of GetCharValue()
/***********************************************************************/ /***********************************************************************/
/* GetShortValue: returns the Result value as a short integer. */ /* GetShortValue: returns the Result value as a short integer. */
/***********************************************************************/ /***********************************************************************/
short XOBJECT::GetShortValue(void) short XOBJECT::GetShortValue(void)
{ {
ASSERT(Value) ASSERT(Value)
return Value->GetShortValue(); return Value->GetShortValue();
} // end of GetShortValue } // end of GetShortValue
/***********************************************************************/ /***********************************************************************/
/* GetIntValue: returns the Result value as a int integer. */ /* GetIntValue: returns the Result value as a int integer. */
/***********************************************************************/ /***********************************************************************/
int XOBJECT::GetIntValue(void) int XOBJECT::GetIntValue(void)
{ {
ASSERT(Value) ASSERT(Value)
return Value->GetIntValue(); return Value->GetIntValue();
} // end of GetIntValue } // end of GetIntValue
/***********************************************************************/ /***********************************************************************/
/* GetFloatValue: returns the Result value as a double float. */ /* GetFloatValue: returns the Result value as a double float. */
/***********************************************************************/ /***********************************************************************/
double XOBJECT::GetFloatValue(void) double XOBJECT::GetFloatValue(void)
{ {
ASSERT(Value) ASSERT(Value)
return Value->GetFloatValue(); return Value->GetFloatValue();
} // end of GetFloatValue } // end of GetFloatValue
/* ------------------------- Class CONSTANT -------------------------- */ /* ------------------------- Class CONSTANT -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* CONSTANT public constructor. */ /* CONSTANT public constructor. */
/***********************************************************************/ /***********************************************************************/
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type) CONSTANT::CONSTANT(PGLOBAL g, void *value, short type)
{ {
if (!(Value = AllocateValue(g, value, (int)type))) if (!(Value = AllocateValue(g, value, (int)type)))
longjmp(g->jumper[g->jump_level], TYPE_CONST); longjmp(g->jumper[g->jump_level], TYPE_CONST);
Constant = true; Constant = true;
} // end of CONSTANT constructor } // end of CONSTANT constructor
/***********************************************************************/ /***********************************************************************/
/* CONSTANT public constructor. */ /* CONSTANT public constructor. */
/***********************************************************************/ /***********************************************************************/
CONSTANT::CONSTANT(PGLOBAL g, int n) CONSTANT::CONSTANT(PGLOBAL g, int n)
{ {
if (!(Value = AllocateValue(g, &n, TYPE_INT))) if (!(Value = AllocateValue(g, &n, TYPE_INT)))
longjmp(g->jumper[g->jump_level], TYPE_CONST); longjmp(g->jumper[g->jump_level], TYPE_CONST);
Constant = true; Constant = true;
} // end of CONSTANT constructor } // end of CONSTANT constructor
/***********************************************************************/ /***********************************************************************/
/* GetLengthEx: returns an evaluation of the constant string length. */ /* GetLengthEx: returns an evaluation of the constant string length. */
/* Note: When converting from token to string, length has to be */ /* Note: When converting from token to string, length has to be */
/* specified but we need the domain length, not the value length. */ /* specified but we need the domain length, not the value length. */
/***********************************************************************/ /***********************************************************************/
int CONSTANT::GetLengthEx(void) int CONSTANT::GetLengthEx(void)
{ {
return Value->GetValLen(); return Value->GetValLen();
} // end of GetLengthEx } // end of GetLengthEx
#if defined(BLK_INDX) /***********************************************************************/
/***********************************************************************/ /* Convert a constant to the given type. */
/* Convert a constant to the given type. */ /***********************************************************************/
/***********************************************************************/ void CONSTANT::Convert(PGLOBAL g, int newtype)
void CONSTANT::Convert(PGLOBAL g, int newtype) {
{ if (Value->GetType() != newtype)
if (Value->GetType() != newtype) if (!(Value = AllocateValue(g, Value, newtype)))
if (!(Value = AllocateValue(g, Value, newtype))) longjmp(g->jumper[g->jump_level], TYPE_CONST);
longjmp(g->jumper[g->jump_level], TYPE_CONST);
} // end of Convert
} // end of Convert
#endif // BLK_INDX /***********************************************************************/
/* Compare: returns true if this object is equivalent to xp. */
/***********************************************************************/ /***********************************************************************/
/* Compare: returns true if this object is equivalent to xp. */ bool CONSTANT::Compare(PXOB xp)
/***********************************************************************/ {
bool CONSTANT::Compare(PXOB xp) if (this == xp)
{ return true;
if (this == xp) else if (xp->GetType() != TYPE_CONST)
return true; return false;
else if (xp->GetType() != TYPE_CONST) else
return false; return Value->IsEqual(xp->GetValue(), true);
else
return Value->IsEqual(xp->GetValue(), true); } // end of Compare
} // end of Compare #if 0
/***********************************************************************/
#if 0 /* Rephrase: temporary implementation used by PlugRephraseSQL. */
/***********************************************************************/ /***********************************************************************/
/* Rephrase: temporary implementation used by PlugRephraseSQL. */ bool CONSTANT::Rephrase(PGLOBAL g, PSZ work)
/***********************************************************************/ {
bool CONSTANT::Rephrase(PGLOBAL g, PSZ work) switch (Value->GetType()) {
{ case TYPE_STRING:
switch (Value->GetType()) { sprintf(work + strlen(work), "'%s'", Value->GetCharValue());
case TYPE_STRING: break;
sprintf(work + strlen(work), "'%s'", Value->GetCharValue()); case TYPE_SHORT:
break; sprintf(work + strlen(work), "%hd", Value->GetShortValue());
case TYPE_SHORT: break;
sprintf(work + strlen(work), "%hd", Value->GetShortValue()); case TYPE_INT:
break; case TYPE_DATE:
case TYPE_INT: sprintf(work + strlen(work), "%d", Value->GetIntValue());
case TYPE_DATE: break;
sprintf(work + strlen(work), "%d", Value->GetIntValue()); case TYPE_DOUBLE:
break; sprintf(work + strlen(work), "%lf", Value->GetFloatValue());
case TYPE_DOUBLE: break;
sprintf(work + strlen(work), "%lf", Value->GetFloatValue()); case TYPE_BIGINT:
break; sprintf(work + strlen(work), "%lld", Value->GetBigintValue());
case TYPE_BIGINT: break;
sprintf(work + strlen(work), "%lld", Value->GetBigintValue()); case TYPE_TINY:
break; sprintf(work + strlen(work), "%d", Value->GetTinyValue());
case TYPE_TINY: break;
sprintf(work + strlen(work), "%d", Value->GetTinyValue()); default:
break; sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType());
default: return false;
sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType()); } // endswitch
return false;
} // endswitch return false;
} // end of Rephrase
return false; #endif // 0
} // end of Rephrase
#endif // 0 /***********************************************************************/
/* Make file output of a constant object. */
/***********************************************************************/ /***********************************************************************/
/* Make file output of a constant object. */ void CONSTANT::Print(PGLOBAL g, FILE *f, uint n)
/***********************************************************************/ {
void CONSTANT::Print(PGLOBAL g, FILE *f, uint n) Value->Print(g, f, n);
{ } /* end of Print */
Value->Print(g, f, n);
} /* end of Print */ /***********************************************************************/
/* Make string output of a constant object. */
/***********************************************************************/ /***********************************************************************/
/* Make string output of a constant object. */ void CONSTANT::Print(PGLOBAL g, char *ps, uint z)
/***********************************************************************/ {
void CONSTANT::Print(PGLOBAL g, char *ps, uint z) Value->Print(g, ps, z);
{ } /* end of Print */
Value->Print(g, ps, z);
} /* end of Print */

View File

@@ -1,137 +1,119 @@
/*************** Xobject H Declares Source Code File (.H) **************/ /*************** Xobject H Declares Source Code File (.H) **************/
/* Name: XOBJECT.H Version 2.3 */ /* Name: XOBJECT.H Version 2.4 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2014 */
/* */ /* */
/* This file contains the XOBJECT and derived classes declares. */ /* This file contains the XOBJECT and derived classes declares. */
/***********************************************************************/ /***********************************************************************/
#ifndef __XOBJECT__H #ifndef __XOBJECT__H
#define __XOBJECT__H #define __XOBJECT__H
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* block.h is header containing Block global declarations. */ /* block.h is header containing Block global declarations. */
/***********************************************************************/ /***********************************************************************/
#include "block.h" #include "block.h"
#include "valblk.h" // includes value.h #include "valblk.h" // includes value.h
/***********************************************************************/ /***********************************************************************/
/* Types used in some class definitions. */ /* Types used in some class definitions. */
/***********************************************************************/ /***********************************************************************/
//typedef struct _tabdesc *PTABD; // For friend setting //typedef struct _tabdesc *PTABD; // For friend setting
/***********************************************************************/ /***********************************************************************/
/* The pointer to the one and only needed void object. */ /* The pointer to the one and only needed void object. */
/***********************************************************************/ /***********************************************************************/
extern PXOB const pXVOID; extern PXOB const pXVOID;
/***********************************************************************/ /***********************************************************************/
/* Class XOBJECT is the base class for all classes that can be used */ /* Class XOBJECT is the base class for all classes that can be used */
/* in evaluation operations: FILTER, EXPRESSION, SCALF, FNC, COLBLK, */ /* in evaluation operations: FILTER, EXPRESSION, SCALF, FNC, COLBLK, */
/* SELECT, FILTER as well as all the constant object types. */ /* SELECT, FILTER as well as all the constant object types. */
/***********************************************************************/ /***********************************************************************/
class DllExport XOBJECT : public BLOCK { class DllExport XOBJECT : public BLOCK {
public: public:
XOBJECT(void) {Value = NULL; Constant = false;} XOBJECT(void) {Value = NULL; Constant = false;}
// Implementation // Implementation
PVAL GetValue(void) {return Value;} PVAL GetValue(void) {return Value;}
bool IsConstant(void) {return Constant;} bool IsConstant(void) {return Constant;}
virtual int GetType(void) {return TYPE_XOBJECT;} virtual int GetType(void) {return TYPE_XOBJECT;}
virtual int GetResultType(void) {return TYPE_VOID;} virtual int GetResultType(void) {return TYPE_VOID;}
virtual int GetKey(void) {return 0;} virtual int GetKey(void) {return 0;}
#if defined(_DEBUG) #if defined(_DEBUG)
virtual void SetKey(int k) {assert(false);} virtual void SetKey(int k) {assert(false);}
#else // !_DEBUG #else // !_DEBUG
virtual void SetKey(int k) {} // Only defined for COLBLK virtual void SetKey(int k) {} // Only defined for COLBLK
#endif // !_DEBUG #endif // !_DEBUG
virtual int GetLength(void) = 0; virtual int GetLength(void) = 0;
virtual int GetLengthEx(void) = 0; virtual int GetLengthEx(void) = 0;
virtual PSZ GetCharValue(void); virtual PSZ GetCharValue(void);
virtual short GetShortValue(void); virtual short GetShortValue(void);
virtual int GetIntValue(void); virtual int GetIntValue(void);
virtual double GetFloatValue(void); virtual double GetFloatValue(void);
virtual int GetScale(void) = 0; virtual int GetScale(void) = 0;
// Methods // Methods
virtual void Reset(void) {} virtual void Reset(void) {}
virtual bool Compare(PXOB) = 0; virtual bool Compare(PXOB) = 0;
virtual bool Init(PGLOBAL) {return false;} virtual bool Init(PGLOBAL) {return false;}
virtual bool Eval(PGLOBAL) {return false;} virtual bool Eval(PGLOBAL) {return false;}
virtual bool SetFormat(PGLOBAL, FORMAT&) = 0; virtual bool SetFormat(PGLOBAL, FORMAT&) = 0;
virtual int CheckColumn(PGLOBAL, PSQL, PXOB &, int &) {return 0;}
virtual int RefNum(PSQL) {return 0;} protected:
virtual void AddTdb(PSQL, PTDB *, int&) {} PVAL Value; // The current value of the object.
virtual PXOB SetSelect(PGLOBAL, PSQL, bool) {return this;} bool Constant; // true for an object having a constant value.
virtual PXOB CheckSubQuery(PGLOBAL, PSQL) {return this;} }; // end of class XOBJECT
virtual bool CheckLocal(PTDB) {return true;}
virtual int CheckSpcCol(PTDB, int) {return 2;} /***********************************************************************/
virtual bool CheckSort(PTDB) {return false;} /* Class XVOID: represent a void (null) object. */
virtual bool VerifyColumn(PTDB txp) {return false;} /* Used to represent a void parameter for count(*) or for a filter. */
virtual bool VerifyTdb(PTDB& tdbp) {return false;} /***********************************************************************/
virtual bool IsColInside(PCOL colp) {return false;} class DllExport XVOID : public XOBJECT {
public:
protected: XVOID(void) {Constant = true;}
PVAL Value; // The current value of the object.
bool Constant; // true for an object having a constant value. // Implementation
}; // end of class XOBJECT virtual int GetType(void) {return TYPE_VOID;}
virtual int GetLength(void) {return 0;}
/***********************************************************************/ virtual int GetLengthEx(void) {return 0;}
/* Class XVOID: represent a void (null) object. */ virtual PSZ GetCharValue(void) {return NULL;}
/* Used to represent a void parameter for count(*) or for a filter. */ virtual int GetIntValue(void) {return 0;}
/***********************************************************************/ virtual double GetFloatValue(void) {return 0.0;}
class DllExport XVOID : public XOBJECT { virtual int GetScale() {return 0;}
public:
XVOID(void) {Constant = true;} // Methods
virtual bool Compare(PXOB xp) {return xp->GetType() == TYPE_VOID;}
// Implementation virtual bool SetFormat(PGLOBAL, FORMAT&) {return true;}
virtual int GetType(void) {return TYPE_VOID;} }; // end of class XVOID
virtual int GetLength(void) {return 0;}
virtual int GetLengthEx(void) {return 0;}
virtual PSZ GetCharValue(void) {return NULL;} /***********************************************************************/
virtual int GetIntValue(void) {return 0;} /* Class CONSTANT: represents a constant XOBJECT of any value type. */
virtual double GetFloatValue(void) {return 0.0;} /* Note that the CONSTANT class is a friend of the VALUE class; */
virtual int GetScale() {return 0;} /***********************************************************************/
class DllExport CONSTANT : public XOBJECT {
// Methods public:
virtual bool Compare(PXOB xp) {return xp->GetType() == TYPE_VOID;} CONSTANT(PGLOBAL g, void *value, short type);
virtual bool SetFormat(PGLOBAL, FORMAT&) {return true;} CONSTANT(PGLOBAL g, int n);
virtual int CheckSpcCol(PTDB, int) {return 0;} CONSTANT(PVAL valp) {Value = valp; Constant = true;}
}; // end of class XVOID
// Implementation
virtual int GetType(void) {return TYPE_CONST;}
/***********************************************************************/ virtual int GetResultType(void) {return Value->Type;}
/* Class CONSTANT: represents a constant XOBJECT of any value type. */ virtual int GetLength(void) {return Value->GetValLen();}
/* Note that the CONSTANT class is a friend of the VALUE class; */ virtual int GetScale() {return Value->GetValPrec();}
/***********************************************************************/ virtual int GetLengthEx(void);
class DllExport CONSTANT : public XOBJECT {
public: // Methods
CONSTANT(PGLOBAL g, void *value, short type); virtual bool Compare(PXOB xp);
CONSTANT(PGLOBAL g, int n); virtual bool SetFormat(PGLOBAL g, FORMAT& fmt)
CONSTANT(PVAL valp) {Value = valp; Constant = true;} {return Value->SetConstFormat(g, fmt);}
void Convert(PGLOBAL g, int newtype);
// Implementation void SetValue(PVAL vp) {Value = vp;}
virtual int GetType(void) {return TYPE_CONST;} virtual void Print(PGLOBAL g, FILE *, uint);
virtual int GetResultType(void) {return Value->Type;} virtual void Print(PGLOBAL g, char *, uint);
virtual int GetLength(void) {return Value->GetValLen();} }; // end of class CONSTANT
virtual int GetScale() {return Value->GetValPrec();}
virtual int GetLengthEx(void); #endif
// Methods
virtual bool Compare(PXOB xp);
virtual bool SetFormat(PGLOBAL g, FORMAT& fmt)
{return Value->SetConstFormat(g, fmt);}
virtual int CheckSpcCol(PTDB, int) {return 1;}
#if defined(BLK_INDX)
void Convert(PGLOBAL g, int newtype);
#endif // BLK_INDX
// bool Rephrase(PGLOBAL g, PSZ work);
void SetValue(PVAL vp) {Value = vp;}
virtual bool VerifyColumn(PTDB txp) {return true;}
virtual bool VerifyTdb(PTDB& tdbp) {return true;}
virtual void Print(PGLOBAL g, FILE *, uint);
virtual void Print(PGLOBAL g, char *, uint);
}; // end of class CONSTANT
#endif

View File

@@ -1,267 +1,259 @@
/**************** Table H Declares Source Code File (.H) ***************/ /**************** Table H Declares Source Code File (.H) ***************/
/* Name: TABLE.H Version 2.3 */ /* Name: TABLE.H Version 2.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ /* (C) Copyright to the author Olivier BERTRAND 1999-2014 */
/* */ /* */
/* This file contains the TBX, OPJOIN and TDB class definitions. */ /* This file contains the TBX, OPJOIN and TDB class definitions. */
/***********************************************************************/ /***********************************************************************/
#if !defined(TABLE_DEFINED) #if !defined(TABLE_DEFINED)
#define TABLE_DEFINED #define TABLE_DEFINED
/***********************************************************************/ /***********************************************************************/
/* Include required application header files */ /* Include required application header files */
/* block.h is header containing Block global declarations. */ /* block.h is header containing Block global declarations. */
/***********************************************************************/ /***********************************************************************/
#include "assert.h" #include "assert.h"
#include "block.h" #include "block.h"
#include "colblk.h" #include "colblk.h"
#include "m_ctype.h" #include "m_ctype.h"
typedef class CMD *PCMD; typedef class CMD *PCMD;
// Commands executed by XDBC and MYX tables // Commands executed by XDBC and MYX tables
class CMD : public BLOCK { class CMD : public BLOCK {
public: public:
// Constructor // Constructor
CMD(PGLOBAL g, char *cmd) { CMD(PGLOBAL g, char *cmd) {
Cmd = (char*)PlugSubAlloc(g, NULL, strlen(cmd) + 1); Cmd = (char*)PlugSubAlloc(g, NULL, strlen(cmd) + 1);
strcpy(Cmd, cmd); Next = NULL; } strcpy(Cmd, cmd); Next = NULL; }
// Members // Members
PCMD Next; PCMD Next;
char *Cmd; char *Cmd;
}; // end of class CMD }; // end of class CMD
// Condition filter structure // Condition filter structure
typedef struct _cond_filter { typedef struct _cond_filter {
char *Body; char *Body;
OPVAL Op; OPVAL Op;
PCMD Cmds; PCMD Cmds;
} CONDFIL, *PCFIL; } CONDFIL, *PCFIL;
typedef class TDBCAT *PTDBCAT; typedef class TDBCAT *PTDBCAT;
typedef class CATCOL *PCATCOL; typedef class CATCOL *PCATCOL;
/***********************************************************************/ /***********************************************************************/
/* Definition of class TDB with all its method functions. */ /* Definition of class TDB with all its method functions. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDB: public BLOCK { // Table Descriptor Block. class DllExport TDB: public BLOCK { // Table Descriptor Block.
public: public:
// Constructors // Constructors
TDB(PTABDEF tdp = NULL); TDB(PTABDEF tdp = NULL);
TDB(PTDB tdbp); TDB(PTDB tdbp);
// Implementation // Implementation
static void SetTnum(int n) {Tnum = n;} static void SetTnum(int n) {Tnum = n;}
inline PTDB GetOrig(void) {return To_Orig;} inline PTDB GetOrig(void) {return To_Orig;}
inline TUSE GetUse(void) {return Use;} inline TUSE GetUse(void) {return Use;}
inline PCFIL GetCondFil(void) {return To_CondFil;} 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 PFIL GetFilter(void) {return To_Filter;} inline void SetFilter(PFIL fp) {To_Filter = fp;}
inline void SetFilter(PFIL fp) {To_Filter = fp;} inline void SetOrig(PTDB txp) {To_Orig = txp;}
#endif // BLK_INDX inline void SetUse(TUSE n) {Use = n;}
inline void SetOrig(PTDB txp) {To_Orig = txp;} inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;}
inline void SetUse(TUSE n) {Use = n;} inline void SetNext(PTDB tdbp) {Next = tdbp;}
inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;} inline void SetName(LPCSTR name) {Name = name;}
inline void SetNext(PTDB tdbp) {Next = tdbp;} inline void SetTable(PTABLE tablep) {To_Table = tablep;}
inline void SetName(LPCSTR name) {Name = name;} inline void SetColumns(PCOL colp) {Columns = colp;}
inline void SetTable(PTABLE tablep) {To_Table = tablep;} inline void SetDegree(int degree) {Degree = degree;}
inline void SetColumns(PCOL colp) {Columns = colp;} inline void SetMode(MODE mode) {Mode = mode;}
inline void SetDegree(int degree) {Degree = degree;}
inline void SetMode(MODE mode) {Mode = mode;} //Properties
virtual AMT GetAmType(void) {return TYPE_AM_ERROR;}
//Properties virtual int GetTdb_No(void) {return Tdb_No;}
virtual AMT GetAmType(void) {return TYPE_AM_ERROR;} virtual PTDB GetNext(void) {return Next;}
virtual int GetTdb_No(void) {return Tdb_No;} virtual PCATLG GetCat(void) {return NULL;}
virtual PTDB GetNext(void) {return Next;}
virtual PCATLG GetCat(void) {return NULL;} // Methods
virtual bool IsSame(PTDB tp) {return tp == this;}
// Methods virtual bool GetBlockValues(PGLOBAL g) {return false;}
virtual bool IsSame(PTDB tp) {return tp == this;} virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;}
virtual bool GetBlockValues(PGLOBAL g) {return false;} virtual int GetMaxSize(PGLOBAL) = 0;
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} virtual int GetProgMax(PGLOBAL) = 0;
virtual int GetMaxSize(PGLOBAL) = 0; virtual int GetProgCur(void) = 0;
virtual int GetProgMax(PGLOBAL) = 0; virtual int RowNumber(PGLOBAL g, bool b = false);
virtual int GetProgCur(void) = 0; virtual bool IsReadOnly(void) {return true;}
virtual int RowNumber(PGLOBAL g, bool b = false); virtual const CHARSET_INFO *data_charset() {return NULL;}
virtual bool IsReadOnly(void) {return true;} virtual PTDB Duplicate(PGLOBAL g) {return NULL;}
virtual const CHARSET_INFO *data_charset() {return NULL;} virtual PTDB CopyOne(PTABS t) {return this;}
virtual PTDB Duplicate(PGLOBAL g) {return NULL;} virtual PTDB Copy(PTABS t);
virtual PTDB CopyOne(PTABS t) {return this;} virtual void PrintAM(FILE *f, char *m)
virtual PTDB Copy(PTABS t); {fprintf(f, "%s AM(%d)\n", m, GetAmType());}
virtual void PrintAM(FILE *f, char *m) virtual void Print(PGLOBAL g, FILE *f, uint n);
{fprintf(f, "%s AM(%d)\n", m, GetAmType());} virtual void Print(PGLOBAL g, char *ps, uint z);
virtual void Print(PGLOBAL g, FILE *f, uint n); virtual PSZ GetServer(void) = 0;
virtual void Print(PGLOBAL g, char *ps, uint z); virtual int GetBadLines(void) {return 0;}
virtual PSZ GetServer(void) = 0;
virtual int GetBadLines(void) {return 0;} // Database pure virtual routines
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num) = 0;
// Database pure virtual routines virtual void MarkDB(PGLOBAL, PTDB) = 0;
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num) = 0; virtual bool OpenDB(PGLOBAL) = 0;
virtual void MarkDB(PGLOBAL, PTDB) = 0; virtual int ReadDB(PGLOBAL) = 0;
virtual bool OpenDB(PGLOBAL) = 0; virtual int WriteDB(PGLOBAL) = 0;
virtual int ReadDB(PGLOBAL) = 0; virtual int DeleteDB(PGLOBAL, int) = 0;
virtual int WriteDB(PGLOBAL) = 0; virtual void CloseDB(PGLOBAL) = 0;
virtual int DeleteDB(PGLOBAL, int) = 0; virtual int CheckWrite(PGLOBAL g) {return 0;}
virtual void CloseDB(PGLOBAL) = 0;
virtual int CheckWrite(PGLOBAL g) {return 0;} protected:
// Members
// Database routines PTDB To_Orig; // Pointer to original if it is a copy
bool OpenTable(PGLOBAL g, PSQL sqlp, MODE mode); TUSE Use;
void CloseTable(PGLOBAL g); PFIL To_Filter;
PCFIL To_CondFil; // To condition filter structure
protected: static int Tnum; // Used to generate Tdb_no's
// Members const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN
PTDB To_Orig; // Pointer to original if it is a copy PTDB Next; // Next in linearized queries
TUSE Use; PTABLE To_Table; // Points to the XTAB object
#if defined(BLK_INDX) LPCSTR Name; // Table name
PFIL To_Filter; PCOL Columns; // Points to the first column of the table
#endif // BLK_INDX MODE Mode; // 10 Read, 30 Update, 40 Insert, 50 Delete
PCFIL To_CondFil; // To condition filter structure int Degree; // Number of columns
static int Tnum; // Used to generate Tdb_no's }; // end of class TDB
const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN
PTDB Next; // Next in linearized queries /***********************************************************************/
PTABLE To_Table; // Points to the XTAB object /* This is the base class for all query tables (except decode). */
LPCSTR Name; // Table name /***********************************************************************/
PCOL Columns; // Points to the first column of the table class DllExport TDBASE : public TDB {
MODE Mode; // 10 Read, 30 Update, 40 Insert, 50 Delete friend class INDEXDEF;
int Degree; // Number of columns friend class XINDEX;
}; // end of class TDB friend class XINDXS;
public:
/***********************************************************************/ // Constructor
/* This is the base class for all query tables (except decode). */ TDBASE(PTABDEF tdp = NULL);
/***********************************************************************/ TDBASE(PTDBASE tdbp);
class DllExport TDBASE : public TDB {
friend class INDEXDEF; // Implementation
friend class XINDEX; inline int GetKnum(void) {return Knum;}
friend class XINDXS; inline PTABDEF GetDef(void) {return To_Def;}
public: inline PKXBASE GetKindex(void) {return To_Kindex;}
// Constructor inline PCOL GetSetCols(void) {return To_SetCols;}
TDBASE(PTABDEF tdp = NULL); inline void SetSetCols(PCOL colp) {To_SetCols = colp;}
TDBASE(PTDBASE tdbp);
// Properties
// Implementation void SetKindex(PKXBASE kxp);
inline int GetKnum(void) {return Knum;} PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;}
inline PTABDEF GetDef(void) {return To_Def;}
inline PKXBASE GetKindex(void) {return To_Kindex;} // Methods
inline PCOL GetSetCols(void) {return To_SetCols;} virtual bool IsUsingTemp(PGLOBAL g) {return false;}
inline void SetSetCols(PCOL colp) {To_SetCols = colp;} virtual PCATLG GetCat(void);
virtual PSZ GetPath(void);
// Properties virtual void PrintAM(FILE *f, char *m);
void SetKindex(PKXBASE kxp); virtual RECFM GetFtype(void) {return RECFM_NAF;}
PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;} virtual int GetAffectedRows(void) {return -1;}
virtual int GetRecpos(void) = 0;
// Methods virtual bool SetRecpos(PGLOBAL g, int recpos);
virtual bool IsUsingTemp(PGLOBAL g) {return false;} virtual bool IsReadOnly(void) {return Read_Only;}
virtual PCATLG GetCat(void); virtual bool IsView(void) {return FALSE;}
virtual PSZ GetPath(void); virtual CHARSET_INFO *data_charset(void);
virtual void PrintAM(FILE *f, char *m); virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);}
virtual RECFM GetFtype(void) {return RECFM_NAF;} virtual int GetProgCur(void) {return GetRecpos();}
virtual int GetAffectedRows(void) {return -1;} virtual PSZ GetFile(PGLOBAL g) {return "Not a file";}
virtual int GetRecpos(void) = 0; virtual int GetRemote(void) {return 0;}
virtual bool SetRecpos(PGLOBAL g, int recpos); virtual void SetFile(PGLOBAL g, PSZ fn) {}
virtual bool IsReadOnly(void) {return Read_Only;} virtual void ResetDB(void) {}
virtual bool IsView(void) {return FALSE;} virtual void ResetSize(void) {MaxSize = -1;}
virtual CHARSET_INFO *data_charset(void); virtual void RestoreNrec(void) {}
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox);
virtual int GetProgCur(void) {return GetRecpos();} virtual PSZ GetServer(void) {return "Current";}
virtual PSZ GetFile(PGLOBAL g) {return "Not a file";}
virtual int GetRemote(void) {return 0;} // Database routines
virtual void SetFile(PGLOBAL g, PSZ fn) {} virtual PCOL ColDB(PGLOBAL g, PSZ name, int num);
virtual void ResetDB(void) {} virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int)
virtual void ResetSize(void) {MaxSize = -1;} {assert(false); return NULL;}
virtual void RestoreNrec(void) {} virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp);
virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox); virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp);
virtual PSZ GetServer(void) {return "Current";} virtual void MarkDB(PGLOBAL g, PTDB tdb2);
// Database routines protected:
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); // Members
virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int) PTABDEF To_Def; // Points to catalog description block
{assert(false); return NULL;} PXOB *To_Link; // Points to column of previous relations
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); PCOL *To_Key_Col; // Points to key columns in current file
virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp); PKXBASE To_Kindex; // Points to table key index
virtual void MarkDB(PGLOBAL g, PTDB tdb2); PCOL To_SetCols; // Points to updated columns
int MaxSize; // Max size in number of lines
protected: int Knum; // Size of key arrays
// Members bool Read_Only; // True for read only tables
PTABDEF To_Def; // Points to catalog description block const CHARSET_INFO *m_data_charset;
PXOB *To_Link; // Points to column of previous relations }; // end of class TDBASE
PCOL *To_Key_Col; // Points to key columns in current file
PKXBASE To_Kindex; // Points to table key index /***********************************************************************/
PCOL To_SetCols; // Points to updated columns /* The abstract base class declaration for the catalog tables. */
int MaxSize; // Max size in number of lines /***********************************************************************/
int Knum; // Size of key arrays class DllExport TDBCAT : public TDBASE {
bool Read_Only; // True for read only tables friend class CATCOL;
const CHARSET_INFO *m_data_charset; public:
}; // end of class TDBASE // Constructor
TDBCAT(PTABDEF tdp);
/***********************************************************************/
/* The abstract base class declaration for the catalog tables. */ // Implementation
/***********************************************************************/ virtual AMT GetAmType(void) {return TYPE_AM_CAT;}
class DllExport TDBCAT : public TDBASE {
friend class CATCOL; // Methods
public: virtual int GetRecpos(void) {return N;}
// Constructor virtual int GetProgCur(void) {return N;}
TDBCAT(PTABDEF tdp); virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
virtual bool SetRecpos(PGLOBAL g, int recpos);
// Implementation
virtual AMT GetAmType(void) {return TYPE_AM_CAT;} // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
// Methods virtual int GetMaxSize(PGLOBAL g);
virtual int GetRecpos(void) {return N;} virtual bool OpenDB(PGLOBAL g);
virtual int GetProgCur(void) {return N;} virtual int ReadDB(PGLOBAL g);
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} virtual int WriteDB(PGLOBAL g);
virtual bool SetRecpos(PGLOBAL g, int recpos); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); protected:
virtual int GetMaxSize(PGLOBAL g); // Specific routines
virtual bool OpenDB(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g) = 0;
virtual int ReadDB(PGLOBAL g); bool Initialize(PGLOBAL g);
virtual int WriteDB(PGLOBAL g); bool InitCol(PGLOBAL g);
virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g); // Members
PQRYRES Qrp;
protected: int N; // Row number
// Specific routines bool Init;
virtual PQRYRES GetResult(PGLOBAL g) = 0; }; // end of class TDBCAT
bool Initialize(PGLOBAL g);
bool InitCol(PGLOBAL g); /***********************************************************************/
/* Class CATCOL: ODBC info column. */
// Members /***********************************************************************/
PQRYRES Qrp; class DllExport CATCOL : public COLBLK {
int N; // Row number friend class TDBCAT;
bool Init; public:
}; // end of class TDBCAT // Constructors
CATCOL(PCOLDEF cdp, PTDB tdbp, int n);
/***********************************************************************/
/* Class CATCOL: ODBC info column. */ // Implementation
/***********************************************************************/ virtual int GetAmType(void) {return TYPE_AM_ODBC;}
class DllExport CATCOL : public COLBLK {
friend class TDBCAT; // Methods
public: virtual void ReadColumn(PGLOBAL g);
// Constructors
CATCOL(PCOLDEF cdp, PTDB tdbp, int n); protected:
CATCOL(void) {} // Default constructor not to be used
// Implementation
virtual int GetAmType(void) {return TYPE_AM_ODBC;} // Members
PTDBCAT Tdbp; // Points to ODBC table block
// Methods PCOLRES Crp; // The column data array
virtual void ReadColumn(PGLOBAL g); int Flag;
}; // end of class CATCOL
protected:
CATCOL(void) {} // Default constructor not to be used #endif // TABLE_DEFINED
// Members
PTDBCAT Tdbp; // Points to ODBC table block
PCOLRES Crp; // The column data array
int Flag;
}; // end of class CATCOL
#endif // TABLE_DEFINED