Browse Source
- MRR + Block Indexing
- 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.hpull/22/head
60 changed files with 32618 additions and 33489 deletions
-
2storage/connect/array.h
-
244storage/connect/catalog.h
-
781storage/connect/colblk.cpp
-
426storage/connect/colblk.h
-
1798storage/connect/connect.cc
-
6storage/connect/connect.h
-
4storage/connect/domdoc.h
-
1479storage/connect/filamap.cpp
-
227storage/connect/filamap.h
-
11storage/connect/filamdbf.h
-
9storage/connect/filamfix.cpp
-
178storage/connect/filamfix.h
-
2904storage/connect/filamtxt.cpp
-
392storage/connect/filamtxt.h
-
8476storage/connect/filamvct.cpp
-
498storage/connect/filamvct.h
-
2829storage/connect/filamzip.cpp
-
340storage/connect/filamzip.h
-
6storage/connect/filter.cpp
-
22storage/connect/filter.h
-
518storage/connect/global.h
-
11421storage/connect/ha_connect.cc
-
1053storage/connect/ha_connect.h
-
6storage/connect/myconn.h
-
140storage/connect/plgcnx.h
-
1240storage/connect/plgdbsem.h
-
11storage/connect/plgdbutl.cpp
-
1102storage/connect/plugutil.c
-
27storage/connect/preparse.h
-
880storage/connect/reldef.cpp
-
456storage/connect/reldef.h
-
2storage/connect/tabcol.h
-
5289storage/connect/tabdos.cpp
-
539storage/connect/tabdos.h
-
15storage/connect/tabfix.cpp
-
2865storage/connect/tabfmt.cpp
-
380storage/connect/tabfmt.h
-
1182storage/connect/table.cpp
-
3240storage/connect/tabmysql.cpp
-
23storage/connect/tabmysql.h
-
1storage/connect/taboccur.h
-
1storage/connect/tabodbc.h
-
363storage/connect/tabsys.h
-
328storage/connect/tabtbl.h
-
3storage/connect/tabutil.h
-
4storage/connect/tabvct.cpp
-
244storage/connect/tabvct.h
-
301storage/connect/tabwmi.h
-
486storage/connect/tabxml.h
-
324storage/connect/user_connect.cc
-
3storage/connect/user_connect.h
-
8storage/connect/valblk.cpp
-
682storage/connect/valblk.h
-
4424storage/connect/value.cpp
-
687storage/connect/value.h
-
6056storage/connect/xindex.cpp
-
15storage/connect/xindex.h
-
374storage/connect/xobject.cpp
-
256storage/connect/xobject.h
-
526storage/connect/xtable.h
@ -1,122 +1,122 @@ |
|||
/*************** Catalog H Declares Source Code File (.H) **************/ |
|||
/* Name: CATALOG.H Version 3.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */ |
|||
/* */ |
|||
/* This file contains the CATALOG PlugDB classes definitions. */ |
|||
/***********************************************************************/ |
|||
#ifndef __CATALOG__H |
|||
#define __CATALOG__H |
|||
|
|||
#include "block.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the length of a buffer to contain entire table section. */ |
|||
/***********************************************************************/ |
|||
#define PLG_MAX_PATH 144 /* Must be the same across systems */ |
|||
#define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */ |
|||
|
|||
|
|||
//typedef class INDEXDEF *PIXDEF; |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the structure used to enumerate tables or views. */ |
|||
/***********************************************************************/ |
|||
typedef struct _curtab { |
|||
PRELDEF CurTdb; |
|||
char *Curp; |
|||
char *Tabpat; |
|||
bool Ispat; |
|||
bool NoView; |
|||
int Nt; |
|||
char *Type[16]; |
|||
} CURTAB, *PCURTAB; |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the structure used to get column catalog info. */ |
|||
/***********************************************************************/ |
|||
typedef struct _colinfo { |
|||
char *Name; |
|||
int Type; |
|||
int Offset; |
|||
int Length; |
|||
int Key; |
|||
int Precision; |
|||
int Scale; |
|||
int Opt; |
|||
int Freq; |
|||
char *Remark; |
|||
char *Datefmt; |
|||
char *Fieldfmt; |
|||
ushort Flags; // Used by MariaDB CONNECT handlers |
|||
} COLINFO, *PCOLINFO; |
|||
|
|||
/***********************************************************************/ |
|||
/* CATALOG: base class for catalog classes. */ |
|||
/***********************************************************************/ |
|||
class DllExport CATALOG { |
|||
friend class RELDEF; |
|||
friend class TABDEF; |
|||
friend class DIRDEF; |
|||
friend class OEMDEF; |
|||
public: |
|||
CATALOG(void); // Constructor |
|||
virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy |
|||
|
|||
// Implementation |
|||
int GetCblen(void) {return Cblen;} |
|||
bool GetDefHuge(void) {return DefHuge;} |
|||
void SetDefHuge(bool b) {DefHuge = b;} |
|||
char *GetCbuf(void) {return Cbuf;} |
|||
char *GetDataPath(void) {return (char*)DataPath;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} |
|||
virtual void SetDataPath(PGLOBAL g, const char *path) {} |
|||
virtual bool GetBoolCatInfo(PSZ what, bool bdef) {return bdef;} |
|||
virtual bool SetIntCatInfo(PSZ what, int ival) {return false;} |
|||
virtual int GetIntCatInfo(PSZ what, int idef) {return idef;} |
|||
virtual int GetSizeCatInfo(PSZ what, PSZ sdef) {return 0;} |
|||
virtual int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size) |
|||
{strncpy(buf, sdef, size); return size;} |
|||
virtual char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) |
|||
{return sdef;} |
|||
virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;} |
|||
virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;} |
|||
virtual bool CheckName(PGLOBAL g, char *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 GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;} |
|||
virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, |
|||
PRELDEF *prp = NULL) {return NULL;} |
|||
virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;} |
|||
virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;} |
|||
virtual bool TestCond(PGLOBAL g, const char *name, const char *type) |
|||
{return true;} |
|||
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;} |
|||
virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, |
|||
MODE mode = MODE_READ, LPCSTR type = NULL) |
|||
{return NULL;} |
|||
virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {} |
|||
virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer, |
|||
int maxbuf, int info[]) {} |
|||
virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer, |
|||
int maxbuf, int info[]) {} |
|||
virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname, |
|||
char *buffer, int maxbuf, int info[]) {return NULL;} |
|||
virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;} |
|||
virtual void ClearDB(PGLOBAL g) {} |
|||
|
|||
protected: |
|||
virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;} |
|||
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} |
|||
|
|||
// Members |
|||
char *Cbuf; /* Buffer used for col section */ |
|||
int Cblen; /* Length of suballoc. buffer */ |
|||
CURTAB Ctb; /* Used to enumerate tables */ |
|||
bool DefHuge; /* true: tables default to huge */ |
|||
LPCSTR DataPath; /* Is the Path of DB data dir */ |
|||
}; // end of class CATALOG |
|||
|
|||
#endif // __CATALOG__H |
|||
/*************** Catalog H Declares Source Code File (.H) **************/ |
|||
/* Name: CATALOG.H Version 3.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2000-2012 */ |
|||
/* */ |
|||
/* This file contains the CATALOG PlugDB classes definitions. */ |
|||
/***********************************************************************/ |
|||
#ifndef __CATALOG__H |
|||
#define __CATALOG__H |
|||
|
|||
#include "block.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the length of a buffer to contain entire table section. */ |
|||
/***********************************************************************/ |
|||
#define PLG_MAX_PATH 144 /* Must be the same across systems */ |
|||
#define PLG_BUFF_LEN 100 /* Number of lines in binary file buffer */ |
|||
|
|||
|
|||
//typedef class INDEXDEF *PIXDEF; |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the structure used to enumerate tables or views. */ |
|||
/***********************************************************************/ |
|||
typedef struct _curtab { |
|||
PRELDEF CurTdb; |
|||
char *Curp; |
|||
char *Tabpat; |
|||
bool Ispat; |
|||
bool NoView; |
|||
int Nt; |
|||
char *Type[16]; |
|||
} CURTAB, *PCURTAB; |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the structure used to get column catalog info. */ |
|||
/***********************************************************************/ |
|||
typedef struct _colinfo { |
|||
char *Name; |
|||
int Type; |
|||
int Offset; |
|||
int Length; |
|||
int Key; |
|||
int Precision; |
|||
int Scale; |
|||
int Opt; |
|||
int Freq; |
|||
char *Remark; |
|||
char *Datefmt; |
|||
char *Fieldfmt; |
|||
ushort Flags; // Used by MariaDB CONNECT handlers |
|||
} COLINFO, *PCOLINFO; |
|||
|
|||
/***********************************************************************/ |
|||
/* CATALOG: base class for catalog classes. */ |
|||
/***********************************************************************/ |
|||
class DllExport CATALOG { |
|||
friend class RELDEF; |
|||
friend class TABDEF; |
|||
friend class DIRDEF; |
|||
friend class OEMDEF; |
|||
public: |
|||
CATALOG(void); // Constructor |
|||
virtual ~CATALOG() { } // Make -Wdelete-non-virtual-dtor happy |
|||
|
|||
// Implementation |
|||
int GetCblen(void) {return Cblen;} |
|||
bool GetDefHuge(void) {return DefHuge;} |
|||
void SetDefHuge(bool b) {DefHuge = b;} |
|||
char *GetCbuf(void) {return Cbuf;} |
|||
char *GetDataPath(void) {return (char*)DataPath;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} |
|||
virtual void SetDataPath(PGLOBAL g, const char *path) {} |
|||
virtual bool GetBoolCatInfo(PSZ what, bool bdef) {return bdef;} |
|||
virtual bool SetIntCatInfo(PSZ what, int ival) {return false;} |
|||
virtual int GetIntCatInfo(PSZ what, int idef) {return idef;} |
|||
virtual int GetSizeCatInfo(PSZ what, PSZ sdef) {return 0;} |
|||
virtual int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size) |
|||
{strncpy(buf, sdef, size); return size;} |
|||
virtual char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef) |
|||
{return sdef;} |
|||
virtual int GetColCatInfo(PGLOBAL g, PTABDEF defp) {return -1;} |
|||
virtual bool GetIndexInfo(PGLOBAL g, PTABDEF defp) {return true;} |
|||
virtual bool CheckName(PGLOBAL g, char *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 GetTableDescEx(PGLOBAL g, PTABLE tablep) {return NULL;} |
|||
virtual PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name, LPCSTR type, |
|||
PRELDEF *prp = NULL) {return NULL;} |
|||
virtual PRELDEF GetFirstTable(PGLOBAL g) {return NULL;} |
|||
virtual PRELDEF GetNextTable(PGLOBAL g) {return NULL;} |
|||
virtual bool TestCond(PGLOBAL g, const char *name, const char *type) |
|||
{return true;} |
|||
virtual bool DropTable(PGLOBAL g, PSZ name, bool erase) {return true;} |
|||
virtual PTDB GetTable(PGLOBAL g, PTABLE tablep, |
|||
MODE mode = MODE_READ, LPCSTR type = NULL) |
|||
{return NULL;} |
|||
virtual void TableNames(PGLOBAL g, char *buffer, int maxbuf, int info[]) {} |
|||
virtual void ColumnNames(PGLOBAL g, char *tabname, char *buffer, |
|||
int maxbuf, int info[]) {} |
|||
virtual void ColumnDefs(PGLOBAL g, char *tabname, char *buffer, |
|||
int maxbuf, int info[]) {} |
|||
virtual void *DecodeValues(PGLOBAL g, char *tabname, char *colname, |
|||
char *buffer, int maxbuf, int info[]) {return NULL;} |
|||
virtual int ColumnType(PGLOBAL g, char *tabname, char *colname) {return 0;} |
|||
virtual void ClearDB(PGLOBAL g) {} |
|||
|
|||
protected: |
|||
virtual bool ClearSection(PGLOBAL g, const char *key, const char *section) {return true;} |
|||
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} |
|||
|
|||
// Members |
|||
char *Cbuf; /* Buffer used for col section */ |
|||
int Cblen; /* Length of suballoc. buffer */ |
|||
CURTAB Ctb; /* Used to enumerate tables */ |
|||
bool DefHuge; /* true: tables default to huge */ |
|||
LPCSTR DataPath; /* Is the Path of DB data dir */ |
|||
}; // end of class CATALOG |
|||
|
|||
#endif // __CATALOG__H |
|||
@ -1,399 +1,382 @@ |
|||
/************* Colblk C++ Functions Source Code File (.CPP) ************/ |
|||
/* Name: COLBLK.CPP Version 2.0 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1998-2013 */ |
|||
/* */ |
|||
/* This file contains the COLBLK class functions. */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include relevant MariaDB header file. */ |
|||
/***********************************************************************/ |
|||
#include "my_global.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* global.h is header containing all global Plug declarations. */ |
|||
/* plgdbsem.h is header containing the DB applic. declarations. */ |
|||
/***********************************************************************/ |
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "tabcol.h"
|
|||
#include "colblk.h"
|
|||
#include "xindex.h"
|
|||
#include "xtable.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* COLBLK protected constructor. */ |
|||
/***********************************************************************/ |
|||
COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i) |
|||
{ |
|||
Next = NULL; |
|||
Index = i; |
|||
//Number = 0;
|
|||
ColUse = 0; |
|||
|
|||
if ((Cdp = cdp)) { |
|||
Name = cdp->Name; |
|||
Format = cdp->F; |
|||
Opt = cdp->Opt; |
|||
Long = cdp->Long; |
|||
Precision = cdp->Precision; |
|||
Freq = cdp->Freq; |
|||
Buf_Type = cdp->Buf_Type; |
|||
ColUse |= cdp->Flags; // Used by CONNECT
|
|||
Nullable = !!(cdp->Flags & U_NULLS); |
|||
Unsigned = !!(cdp->Flags & U_UNSIGNED); |
|||
} else { |
|||
Name = NULL; |
|||
memset(&Format, 0, sizeof(FORMAT)); |
|||
Opt = 0; |
|||
Long = 0; |
|||
Precision = 0; |
|||
Freq = 0; |
|||
Buf_Type = TYPE_ERROR; |
|||
Nullable = false; |
|||
Unsigned = false; |
|||
} // endif cdp
|
|||
|
|||
To_Tdb = tdbp; |
|||
Status = BUF_NO; |
|||
//Value = NULL; done in XOBJECT constructor
|
|||
To_Kcol = NULL; |
|||
} // end of COLBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* COLBLK constructor used for copying columns. */ |
|||
/* tdbp is the pointer to the new table descriptor. */ |
|||
/***********************************************************************/ |
|||
COLBLK::COLBLK(PCOL col1, PTDB tdbp) |
|||
{ |
|||
PCOL colp; |
|||
|
|||
// Copy the old column block to the new one
|
|||
*this = *col1; |
|||
Next = NULL; |
|||
//To_Orig = col1;
|
|||
To_Tdb = tdbp; |
|||
|
|||
#ifdef DEBTRACE
|
|||
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); |
|||
#endif
|
|||
|
|||
if (tdbp) |
|||
// Attach the new column to the table block
|
|||
if (!tdbp->GetColumns()) |
|||
tdbp->SetColumns(this); |
|||
else { |
|||
for (colp = tdbp->GetColumns(); colp->Next; colp = colp->Next) ; |
|||
|
|||
colp->Next = this; |
|||
} // endelse
|
|||
|
|||
} // end of COLBLK copy constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* Reset the column descriptor to non evaluated yet. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::Reset(void) |
|||
{ |
|||
Status &= ~BUF_READ; |
|||
} // end of Reset
|
|||
|
|||
/***********************************************************************/ |
|||
/* Compare: compares itself to an (expression) object and returns */ |
|||
/* true if it is equivalent. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::Compare(PXOB xp) |
|||
{ |
|||
return (this == xp); |
|||
} // end of Compare
|
|||
|
|||
/***********************************************************************/ |
|||
/* SetFormat: function used to set SELECT output format. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) |
|||
{ |
|||
fmt = Format; |
|||
|
|||
#ifdef DEBTRACE
|
|||
htrc("COLBLK: %p format=%c(%d,%d)\n", |
|||
this, *fmt.Type, fmt.Length, fmt.Prec); |
|||
#endif
|
|||
|
|||
return false; |
|||
} // end of SetFormat
|
|||
|
|||
/***********************************************************************/ |
|||
/* CheckColumn: a column descriptor is found, say it by returning 1. */ |
|||
/***********************************************************************/ |
|||
int COLBLK::CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &p, int &ag) |
|||
{ |
|||
return 1; |
|||
} // end of CheckColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* Eval: get the column value from the last read record or from a */ |
|||
/* matching Index column if there is one. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::Eval(PGLOBAL g) |
|||
{ |
|||
#ifdef DEBTRACE
|
|||
htrc("Col Eval: %s status=%.4X\n", Name, Status); |
|||
#endif
|
|||
|
|||
if (!GetStatus(BUF_READ)) { |
|||
// if (To_Tdb->IsNull())
|
|||
// Value->Reset();
|
|||
if (To_Kcol) |
|||
To_Kcol->FillValue(Value); |
|||
else |
|||
ReadColumn(g); |
|||
|
|||
AddStatus(BUF_READ); |
|||
} // endif
|
|||
|
|||
return false; |
|||
} // end of Eval
|
|||
|
|||
/***********************************************************************/ |
|||
/* CheckSort: */ |
|||
/* Used to check that a table is involved in the sort list items. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::CheckSort(PTDB tdbp) |
|||
{ |
|||
return (tdbp == To_Tdb); |
|||
} // end of CheckSort
|
|||
|
|||
/***********************************************************************/ |
|||
/* InitValue: prepare a column block for read operation. */ |
|||
/* Now we use Format.Length for the len parameter to avoid strings */ |
|||
/* to be truncated when converting from string to coded string. */ |
|||
/* Added in version 1.5 is the arguments GetScale() and Domain */ |
|||
/* in calling AllocateValue. Domain is used for TYPE_DATE only. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::InitValue(PGLOBAL g) |
|||
{ |
|||
if (Value) |
|||
return false; // Already done
|
|||
|
|||
// Allocate a Value object
|
|||
if (!(Value = AllocateValue(g, Buf_Type, Precision, |
|||
GetScale(), Unsigned, GetDomain()))) |
|||
return true; |
|||
|
|||
AddStatus(BUF_READY); |
|||
Value->SetNullable(Nullable); |
|||
|
|||
#ifdef DEBTRACE
|
|||
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n", |
|||
this, Buf_Type, Value, ColUse, Status); |
|||
#endif
|
|||
|
|||
return false; |
|||
} // end of InitValue
|
|||
|
|||
/***********************************************************************/ |
|||
/* SetBuffer: prepare a column block for write operation. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) |
|||
{ |
|||
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer"); |
|||
return true; |
|||
} // end of SetBuffer
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetLength: returns an evaluation of the column string length. */ |
|||
/***********************************************************************/ |
|||
int COLBLK::GetLengthEx(void) |
|||
{ |
|||
return Long; |
|||
} // end of GetLengthEx
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to access the last line */ |
|||
/* read from the corresponding table, extract from it the field */ |
|||
/* corresponding to this column and convert it to buffer type. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); |
|||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); |
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* WriteColumn: what this routine does is to access the last line */ |
|||
/* read from the corresponding table, and rewrite the field */ |
|||
/* corresponding to this column from the column buffer and type. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::WriteColumn(PGLOBAL g) |
|||
{ |
|||
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); |
|||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); |
|||
} // end of WriteColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* Make file output of a column descriptor block. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::Print(PGLOBAL g, FILE *f, uint n) |
|||
{ |
|||
char m[64]; |
|||
int i; |
|||
PCOL colp; |
|||
|
|||
memset(m, ' ', n); // Make margin string
|
|||
m[n] = '\0'; |
|||
|
|||
for (colp = To_Tdb->GetColumns(), i = 1; colp; colp = colp->Next, i++) |
|||
if (colp == this) |
|||
break; |
|||
|
|||
fprintf(f, "%sR%dC%d type=%d F=%.2s(%d,%d)", m, To_Tdb->GetTdb_No(), |
|||
i, GetAmType(), Format.Type, Format.Length, Format.Prec); |
|||
fprintf(f, |
|||
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n", |
|||
ColUse, Status, Buf_Type, Value, Name); |
|||
} // end of Print
|
|||
|
|||
/***********************************************************************/ |
|||
/* Make string output of a column descriptor block. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::Print(PGLOBAL g, char *ps, uint z) |
|||
{ |
|||
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name); |
|||
} // end of Print
|
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* SPCBLK constructor. */ |
|||
/***********************************************************************/ |
|||
SPCBLK::SPCBLK(PCOLUMN cp) |
|||
: COLBLK((PCOLDEF)NULL, cp->GetTo_Table()->GetTo_Tdb(), 0) |
|||
{ |
|||
Name = (char*)cp->GetName(); |
|||
Precision = Long = 0; |
|||
Buf_Type = TYPE_ERROR; |
|||
} // end of SPCBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* WriteColumn: what this routine does is to access the last line */ |
|||
/* read from the corresponding table, and rewrite the field */ |
|||
/* corresponding to this column from the column buffer and type. */ |
|||
/***********************************************************************/ |
|||
void SPCBLK::WriteColumn(PGLOBAL g) |
|||
{ |
|||
sprintf(g->Message, MSG(SPCOL_READONLY), Name); |
|||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); |
|||
} // end of WriteColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* RIDBLK constructor for the ROWID special column. */ |
|||
/***********************************************************************/ |
|||
RIDBLK::RIDBLK(PCOLUMN cp, bool rnm) : SPCBLK(cp) |
|||
{ |
|||
Precision = Long = 10; |
|||
Buf_Type = TYPE_INT; |
|||
Rnm = rnm; |
|||
*Format.Type = 'N'; |
|||
Format.Length = 10; |
|||
} // end of RIDBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to return the ordinal */ |
|||
/* number of the current row in the table (if Rnm is true) or in the */ |
|||
/* current file (if Rnm is false) the same except for multiple tables.*/ |
|||
/***********************************************************************/ |
|||
void RIDBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
Value->SetValue(To_Tdb->RowNumber(g, Rnm)); |
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* FIDBLK constructor for the FILEID special column. */ |
|||
/***********************************************************************/ |
|||
FIDBLK::FIDBLK(PCOLUMN cp) : SPCBLK(cp) |
|||
{ |
|||
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
|
|||
Precision = Long = _MAX_PATH; |
|||
Buf_Type = TYPE_STRING; |
|||
*Format.Type = 'C'; |
|||
Format.Length = Long; |
|||
#if defined(WIN32)
|
|||
Format.Prec = 1; // Case insensitive
|
|||
#endif // WIN32
|
|||
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() && |
|||
To_Tdb->GetAmType() != TYPE_AM_PLG && |
|||
To_Tdb->GetAmType() != TYPE_AM_PLM); |
|||
Fn = NULL; |
|||
} // end of FIDBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to return the current */ |
|||
/* file ID of the table (can change for Multiple tables). */ |
|||
/***********************************************************************/ |
|||
void FIDBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) { |
|||
char filename[_MAX_PATH]; |
|||
|
|||
Fn = ((PTDBASE)To_Tdb)->GetFile(g); |
|||
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath()); |
|||
Value->SetValue_psz(filename); |
|||
} // endif Fn
|
|||
|
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* TIDBLK constructor for the TABID special column. */ |
|||
/***********************************************************************/ |
|||
TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp) |
|||
{ |
|||
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
|
|||
Precision = Long = 64; |
|||
Buf_Type = TYPE_STRING; |
|||
*Format.Type = 'C'; |
|||
Format.Length = Long; |
|||
Format.Prec = 1; // Case insensitive
|
|||
Constant = (To_Tdb->GetAmType() != TYPE_AM_TBL); |
|||
Tname = NULL; |
|||
} // end of TIDBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to return the table ID. */ |
|||
/***********************************************************************/ |
|||
void TIDBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
if (Tname == NULL) { |
|||
Tname = (char*)To_Tdb->GetName(); |
|||
Value->SetValue_psz(Tname); |
|||
} // endif Tname
|
|||
|
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* SIDBLK constructor for the SERVID special column. */ |
|||
/***********************************************************************/ |
|||
SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp) |
|||
{ |
|||
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
|
|||
Precision = Long = 64; |
|||
Buf_Type = TYPE_STRING; |
|||
*Format.Type = 'C'; |
|||
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
|
|||
|
|||
/************* Colblk C++ Functions Source Code File (.CPP) ************/ |
|||
/* Name: COLBLK.CPP Version 2.1 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ |
|||
/* */ |
|||
/* This file contains the COLBLK class functions. */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include relevant MariaDB header file. */ |
|||
/***********************************************************************/ |
|||
#include "my_global.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* global.h is header containing all global Plug declarations. */ |
|||
/* plgdbsem.h is header containing the DB applic. declarations. */ |
|||
/***********************************************************************/ |
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "tabcol.h"
|
|||
#include "colblk.h"
|
|||
#include "xindex.h"
|
|||
#include "xtable.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* COLBLK protected constructor. */ |
|||
/***********************************************************************/ |
|||
COLBLK::COLBLK(PCOLDEF cdp, PTDB tdbp, int i) |
|||
{ |
|||
Next = NULL; |
|||
Index = i; |
|||
//Number = 0;
|
|||
ColUse = 0; |
|||
|
|||
if ((Cdp = cdp)) { |
|||
Name = cdp->Name; |
|||
Format = cdp->F; |
|||
Opt = cdp->Opt; |
|||
Long = cdp->Long; |
|||
Precision = cdp->Precision; |
|||
Freq = cdp->Freq; |
|||
Buf_Type = cdp->Buf_Type; |
|||
ColUse |= cdp->Flags; // Used by CONNECT
|
|||
Nullable = !!(cdp->Flags & U_NULLS); |
|||
Unsigned = !!(cdp->Flags & U_UNSIGNED); |
|||
} else { |
|||
Name = NULL; |
|||
memset(&Format, 0, sizeof(FORMAT)); |
|||
Opt = 0; |
|||
Long = 0; |
|||
Precision = 0; |
|||
Freq = 0; |
|||
Buf_Type = TYPE_ERROR; |
|||
Nullable = false; |
|||
Unsigned = false; |
|||
} // endif cdp
|
|||
|
|||
To_Tdb = tdbp; |
|||
Status = BUF_NO; |
|||
//Value = NULL; done in XOBJECT constructor
|
|||
To_Kcol = NULL; |
|||
} // end of COLBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* COLBLK constructor used for copying columns. */ |
|||
/* tdbp is the pointer to the new table descriptor. */ |
|||
/***********************************************************************/ |
|||
COLBLK::COLBLK(PCOL col1, PTDB tdbp) |
|||
{ |
|||
PCOL colp; |
|||
|
|||
// Copy the old column block to the new one
|
|||
*this = *col1; |
|||
Next = NULL; |
|||
//To_Orig = col1;
|
|||
To_Tdb = tdbp; |
|||
|
|||
#ifdef DEBTRACE
|
|||
htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); |
|||
#endif
|
|||
|
|||
if (tdbp) |
|||
// Attach the new column to the table block
|
|||
if (!tdbp->GetColumns()) |
|||
tdbp->SetColumns(this); |
|||
else { |
|||
for (colp = tdbp->GetColumns(); colp->Next; colp = colp->Next) ; |
|||
|
|||
colp->Next = this; |
|||
} // endelse
|
|||
|
|||
} // end of COLBLK copy constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* Reset the column descriptor to non evaluated yet. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::Reset(void) |
|||
{ |
|||
Status &= ~BUF_READ; |
|||
} // end of Reset
|
|||
|
|||
/***********************************************************************/ |
|||
/* Compare: compares itself to an (expression) object and returns */ |
|||
/* true if it is equivalent. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::Compare(PXOB xp) |
|||
{ |
|||
return (this == xp); |
|||
} // end of Compare
|
|||
|
|||
/***********************************************************************/ |
|||
/* SetFormat: function used to set SELECT output format. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::SetFormat(PGLOBAL g, FORMAT& fmt) |
|||
{ |
|||
fmt = Format; |
|||
|
|||
#ifdef DEBTRACE
|
|||
htrc("COLBLK: %p format=%c(%d,%d)\n", |
|||
this, *fmt.Type, fmt.Length, fmt.Prec); |
|||
#endif
|
|||
|
|||
return false; |
|||
} // end of SetFormat
|
|||
|
|||
/***********************************************************************/ |
|||
/* Eval: get the column value from the last read record or from a */ |
|||
/* matching Index column if there is one. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::Eval(PGLOBAL g) |
|||
{ |
|||
#ifdef DEBTRACE
|
|||
htrc("Col Eval: %s status=%.4X\n", Name, Status); |
|||
#endif
|
|||
|
|||
if (!GetStatus(BUF_READ)) { |
|||
// if (To_Tdb->IsNull())
|
|||
// Value->Reset();
|
|||
if (To_Kcol) |
|||
To_Kcol->FillValue(Value); |
|||
else |
|||
ReadColumn(g); |
|||
|
|||
AddStatus(BUF_READ); |
|||
} // endif
|
|||
|
|||
return false; |
|||
} // end of Eval
|
|||
|
|||
/***********************************************************************/ |
|||
/* InitValue: prepare a column block for read operation. */ |
|||
/* Now we use Format.Length for the len parameter to avoid strings */ |
|||
/* to be truncated when converting from string to coded string. */ |
|||
/* Added in version 1.5 is the arguments GetScale() and Domain */ |
|||
/* in calling AllocateValue. Domain is used for TYPE_DATE only. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::InitValue(PGLOBAL g) |
|||
{ |
|||
if (Value) |
|||
return false; // Already done
|
|||
|
|||
// Allocate a Value object
|
|||
if (!(Value = AllocateValue(g, Buf_Type, Precision, |
|||
GetScale(), Unsigned, GetDomain()))) |
|||
return true; |
|||
|
|||
AddStatus(BUF_READY); |
|||
Value->SetNullable(Nullable); |
|||
|
|||
#ifdef DEBTRACE
|
|||
htrc(" colp=%p type=%d value=%p coluse=%.4X status=%.4X\n", |
|||
this, Buf_Type, Value, ColUse, Status); |
|||
#endif
|
|||
|
|||
return false; |
|||
} // end of InitValue
|
|||
|
|||
/***********************************************************************/ |
|||
/* SetBuffer: prepare a column block for write operation. */ |
|||
/***********************************************************************/ |
|||
bool COLBLK::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) |
|||
{ |
|||
sprintf(g->Message, MSG(UNDEFINED_AM), "SetBuffer"); |
|||
return true; |
|||
} // end of SetBuffer
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetLength: returns an evaluation of the column string length. */ |
|||
/***********************************************************************/ |
|||
int COLBLK::GetLengthEx(void) |
|||
{ |
|||
return Long; |
|||
} // end of GetLengthEx
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to access the last line */ |
|||
/* read from the corresponding table, extract from it the field */ |
|||
/* corresponding to this column and convert it to buffer type. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn"); |
|||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); |
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* WriteColumn: what this routine does is to access the last line */ |
|||
/* read from the corresponding table, and rewrite the field */ |
|||
/* corresponding to this column from the column buffer and type. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::WriteColumn(PGLOBAL g) |
|||
{ |
|||
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn"); |
|||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); |
|||
} // end of WriteColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* Make file output of a column descriptor block. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::Print(PGLOBAL g, FILE *f, uint n) |
|||
{ |
|||
char m[64]; |
|||
int i; |
|||
PCOL colp; |
|||
|
|||
memset(m, ' ', n); // Make margin string
|
|||
m[n] = '\0'; |
|||
|
|||
for (colp = To_Tdb->GetColumns(), i = 1; colp; colp = colp->Next, i++) |
|||
if (colp == this) |
|||
break; |
|||
|
|||
fprintf(f, "%sR%dC%d type=%d F=%.2s(%d,%d)", m, To_Tdb->GetTdb_No(), |
|||
i, GetAmType(), Format.Type, Format.Length, Format.Prec); |
|||
fprintf(f, |
|||
" coluse=%04X status=%04X buftyp=%d value=%p name=%s\n", |
|||
ColUse, Status, Buf_Type, Value, Name); |
|||
} // end of Print
|
|||
|
|||
/***********************************************************************/ |
|||
/* Make string output of a column descriptor block. */ |
|||
/***********************************************************************/ |
|||
void COLBLK::Print(PGLOBAL g, char *ps, uint z) |
|||
{ |
|||
sprintf(ps, "R%d.%s", To_Tdb->GetTdb_No(), Name); |
|||
} // end of Print
|
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* SPCBLK constructor. */ |
|||
/***********************************************************************/ |
|||
SPCBLK::SPCBLK(PCOLUMN cp) |
|||
: COLBLK((PCOLDEF)NULL, cp->GetTo_Table()->GetTo_Tdb(), 0) |
|||
{ |
|||
Name = (char*)cp->GetName(); |
|||
Precision = Long = 0; |
|||
Buf_Type = TYPE_ERROR; |
|||
} // end of SPCBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* WriteColumn: what this routine does is to access the last line */ |
|||
/* read from the corresponding table, and rewrite the field */ |
|||
/* corresponding to this column from the column buffer and type. */ |
|||
/***********************************************************************/ |
|||
void SPCBLK::WriteColumn(PGLOBAL g) |
|||
{ |
|||
sprintf(g->Message, MSG(SPCOL_READONLY), Name); |
|||
longjmp(g->jumper[g->jump_level], TYPE_COLBLK); |
|||
} // end of WriteColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* RIDBLK constructor for the ROWID special column. */ |
|||
/***********************************************************************/ |
|||
RIDBLK::RIDBLK(PCOLUMN cp, bool rnm) : SPCBLK(cp) |
|||
{ |
|||
Precision = Long = 10; |
|||
Buf_Type = TYPE_INT; |
|||
Rnm = rnm; |
|||
*Format.Type = 'N'; |
|||
Format.Length = 10; |
|||
} // end of RIDBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to return the ordinal */ |
|||
/* number of the current row in the table (if Rnm is true) or in the */ |
|||
/* current file (if Rnm is false) the same except for multiple tables.*/ |
|||
/***********************************************************************/ |
|||
void RIDBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
Value->SetValue(To_Tdb->RowNumber(g, Rnm)); |
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* FIDBLK constructor for the FILEID special column. */ |
|||
/***********************************************************************/ |
|||
FIDBLK::FIDBLK(PCOLUMN cp) : SPCBLK(cp) |
|||
{ |
|||
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
|
|||
Precision = Long = _MAX_PATH; |
|||
Buf_Type = TYPE_STRING; |
|||
*Format.Type = 'C'; |
|||
Format.Length = Long; |
|||
#if defined(WIN32)
|
|||
Format.Prec = 1; // Case insensitive
|
|||
#endif // WIN32
|
|||
Constant = (!((PTDBASE)To_Tdb)->GetDef()->GetMultiple() && |
|||
To_Tdb->GetAmType() != TYPE_AM_PLG && |
|||
To_Tdb->GetAmType() != TYPE_AM_PLM); |
|||
Fn = NULL; |
|||
} // end of FIDBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to return the current */ |
|||
/* file ID of the table (can change for Multiple tables). */ |
|||
/***********************************************************************/ |
|||
void FIDBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
if (Fn != ((PTDBASE)To_Tdb)->GetFile(g)) { |
|||
char filename[_MAX_PATH]; |
|||
|
|||
Fn = ((PTDBASE)To_Tdb)->GetFile(g); |
|||
PlugSetPath(filename, Fn, ((PTDBASE)To_Tdb)->GetPath()); |
|||
Value->SetValue_psz(filename); |
|||
} // endif Fn
|
|||
|
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* TIDBLK constructor for the TABID special column. */ |
|||
/***********************************************************************/ |
|||
TIDBLK::TIDBLK(PCOLUMN cp) : SPCBLK(cp) |
|||
{ |
|||
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
|
|||
Precision = Long = 64; |
|||
Buf_Type = TYPE_STRING; |
|||
*Format.Type = 'C'; |
|||
Format.Length = Long; |
|||
Format.Prec = 1; // Case insensitive
|
|||
Constant = (To_Tdb->GetAmType() != TYPE_AM_TBL); |
|||
Tname = NULL; |
|||
} // end of TIDBLK constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* ReadColumn: what this routine does is to return the table ID. */ |
|||
/***********************************************************************/ |
|||
void TIDBLK::ReadColumn(PGLOBAL g) |
|||
{ |
|||
if (Tname == NULL) { |
|||
Tname = (char*)To_Tdb->GetName(); |
|||
Value->SetValue_psz(Tname); |
|||
} // endif Tname
|
|||
|
|||
} // end of ReadColumn
|
|||
|
|||
/***********************************************************************/ |
|||
/* SIDBLK constructor for the SERVID special column. */ |
|||
/***********************************************************************/ |
|||
SIDBLK::SIDBLK(PCOLUMN cp) : SPCBLK(cp) |
|||
{ |
|||
//Is_Key = 2; for when the MUL table indexed reading will be implemented.
|
|||
Precision = Long = 64; |
|||
Buf_Type = TYPE_STRING; |
|||
*Format.Type = 'C'; |
|||
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
|
|||
|
|||
@ -1,221 +1,205 @@ |
|||
/*************** Colblk H Declares Source Code File (.H) ***************/ |
|||
/* Name: COLBLK.H Version 1.7 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ |
|||
/* */ |
|||
/* This file contains the COLBLK and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __COLBLK__H |
|||
#define __COLBLK__H |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/***********************************************************************/ |
|||
#include "xobject.h" |
|||
#include "reldef.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Class COLBLK: Base class for table column descriptors. */ |
|||
/***********************************************************************/ |
|||
class DllExport COLBLK : public XOBJECT { |
|||
friend class TDBPIVOT; |
|||
protected: |
|||
// Default constructors used by derived classes |
|||
COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0); |
|||
COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process |
|||
COLBLK(int n) {} // Used when changing a column class in TDBXML |
|||
|
|||
public: |
|||
// Implementation |
|||
virtual int GetType(void) {return TYPE_COLBLK;} |
|||
virtual int GetResultType(void) {return Buf_Type;} |
|||
virtual int GetScale(void) {return Format.Prec;} |
|||
virtual int GetPrecision(void) {return Precision;} |
|||
virtual int GetLength(void) {return Long;} |
|||
virtual int GetLengthEx(void); |
|||
virtual int GetAmType() {return TYPE_AM_ERROR;} |
|||
virtual void SetOk(void) {Status |= BUF_EMPTY;} |
|||
virtual PTDB GetTo_Tdb(void) {return To_Tdb;} |
|||
#if defined(BLK_INDX) |
|||
virtual int GetClustered(void) {return 0;} |
|||
virtual int IsClustered(void) {return FALSE;} |
|||
#endif // BLK_INDX |
|||
PCOL GetNext(void) {return Next;} |
|||
PSZ GetName(void) {return Name;} |
|||
int GetIndex(void) {return Index;} |
|||
int GetOpt(void) {return Opt;} |
|||
ushort GetColUse(void) {return ColUse;} |
|||
ushort GetColUse(ushort u) {return (ColUse & u);} |
|||
ushort GetStatus(void) {return Status;} |
|||
ushort GetStatus(ushort u) {return (Status & u);} |
|||
void SetColUse(ushort u) {ColUse = u;} |
|||
void SetStatus(ushort u) {Status = u;} |
|||
void AddColUse(ushort u) {ColUse |= u;} |
|||
void AddStatus(ushort u) {Status |= u;} |
|||
void SetNext(PCOL cp) {Next = cp;} |
|||
#if defined(MRRBKA_SUPPORT) |
|||
PXCOL GetKcol(void) {return To_Kcol;} |
|||
#endif // MRRBKA_SUPPORT |
|||
void SetKcol(PXCOL kcp) {To_Kcol = kcp;} |
|||
PCOLDEF GetCdp(void) {return Cdp;} |
|||
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;} |
|||
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;} |
|||
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;} |
|||
bool IsUnsigned(void) {return Unsigned;} |
|||
bool IsNullable(void) {return Nullable;} |
|||
void SetNullable(bool b) {Nullable = b;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual bool Compare(PXOB xp); |
|||
virtual bool SetFormat(PGLOBAL, FORMAT&); |
|||
virtual int CheckColumn(PGLOBAL g, PSQL sqlp, PXOB &xp, int &ag); |
|||
virtual bool IsSpecial(void) {return false;} |
|||
virtual int CheckSpcCol(PTDB tdbp, int n) {return 2;} |
|||
virtual bool CheckSort(PTDB tdbp); |
|||
virtual bool Eval(PGLOBAL g); |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void SetTo_Val(PVAL valp) {} |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual void Print(PGLOBAL g, FILE *, uint); |
|||
virtual void Print(PGLOBAL g, char *, uint); |
|||
#if defined(BLK_INDX) |
|||
virtual bool VarSize(void) {return false;} |
|||
#endif // BLK_INDX |
|||
virtual bool IsColInside(PCOL colp) {return this == colp;} |
|||
bool InitValue(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
PCOL Next; // Next column in table |
|||
PSZ Name; // Column name |
|||
PCOLDEF Cdp; // To column definition block |
|||
PTDB To_Tdb; // Points to Table Descriptor Block |
|||
PXCOL To_Kcol; // Points to Xindex matching column |
|||
bool Nullable; // True if nullable |
|||
bool Unsigned; // True if unsigned |
|||
int Index; // Column number in table |
|||
int Opt; // Cluster/sort information |
|||
int Buf_Type; // Data type |
|||
int Long; // Internal length in table |
|||
int Precision; // Column length (as for ODBC) |
|||
int Freq; // Evaluated ceiling of distinct values |
|||
FORMAT Format; // Output format |
|||
ushort ColUse; // Column usage |
|||
ushort Status; // Column read status |
|||
}; // end of class COLBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class SPCBLK: Base class for special column descriptors. */ |
|||
/***********************************************************************/ |
|||
class DllExport SPCBLK : public COLBLK { |
|||
public: |
|||
// Constructor |
|||
SPCBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) = 0; |
|||
virtual bool GetRnm(void) {return false;} |
|||
|
|||
// Methods |
|||
virtual bool IsSpecial(void) {return true;} |
|||
virtual void ReadColumn(PGLOBAL g) = 0; |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
SPCBLK(void) : COLBLK(1) {} |
|||
}; // end of class SPCBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class RIDBLK: ROWID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport RIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
RIDBLK(PCOLUMN cp, bool rnm); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_ROWID;} |
|||
virtual bool GetRnm(void) {return Rnm;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
bool Rnm; // False for RowID, True for RowNum |
|||
}; // end of class RIDBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class FIDBLK: FILEID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport FIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
FIDBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_FILID;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} // This is a pseudo constant column |
|||
virtual int CheckSpcCol(PTDB tdbp, int n) |
|||
{return (n == 2 && tdbp == To_Tdb) ? 1 : 2;} |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
PSZ Fn; // The current To_File of the table |
|||
}; // end of class FIDBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TIDBLK: TABID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport TIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
TIDBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_TABID;} |
|||
|
|||
// 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 |
|||
TIDBLK(void) {} |
|||
|
|||
// Members |
|||
PSZ Tname; // The current table name |
|||
}; // end of class TIDBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class SIDBLK: SERVID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport SIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
SIDBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_SRVID;} |
|||
|
|||
// 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 |
|||
/*************** Colblk H Declares Source Code File (.H) ***************/ |
|||
/* Name: COLBLK.H Version 1.7 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ |
|||
/* */ |
|||
/* This file contains the COLBLK and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __COLBLK__H |
|||
#define __COLBLK__H |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/***********************************************************************/ |
|||
#include "xobject.h" |
|||
#include "reldef.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Class COLBLK: Base class for table column descriptors. */ |
|||
/***********************************************************************/ |
|||
class DllExport COLBLK : public XOBJECT { |
|||
friend class TDBPIVOT; |
|||
protected: |
|||
// Default constructors used by derived classes |
|||
COLBLK(PCOLDEF cdp = NULL, PTDB tdbp = NULL, int i = 0); |
|||
COLBLK(PCOL colp, PTDB tdbp = NULL); // Used in copy process |
|||
COLBLK(int n) {} // Used when changing a column class in TDBXML |
|||
|
|||
public: |
|||
// Implementation |
|||
virtual int GetType(void) {return TYPE_COLBLK;} |
|||
virtual int GetResultType(void) {return Buf_Type;} |
|||
virtual int GetScale(void) {return Format.Prec;} |
|||
virtual int GetPrecision(void) {return Precision;} |
|||
virtual int GetLength(void) {return Long;} |
|||
virtual int GetLengthEx(void); |
|||
virtual int GetAmType() {return TYPE_AM_ERROR;} |
|||
virtual void SetOk(void) {Status |= BUF_EMPTY;} |
|||
virtual PTDB GetTo_Tdb(void) {return To_Tdb;} |
|||
virtual int GetClustered(void) {return 0;} |
|||
virtual int IsClustered(void) {return FALSE;} |
|||
PCOL GetNext(void) {return Next;} |
|||
PSZ GetName(void) {return Name;} |
|||
int GetIndex(void) {return Index;} |
|||
ushort GetColUse(void) {return ColUse;} |
|||
int GetOpt(void) {return Opt;} |
|||
ushort GetColUse(ushort u) {return (ColUse & u);} |
|||
ushort GetStatus(void) {return Status;} |
|||
ushort GetStatus(ushort u) {return (Status & u);} |
|||
void SetColUse(ushort u) {ColUse = u;} |
|||
void SetStatus(ushort u) {Status = u;} |
|||
void AddColUse(ushort u) {ColUse |= u;} |
|||
void AddStatus(ushort u) {Status |= u;} |
|||
void SetNext(PCOL cp) {Next = cp;} |
|||
PXCOL GetKcol(void) {return To_Kcol;} |
|||
void SetKcol(PXCOL kcp) {To_Kcol = kcp;} |
|||
PCOLDEF GetCdp(void) {return Cdp;} |
|||
PSZ GetDomain(void) {return (Cdp) ? Cdp->Decode : NULL;} |
|||
PSZ GetDesc(void) {return (Cdp) ? Cdp->Desc : NULL;} |
|||
PSZ GetFmt(void) {return (Cdp) ? Cdp->Fmt : NULL;} |
|||
bool IsUnsigned(void) {return Unsigned;} |
|||
bool IsNullable(void) {return Nullable;} |
|||
void SetNullable(bool b) {Nullable = b;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual bool Compare(PXOB xp); |
|||
virtual bool SetFormat(PGLOBAL, FORMAT&); |
|||
virtual bool IsSpecial(void) {return false;} |
|||
virtual bool Eval(PGLOBAL g); |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void SetTo_Val(PVAL valp) {} |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual void Print(PGLOBAL g, FILE *, uint); |
|||
virtual void Print(PGLOBAL g, char *, uint); |
|||
virtual bool VarSize(void) {return false;} |
|||
bool InitValue(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
PCOL Next; // Next column in table |
|||
PSZ Name; // Column name |
|||
PCOLDEF Cdp; // To column definition block |
|||
PTDB To_Tdb; // Points to Table Descriptor Block |
|||
PXCOL To_Kcol; // Points to Xindex matching column |
|||
bool Nullable; // True if nullable |
|||
bool Unsigned; // True if unsigned |
|||
int Index; // Column number in table |
|||
int Opt; // Cluster/sort information |
|||
int Buf_Type; // Data type |
|||
int Long; // Internal length in table |
|||
int Precision; // Column length (as for ODBC) |
|||
int Freq; // Evaluated ceiling of distinct values |
|||
FORMAT Format; // Output format |
|||
ushort ColUse; // Column usage |
|||
ushort Status; // Column read status |
|||
}; // end of class COLBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class SPCBLK: Base class for special column descriptors. */ |
|||
/***********************************************************************/ |
|||
class DllExport SPCBLK : public COLBLK { |
|||
public: |
|||
// Constructor |
|||
SPCBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) = 0; |
|||
virtual bool GetRnm(void) {return false;} |
|||
|
|||
// Methods |
|||
virtual bool IsSpecial(void) {return true;} |
|||
virtual void ReadColumn(PGLOBAL g) = 0; |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
SPCBLK(void) : COLBLK(1) {} |
|||
}; // end of class SPCBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class RIDBLK: ROWID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport RIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
RIDBLK(PCOLUMN cp, bool rnm); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_ROWID;} |
|||
virtual bool GetRnm(void) {return Rnm;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
bool Rnm; // False for RowID, True for RowNum |
|||
}; // end of class RIDBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class FIDBLK: FILEID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport FIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
FIDBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_FILID;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} // This is a pseudo constant column |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
PSZ Fn; // The current To_File of the table |
|||
}; // end of class FIDBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TIDBLK: TABID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport TIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
TIDBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_TABID;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} // This is a pseudo constant column |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
TIDBLK(void) {} |
|||
|
|||
// Members |
|||
PSZ Tname; // The current table name |
|||
}; // end of class TIDBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class SIDBLK: SERVID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class DllExport SIDBLK : public SPCBLK { |
|||
public: |
|||
// Constructor |
|||
SIDBLK(PCOLUMN cp); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_SRVID;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} // This is a pseudo constant column |
|||
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 |
|||
1798
storage/connect/connect.cc
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1479
storage/connect/filamap.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,114 +1,113 @@ |
|||
/*************** FilAMap H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMAP.H Version 1.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ |
|||
/* */ |
|||
/* This file contains the MAP file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __FILAMAP_H |
|||
#define __FILAMAP_H |
|||
|
|||
#include "block.h" |
|||
#include "filamtxt.h" |
|||
|
|||
typedef class MAPFAM *PMAPFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the variable file access method using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport MAPFAM : public TXTFAM { |
|||
public: |
|||
// Constructor |
|||
MAPFAM(PDOSDEF tdp); |
|||
MAPFAM(PMAPFAM tmfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_MAP;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) MAPFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual bool DeferReading(void) {return false;} |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Memory; // Pointer on file mapping view. |
|||
char *Mempos; // Position of next data to read |
|||
char *Fpos; // Position of last read record |
|||
char *Tpos; // Target Position for delete move |
|||
char *Spos; // Start position for delete move |
|||
char *Top; // Mark end of file mapping view |
|||
}; // end of class MAPFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the blocked file access method using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport MBKFAM : public MAPFAM { |
|||
public: |
|||
// Constructor |
|||
MBKFAM(PDOSDEF tdp); |
|||
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {} |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) MBKFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) |
|||
{return TXTFAM::MaxBlkSize(g, s);} |
|||
virtual int GetRowID(void); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// No additional members |
|||
}; // end of class MBKFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the fixed file access method using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport MPXFAM : public MBKFAM { |
|||
public: |
|||
// Constructor |
|||
MPXFAM(PDOSDEF tdp); |
|||
MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {} |
|||
|
|||
// Implementation |
|||
virtual int GetPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) MPXFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) |
|||
{return TXTFAM::MaxBlkSize(g, s);} |
|||
//virtual int GetRowID(void); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual bool DeferReading(void) {return false;} |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
|
|||
protected: |
|||
// No additional members |
|||
}; // end of class MPXFAM |
|||
|
|||
#endif // __FILAMAP_H |
|||
/*************** FilAMap H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMAP.H Version 1.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ |
|||
/* */ |
|||
/* This file contains the MAP file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __FILAMAP_H |
|||
#define __FILAMAP_H |
|||
|
|||
#include "block.h" |
|||
#include "filamtxt.h" |
|||
|
|||
typedef class MAPFAM *PMAPFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the variable file access method using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport MAPFAM : public TXTFAM { |
|||
public: |
|||
// Constructor |
|||
MAPFAM(PDOSDEF tdp); |
|||
MAPFAM(PMAPFAM tmfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_MAP;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) MAPFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual bool DeferReading(void) {return false;} |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Memory; // Pointer on file mapping view. |
|||
char *Mempos; // Position of next data to read |
|||
char *Fpos; // Position of last read record |
|||
char *Tpos; // Target Position for delete move |
|||
char *Spos; // Start position for delete move |
|||
char *Top; // Mark end of file mapping view |
|||
}; // end of class MAPFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the blocked file access method using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport MBKFAM : public MAPFAM { |
|||
public: |
|||
// Constructor |
|||
MBKFAM(PDOSDEF tdp); |
|||
MBKFAM(PMAPFAM tmfp) : MAPFAM(tmfp) {} |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) MBKFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) |
|||
{return TXTFAM::MaxBlkSize(g, s);} |
|||
virtual int GetRowID(void); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// No additional members |
|||
}; // end of class MBKFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the fixed file access method using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport MPXFAM : public MBKFAM { |
|||
public: |
|||
// Constructor |
|||
MPXFAM(PDOSDEF tdp); |
|||
MPXFAM(PMAPFAM tmfp) : MBKFAM(tmfp) {} |
|||
|
|||
// Implementation |
|||
virtual int GetPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) MPXFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) |
|||
{return TXTFAM::MaxBlkSize(g, s);} |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual bool DeferReading(void) {return false;} |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
|
|||
protected: |
|||
// No additional members |
|||
}; // end of class MPXFAM |
|||
|
|||
#endif // __FILAMAP_H |
|||
@ -1,90 +1,88 @@ |
|||
/************** FilAMFix H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMFIX.H Version 1.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005 - 2012 */ |
|||
/* */ |
|||
/* This file contains the FIX file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __FILAMFIX_H |
|||
#define __FILAMFIX_H |
|||
|
|||
#include "filamtxt.h" |
|||
|
|||
typedef class FIXFAM *PFIXFAM; |
|||
typedef class BGXFAM *PBGXFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for standard */ |
|||
/* files with fixed record format (FIX, BIN) */ |
|||
/***********************************************************************/ |
|||
class DllExport FIXFAM : public BLKFAM { |
|||
public: |
|||
// Constructor |
|||
FIXFAM(PDOSDEF tdp); |
|||
FIXFAM(PFIXFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_FIX;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) FIXFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) |
|||
{return TXTFAM::MaxBlkSize(g, s);} |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual void ResetBuffer(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
protected: |
|||
virtual bool CopyHeader(PGLOBAL g) {return false;} |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); |
|||
|
|||
// No additional members |
|||
}; // end of class FIXFAM |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* that are standard files with columns starting at fixed offset */ |
|||
/* This class is for fixed formatted files of more than 2 gigabytes. */ |
|||
/***********************************************************************/ |
|||
class BGXFAM : public FIXFAM { |
|||
public: |
|||
// Constructor |
|||
BGXFAM(PDOSDEF tdp); |
|||
BGXFAM(PBGXFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) BGXFAM(this);} |
|||
|
|||
// Methods |
|||
//virtual void Reset(void); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos |
|||
, int org = FILE_BEGIN); |
|||
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
|
|||
// Members |
|||
HANDLE Hfile; // Handle(descriptor) to big file |
|||
HANDLE Tfile; // Handle(descriptor) to big temp file |
|||
//BIGINT Xpos; // Current file position |
|||
}; // end of class BGXFAM |
|||
|
|||
#endif // __FILAMFIX_H |
|||
/************** FilAMFix H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMFIX.H Version 1.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005 - 2014 */ |
|||
/* */ |
|||
/* This file contains the FIX file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __FILAMFIX_H |
|||
#define __FILAMFIX_H |
|||
|
|||
#include "filamtxt.h" |
|||
|
|||
typedef class FIXFAM *PFIXFAM; |
|||
typedef class BGXFAM *PBGXFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for standard */ |
|||
/* files with fixed record format (FIX, BIN) */ |
|||
/***********************************************************************/ |
|||
class DllExport FIXFAM : public BLKFAM { |
|||
public: |
|||
// Constructor |
|||
FIXFAM(PDOSDEF tdp); |
|||
FIXFAM(PFIXFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_FIX;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) FIXFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g) {return TXTFAM::Cardinality(g);} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) |
|||
{return TXTFAM::MaxBlkSize(g, s);} |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual void ResetBuffer(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
protected: |
|||
virtual bool CopyHeader(PGLOBAL g) {return false;} |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); |
|||
|
|||
// No additional members |
|||
}; // end of class FIXFAM |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* that are standard files with columns starting at fixed offset */ |
|||
/* This class is for fixed formatted files of more than 2 gigabytes. */ |
|||
/***********************************************************************/ |
|||
class BGXFAM : public FIXFAM { |
|||
public: |
|||
// Constructor |
|||
BGXFAM(PDOSDEF tdp); |
|||
BGXFAM(PBGXFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) BGXFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos |
|||
, int org = FILE_BEGIN); |
|||
int BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
|
|||
// Members |
|||
HANDLE Hfile; // Handle(descriptor) to big file |
|||
HANDLE Tfile; // Handle(descriptor) to big temp file |
|||
}; // end of class BGXFAM |
|||
|
|||
#endif // __FILAMFIX_H |
|||
2904
storage/connect/filamtxt.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,196 +1,196 @@ |
|||
/************** FilAMTxt H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMTXT.H Version 1.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ |
|||
/* */ |
|||
/* This file contains the file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __FILAMTXT_H |
|||
#define __FILAMTXT_H |
|||
|
|||
#include "block.h" |
|||
|
|||
typedef class TXTFAM *PTXF; |
|||
typedef class DOSFAM *PDOSFAM; |
|||
typedef class BLKFAM *PBLKFAM; |
|||
typedef class DOSDEF *PDOSDEF; |
|||
typedef class TDBDOS *PTDBDOS; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the base class for all file access method classes. */ |
|||
/***********************************************************************/ |
|||
class DllExport TXTFAM : public BLOCK { |
|||
friend class TDBDOS; |
|||
friend class TDBCSV; |
|||
friend class TDBFIX; |
|||
friend class TDBVCT; |
|||
friend class DOSCOL; |
|||
friend class BINCOL; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
TXTFAM(PDOSDEF tdp); |
|||
TXTFAM(PTXF txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) = 0; |
|||
virtual int GetPos(void) = 0; |
|||
virtual int GetNextPos(void) = 0; |
|||
virtual PTXF Duplicate(PGLOBAL g) = 0; |
|||
virtual bool GetUseTemp(void) {return false;} |
|||
virtual int GetDelRows(void) {return DelRows;} |
|||
int GetCurBlk(void) {return CurBlk;} |
|||
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;} |
|||
int GetBlock(void) {return Block;} |
|||
void SetBlkPos(int *bkp) {BlkPos = bkp;} |
|||
void SetNrec(int n) {Nrec = n;} |
|||
char *GetBuf(void) {return To_Buf;} |
|||
int GetRows(void) {return Rows;} |
|||
bool IsBlocked(void) {return Blocked;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g) {return false;} |
|||
virtual void ResetBuffer(PGLOBAL g) {} |
|||
virtual int GetNerr(void) {return 0;} |
|||
virtual int GetRowID(void) = 0; |
|||
virtual bool RecordPos(PGLOBAL g) = 0; |
|||
virtual bool SetPos(PGLOBAL g, int recpos) = 0; |
|||
virtual int SkipRecord(PGLOBAL g, bool header) = 0; |
|||
virtual bool OpenTableFile(PGLOBAL g) = 0; |
|||
virtual bool DeferReading(void) {IsRead = false; return true;} |
|||
virtual int ReadBuffer(PGLOBAL g) = 0; |
|||
virtual int WriteBuffer(PGLOBAL g) = 0; |
|||
virtual int DeleteRecords(PGLOBAL g, int irc) = 0; |
|||
virtual void CloseTableFile(PGLOBAL g) = 0; |
|||
virtual void Rewind(void) = 0; |
|||
|
|||
protected: |
|||
// Members |
|||
PTDBDOS Tdbp; // To table class |
|||
PSZ To_File; // Points to table file name |
|||
PFBLOCK To_Fb; // Pointer to file block |
|||
bool Placed; // true if Recpos was externally set |
|||
bool IsRead; // false for deferred reading |
|||
bool Blocked; // true if using blocked I/O |
|||
char *To_Buf; // Points to I/O buffer |
|||
void *DelBuf; // Buffer used to move lines in Delete |
|||
int *BlkPos; // To array of block positions |
|||
int BlkLen; // Current block length |
|||
int Buflen; // Buffer length |
|||
int Dbflen; // Delete buffer length |
|||
int Rows; // Number of rows read so far |
|||
int DelRows; // Number of deleted rows |
|||
int Headlen; // Number of bytes in header |
|||
int Lrecl; // Logical Record Length |
|||
int Block; // Number of blocks in table |
|||
int Last; // Number of elements of last block |
|||
int Nrec; // Number of records in buffer |
|||
int OldBlk; // Index of last read block |
|||
int CurBlk; // Index of current block |
|||
int CurNum; // Current buffer line number |
|||
int ReadBlks; // Number of blocks read (selected) |
|||
int Rbuf; // Number of lines read in buffer |
|||
int Modif; // Number of modified lines in block |
|||
int Blksize; // Size of padded blocks |
|||
int Ending; // Length of line end |
|||
bool Padded; // true if fixed size blocks are padded |
|||
bool Eof; // true if an EOF (0xA) character exists |
|||
char *CrLf; // End of line character(s) |
|||
}; // end of class TXTFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for standard */ |
|||
/* text files with variable record format (DOS, CSV, FMT) */ |
|||
/***********************************************************************/ |
|||
class DllExport DOSFAM : public TXTFAM { |
|||
public: |
|||
// Constructor |
|||
DOSFAM(PDOSDEF tdp); |
|||
DOSFAM(PDOSFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_DOS;} |
|||
virtual bool GetUseTemp(void) {return UseTemp;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) DOSFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); |
|||
virtual int RenameTempFile(PGLOBAL g); |
|||
|
|||
// Members |
|||
FILE *Stream; // Points to Dos file structure |
|||
FILE *T_Stream; // Points to temporary file structure |
|||
PFBLOCK To_Fbt; // Pointer to temp file block |
|||
int Fpos; // Position of last read record |
|||
int Tpos; // Target Position for delete move |
|||
int Spos; // Start position for delete move |
|||
bool UseTemp; // True to use a temporary file in Delete |
|||
bool Bin; // True to force binary mode |
|||
}; // end of class DOSFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for standard */ |
|||
/* text files with variable record format (DOS, CSV, FMT) */ |
|||
/***********************************************************************/ |
|||
class DllExport BLKFAM : public DOSFAM { |
|||
public: |
|||
// Constructor |
|||
BLKFAM(PDOSDEF tdp); |
|||
BLKFAM(PBLKFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_BLK;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) BLKFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char *CurLine; // Position of current line in buffer |
|||
char *NxtLine; // Position of Next line in buffer |
|||
char *OutBuf; // Buffer to write in temporary file |
|||
bool Closing; // True when closing on Update |
|||
}; // end of class BLKFAM |
|||
|
|||
#endif // __FILAMTXT_H |
|||
/************** FilAMTxt H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMTXT.H Version 1.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ |
|||
/* */ |
|||
/* This file contains the file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __FILAMTXT_H |
|||
#define __FILAMTXT_H |
|||
|
|||
#include "block.h" |
|||
|
|||
typedef class TXTFAM *PTXF; |
|||
typedef class DOSFAM *PDOSFAM; |
|||
typedef class BLKFAM *PBLKFAM; |
|||
typedef class DOSDEF *PDOSDEF; |
|||
typedef class TDBDOS *PTDBDOS; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the base class for all file access method classes. */ |
|||
/***********************************************************************/ |
|||
class DllExport TXTFAM : public BLOCK { |
|||
friend class TDBDOS; |
|||
friend class TDBCSV; |
|||
friend class TDBFIX; |
|||
friend class TDBVCT; |
|||
friend class DOSCOL; |
|||
friend class BINCOL; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
TXTFAM(PDOSDEF tdp); |
|||
TXTFAM(PTXF txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) = 0; |
|||
virtual int GetPos(void) = 0; |
|||
virtual int GetNextPos(void) = 0; |
|||
virtual PTXF Duplicate(PGLOBAL g) = 0; |
|||
virtual bool GetUseTemp(void) {return false;} |
|||
virtual int GetDelRows(void) {return DelRows;} |
|||
int GetCurBlk(void) {return CurBlk;} |
|||
void SetTdbp(PTDBDOS tdbp) {Tdbp = tdbp;} |
|||
int GetBlock(void) {return Block;} |
|||
void SetBlkPos(int *bkp) {BlkPos = bkp;} |
|||
void SetNrec(int n) {Nrec = n;} |
|||
char *GetBuf(void) {return To_Buf;} |
|||
int GetRows(void) {return Rows;} |
|||
bool IsBlocked(void) {return Blocked;} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g) {return false;} |
|||
virtual void ResetBuffer(PGLOBAL g) {} |
|||
virtual int GetNerr(void) {return 0;} |
|||
virtual int GetRowID(void) = 0; |
|||
virtual bool RecordPos(PGLOBAL g) = 0; |
|||
virtual bool SetPos(PGLOBAL g, int recpos) = 0; |
|||
virtual int SkipRecord(PGLOBAL g, bool header) = 0; |
|||
virtual bool OpenTableFile(PGLOBAL g) = 0; |
|||
virtual bool DeferReading(void) {IsRead = false; return true;} |
|||
virtual int ReadBuffer(PGLOBAL g) = 0; |
|||
virtual int WriteBuffer(PGLOBAL g) = 0; |
|||
virtual int DeleteRecords(PGLOBAL g, int irc) = 0; |
|||
virtual void CloseTableFile(PGLOBAL g) = 0; |
|||
virtual void Rewind(void) = 0; |
|||
|
|||
protected: |
|||
// Members |
|||
PTDBDOS Tdbp; // To table class |
|||
PSZ To_File; // Points to table file name |
|||
PFBLOCK To_Fb; // Pointer to file block |
|||
bool Placed; // true if Recpos was externally set |
|||
bool IsRead; // false for deferred reading |
|||
bool Blocked; // true if using blocked I/O |
|||
char *To_Buf; // Points to I/O buffer |
|||
void *DelBuf; // Buffer used to move lines in Delete |
|||
int *BlkPos; // To array of block positions |
|||
int BlkLen; // Current block length |
|||
int Buflen; // Buffer length |
|||
int Dbflen; // Delete buffer length |
|||
int Rows; // Number of rows read so far |
|||
int DelRows; // Number of deleted rows |
|||
int Headlen; // Number of bytes in header |
|||
int Lrecl; // Logical Record Length |
|||
int Block; // Number of blocks in table |
|||
int Last; // Number of elements of last block |
|||
int Nrec; // Number of records in buffer |
|||
int OldBlk; // Index of last read block |
|||
int CurBlk; // Index of current block |
|||
int CurNum; // Current buffer line number |
|||
int ReadBlks; // Number of blocks read (selected) |
|||
int Rbuf; // Number of lines read in buffer |
|||
int Modif; // Number of modified lines in block |
|||
int Blksize; // Size of padded blocks |
|||
int Ending; // Length of line end |
|||
bool Padded; // true if fixed size blocks are padded |
|||
bool Eof; // true if an EOF (0xA) character exists |
|||
char *CrLf; // End of line character(s) |
|||
}; // end of class TXTFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for standard */ |
|||
/* text files with variable record format (DOS, CSV, FMT) */ |
|||
/***********************************************************************/ |
|||
class DllExport DOSFAM : public TXTFAM { |
|||
public: |
|||
// Constructor |
|||
DOSFAM(PDOSDEF tdp); |
|||
DOSFAM(PDOSFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_DOS;} |
|||
virtual bool GetUseTemp(void) {return UseTemp;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) DOSFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b); |
|||
virtual int RenameTempFile(PGLOBAL g); |
|||
|
|||
// Members |
|||
FILE *Stream; // Points to Dos file structure |
|||
FILE *T_Stream; // Points to temporary file structure |
|||
PFBLOCK To_Fbt; // Pointer to temp file block |
|||
int Fpos; // Position of last read record |
|||
int Tpos; // Target Position for delete move |
|||
int Spos; // Start position for delete move |
|||
bool UseTemp; // True to use a temporary file in Delete |
|||
bool Bin; // True to force binary mode |
|||
}; // end of class DOSFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for standard */ |
|||
/* text files with variable record format (DOS, CSV, FMT) */ |
|||
/***********************************************************************/ |
|||
class DllExport BLKFAM : public DOSFAM { |
|||
public: |
|||
// Constructor |
|||
BLKFAM(PDOSDEF tdp); |
|||
BLKFAM(PBLKFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_BLK;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) BLKFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char *CurLine; // Position of current line in buffer |
|||
char *NxtLine; // Position of Next line in buffer |
|||
char *OutBuf; // Buffer to write in temporary file |
|||
bool Closing; // True when closing on Update |
|||
}; // end of class BLKFAM |
|||
|
|||
#endif // __FILAMTXT_H |
|||
8476
storage/connect/filamvct.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,249 +1,249 @@ |
|||
/************** FilAMVct H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMVCT.H Version 1.5 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ |
|||
/* */ |
|||
/* This file contains the VCT file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __FILAMVCT__ |
|||
#define __FILAMVCT__ |
|||
|
|||
#include "filamfix.h" |
|||
|
|||
typedef class VCTFAM *PVCTFAM; |
|||
typedef class VCTCOL *PVCTCOL; |
|||
typedef class VCMFAM *PVCMFAM; |
|||
typedef class VECFAM *PVECFAM; |
|||
typedef class VMPFAM *PVMPFAM; |
|||
typedef class BGVFAM *PBGVFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in vector format. If MaxBlk=0, each block containing "Elements" */ |
|||
/* records, values of each columns are consecutively stored (vector). */ |
|||
/* Otherwise, data is arranged by column in the file and MaxBlk is */ |
|||
/* used to set the maximum number of blocks. This leave some white */ |
|||
/* space allowing to insert new values up to this maximum size. */ |
|||
/***********************************************************************/ |
|||
class DllExport VCTFAM : public FIXFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VCTFAM(PVCTDEF tdp); |
|||
VCTFAM(PVCTFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VCTFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual bool InitInsert(PGLOBAL g); |
|||
virtual void ResetBuffer(PGLOBAL g) {} |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
protected: |
|||
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveLines(PGLOBAL g) {return false;} |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
virtual bool CleanUnusedSpace(PGLOBAL g); |
|||
virtual int GetBlockInfo(PGLOBAL g); |
|||
virtual bool SetBlockInfo(PGLOBAL g); |
|||
bool ResetTableSize(PGLOBAL g, int block, int last); |
|||
|
|||
// Members |
|||
char *NewBlock; // To block written on Insert |
|||
char *Colfn; // Pattern for column file names (VER) |
|||
char *Tempat; // Pattern for temp file names (VER) |
|||
int *Clens; // Pointer to col size array |
|||
int *Deplac; // Pointer to col start position array |
|||
bool *Isnum; // Pointer to buffer type isnum result |
|||
bool AddBlock; // True when adding new blocks on Insert |
|||
bool Split; // true: split column file vector format |
|||
int Header; // 0: no, 1: separate, 2: in data file |
|||
int MaxBlk; // Max number of blocks (True vector format) |
|||
int Bsize; // Because Nrec can be modified |
|||
int Ncol; // The number of columns; |
|||
}; // end of class VCTFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in vector format accessed using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport VCMFAM : public VCTFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VCMFAM(PVCTDEF tdp); |
|||
VCMFAM(PVCMFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_VMP;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VCMFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual bool InitInsert(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
// Members |
|||
char* Memory; // Pointer on file mapping view. |
|||
char* *Memcol; // Pointer on column start. |
|||
}; // end of class VCMFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in full vertical format. Each column is contained in a separate */ |
|||
/* file whose name is the table name followed by the column number. */ |
|||
/***********************************************************************/ |
|||
class DllExport VECFAM : public VCTFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VECFAM(PVCTDEF tdp); |
|||
VECFAM(PVECFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VECFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual bool InitInsert(PGLOBAL g); |
|||
virtual void ResetBuffer(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
protected: |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveLines(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
virtual int RenameTempFile(PGLOBAL g); |
|||
bool OpenColumnFile(PGLOBAL g, char *opmode, int i); |
|||
|
|||
// Members |
|||
FILE* *Streams; // Points to Dos file structure array |
|||
FILE* *T_Streams; // Points to temp file structure array |
|||
PFBLOCK *To_Fbs; // Pointer to file block array |
|||
PFBLOCK *T_Fbs; // Pointer to temp file block array |
|||
void* *To_Bufs; // Pointer to col val block array |
|||
bool InitUpdate; // Used to initialize updating |
|||
}; // end of class VECFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in full vertical format accessed using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport VMPFAM : public VCMFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VMPFAM(PVCTDEF tdp); |
|||
VMPFAM(PVMPFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VMPFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
protected: |
|||
bool MapColumnFile(PGLOBAL g, MODE mode, int i); |
|||
|
|||
// Members |
|||
PFBLOCK *To_Fbs; // Pointer to file block array |
|||
}; // end of class VMPFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in (possibly blocked) vector format that can be larger than 2GB. */ |
|||
/***********************************************************************/ |
|||
class BGVFAM : public VCTFAM { |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructors |
|||
BGVFAM(PVCTDEF tdp); |
|||
BGVFAM(PBGVFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) BGVFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
protected: |
|||
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false); |
|||
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
virtual bool CleanUnusedSpace(PGLOBAL g); |
|||
virtual bool SetBlockInfo(PGLOBAL g); |
|||
virtual int GetBlockInfo(PGLOBAL g); |
|||
|
|||
// Members |
|||
HANDLE Hfile; // Handle to big file |
|||
HANDLE Tfile; // Handle to temporary file |
|||
BIGINT *BigDep; // Pointer to col start position array |
|||
}; // end of class BGVFAM |
|||
|
|||
#endif // __FILAMVCT__ |
|||
|
|||
/************** FilAMVct H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMVCT.H Version 1.5 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ |
|||
/* */ |
|||
/* This file contains the VCT file access method classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __FILAMVCT__ |
|||
#define __FILAMVCT__ |
|||
|
|||
#include "filamfix.h" |
|||
|
|||
typedef class VCTFAM *PVCTFAM; |
|||
typedef class VCTCOL *PVCTCOL; |
|||
typedef class VCMFAM *PVCMFAM; |
|||
typedef class VECFAM *PVECFAM; |
|||
typedef class VMPFAM *PVMPFAM; |
|||
typedef class BGVFAM *PBGVFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in vector format. If MaxBlk=0, each block containing "Elements" */ |
|||
/* records, values of each columns are consecutively stored (vector). */ |
|||
/* Otherwise, data is arranged by column in the file and MaxBlk is */ |
|||
/* used to set the maximum number of blocks. This leave some white */ |
|||
/* space allowing to insert new values up to this maximum size. */ |
|||
/***********************************************************************/ |
|||
class DllExport VCTFAM : public FIXFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VCTFAM(PVCTDEF tdp); |
|||
VCTFAM(PVCTFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VCTFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual bool InitInsert(PGLOBAL g); |
|||
virtual void ResetBuffer(PGLOBAL g) {} |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
protected: |
|||
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveLines(PGLOBAL g) {return false;} |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
virtual bool CleanUnusedSpace(PGLOBAL g); |
|||
virtual int GetBlockInfo(PGLOBAL g); |
|||
virtual bool SetBlockInfo(PGLOBAL g); |
|||
bool ResetTableSize(PGLOBAL g, int block, int last); |
|||
|
|||
// Members |
|||
char *NewBlock; // To block written on Insert |
|||
char *Colfn; // Pattern for column file names (VER) |
|||
char *Tempat; // Pattern for temp file names (VER) |
|||
int *Clens; // Pointer to col size array |
|||
int *Deplac; // Pointer to col start position array |
|||
bool *Isnum; // Pointer to buffer type isnum result |
|||
bool AddBlock; // True when adding new blocks on Insert |
|||
bool Split; // true: split column file vector format |
|||
int Header; // 0: no, 1: separate, 2: in data file |
|||
int MaxBlk; // Max number of blocks (True vector format) |
|||
int Bsize; // Because Nrec can be modified |
|||
int Ncol; // The number of columns; |
|||
}; // end of class VCTFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in vector format accessed using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport VCMFAM : public VCTFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VCMFAM(PVCTDEF tdp); |
|||
VCMFAM(PVCMFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_VMP;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VCMFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual bool InitInsert(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
// Members |
|||
char* Memory; // Pointer on file mapping view. |
|||
char* *Memcol; // Pointer on column start. |
|||
}; // end of class VCMFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in full vertical format. Each column is contained in a separate */ |
|||
/* file whose name is the table name followed by the column number. */ |
|||
/***********************************************************************/ |
|||
class DllExport VECFAM : public VCTFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VECFAM(PVCTDEF tdp); |
|||
VECFAM(PVECFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VECFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual bool InitInsert(PGLOBAL g); |
|||
virtual void ResetBuffer(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
protected: |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveLines(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
virtual int RenameTempFile(PGLOBAL g); |
|||
bool OpenColumnFile(PGLOBAL g, char *opmode, int i); |
|||
|
|||
// Members |
|||
FILE* *Streams; // Points to Dos file structure array |
|||
FILE* *T_Streams; // Points to temp file structure array |
|||
PFBLOCK *To_Fbs; // Pointer to file block array |
|||
PFBLOCK *T_Fbs; // Pointer to temp file block array |
|||
void* *To_Bufs; // Pointer to col val block array |
|||
bool InitUpdate; // Used to initialize updating |
|||
}; // end of class VECFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in full vertical format accessed using file mapping. */ |
|||
/***********************************************************************/ |
|||
class DllExport VMPFAM : public VCMFAM { |
|||
friend class TDBVCT; |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructor |
|||
VMPFAM(PVCTDEF tdp); |
|||
VMPFAM(PVMPFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) VMPFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
|
|||
protected: |
|||
bool MapColumnFile(PGLOBAL g, MODE mode, int i); |
|||
|
|||
// Members |
|||
PFBLOCK *To_Fbs; // Pointer to file block array |
|||
}; // end of class VMPFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* in (possibly blocked) vector format that can be larger than 2GB. */ |
|||
/***********************************************************************/ |
|||
class BGVFAM : public VCTFAM { |
|||
friend class VCTCOL; |
|||
public: |
|||
// Constructors |
|||
BGVFAM(PVCTDEF tdp); |
|||
BGVFAM(PBGVFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) BGVFAM(this);} |
|||
|
|||
// Methods |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
// Specific functions |
|||
virtual bool ReadBlock(PGLOBAL g, PVCTCOL colp); |
|||
virtual bool WriteBlock(PGLOBAL g, PVCTCOL colp); |
|||
|
|||
protected: |
|||
bool BigSeek(PGLOBAL g, HANDLE h, BIGINT pos, bool b = false); |
|||
bool BigRead(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
bool BigWrite(PGLOBAL g, HANDLE h, void *inbuf, int req); |
|||
virtual bool MakeEmptyFile(PGLOBAL g, char *fn); |
|||
virtual bool OpenTempFile(PGLOBAL g); |
|||
virtual bool MoveIntermediateLines(PGLOBAL g, bool *b = NULL); |
|||
virtual bool CleanUnusedSpace(PGLOBAL g); |
|||
virtual bool SetBlockInfo(PGLOBAL g); |
|||
virtual int GetBlockInfo(PGLOBAL g); |
|||
|
|||
// Members |
|||
HANDLE Hfile; // Handle to big file |
|||
HANDLE Tfile; // Handle to temporary file |
|||
BIGINT *BigDep; // Pointer to col start position array |
|||
}; // end of class BGVFAM |
|||
|
|||
#endif // __FILAMVCT__ |
|||
|
|||
2829
storage/connect/filamzip.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,171 +1,169 @@ |
|||
/************** FilAmZip H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMZIP.H Version 1.1 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2012 */ |
|||
/* */ |
|||
/* This file contains the GZIP access method classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __FILAMZIP_H |
|||
#define __FILAMZIP_H |
|||
|
|||
#include "zlib.h" |
|||
|
|||
typedef class ZIPFAM *PZIPFAM; |
|||
typedef class ZBKFAM *PZBKFAM; |
|||
typedef class ZIXFAM *PZIXFAM; |
|||
typedef class ZLBFAM *PZLBFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the access method class declaration for not optimized */ |
|||
/* variable record length files compressed using the gzip library */ |
|||
/* functions. File is accessed record by record (row). */ |
|||
/***********************************************************************/ |
|||
class DllExport ZIPFAM : public TXTFAM { |
|||
// friend class DOSCOL; |
|||
public: |
|||
// Constructor |
|||
ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;} |
|||
ZIPFAM(PZIPFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZIPFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
int Zerror(PGLOBAL g); // GZ error function |
|||
|
|||
// Members |
|||
gzFile Zfile; // Points to GZ file structure |
|||
z_off_t Zpos; // Uncompressed file position |
|||
}; // end of class ZIPFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the access method class declaration for optimized variable */ |
|||
/* record length files compressed using the gzip library functions. */ |
|||
/* The File is accessed by block (requires an opt file). */ |
|||
/***********************************************************************/ |
|||
class DllExport ZBKFAM : public ZIPFAM { |
|||
public: |
|||
// Constructor |
|||
ZBKFAM(PDOSDEF tdp); |
|||
ZBKFAM(PZBKFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void) {return 0;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZBKFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char *CurLine; // Position of current line in buffer |
|||
char *NxtLine; // Position of Next line in buffer |
|||
bool Closing; // True when closing on Insert |
|||
}; // end of class ZBKFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the access method class declaration for fixed record */ |
|||
/* length files compressed using the gzip library functions. */ |
|||
/* The file is always accessed by block. */ |
|||
/***********************************************************************/ |
|||
class DllExport ZIXFAM : public ZBKFAM { |
|||
public: |
|||
// Constructor |
|||
ZIXFAM(PDOSDEF tdp); |
|||
ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {} |
|||
|
|||
// Implementation |
|||
virtual int GetNextPos(void) {return 0;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZIXFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
|
|||
protected: |
|||
// No additional Members |
|||
}; // end of class ZIXFAM |
|||
|
|||
#if defined(BLK_INDX) |
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for PlugDB */ |
|||
/* fixed/variable files compressed using the zlib library functions. */ |
|||
/* Physically these are written and read using the same technique */ |
|||
/* than blocked variable files, only the contain of each block is */ |
|||
/* compressed using the deflate zlib function. The purpose of this */ |
|||
/* specific format is to have a fast mechanism for direct access of */ |
|||
/* records so blocked optimization is fast and direct access (joins) */ |
|||
/* is allowed. Note that the block length is written ahead of each */ |
|||
/* block to enable reading when optimization file is not available. */ |
|||
/***********************************************************************/ |
|||
class DllExport ZLBFAM : public BLKFAM { |
|||
public: |
|||
// Constructor |
|||
ZLBFAM(PDOSDEF tdp); |
|||
ZLBFAM(PZLBFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZLBFAM(this);} |
|||
inline void SetOptimized(bool b) {Optimized = b;} |
|||
|
|||
// Methods |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
bool WriteCompressedBuffer(PGLOBAL g); |
|||
int ReadCompressedBuffer(PGLOBAL g, void *rdbuf); |
|||
|
|||
// Members |
|||
z_streamp Zstream; // Compression/decompression stream |
|||
Byte *Zbuffer; // Compressed block buffer |
|||
int *Zlenp; // Pointer to block length |
|||
bool Optimized; // true when opt file is available |
|||
}; // end of class ZLBFAM |
|||
#endif // BLK_INDX |
|||
|
|||
#endif // __FILAMZIP_H |
|||
/************** FilAmZip H Declares Source Code File (.H) **************/ |
|||
/* Name: FILAMZIP.H Version 1.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ |
|||
/* */ |
|||
/* This file contains the GZIP access method classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __FILAMZIP_H |
|||
#define __FILAMZIP_H |
|||
|
|||
#include "zlib.h" |
|||
|
|||
typedef class ZIPFAM *PZIPFAM; |
|||
typedef class ZBKFAM *PZBKFAM; |
|||
typedef class ZIXFAM *PZIXFAM; |
|||
typedef class ZLBFAM *PZLBFAM; |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the access method class declaration for not optimized */ |
|||
/* variable record length files compressed using the gzip library */ |
|||
/* functions. File is accessed record by record (row). */ |
|||
/***********************************************************************/ |
|||
class DllExport ZIPFAM : public TXTFAM { |
|||
// friend class DOSCOL; |
|||
public: |
|||
// Constructor |
|||
ZIPFAM(PDOSDEF tdp) : TXTFAM(tdp) {Zfile = NULL; Zpos = 0;} |
|||
ZIPFAM(PZIPFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_ZIP;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZIPFAM(this);} |
|||
|
|||
// Methods |
|||
virtual void Reset(void); |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} |
|||
virtual int MaxBlkSize(PGLOBAL g, int s) {return s;} |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual bool SetPos(PGLOBAL g, int recpos); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual bool OpenTableFile(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
int Zerror(PGLOBAL g); // GZ error function |
|||
|
|||
// Members |
|||
gzFile Zfile; // Points to GZ file structure |
|||
z_off_t Zpos; // Uncompressed file position |
|||
}; // end of class ZIPFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the access method class declaration for optimized variable */ |
|||
/* record length files compressed using the gzip library functions. */ |
|||
/* The File is accessed by block (requires an opt file). */ |
|||
/***********************************************************************/ |
|||
class DllExport ZBKFAM : public ZIPFAM { |
|||
public: |
|||
// Constructor |
|||
ZBKFAM(PDOSDEF tdp); |
|||
ZBKFAM(PZBKFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void) {return 0;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZBKFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int MaxBlkSize(PGLOBAL g, int s); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int GetRowID(void); |
|||
virtual bool RecordPos(PGLOBAL g); |
|||
virtual int SkipRecord(PGLOBAL g, bool header); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual int DeleteRecords(PGLOBAL g, int irc); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char *CurLine; // Position of current line in buffer |
|||
char *NxtLine; // Position of Next line in buffer |
|||
bool Closing; // True when closing on Insert |
|||
}; // end of class ZBKFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the access method class declaration for fixed record */ |
|||
/* length files compressed using the gzip library functions. */ |
|||
/* The file is always accessed by block. */ |
|||
/***********************************************************************/ |
|||
class DllExport ZIXFAM : public ZBKFAM { |
|||
public: |
|||
// Constructor |
|||
ZIXFAM(PDOSDEF tdp); |
|||
ZIXFAM(PZIXFAM txfp) : ZBKFAM(txfp) {} |
|||
|
|||
// Implementation |
|||
virtual int GetNextPos(void) {return 0;} |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZIXFAM(this);} |
|||
|
|||
// Methods |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
|
|||
protected: |
|||
// No additional Members |
|||
}; // end of class ZIXFAM |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for PlugDB */ |
|||
/* fixed/variable files compressed using the zlib library functions. */ |
|||
/* Physically these are written and read using the same technique */ |
|||
/* than blocked variable files, only the contain of each block is */ |
|||
/* compressed using the deflate zlib function. The purpose of this */ |
|||
/* specific format is to have a fast mechanism for direct access of */ |
|||
/* records so blocked optimization is fast and direct access (joins) */ |
|||
/* is allowed. Note that the block length is written ahead of each */ |
|||
/* block to enable reading when optimization file is not available. */ |
|||
/***********************************************************************/ |
|||
class DllExport ZLBFAM : public BLKFAM { |
|||
public: |
|||
// Constructor |
|||
ZLBFAM(PDOSDEF tdp); |
|||
ZLBFAM(PZLBFAM txfp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_ZLIB;} |
|||
virtual int GetPos(void); |
|||
virtual int GetNextPos(void); |
|||
virtual PTXF Duplicate(PGLOBAL g) |
|||
{return (PTXF)new(g) ZLBFAM(this);} |
|||
inline void SetOptimized(bool b) {Optimized = b;} |
|||
|
|||
// Methods |
|||
virtual int GetFileLength(PGLOBAL g); |
|||
virtual bool AllocateBuffer(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); |
|||
virtual int WriteBuffer(PGLOBAL g); |
|||
virtual void CloseTableFile(PGLOBAL g); |
|||
virtual void Rewind(void); |
|||
|
|||
protected: |
|||
bool WriteCompressedBuffer(PGLOBAL g); |
|||
int ReadCompressedBuffer(PGLOBAL g, void *rdbuf); |
|||
|
|||
// Members |
|||
z_streamp Zstream; // Compression/decompression stream |
|||
Byte *Zbuffer; // Compressed block buffer |
|||
int *Zlenp; // Pointer to block length |
|||
bool Optimized; // true when opt file is available |
|||
}; // end of class ZLBFAM |
|||
|
|||
#endif // __FILAMZIP_H |
|||
@ -1,260 +1,258 @@ |
|||
/***********************************************************************/ |
|||
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */ |
|||
/* (C) Copyright Olivier Bertrand 1993-2012 */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Included C-definition files common to all Plug routines */ |
|||
/***********************************************************************/ |
|||
#include <string.h> /* String manipulation declares */ |
|||
#include <stdlib.h> /* C standard library */ |
|||
#include <ctype.h> /* C language specific types */ |
|||
#include <stdio.h> /* FOPEN_MAX declaration */ |
|||
#include <time.h> /* time_t type declaration */ |
|||
#include <setjmp.h> /* Long jump declarations */ |
|||
|
|||
#if defined(WIN32) && !defined(NOEX) |
|||
#define DllExport __declspec( dllexport ) |
|||
#else // !WIN32 |
|||
#define DllExport |
|||
#endif // !WIN32 |
|||
|
|||
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) |
|||
#define XML_SUPPORT 1 |
|||
#endif |
|||
|
|||
#if defined(XMSG) |
|||
// Definition used to read messages from message file. |
|||
#include "msgid.h" |
|||
#define MSG(I) PlugReadMessage(NULL, MSG_##I, #I) |
|||
#define STEP(I) PlugReadMessage(g, MSG_##I, #I) |
|||
#elif defined(NEWMSG) |
|||
// Definition used to get messages from resource. |
|||
#include "msgid.h" |
|||
#define MSG(I) PlugGetMessage(NULL, MSG_##I) |
|||
#define STEP(I) PlugGetMessage(g, MSG_##I) |
|||
#else // !XMSG and !NEWMSG |
|||
// Definition used to replace messages ID's by their definition. |
|||
#include "messages.h" |
|||
#define MSG(I) MSG_##I |
|||
#define STEP(I) MSG_##I |
|||
#endif // !XMSG and !NEWMSG |
|||
|
|||
#if defined(WIN32) |
|||
#define CRLF 2 |
|||
#else // !WIN32 |
|||
#define CRLF 1 |
|||
#endif // !WIN32 |
|||
|
|||
/***********************************************************************/ |
|||
/* Miscellaneous Constants */ |
|||
/***********************************************************************/ |
|||
#define NO_IVAL -95684275 /* Used by GetIntegerOption */ |
|||
#define VMLANG 370 /* Size of olf VM lang blocks */ |
|||
#define MAX_JUMP 24 /* Maximum jump level number */ |
|||
#define MAX_STR 1024 /* Maximum string length */ |
|||
#define STR_SIZE 501 /* Length of char strings. */ |
|||
#define STD_INPUT 0 /* Standard language input */ |
|||
#define STD_OUTPUT 1 /* Standard language output */ |
|||
#define ERROR_OUTPUT 2 /* Error message output */ |
|||
#define DEBUG_OUTPUT 3 /* Debug info output */ |
|||
#define PROMPT_OUTPUT 4 /* Prompt message output */ |
|||
#define COPY_OUTPUT 5 /* Copy of language input */ |
|||
#define STD_MSG 6 /* System message file */ |
|||
#define DEBUG_MSG 7 /* Debug message file */ |
|||
#define DUMMY 0 /* Dummy file index in Ldm block */ |
|||
#define STDIN 1 /* stdin file index in Ldm block */ |
|||
#define STDOUT 2 /* stdout file index in Ldm block */ |
|||
#define STDERR 3 /* stderr file index in Ldm block */ |
|||
#define STDEBUG 4 /* debug file index in Ldm block */ |
|||
#define STDPRN 5 /* stdprn file index in Ldm block */ |
|||
#define STDFREE 6 /* Free file index in Ldm block */ |
|||
|
|||
#define TYPE_SEM -2 /* Returned semantic function */ |
|||
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */ |
|||
#define TYPE_VOID -1 |
|||
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */ |
|||
#define TYPE_SEMX 0 /* Initial semantic function type? */ |
|||
#define TYPE_ERROR 0 |
|||
#define TYPE_STRING 1 |
|||
#define TYPE_DOUBLE 2 |
|||
#define TYPE_SHORT 3 |
|||
#define TYPE_TINY 4 |
|||
#define TYPE_BIGINT 5 |
|||
#define TYPE_LIST 6 |
|||
#define TYPE_INT 7 |
|||
#define TYPE_DECIM 9 |
|||
|
|||
#if defined(OS32) |
|||
#define SYS_STAMP "OS32" |
|||
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) |
|||
#define SYS_STAMP "UNIX" |
|||
#elif defined(OS16) |
|||
#define SYS_STAMP "OS16" |
|||
#elif defined(DOSR) |
|||
#define SYS_STAMP "DOSR" |
|||
#elif defined(WIN) |
|||
#define SYS_STAMP "WIN1" |
|||
#elif defined(WIN32) |
|||
#define SYS_STAMP "WIN2" |
|||
#else |
|||
#define SYS_STAMP "XXXX" |
|||
#endif |
|||
|
|||
#if defined(__cplusplus) |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/***********************************************************************/ |
|||
/* Static variables */ |
|||
/***********************************************************************/ |
|||
#if defined(STORAGE) |
|||
char sys_stamp[4] = SYS_STAMP; |
|||
#else |
|||
extern char sys_stamp[]; |
|||
#endif |
|||
|
|||
/***********************************************************************/ |
|||
/* File-Selection Indicators */ |
|||
/***********************************************************************/ |
|||
#define PAT_LOG "log" |
|||
|
|||
#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) |
|||
/*********************************************************************/ |
|||
/* printf does not accept null pointer for %s target. */ |
|||
/*********************************************************************/ |
|||
#define SVP(S) ((S) ? S : "<null>") |
|||
#else |
|||
/*********************************************************************/ |
|||
/* printf accepts null pointer for %s target. */ |
|||
/*********************************************************************/ |
|||
#define SVP(S) S |
|||
#endif |
|||
|
|||
#if defined(STORAGE) |
|||
FILE *debug; |
|||
#else |
|||
extern FILE *debug; |
|||
#endif |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* General purpose type definitions. */ |
|||
/***********************************************************************/ |
|||
#include "os.h" |
|||
|
|||
typedef uint OFFSET; |
|||
typedef char NAME[9]; |
|||
|
|||
typedef struct { |
|||
ushort Length; |
|||
char String[2]; |
|||
} VARSTR; |
|||
|
|||
#if !defined(PGLOBAL_DEFINED) |
|||
typedef struct _global *PGLOBAL; |
|||
#define PGLOBAL_DEFINED |
|||
#endif |
|||
typedef struct _globplg *PGS; |
|||
typedef struct _activity *PACTIVITY; |
|||
typedef struct _parm *PPARM; |
|||
|
|||
/***********************************************************************/ |
|||
/* Segment Sub-Allocation block structure declares. */ |
|||
/* Next block is an implementation dependent segment suballoc save */ |
|||
/* structure used to keep the suballocation system offsets and to */ |
|||
/* restore them if needed. This scheme implies that no SubFree be used */ |
|||
/***********************************************************************/ |
|||
typedef struct { /* Plug Area SubAlloc header */ |
|||
OFFSET To_Free; /* Offset of next free block */ |
|||
uint FreeBlk; /* Size of remaining free memory */ |
|||
} POOLHEADER, *PPOOLHEADER; |
|||
|
|||
/***********************************************************************/ |
|||
/* Language block. Containing all global information for the language */ |
|||
/* this block is saved and retrieved with the language. Information */ |
|||
/* in this block can be set and modified under Grammar editing. */ |
|||
/***********************************************************************/ |
|||
#if defined(BIT64) |
|||
typedef int TIME_T; /* Lang block size must not change */ |
|||
#else // BIT32 |
|||
typedef time_t TIME_T; /* time_t */ |
|||
#endif // BIT32 |
|||
|
|||
typedef struct { |
|||
uint Memsize; |
|||
uint Size; |
|||
} AREADEF; |
|||
|
|||
typedef struct Lang_block { |
|||
NAME LangName; /* Language name */ |
|||
NAME Application; /* Application name */ |
|||
} LANG, *PLANG; |
|||
|
|||
/***********************************************************************/ |
|||
/* Application block. It contains all global information for the */ |
|||
/* current parse and execution using the corresponding language. */ |
|||
/* This block is dynamically allocated and set at language init. */ |
|||
/***********************************************************************/ |
|||
typedef struct _activity { /* Describes activity and language */ |
|||
void *Aptr; /* Points to user work area(s) */ |
|||
NAME Ap_Name; /* Current application name */ |
|||
} ACTIVITY; |
|||
|
|||
/*---------------- UNIT ?????????? VERSION ? ----------------------*/ |
|||
typedef struct _parm { |
|||
void *Value; |
|||
short Type, Domain; |
|||
PPARM Next; |
|||
} PARM; |
|||
|
|||
/***********************************************************************/ |
|||
/* Global Structure Block. This block contains, or points to, all */ |
|||
/* information used by CONNECT tables. Passed as an argument */ |
|||
/* to any routine allows it to have access to the entire information */ |
|||
/* currently available for the whole set of loaded languages. */ |
|||
/***********************************************************************/ |
|||
typedef struct _global { /* Global structure */ |
|||
void *Sarea; /* Points to work area */ |
|||
uint Sarea_Size; /* Work area size */ |
|||
PACTIVITY Activityp, ActivityStart; |
|||
char Message[MAX_STR]; |
|||
int Createas; /* To pass info to created table */ |
|||
void *Xchk; /* indexes in create/alter */ |
|||
short Alchecked; /* Checked for ALTER */ |
|||
#if defined(MRRBKA_SUPPORT) |
|||
short Mrr; /* True when doing mrr */ |
|||
#endif // MRRBKA_SUPPORT |
|||
short Trace; |
|||
int jump_level; |
|||
jmp_buf jumper[MAX_JUMP + 2]; |
|||
} GLOBAL; |
|||
|
|||
/***********************************************************************/ |
|||
/* Exported routine declarations. */ |
|||
/***********************************************************************/ |
|||
#if defined(XMSG) |
|||
DllExport char *PlugReadMessage(PGLOBAL, int, char *); |
|||
#elif defined(NEWMSG) |
|||
DllExport char *PlugGetMessage(PGLOBAL, int); |
|||
#endif // XMSG || NEWMSG |
|||
#if defined(WIN32) |
|||
DllExport short GetLineLength(PGLOBAL); // Console line length |
|||
#endif // WIN32 |
|||
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization |
|||
DllExport int PlugExit(PGLOBAL); // Plug global termination |
|||
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); |
|||
DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir); |
|||
DllExport BOOL PlugIsAbsolutePath(LPCSTR path); |
|||
DllExport void *PlugAllocMem(PGLOBAL, uint); |
|||
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); |
|||
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); |
|||
DllExport char *PlugDup(PGLOBAL g, const char *str); |
|||
DllExport void *MakePtr(void *, OFFSET); |
|||
DllExport void htrc(char const *fmt, ...); |
|||
|
|||
#if defined(__cplusplus) |
|||
} // extern "C" |
|||
#endif |
|||
|
|||
/*-------------------------- End of Global.H --------------------------*/ |
|||
/***********************************************************************/ |
|||
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */ |
|||
/* (C) Copyright Olivier Bertrand 1993-2012 */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Included C-definition files common to all Plug routines */ |
|||
/***********************************************************************/ |
|||
#include <string.h> /* String manipulation declares */ |
|||
#include <stdlib.h> /* C standard library */ |
|||
#include <ctype.h> /* C language specific types */ |
|||
#include <stdio.h> /* FOPEN_MAX declaration */ |
|||
#include <time.h> /* time_t type declaration */ |
|||
#include <setjmp.h> /* Long jump declarations */ |
|||
|
|||
#if defined(WIN32) && !defined(NOEX) |
|||
#define DllExport __declspec( dllexport ) |
|||
#else // !WIN32 |
|||
#define DllExport |
|||
#endif // !WIN32 |
|||
|
|||
#if defined(DOMDOC_SUPPORT) || defined(LIBXML2_SUPPORT) |
|||
#define XML_SUPPORT 1 |
|||
#endif |
|||
|
|||
#if defined(XMSG) |
|||
// Definition used to read messages from message file. |
|||
#include "msgid.h" |
|||
#define MSG(I) PlugReadMessage(NULL, MSG_##I, #I) |
|||
#define STEP(I) PlugReadMessage(g, MSG_##I, #I) |
|||
#elif defined(NEWMSG) |
|||
// Definition used to get messages from resource. |
|||
#include "msgid.h" |
|||
#define MSG(I) PlugGetMessage(NULL, MSG_##I) |
|||
#define STEP(I) PlugGetMessage(g, MSG_##I) |
|||
#else // !XMSG and !NEWMSG |
|||
// Definition used to replace messages ID's by their definition. |
|||
#include "messages.h" |
|||
#define MSG(I) MSG_##I |
|||
#define STEP(I) MSG_##I |
|||
#endif // !XMSG and !NEWMSG |
|||
|
|||
#if defined(WIN32) |
|||
#define CRLF 2 |
|||
#else // !WIN32 |
|||
#define CRLF 1 |
|||
#endif // !WIN32 |
|||
|
|||
/***********************************************************************/ |
|||
/* Miscellaneous Constants */ |
|||
/***********************************************************************/ |
|||
#define NO_IVAL -95684275 /* Used by GetIntegerOption */ |
|||
#define VMLANG 370 /* Size of olf VM lang blocks */ |
|||
#define MAX_JUMP 24 /* Maximum jump level number */ |
|||
#define MAX_STR 1024 /* Maximum string length */ |
|||
#define STR_SIZE 501 /* Length of char strings. */ |
|||
#define STD_INPUT 0 /* Standard language input */ |
|||
#define STD_OUTPUT 1 /* Standard language output */ |
|||
#define ERROR_OUTPUT 2 /* Error message output */ |
|||
#define DEBUG_OUTPUT 3 /* Debug info output */ |
|||
#define PROMPT_OUTPUT 4 /* Prompt message output */ |
|||
#define COPY_OUTPUT 5 /* Copy of language input */ |
|||
#define STD_MSG 6 /* System message file */ |
|||
#define DEBUG_MSG 7 /* Debug message file */ |
|||
#define DUMMY 0 /* Dummy file index in Ldm block */ |
|||
#define STDIN 1 /* stdin file index in Ldm block */ |
|||
#define STDOUT 2 /* stdout file index in Ldm block */ |
|||
#define STDERR 3 /* stderr file index in Ldm block */ |
|||
#define STDEBUG 4 /* debug file index in Ldm block */ |
|||
#define STDPRN 5 /* stdprn file index in Ldm block */ |
|||
#define STDFREE 6 /* Free file index in Ldm block */ |
|||
|
|||
#define TYPE_SEM -2 /* Returned semantic function */ |
|||
#define TYPE_DFONC -2 /* Indirect sem ref in FPARM */ |
|||
#define TYPE_VOID -1 |
|||
#define TYPE_SBPAR -1 /* Phrase reference in FPARM */ |
|||
#define TYPE_SEMX 0 /* Initial semantic function type? */ |
|||
#define TYPE_ERROR 0 |
|||
#define TYPE_STRING 1 |
|||
#define TYPE_DOUBLE 2 |
|||
#define TYPE_SHORT 3 |
|||
#define TYPE_TINY 4 |
|||
#define TYPE_BIGINT 5 |
|||
#define TYPE_LIST 6 |
|||
#define TYPE_INT 7 |
|||
#define TYPE_DECIM 9 |
|||
|
|||
#if defined(OS32) |
|||
#define SYS_STAMP "OS32" |
|||
#elif defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) |
|||
#define SYS_STAMP "UNIX" |
|||
#elif defined(OS16) |
|||
#define SYS_STAMP "OS16" |
|||
#elif defined(DOSR) |
|||
#define SYS_STAMP "DOSR" |
|||
#elif defined(WIN) |
|||
#define SYS_STAMP "WIN1" |
|||
#elif defined(WIN32) |
|||
#define SYS_STAMP "WIN2" |
|||
#else |
|||
#define SYS_STAMP "XXXX" |
|||
#endif |
|||
|
|||
#if defined(__cplusplus) |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/***********************************************************************/ |
|||
/* Static variables */ |
|||
/***********************************************************************/ |
|||
#if defined(STORAGE) |
|||
char sys_stamp[4] = SYS_STAMP; |
|||
#else |
|||
extern char sys_stamp[]; |
|||
#endif |
|||
|
|||
/***********************************************************************/ |
|||
/* File-Selection Indicators */ |
|||
/***********************************************************************/ |
|||
#define PAT_LOG "log" |
|||
|
|||
#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX) |
|||
/*********************************************************************/ |
|||
/* printf does not accept null pointer for %s target. */ |
|||
/*********************************************************************/ |
|||
#define SVP(S) ((S) ? S : "<null>") |
|||
#else |
|||
/*********************************************************************/ |
|||
/* printf accepts null pointer for %s target. */ |
|||
/*********************************************************************/ |
|||
#define SVP(S) S |
|||
#endif |
|||
|
|||
#if defined(STORAGE) |
|||
FILE *debug; |
|||
#else |
|||
extern FILE *debug; |
|||
#endif |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* General purpose type definitions. */ |
|||
/***********************************************************************/ |
|||
#include "os.h" |
|||
|
|||
typedef uint OFFSET; |
|||
typedef char NAME[9]; |
|||
|
|||
typedef struct { |
|||
ushort Length; |
|||
char String[2]; |
|||
} VARSTR; |
|||
|
|||
#if !defined(PGLOBAL_DEFINED) |
|||
typedef struct _global *PGLOBAL; |
|||
#define PGLOBAL_DEFINED |
|||
#endif |
|||
typedef struct _globplg *PGS; |
|||
typedef struct _activity *PACTIVITY; |
|||
typedef struct _parm *PPARM; |
|||
|
|||
/***********************************************************************/ |
|||
/* Segment Sub-Allocation block structure declares. */ |
|||
/* Next block is an implementation dependent segment suballoc save */ |
|||
/* structure used to keep the suballocation system offsets and to */ |
|||
/* restore them if needed. This scheme implies that no SubFree be used */ |
|||
/***********************************************************************/ |
|||
typedef struct { /* Plug Area SubAlloc header */ |
|||
OFFSET To_Free; /* Offset of next free block */ |
|||
uint FreeBlk; /* Size of remaining free memory */ |
|||
} POOLHEADER, *PPOOLHEADER; |
|||
|
|||
/***********************************************************************/ |
|||
/* Language block. Containing all global information for the language */ |
|||
/* this block is saved and retrieved with the language. Information */ |
|||
/* in this block can be set and modified under Grammar editing. */ |
|||
/***********************************************************************/ |
|||
#if defined(BIT64) |
|||
typedef int TIME_T; /* Lang block size must not change */ |
|||
#else // BIT32 |
|||
typedef time_t TIME_T; /* time_t */ |
|||
#endif // BIT32 |
|||
|
|||
typedef struct { |
|||
uint Memsize; |
|||
uint Size; |
|||
} AREADEF; |
|||
|
|||
typedef struct Lang_block { |
|||
NAME LangName; /* Language name */ |
|||
NAME Application; /* Application name */ |
|||
} LANG, *PLANG; |
|||
|
|||
/***********************************************************************/ |
|||
/* Application block. It contains all global information for the */ |
|||
/* current parse and execution using the corresponding language. */ |
|||
/* This block is dynamically allocated and set at language init. */ |
|||
/***********************************************************************/ |
|||
typedef struct _activity { /* Describes activity and language */ |
|||
void *Aptr; /* Points to user work area(s) */ |
|||
NAME Ap_Name; /* Current application name */ |
|||
} ACTIVITY; |
|||
|
|||
/*---------------- UNIT ?????????? VERSION ? ----------------------*/ |
|||
typedef struct _parm { |
|||
void *Value; |
|||
short Type, Domain; |
|||
PPARM Next; |
|||
} PARM; |
|||
|
|||
/***********************************************************************/ |
|||
/* Global Structure Block. This block contains, or points to, all */ |
|||
/* information used by CONNECT tables. Passed as an argument */ |
|||
/* to any routine allows it to have access to the entire information */ |
|||
/* currently available for the whole set of loaded languages. */ |
|||
/***********************************************************************/ |
|||
typedef struct _global { /* Global structure */ |
|||
void *Sarea; /* Points to work area */ |
|||
uint Sarea_Size; /* Work area size */ |
|||
PACTIVITY Activityp, ActivityStart; |
|||
char Message[MAX_STR]; |
|||
int Createas; /* To pass info to created table */ |
|||
void *Xchk; /* indexes in create/alter */ |
|||
short Alchecked; /* Checked for ALTER */ |
|||
short Mrr; /* True when doing mrr */ |
|||
short Trace; |
|||
int jump_level; |
|||
jmp_buf jumper[MAX_JUMP + 2]; |
|||
} GLOBAL; |
|||
|
|||
/***********************************************************************/ |
|||
/* Exported routine declarations. */ |
|||
/***********************************************************************/ |
|||
#if defined(XMSG) |
|||
DllExport char *PlugReadMessage(PGLOBAL, int, char *); |
|||
#elif defined(NEWMSG) |
|||
DllExport char *PlugGetMessage(PGLOBAL, int); |
|||
#endif // XMSG || NEWMSG |
|||
#if defined(WIN32) |
|||
DllExport short GetLineLength(PGLOBAL); // Console line length |
|||
#endif // WIN32 |
|||
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization |
|||
DllExport int PlugExit(PGLOBAL); // Plug global termination |
|||
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR); |
|||
DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir); |
|||
DllExport BOOL PlugIsAbsolutePath(LPCSTR path); |
|||
DllExport void *PlugAllocMem(PGLOBAL, uint); |
|||
DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); |
|||
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); |
|||
DllExport char *PlugDup(PGLOBAL g, const char *str); |
|||
DllExport void *MakePtr(void *, OFFSET); |
|||
DllExport void htrc(char const *fmt, ...); |
|||
|
|||
#if defined(__cplusplus) |
|||
} // extern "C" |
|||
#endif |
|||
|
|||
/*-------------------------- End of Global.H --------------------------*/ |
|||
11421
storage/connect/ha_connect.cc
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1053
storage/connect/ha_connect.h
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1240
storage/connect/plgdbsem.h
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1102
storage/connect/plugutil.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,444 +1,436 @@ |
|||
/************* RelDef CPP Program Source Code File (.CPP) **************/ |
|||
/* PROGRAM NAME: REFDEF */ |
|||
/* ------------- */ |
|||
/* Version 1.3 */ |
|||
/* */ |
|||
/* COPYRIGHT: */ |
|||
/* ---------- */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */ |
|||
/* */ |
|||
/* WHAT THIS PROGRAM DOES: */ |
|||
/* ----------------------- */ |
|||
/* This program are the DB definition related routines. */ |
|||
/* */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include relevant MariaDB header file. */ |
|||
/***********************************************************************/ |
|||
#include "my_global.h"
|
|||
#if defined(WIN32)
|
|||
#include <sqlext.h>
|
|||
#else
|
|||
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
|
|||
#include "osutil.h"
|
|||
//#include "sqlext.h"
|
|||
#endif
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include application header files */ |
|||
/* */ |
|||
/* global.h is header containing all global declarations. */ |
|||
/* plgdbsem.h is header containing DB application declarations. */ |
|||
/* catalog.h is header containing DB description declarations. */ |
|||
/***********************************************************************/ |
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "mycat.h"
|
|||
#include "reldef.h"
|
|||
#include "colblk.h"
|
|||
#include "filamap.h"
|
|||
#include "filamfix.h"
|
|||
#include "filamvct.h"
|
|||
#if defined(ZIP_SUPPORT)
|
|||
#include "filamzip.h"
|
|||
#endif // ZIP_SUPPORT
|
|||
#include "tabdos.h"
|
|||
#include "valblk.h"
|
|||
#include "tabmul.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* External static variables. */ |
|||
/***********************************************************************/ |
|||
//extern "C" char plgini[];
|
|||
|
|||
/* --------------------------- Class RELDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* RELDEF Constructor. */ |
|||
/***********************************************************************/ |
|||
RELDEF::RELDEF(void) |
|||
{ |
|||
Next = NULL; |
|||
To_Cols = NULL; |
|||
Name = NULL; |
|||
Database = NULL; |
|||
Cat = NULL; |
|||
} // end of RELDEF constructor
|
|||
|
|||
/* --------------------------- Class TABDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* TABDEF Constructor. */ |
|||
/***********************************************************************/ |
|||
TABDEF::TABDEF(void) |
|||
{ |
|||
Schema = NULL; |
|||
Desc = NULL; |
|||
Catfunc = FNC_NO; |
|||
Card = 0; |
|||
Elemt = 0; |
|||
Sort = 0; |
|||
Multiple = 0; |
|||
Degree = 0; |
|||
Pseudo = 0; |
|||
Read_Only = false; |
|||
} // end of TABDEF constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* Define: initialize the table definition block from XDB file. */ |
|||
/***********************************************************************/ |
|||
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) |
|||
{ |
|||
int poff = 0; |
|||
|
|||
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); |
|||
strcpy(Name, name); |
|||
Cat = cat; |
|||
Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL)); |
|||
Elemt = cat->GetIntCatInfo("Elements", 0); |
|||
Multiple = cat->GetIntCatInfo("Multiple", 0); |
|||
Degree = cat->GetIntCatInfo("Degree", 0); |
|||
Read_Only = cat->GetBoolCatInfo("ReadOnly", false); |
|||
const char *data_charset_name= cat->GetStringCatInfo(g, "Data_charset", NULL); |
|||
m_data_charset= data_charset_name ? |
|||
get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0): |
|||
NULL; |
|||
|
|||
// Get The column definitions
|
|||
if ((poff = cat->GetColCatInfo(g, this)) < 0) |
|||
return true; |
|||
|
|||
// Do the definition of AM specific fields
|
|||
return DefineAM(g, am, poff); |
|||
} // end of Define
|
|||
|
|||
/* --------------------------- Class OEMDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* GetXdef: get the external TABDEF from OEM module. */ |
|||
/***********************************************************************/ |
|||
PTABDEF OEMDEF::GetXdef(PGLOBAL g) |
|||
{ |
|||
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *); |
|||
char c, getname[40] = "Get"; |
|||
PTABDEF xdefp; |
|||
XGETDEF getdef = NULL; |
|||
PCATLG cat = Cat; |
|||
|
|||
#if defined(WIN32)
|
|||
// Is the DLL already loaded?
|
|||
if (!Hdll && !(Hdll = GetModuleHandle(Module))) |
|||
// No, load the Dll implementing the function
|
|||
if (!(Hdll = LoadLibrary(Module))) { |
|||
char buf[256]; |
|||
DWORD rc = GetLastError(); |
|||
|
|||
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module); |
|||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | |
|||
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, |
|||
(LPTSTR)buf, sizeof(buf), NULL); |
|||
strcat(strcat(g->Message, ": "), buf); |
|||
return NULL; |
|||
} // endif hDll
|
|||
|
|||
// The exported name is always in uppercase
|
|||
for (int i = 0; ; i++) { |
|||
c = Subtype[i]; |
|||
getname[i + 3] = toupper(c); |
|||
if (!c) break; |
|||
} // endfor i
|
|||
|
|||
// Get the function returning an instance of the external DEF class
|
|||
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) { |
|||
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname); |
|||
FreeLibrary((HMODULE)Hdll); |
|||
return NULL; |
|||
} // endif getdef
|
|||
#else // !WIN32
|
|||
const char *error = NULL; |
|||
// Is the library already loaded?
|
|||
// if (!Hdll && !(Hdll = ???))
|
|||
// Load the desired shared library
|
|||
if (!(Hdll = dlopen(Module, RTLD_LAZY))) { |
|||
error = dlerror(); |
|||
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error)); |
|||
return NULL; |
|||
} // endif Hdll
|
|||
|
|||
// The exported name is always in uppercase
|
|||
for (int i = 0; ; i++) { |
|||
c = Subtype[i]; |
|||
getname[i + 3] = toupper(c); |
|||
if (!c) break; |
|||
} // endfor i
|
|||
|
|||
// Get the function returning an instance of the external DEF class
|
|||
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) { |
|||
error = dlerror(); |
|||
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error)); |
|||
dlclose(Hdll); |
|||
return NULL; |
|||
} // endif getdef
|
|||
#endif // !WIN32
|
|||
|
|||
// Just in case the external Get function does not set error messages
|
|||
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); |
|||
|
|||
// Get the table definition block
|
|||
if (!(xdefp = getdef(g, NULL))) |
|||
return NULL; |
|||
|
|||
// Have the external class do its complete definition
|
|||
if (!cat->Cbuf) { |
|||
// Suballocate a temporary buffer for the entire column section
|
|||
cat->Cblen = cat->GetSizeCatInfo("Colsize", "8K"); |
|||
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen); |
|||
} // endif Cbuf
|
|||
|
|||
// Here "OEM" should be replace by a more useful value
|
|||
if (xdefp->Define(g, cat, Name, "OEM")) |
|||
return NULL; |
|||
|
|||
// Ok, return external block
|
|||
return xdefp; |
|||
} // end of GetXdef
|
|||
|
|||
#if 0
|
|||
/***********************************************************************/ |
|||
/* DeleteTableFile: Delete an OEM table file if applicable. */ |
|||
/***********************************************************************/ |
|||
bool OEMDEF::DeleteTableFile(PGLOBAL g) |
|||
{ |
|||
if (!Pxdef) |
|||
Pxdef = GetXdef(g); |
|||
|
|||
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true; |
|||
} // end of DeleteTableFile
|
|||
#endif // 0
|
|||
|
|||
/***********************************************************************/ |
|||
/* Define: initialize the table definition block from XDB file. */ |
|||
/***********************************************************************/ |
|||
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) |
|||
{ |
|||
Module = Cat->GetStringCatInfo(g, "Module", ""); |
|||
Subtype = Cat->GetStringCatInfo(g, "Subtype", Module); |
|||
|
|||
if (!*Module) |
|||
Module = Subtype; |
|||
|
|||
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module) |
|||
+ strlen(Subtype) + 3); |
|||
sprintf(Desc, "%s(%s)", Module, Subtype); |
|||
return false; |
|||
} // end of DefineAM
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetTable: makes a new Table Description Block. */ |
|||
/***********************************************************************/ |
|||
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode) |
|||
{ |
|||
RECFM rfm; |
|||
PTDBASE tdbp = NULL; |
|||
|
|||
// If define block not here yet, get it now
|
|||
if (!Pxdef && !(Pxdef = GetXdef(g))) |
|||
return NULL; // Error
|
|||
|
|||
/*********************************************************************/ |
|||
/* Allocate a TDB of the proper type. */ |
|||
/* Column blocks will be allocated only when needed. */ |
|||
/*********************************************************************/ |
|||
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode))) |
|||
return NULL; |
|||
else |
|||
rfm = tdbp->GetFtype(); |
|||
|
|||
if (rfm == RECFM_NAF) |
|||
return tdbp; |
|||
else if (rfm == RECFM_OEM) { |
|||
if (Multiple) |
|||
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
|
|||
|
|||
return tdbp; |
|||
} // endif OEM
|
|||
|
|||
/*********************************************************************/ |
|||
/* The OEM table is based on a file type (currently DOS+ only) */ |
|||
/*********************************************************************/ |
|||
assert (rfm == RECFM_VAR || rfm == RECFM_FIX || |
|||
rfm == RECFM_BIN || rfm == RECFM_VCT); |
|||
|
|||
PTXF txfp = NULL; |
|||
PDOSDEF defp = (PDOSDEF)Pxdef; |
|||
bool map = defp->Mapped && mode != MODE_INSERT && |
|||
!(PlgGetUser(g)->UseTemp == TMP_FORCE && |
|||
(mode == MODE_UPDATE || mode == MODE_DELETE)); |
|||
int cmpr = defp->Compressed; |
|||
|
|||
/*********************************************************************/ |
|||
/* Allocate table and file processing class of the proper type. */ |
|||
/* Column blocks will be allocated only when needed. */ |
|||
/*********************************************************************/ |
|||
if (!((PTDBDOS)tdbp)->GetTxfp()) { |
|||
if (cmpr) { |
|||
#if defined(ZIP_SUPPORT)
|
|||
if (cmpr == 1) |
|||
txfp = new(g) ZIPFAM(defp); |
|||
else { |
|||
#if defined(BLK_INDX)
|
|||
txfp = new(g) ZLBFAM(defp); |
|||
#else // !BLK_INDX
|
|||
strcpy(g->Message, "Compress 2 not supported yet"); |
|||
#endif // !BLK_INDX
|
|||
return NULL; |
|||
} // endelse
|
|||
#else // !ZIP_SUPPORT
|
|||
strcpy(g->Message, "Compress not supported"); |
|||
return NULL; |
|||
#endif // !ZIP_SUPPORT
|
|||
} else if (rfm == RECFM_VAR) { |
|||
if (map) |
|||
txfp = new(g) MAPFAM(defp); |
|||
else |
|||
txfp = new(g) DOSFAM(defp); |
|||
|
|||
} else if (rfm == RECFM_FIX || rfm == RECFM_BIN) { |
|||
if (map) |
|||
txfp = new(g) MPXFAM(defp); |
|||
else |
|||
txfp = new(g) FIXFAM(defp); |
|||
|
|||
} else if (rfm == RECFM_VCT) { |
|||
assert (Pxdef->GetDefType() == TYPE_AM_VCT); |
|||
|
|||
if (map) |
|||
txfp = new(g) VCMFAM((PVCTDEF)defp); |
|||
else |
|||
txfp = new(g) VCTFAM((PVCTDEF)defp); |
|||
|
|||
} // endif's
|
|||
|
|||
((PTDBDOS)tdbp)->SetTxfp(txfp); |
|||
} // endif Txfp
|
|||
|
|||
if (Multiple) |
|||
tdbp = new(g) TDBMUL(tdbp); |
|||
|
|||
return tdbp; |
|||
} // end of GetTable
|
|||
|
|||
/* --------------------------- Class COLCRT -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* COLCRT Constructors. */ |
|||
/***********************************************************************/ |
|||
COLCRT::COLCRT(PSZ name) |
|||
{ |
|||
Next = NULL; |
|||
Name = name; |
|||
Desc = NULL; |
|||
Decode = NULL; |
|||
Fmt = NULL; |
|||
Offset = -1; |
|||
Long = -1; |
|||
Precision = -1; |
|||
Freq = -1; |
|||
Key = -1; |
|||
Scale = -1; |
|||
Opt = -1; |
|||
DataType = '*'; |
|||
} // end of COLCRT constructor for table creation
|
|||
|
|||
COLCRT::COLCRT(void) |
|||
{ |
|||
Next = NULL; |
|||
Name = NULL; |
|||
Desc = NULL; |
|||
Decode = NULL; |
|||
Fmt = NULL; |
|||
Offset = 0; |
|||
Long = 0; |
|||
Precision = 0; |
|||
Freq = 0; |
|||
Key = 0; |
|||
Scale = 0; |
|||
Opt = 0; |
|||
DataType = '*'; |
|||
} // end of COLCRT constructor for table & view definition
|
|||
|
|||
/* --------------------------- Class COLDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* COLDEF Constructor. */ |
|||
/***********************************************************************/ |
|||
COLDEF::COLDEF(void) : COLCRT() |
|||
{ |
|||
#if defined(BLK_INDX)
|
|||
To_Min = NULL; |
|||
To_Max = NULL; |
|||
To_Pos = NULL; |
|||
Xdb2 = FALSE; |
|||
To_Bmap = NULL; |
|||
To_Dval = NULL; |
|||
Ndv = 0; |
|||
Nbm = 0; |
|||
#endif // BLK_INDX
|
|||
Buf_Type = TYPE_ERROR; |
|||
Clen = 0; |
|||
Poff = 0; |
|||
memset(&F, 0, sizeof(FORMAT)); |
|||
Flags = 0; |
|||
} // end of COLDEF constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* Define: initialize a column definition from a COLINFO structure. */ |
|||
/***********************************************************************/ |
|||
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) |
|||
{ |
|||
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1); |
|||
strcpy(Name, cfp->Name); |
|||
|
|||
if (!(cfp->Flags & U_SPECIAL)) { |
|||
Poff = poff; |
|||
Buf_Type = cfp->Type; |
|||
|
|||
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) { |
|||
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name); |
|||
return -1; |
|||
} // endswitch
|
|||
|
|||
strcpy(F.Type, GetFormatType(Buf_Type)); |
|||
F.Length = cfp->Length; |
|||
F.Prec = cfp->Scale; |
|||
Offset = (cfp->Offset < 0) ? poff : cfp->Offset; |
|||
Precision = cfp->Precision; |
|||
Scale = cfp->Scale; |
|||
Long = cfp->Length; |
|||
Opt = cfp->Opt; |
|||
Key = cfp->Key; |
|||
Freq = cfp->Freq; |
|||
|
|||
if (cfp->Remark && *cfp->Remark) { |
|||
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1); |
|||
strcpy(Desc, cfp->Remark); |
|||
} // endif Remark
|
|||
|
|||
if (cfp->Datefmt) { |
|||
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1); |
|||
strcpy(Decode, cfp->Datefmt); |
|||
} // endif Datefmt
|
|||
|
|||
} // endif special
|
|||
|
|||
if (cfp->Fieldfmt) { |
|||
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1); |
|||
strcpy(Fmt, cfp->Fieldfmt); |
|||
} // endif Fieldfmt
|
|||
|
|||
Flags = cfp->Flags; |
|||
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long; |
|||
} // end of Define
|
|||
|
|||
/* ------------------------- End of RelDef --------------------------- */ |
|||
/************* RelDef CPP Program Source Code File (.CPP) **************/ |
|||
/* PROGRAM NAME: REFDEF */ |
|||
/* ------------- */ |
|||
/* Version 1.4 */ |
|||
/* */ |
|||
/* COPYRIGHT: */ |
|||
/* ---------- */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ |
|||
/* */ |
|||
/* WHAT THIS PROGRAM DOES: */ |
|||
/* ----------------------- */ |
|||
/* This program are the DB definition related routines. */ |
|||
/* */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include relevant MariaDB header file. */ |
|||
/***********************************************************************/ |
|||
#include "my_global.h"
|
|||
#if defined(WIN32)
|
|||
#include <sqlext.h>
|
|||
#else
|
|||
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
|
|||
#include "osutil.h"
|
|||
//#include "sqlext.h"
|
|||
#endif
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include application header files */ |
|||
/* */ |
|||
/* global.h is header containing all global declarations. */ |
|||
/* plgdbsem.h is header containing DB application declarations. */ |
|||
/* catalog.h is header containing DB description declarations. */ |
|||
/***********************************************************************/ |
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "mycat.h"
|
|||
#include "reldef.h"
|
|||
#include "colblk.h"
|
|||
#include "filamap.h"
|
|||
#include "filamfix.h"
|
|||
#include "filamvct.h"
|
|||
#if defined(ZIP_SUPPORT)
|
|||
#include "filamzip.h"
|
|||
#endif // ZIP_SUPPORT
|
|||
#include "tabdos.h"
|
|||
#include "valblk.h"
|
|||
#include "tabmul.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* External static variables. */ |
|||
/***********************************************************************/ |
|||
//extern "C" char plgini[];
|
|||
|
|||
/* --------------------------- Class RELDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* RELDEF Constructor. */ |
|||
/***********************************************************************/ |
|||
RELDEF::RELDEF(void) |
|||
{ |
|||
Next = NULL; |
|||
To_Cols = NULL; |
|||
Name = NULL; |
|||
Database = NULL; |
|||
Cat = NULL; |
|||
} // end of RELDEF constructor
|
|||
|
|||
/* --------------------------- Class TABDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* TABDEF Constructor. */ |
|||
/***********************************************************************/ |
|||
TABDEF::TABDEF(void) |
|||
{ |
|||
Schema = NULL; |
|||
Desc = NULL; |
|||
Catfunc = FNC_NO; |
|||
Card = 0; |
|||
Elemt = 0; |
|||
Sort = 0; |
|||
Multiple = 0; |
|||
Degree = 0; |
|||
Pseudo = 0; |
|||
Read_Only = false; |
|||
} // end of TABDEF constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* Define: initialize the table definition block from XDB file. */ |
|||
/***********************************************************************/ |
|||
bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) |
|||
{ |
|||
int poff = 0; |
|||
|
|||
Name = (PSZ)PlugSubAlloc(g, NULL, strlen(name) + 1); |
|||
strcpy(Name, name); |
|||
Cat = cat; |
|||
Catfunc = GetFuncID(Cat->GetStringCatInfo(g, "Catfunc", NULL)); |
|||
Elemt = cat->GetIntCatInfo("Elements", 0); |
|||
Multiple = cat->GetIntCatInfo("Multiple", 0); |
|||
Degree = cat->GetIntCatInfo("Degree", 0); |
|||
Read_Only = cat->GetBoolCatInfo("ReadOnly", false); |
|||
const char *data_charset_name= cat->GetStringCatInfo(g, "Data_charset", NULL); |
|||
m_data_charset= data_charset_name ? |
|||
get_charset_by_csname(data_charset_name, MY_CS_PRIMARY, 0): |
|||
NULL; |
|||
|
|||
// Get The column definitions
|
|||
if ((poff = cat->GetColCatInfo(g, this)) < 0) |
|||
return true; |
|||
|
|||
// Do the definition of AM specific fields
|
|||
return DefineAM(g, am, poff); |
|||
} // end of Define
|
|||
|
|||
/* --------------------------- Class OEMDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* GetXdef: get the external TABDEF from OEM module. */ |
|||
/***********************************************************************/ |
|||
PTABDEF OEMDEF::GetXdef(PGLOBAL g) |
|||
{ |
|||
typedef PTABDEF (__stdcall *XGETDEF) (PGLOBAL, void *); |
|||
char c, getname[40] = "Get"; |
|||
PTABDEF xdefp; |
|||
XGETDEF getdef = NULL; |
|||
PCATLG cat = Cat; |
|||
|
|||
#if defined(WIN32)
|
|||
// Is the DLL already loaded?
|
|||
if (!Hdll && !(Hdll = GetModuleHandle(Module))) |
|||
// No, load the Dll implementing the function
|
|||
if (!(Hdll = LoadLibrary(Module))) { |
|||
char buf[256]; |
|||
DWORD rc = GetLastError(); |
|||
|
|||
sprintf(g->Message, MSG(DLL_LOAD_ERROR), rc, Module); |
|||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | |
|||
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, |
|||
(LPTSTR)buf, sizeof(buf), NULL); |
|||
strcat(strcat(g->Message, ": "), buf); |
|||
return NULL; |
|||
} // endif hDll
|
|||
|
|||
// The exported name is always in uppercase
|
|||
for (int i = 0; ; i++) { |
|||
c = Subtype[i]; |
|||
getname[i + 3] = toupper(c); |
|||
if (!c) break; |
|||
} // endfor i
|
|||
|
|||
// Get the function returning an instance of the external DEF class
|
|||
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) { |
|||
sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname); |
|||
FreeLibrary((HMODULE)Hdll); |
|||
return NULL; |
|||
} // endif getdef
|
|||
#else // !WIN32
|
|||
const char *error = NULL; |
|||
// Is the library already loaded?
|
|||
// if (!Hdll && !(Hdll = ???))
|
|||
// Load the desired shared library
|
|||
if (!(Hdll = dlopen(Module, RTLD_LAZY))) { |
|||
error = dlerror(); |
|||
sprintf(g->Message, MSG(SHARED_LIB_ERR), Module, SVP(error)); |
|||
return NULL; |
|||
} // endif Hdll
|
|||
|
|||
// The exported name is always in uppercase
|
|||
for (int i = 0; ; i++) { |
|||
c = Subtype[i]; |
|||
getname[i + 3] = toupper(c); |
|||
if (!c) break; |
|||
} // endfor i
|
|||
|
|||
// Get the function returning an instance of the external DEF class
|
|||
if (!(getdef = (XGETDEF)dlsym(Hdll, getname))) { |
|||
error = dlerror(); |
|||
sprintf(g->Message, MSG(GET_FUNC_ERR), getname, SVP(error)); |
|||
dlclose(Hdll); |
|||
return NULL; |
|||
} // endif getdef
|
|||
#endif // !WIN32
|
|||
|
|||
// Just in case the external Get function does not set error messages
|
|||
sprintf(g->Message, MSG(DEF_ALLOC_ERROR), Subtype); |
|||
|
|||
// Get the table definition block
|
|||
if (!(xdefp = getdef(g, NULL))) |
|||
return NULL; |
|||
|
|||
// Have the external class do its complete definition
|
|||
if (!cat->Cbuf) { |
|||
// Suballocate a temporary buffer for the entire column section
|
|||
cat->Cblen = cat->GetSizeCatInfo("Colsize", "8K"); |
|||
cat->Cbuf = (char*)PlugSubAlloc(g, NULL, cat->Cblen); |
|||
} // endif Cbuf
|
|||
|
|||
// Here "OEM" should be replace by a more useful value
|
|||
if (xdefp->Define(g, cat, Name, "OEM")) |
|||
return NULL; |
|||
|
|||
// Ok, return external block
|
|||
return xdefp; |
|||
} // end of GetXdef
|
|||
|
|||
#if 0
|
|||
/***********************************************************************/ |
|||
/* DeleteTableFile: Delete an OEM table file if applicable. */ |
|||
/***********************************************************************/ |
|||
bool OEMDEF::DeleteTableFile(PGLOBAL g) |
|||
{ |
|||
if (!Pxdef) |
|||
Pxdef = GetXdef(g); |
|||
|
|||
return (Pxdef) ? Pxdef->DeleteTableFile(g) : true; |
|||
} // end of DeleteTableFile
|
|||
#endif // 0
|
|||
|
|||
/***********************************************************************/ |
|||
/* Define: initialize the table definition block from XDB file. */ |
|||
/***********************************************************************/ |
|||
bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) |
|||
{ |
|||
Module = Cat->GetStringCatInfo(g, "Module", ""); |
|||
Subtype = Cat->GetStringCatInfo(g, "Subtype", Module); |
|||
|
|||
if (!*Module) |
|||
Module = Subtype; |
|||
|
|||
Desc = (char*)PlugSubAlloc(g, NULL, strlen(Module) |
|||
+ strlen(Subtype) + 3); |
|||
sprintf(Desc, "%s(%s)", Module, Subtype); |
|||
return false; |
|||
} // end of DefineAM
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetTable: makes a new Table Description Block. */ |
|||
/***********************************************************************/ |
|||
PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode) |
|||
{ |
|||
RECFM rfm; |
|||
PTDBASE tdbp = NULL; |
|||
|
|||
// If define block not here yet, get it now
|
|||
if (!Pxdef && !(Pxdef = GetXdef(g))) |
|||
return NULL; // Error
|
|||
|
|||
/*********************************************************************/ |
|||
/* Allocate a TDB of the proper type. */ |
|||
/* Column blocks will be allocated only when needed. */ |
|||
/*********************************************************************/ |
|||
if (!(tdbp = (PTDBASE)Pxdef->GetTable(g, mode))) |
|||
return NULL; |
|||
else |
|||
rfm = tdbp->GetFtype(); |
|||
|
|||
if (rfm == RECFM_NAF) |
|||
return tdbp; |
|||
else if (rfm == RECFM_OEM) { |
|||
if (Multiple) |
|||
tdbp = new(g) TDBMUL(tdbp); // No block optimization yet
|
|||
|
|||
return tdbp; |
|||
} // endif OEM
|
|||
|
|||
/*********************************************************************/ |
|||
/* The OEM table is based on a file type (currently DOS+ only) */ |
|||
/*********************************************************************/ |
|||
assert (rfm == RECFM_VAR || rfm == RECFM_FIX || |
|||
rfm == RECFM_BIN || rfm == RECFM_VCT); |
|||
|
|||
PTXF txfp = NULL; |
|||
PDOSDEF defp = (PDOSDEF)Pxdef; |
|||
bool map = defp->Mapped && mode != MODE_INSERT && |
|||
!(PlgGetUser(g)->UseTemp == TMP_FORCE && |
|||
(mode == MODE_UPDATE || mode == MODE_DELETE)); |
|||
int cmpr = defp->Compressed; |
|||
|
|||
/*********************************************************************/ |
|||
/* Allocate table and file processing class of the proper type. */ |
|||
/* Column blocks will be allocated only when needed. */ |
|||
/*********************************************************************/ |
|||
if (!((PTDBDOS)tdbp)->GetTxfp()) { |
|||
if (cmpr) { |
|||
#if defined(ZIP_SUPPORT)
|
|||
if (cmpr == 1) |
|||
txfp = new(g) ZIPFAM(defp); |
|||
else |
|||
txfp = new(g) ZLBFAM(defp); |
|||
#else // !ZIP_SUPPORT
|
|||
strcpy(g->Message, "Compress not supported"); |
|||
return NULL; |
|||
#endif // !ZIP_SUPPORT
|
|||
} else if (rfm == RECFM_VAR) { |
|||
if (map) |
|||
txfp = new(g) MAPFAM(defp); |
|||
else |
|||
txfp = new(g) DOSFAM(defp); |
|||
|
|||
} else if (rfm == RECFM_FIX || rfm == RECFM_BIN) { |
|||
if (map) |
|||
txfp = new(g) MPXFAM(defp); |
|||
else |
|||
txfp = new(g) FIXFAM(defp); |
|||
|
|||
} else if (rfm == RECFM_VCT) { |
|||
assert (Pxdef->GetDefType() == TYPE_AM_VCT); |
|||
|
|||
if (map) |
|||
txfp = new(g) VCMFAM((PVCTDEF)defp); |
|||
else |
|||
txfp = new(g) VCTFAM((PVCTDEF)defp); |
|||
|
|||
} // endif's
|
|||
|
|||
((PTDBDOS)tdbp)->SetTxfp(txfp); |
|||
} // endif Txfp
|
|||
|
|||
if (Multiple) |
|||
tdbp = new(g) TDBMUL(tdbp); |
|||
|
|||
return tdbp; |
|||
} // end of GetTable
|
|||
|
|||
/* --------------------------- Class COLCRT -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* COLCRT Constructors. */ |
|||
/***********************************************************************/ |
|||
COLCRT::COLCRT(PSZ name) |
|||
{ |
|||
Next = NULL; |
|||
Name = name; |
|||
Desc = NULL; |
|||
Decode = NULL; |
|||
Fmt = NULL; |
|||
Offset = -1; |
|||
Long = -1; |
|||
Precision = -1; |
|||
Freq = -1; |
|||
Key = -1; |
|||
Scale = -1; |
|||
Opt = -1; |
|||
DataType = '*'; |
|||
} // end of COLCRT constructor for table creation
|
|||
|
|||
COLCRT::COLCRT(void) |
|||
{ |
|||
Next = NULL; |
|||
Name = NULL; |
|||
Desc = NULL; |
|||
Decode = NULL; |
|||
Fmt = NULL; |
|||
Offset = 0; |
|||
Long = 0; |
|||
Precision = 0; |
|||
Freq = 0; |
|||
Key = 0; |
|||
Scale = 0; |
|||
Opt = 0; |
|||
DataType = '*'; |
|||
} // end of COLCRT constructor for table & view definition
|
|||
|
|||
/* --------------------------- Class COLDEF -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* COLDEF Constructor. */ |
|||
/***********************************************************************/ |
|||
COLDEF::COLDEF(void) : COLCRT() |
|||
{ |
|||
To_Min = NULL; |
|||
To_Max = NULL; |
|||
To_Pos = NULL; |
|||
Xdb2 = FALSE; |
|||
To_Bmap = NULL; |
|||
To_Dval = NULL; |
|||
Ndv = 0; |
|||
Nbm = 0; |
|||
Buf_Type = TYPE_ERROR; |
|||
Clen = 0; |
|||
Poff = 0; |
|||
memset(&F, 0, sizeof(FORMAT)); |
|||
Flags = 0; |
|||
} // end of COLDEF constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* Define: initialize a column definition from a COLINFO structure. */ |
|||
/***********************************************************************/ |
|||
int COLDEF::Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff) |
|||
{ |
|||
Name = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Name) + 1); |
|||
strcpy(Name, cfp->Name); |
|||
|
|||
if (!(cfp->Flags & U_SPECIAL)) { |
|||
Poff = poff; |
|||
Buf_Type = cfp->Type; |
|||
|
|||
if ((Clen = GetTypeSize(Buf_Type, cfp->Length)) <= 0) { |
|||
sprintf(g->Message, MSG(BAD_COL_TYPE), GetTypeName(Buf_Type), Name); |
|||
return -1; |
|||
} // endswitch
|
|||
|
|||
strcpy(F.Type, GetFormatType(Buf_Type)); |
|||
F.Length = cfp->Length; |
|||
F.Prec = cfp->Scale; |
|||
Offset = (cfp->Offset < 0) ? poff : cfp->Offset; |
|||
Precision = cfp->Precision; |
|||
Scale = cfp->Scale; |
|||
Long = cfp->Length; |
|||
Opt = cfp->Opt; |
|||
Key = cfp->Key; |
|||
Freq = cfp->Freq; |
|||
|
|||
if (cfp->Remark && *cfp->Remark) { |
|||
Desc = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Remark) + 1); |
|||
strcpy(Desc, cfp->Remark); |
|||
} // endif Remark
|
|||
|
|||
if (cfp->Datefmt) { |
|||
Decode = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Datefmt) + 1); |
|||
strcpy(Decode, cfp->Datefmt); |
|||
} // endif Datefmt
|
|||
|
|||
} // endif special
|
|||
|
|||
if (cfp->Fieldfmt) { |
|||
Fmt = (PSZ)PlugSubAlloc(g, memp, strlen(cfp->Fieldfmt) + 1); |
|||
strcpy(Fmt, cfp->Fieldfmt); |
|||
} // endif Fieldfmt
|
|||
|
|||
Flags = cfp->Flags; |
|||
return (Flags & (U_VIRTUAL|U_SPECIAL)) ? 0 : Long; |
|||
} // end of Define
|
|||
|
|||
/* ------------------------- End of RelDef --------------------------- */ |
|||
@ -1,231 +1,225 @@ |
|||
/*************** RelDef H Declares Source Code File (.H) ***************/ |
|||
/* Name: RELDEF.H Version 1.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2004-2012 */ |
|||
/* */ |
|||
/* This file contains the DEF classes definitions. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __RELDEF_H |
|||
#define __RELDEF_H |
|||
|
|||
#include "block.h" |
|||
#include "catalog.h" |
|||
#include "my_sys.h" |
|||
|
|||
typedef class INDEXDEF *PIXDEF; |
|||
|
|||
/***********************************************************************/ |
|||
/* Table or View (relation) definition block. */ |
|||
/***********************************************************************/ |
|||
class DllExport RELDEF : public BLOCK { // Relation definition block |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
public: |
|||
RELDEF(void); // Constructor |
|||
|
|||
// Implementation |
|||
PRELDEF GetNext(void) {return Next;} |
|||
PSZ GetName(void) {return Name;} |
|||
PSZ GetDB(void) {return (PSZ)Database;} |
|||
PCOLDEF GetCols(void) {return To_Cols;} |
|||
void SetCols(PCOLDEF pcd) {To_Cols = pcd;} |
|||
PCATLG GetCat(void) {return Cat;} |
|||
virtual const char *GetType(void) = 0; |
|||
virtual AMT GetDefType(void) = 0; |
|||
void SetName(const char *str) { Name=(char*)str; } |
|||
void SetCat(PCATLG cat) { Cat=cat; } |
|||
|
|||
// Methods |
|||
//virtual bool DeleteTableFile(PGLOBAL g) {return true;} |
|||
virtual bool Indexable(void) {return false;} |
|||
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0; |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0; |
|||
|
|||
protected: |
|||
PRELDEF Next; /* To next definition block */ |
|||
PSZ Name; /* Name of the view */ |
|||
LPCSTR Database; /* Table database */ |
|||
PCOLDEF To_Cols; /* To a list of column desc */ |
|||
PCATLG Cat; /* To DB catalog info */ |
|||
}; // end of RELDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* 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. */ |
|||
/***********************************************************************/ |
|||
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */ |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
public: |
|||
// Constructor |
|||
TABDEF(void); // Constructor |
|||
|
|||
// Implementation |
|||
int GetDegree(void) {return Degree;} |
|||
void SetDegree(int d) {Degree = d;} |
|||
int GetElemt(void) {return Elemt;} |
|||
void SetNext(PTABDEF tdfp) {Next = tdfp;} |
|||
int GetMultiple(void) {return Multiple;} |
|||
int GetPseudo(void) {return Pseudo;} |
|||
PSZ GetPath(void) |
|||
{return (Database) ? (PSZ)Database : Cat->GetDataPath();} |
|||
bool SepIndex(void) {return Cat->GetBoolCatInfo("SepIndex", false);} |
|||
bool IsReadOnly(void) {return Read_Only;} |
|||
virtual AMT GetDefType(void) {return TYPE_AM_TAB;} |
|||
virtual PIXDEF GetIndx(void) {return NULL;} |
|||
virtual void SetIndx(PIXDEF xp) {} |
|||
virtual bool IsHuge(void) {return false;} |
|||
const CHARSET_INFO *data_charset() {return m_data_charset;} |
|||
|
|||
// Methods |
|||
bool DropTable(PGLOBAL g, PSZ name); |
|||
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am); |
|||
virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0; |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ Schema; /* Table schema (for ODBC) */ |
|||
PSZ Desc; /* Table description */ |
|||
uint Catfunc; /* Catalog function ID */ |
|||
int Card; /* (max) number of rows in table */ |
|||
int Elemt; /* Number of rows in blocks or rowset */ |
|||
int Sort; /* Table already sorted ??? */ |
|||
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */ |
|||
int Degree; /* Number of columns in the table */ |
|||
int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */ |
|||
bool Read_Only; /* true for read only tables */ |
|||
const CHARSET_INFO *m_data_charset; |
|||
}; // end of TABDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* Externally defined OEM tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport OEMDEF : public TABDEF { /* OEM table */ |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
public: |
|||
// Constructor |
|||
OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;} |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "OEM";} |
|||
virtual AMT GetDefType(void) {return TYPE_AM_OEM;} |
|||
|
|||
// Methods |
|||
//virtual bool DeleteTableFile(PGLOBAL g); |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
|
|||
protected: |
|||
PTABDEF GetXdef(PGLOBAL g); |
|||
|
|||
// Members |
|||
#if defined(WIN32) |
|||
HANDLE Hdll; /* Handle to the external DLL */ |
|||
#else // !WIN32 |
|||
void *Hdll; /* Handle for the loaded shared library */ |
|||
#endif // !WIN32 |
|||
PTABDEF Pxdef; /* Pointer to the external TABDEF class */ |
|||
char *Module; /* Path/Name of the DLL implenting it */ |
|||
char *Subtype; /* The name of the OEM table sub type */ |
|||
}; // end of OEMDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* Column definition block used during creation. */ |
|||
/***********************************************************************/ |
|||
class DllExport COLCRT : public BLOCK { /* Column description block */ |
|||
friend class TABDEF; |
|||
public: |
|||
COLCRT(PSZ name); // Constructor |
|||
COLCRT(void); // Constructor (for views) |
|||
|
|||
// Implementation |
|||
PSZ GetName(void) {return Name;} |
|||
PSZ GetDecode(void) {return Decode;} |
|||
PSZ GetFmt(void) {return Fmt;} |
|||
int GetOpt(void) {return Opt;} |
|||
int GetFreq(void) {return Freq;} |
|||
int GetLong(void) {return Long;} |
|||
int GetPrecision(void) {return Precision;} |
|||
int GetOffset(void) {return Offset;} |
|||
void SetOffset(int offset) {Offset = offset;} |
|||
|
|||
protected: |
|||
PCOLCRT Next; /* To next block */ |
|||
PSZ Name; /* Column name */ |
|||
PSZ Desc; /* Column description */ |
|||
PSZ Decode; /* Date format */ |
|||
PSZ Fmt; /* Input format for formatted files */ |
|||
int Offset; /* Offset of field within record */ |
|||
int Long; /* Length of field in file record (!BIN) */ |
|||
int Key; /* Key (greater than 1 if multiple) */ |
|||
int Precision; /* Logical column length */ |
|||
int Scale; /* Decimals for float/decimal values */ |
|||
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */ |
|||
int Freq; /* Estimated number of different values */ |
|||
char DataType; /* Internal data type (C, N, F, T) */ |
|||
}; // end of COLCRT |
|||
|
|||
/***********************************************************************/ |
|||
/* Column definition block. */ |
|||
/***********************************************************************/ |
|||
class DllExport COLDEF : public COLCRT { /* Column description block */ |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
friend class COLBLK; |
|||
friend class DBFFAM; |
|||
friend class TDBASE; |
|||
public: |
|||
COLDEF(void); // Constructor |
|||
|
|||
// Implementation |
|||
PCOLDEF GetNext(void) {return (PCOLDEF)Next;} |
|||
void SetNext(PCOLDEF pcdf) {Next = pcdf;} |
|||
int GetLength(void) {return (int)F.Length;} |
|||
int GetClen(void) {return Clen;} |
|||
int GetType(void) {return Buf_Type;} |
|||
int GetPoff(void) {return Poff;} |
|||
#if defined(BLK_INDX) |
|||
void *GetMin(void) {return To_Min;} |
|||
void SetMin(void *minp) {To_Min = minp;} |
|||
void *GetMax(void) {return To_Max;} |
|||
void SetMax(void *maxp) {To_Max = maxp;} |
|||
bool GetXdb2(void) {return Xdb2;} |
|||
void SetXdb2(bool b) {Xdb2 = b;} |
|||
void *GetBmap(void) {return To_Bmap;} |
|||
void SetBmap(void *bmp) {To_Bmap = bmp;} |
|||
void *GetDval(void) {return To_Dval;} |
|||
void SetDval(void *dvp) {To_Dval = dvp;} |
|||
int GetNdv(void) {return Ndv;} |
|||
void SetNdv(int ndv) {Ndv = ndv;} |
|||
int GetNbm(void) {return Nbm;} |
|||
void SetNbm(int nbm) {Nbm = nbm;} |
|||
#endif // BLK_INDX |
|||
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff); |
|||
void Define(PGLOBAL g, PCOL colp); |
|||
|
|||
protected: |
|||
#if defined(BLK_INDX) |
|||
void *To_Min; /* Point to array of block min values */ |
|||
void *To_Max; /* Point to array of block max values */ |
|||
int *To_Pos; /* Point to array of block positions */ |
|||
bool Xdb2; /* TRUE if to be optimized by XDB2 */ |
|||
void *To_Bmap; /* To array of block bitmap values */ |
|||
void *To_Dval; /* To array of column distinct values */ |
|||
int Ndv; /* Number of distinct values */ |
|||
int Nbm; /* Number of ULONG in bitmap (XDB2) */ |
|||
#endif // BLK_INDX |
|||
int Buf_Type; /* Internal data type */ |
|||
int Clen; /* Internal data size in chars (bytes) */ |
|||
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 |
|||
|
|||
/*************** RelDef H Declares Source Code File (.H) ***************/ |
|||
/* Name: RELDEF.H Version 1.4 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2004-2014 */ |
|||
/* */ |
|||
/* This file contains the DEF classes definitions. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __RELDEF_H |
|||
#define __RELDEF_H |
|||
|
|||
#include "block.h" |
|||
#include "catalog.h" |
|||
#include "my_sys.h" |
|||
|
|||
typedef class INDEXDEF *PIXDEF; |
|||
|
|||
/***********************************************************************/ |
|||
/* Table or View (relation) definition block. */ |
|||
/***********************************************************************/ |
|||
class DllExport RELDEF : public BLOCK { // Relation definition block |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
public: |
|||
RELDEF(void); // Constructor |
|||
|
|||
// Implementation |
|||
PRELDEF GetNext(void) {return Next;} |
|||
PSZ GetName(void) {return Name;} |
|||
PSZ GetDB(void) {return (PSZ)Database;} |
|||
PCOLDEF GetCols(void) {return To_Cols;} |
|||
void SetCols(PCOLDEF pcd) {To_Cols = pcd;} |
|||
PCATLG GetCat(void) {return Cat;} |
|||
virtual const char *GetType(void) = 0; |
|||
virtual AMT GetDefType(void) = 0; |
|||
void SetName(const char *str) { Name=(char*)str; } |
|||
void SetCat(PCATLG cat) { Cat=cat; } |
|||
|
|||
// Methods |
|||
virtual bool Indexable(void) {return false;} |
|||
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0; |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0; |
|||
|
|||
protected: |
|||
PRELDEF Next; /* To next definition block */ |
|||
PSZ Name; /* Name of the view */ |
|||
LPCSTR Database; /* Table database */ |
|||
PCOLDEF To_Cols; /* To a list of column desc */ |
|||
PCATLG Cat; /* To DB catalog info */ |
|||
}; // end of RELDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* 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. */ |
|||
/***********************************************************************/ |
|||
class DllExport TABDEF : public RELDEF { /* Logical table descriptor */ |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
public: |
|||
// Constructor |
|||
TABDEF(void); // Constructor |
|||
|
|||
// Implementation |
|||
int GetDegree(void) {return Degree;} |
|||
void SetDegree(int d) {Degree = d;} |
|||
int GetElemt(void) {return Elemt;} |
|||
void SetNext(PTABDEF tdfp) {Next = tdfp;} |
|||
int GetMultiple(void) {return Multiple;} |
|||
int GetPseudo(void) {return Pseudo;} |
|||
PSZ GetPath(void) |
|||
{return (Database) ? (PSZ)Database : Cat->GetDataPath();} |
|||
bool SepIndex(void) {return Cat->GetBoolCatInfo("SepIndex", false);} |
|||
bool IsReadOnly(void) {return Read_Only;} |
|||
virtual AMT GetDefType(void) {return TYPE_AM_TAB;} |
|||
virtual PIXDEF GetIndx(void) {return NULL;} |
|||
virtual void SetIndx(PIXDEF xp) {} |
|||
virtual bool IsHuge(void) {return false;} |
|||
const CHARSET_INFO *data_charset() {return m_data_charset;} |
|||
|
|||
// Methods |
|||
bool DropTable(PGLOBAL g, PSZ name); |
|||
virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am); |
|||
virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0; |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ Schema; /* Table schema (for ODBC) */ |
|||
PSZ Desc; /* Table description */ |
|||
uint Catfunc; /* Catalog function ID */ |
|||
int Card; /* (max) number of rows in table */ |
|||
int Elemt; /* Number of rows in blocks or rowset */ |
|||
int Sort; /* Table already sorted ??? */ |
|||
int Multiple; /* 0: No 1: DIR 2: Section 3: filelist */ |
|||
int Degree; /* Number of columns in the table */ |
|||
int Pseudo; /* Bit: 1 ROWID Ok, 2 FILEID Ok */ |
|||
bool Read_Only; /* true for read only tables */ |
|||
const CHARSET_INFO *m_data_charset; |
|||
}; // end of TABDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* Externally defined OEM tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport OEMDEF : public TABDEF { /* OEM table */ |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
public: |
|||
// Constructor |
|||
OEMDEF(void) {Hdll = NULL; Pxdef = NULL; Module = Subtype = NULL;} |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "OEM";} |
|||
virtual AMT GetDefType(void) {return TYPE_AM_OEM;} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
|
|||
protected: |
|||
PTABDEF GetXdef(PGLOBAL g); |
|||
|
|||
// Members |
|||
#if defined(WIN32) |
|||
HANDLE Hdll; /* Handle to the external DLL */ |
|||
#else // !WIN32 |
|||
void *Hdll; /* Handle for the loaded shared library */ |
|||
#endif // !WIN32 |
|||
PTABDEF Pxdef; /* Pointer to the external TABDEF class */ |
|||
char *Module; /* Path/Name of the DLL implenting it */ |
|||
char *Subtype; /* The name of the OEM table sub type */ |
|||
}; // end of OEMDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* Column definition block used during creation. */ |
|||
/***********************************************************************/ |
|||
class DllExport COLCRT : public BLOCK { /* Column description block */ |
|||
friend class TABDEF; |
|||
public: |
|||
COLCRT(PSZ name); // Constructor |
|||
COLCRT(void); // Constructor (for views) |
|||
|
|||
// Implementation |
|||
PSZ GetName(void) {return Name;} |
|||
PSZ GetDecode(void) {return Decode;} |
|||
PSZ GetFmt(void) {return Fmt;} |
|||
int GetOpt(void) {return Opt;} |
|||
int GetFreq(void) {return Freq;} |
|||
int GetLong(void) {return Long;} |
|||
int GetPrecision(void) {return Precision;} |
|||
int GetOffset(void) {return Offset;} |
|||
void SetOffset(int offset) {Offset = offset;} |
|||
|
|||
protected: |
|||
PCOLCRT Next; /* To next block */ |
|||
PSZ Name; /* Column name */ |
|||
PSZ Desc; /* Column description */ |
|||
PSZ Decode; /* Date format */ |
|||
PSZ Fmt; /* Input format for formatted files */ |
|||
int Offset; /* Offset of field within record */ |
|||
int Long; /* Length of field in file record (!BIN) */ |
|||
int Key; /* Key (greater than 1 if multiple) */ |
|||
int Precision; /* Logical column length */ |
|||
int Scale; /* Decimals for float/decimal values */ |
|||
int Opt; /* 0:Not 1:clustered 2:sorted-asc 3:desc */ |
|||
int Freq; /* Estimated number of different values */ |
|||
char DataType; /* Internal data type (C, N, F, T) */ |
|||
}; // end of COLCRT |
|||
|
|||
/***********************************************************************/ |
|||
/* Column definition block. */ |
|||
/***********************************************************************/ |
|||
class DllExport COLDEF : public COLCRT { /* Column description block */ |
|||
friend class CATALOG; |
|||
friend class PLUGCAT; |
|||
friend class MYCAT; |
|||
friend class COLBLK; |
|||
friend class DBFFAM; |
|||
friend class TDBASE; |
|||
public: |
|||
COLDEF(void); // Constructor |
|||
|
|||
// Implementation |
|||
PCOLDEF GetNext(void) {return (PCOLDEF)Next;} |
|||
void SetNext(PCOLDEF pcdf) {Next = pcdf;} |
|||
int GetLength(void) {return (int)F.Length;} |
|||
int GetClen(void) {return Clen;} |
|||
int GetType(void) {return Buf_Type;} |
|||
int GetPoff(void) {return Poff;} |
|||
void *GetMin(void) {return To_Min;} |
|||
void SetMin(void *minp) {To_Min = minp;} |
|||
void *GetMax(void) {return To_Max;} |
|||
void SetMax(void *maxp) {To_Max = maxp;} |
|||
bool GetXdb2(void) {return Xdb2;} |
|||
void SetXdb2(bool b) {Xdb2 = b;} |
|||
void *GetBmap(void) {return To_Bmap;} |
|||
void SetBmap(void *bmp) {To_Bmap = bmp;} |
|||
void *GetDval(void) {return To_Dval;} |
|||
void SetDval(void *dvp) {To_Dval = dvp;} |
|||
int GetNdv(void) {return Ndv;} |
|||
void SetNdv(int ndv) {Ndv = ndv;} |
|||
int GetNbm(void) {return Nbm;} |
|||
void SetNbm(int nbm) {Nbm = nbm;} |
|||
int Define(PGLOBAL g, void *memp, PCOLINFO cfp, int poff); |
|||
void Define(PGLOBAL g, PCOL colp); |
|||
|
|||
protected: |
|||
void *To_Min; /* Point to array of block min values */ |
|||
void *To_Max; /* Point to array of block max values */ |
|||
int *To_Pos; /* Point to array of block positions */ |
|||
bool Xdb2; /* TRUE if to be optimized by XDB2 */ |
|||
void *To_Bmap; /* To array of block bitmap values */ |
|||
void *To_Dval; /* To array of column distinct values */ |
|||
int Ndv; /* Number of distinct values */ |
|||
int Nbm; /* Number of ULONG in bitmap (XDB2) */ |
|||
int Buf_Type; /* Internal data type */ |
|||
int Clen; /* Internal data size in chars (bytes) */ |
|||
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 |
|||
|
|||
5289
storage/connect/tabdos.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,286 +1,253 @@ |
|||
/*************** TabDos H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABDOS.H Version 3.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ |
|||
/* */ |
|||
/* This file contains the DOS classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __TABDOS_H |
|||
#define __TABDOS_H |
|||
|
|||
#include "xtable.h" // Table base class declares |
|||
#include "colblk.h" // Column base class declares |
|||
#include "xindex.h" |
|||
#if defined(BLK_INDX) |
|||
#include "filter.h" |
|||
#endif // BLK_INDX |
|||
|
|||
//pedef struct _tabdesc *PTABD; // For friend setting |
|||
typedef class TXTFAM *PTXF; |
|||
#if defined(BLK_INDX) |
|||
typedef class BLOCKFILTER *PBF; |
|||
typedef class BLOCKINDEX *PBX; |
|||
#endif // BLK_INDX |
|||
|
|||
/***********************************************************************/ |
|||
/* DOS table. */ |
|||
/***********************************************************************/ |
|||
class DllExport DOSDEF : public TABDEF { /* Logical table description */ |
|||
friend class OEMDEF; |
|||
friend class TDBDOS; |
|||
friend class TDBFIX; |
|||
friend class TXTFAM; |
|||
friend class DBFBASE; |
|||
public: |
|||
// Constructor |
|||
DOSDEF(void); |
|||
|
|||
// Implementation |
|||
virtual AMT GetDefType(void) {return TYPE_AM_DOS;} |
|||
virtual const char *GetType(void) {return "DOS";} |
|||
virtual PIXDEF GetIndx(void) {return To_Indx;} |
|||
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;} |
|||
virtual bool IsHuge(void) {return Huge;} |
|||
PSZ GetFn(void) {return Fn;} |
|||
PSZ GetOfn(void) {return Ofn;} |
|||
void SetBlock(int block) {Block = block;} |
|||
int GetBlock(void) {return Block;} |
|||
int GetLast(void) {return Last;} |
|||
void SetLast(int last) {Last = last;} |
|||
int GetLrecl(void) {return Lrecl;} |
|||
void SetLrecl(int lrecl) {Lrecl = lrecl;} |
|||
bool GetPadded(void) {return Padded;} |
|||
bool GetEof(void) {return Eof;} |
|||
int GetBlksize(void) {return Blksize;} |
|||
int GetEnding(void) {return Ending;} |
|||
#if defined(BLK_INDX) |
|||
bool IsOptimized(void) {return (Optimized == 1);} |
|||
void SetOptimized(int opt) {Optimized = opt;} |
|||
void SetAllocBlks(int blks) {AllocBlks = blks;} |
|||
int GetAllocBlks(void) {return AllocBlks;} |
|||
int *GetTo_Pos(void) {return To_Pos;} |
|||
#endif // BLK_INDX |
|||
|
|||
// Methods |
|||
//virtual bool DeleteTableFile(PGLOBAL g); |
|||
virtual bool Indexable(void) {return Compressed != 1;} |
|||
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf); |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
bool InvalidateIndex(PGLOBAL g); |
|||
#if defined(BLK_INDX) |
|||
bool GetOptFileName(PGLOBAL g, char *filename); |
|||
void RemoveOptValues(PGLOBAL g); |
|||
#endif // BLK_INDX |
|||
|
|||
protected: |
|||
//virtual bool Erase(char *filename); |
|||
|
|||
// Members |
|||
PSZ Fn; /* Path/Name of corresponding file */ |
|||
PSZ Ofn; /* Base Path/Name of matching index files*/ |
|||
PIXDEF To_Indx; /* To index definitions blocks */ |
|||
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */ |
|||
bool Mapped; /* 0: disk file, 1: memory mapped file */ |
|||
bool Padded; /* true for padded table file */ |
|||
bool Huge; /* true for files larger than 2GB */ |
|||
bool Accept; /* true if wrong lines are accepted (DBF)*/ |
|||
bool Eof; /* true if an EOF (0xA) character exists */ |
|||
#if defined(BLK_INDX) |
|||
int *To_Pos; /* To array of block starting positions */ |
|||
int Optimized; /* 0: No, 1:Yes, 2:Redo optimization */ |
|||
int AllocBlks; /* Number of suballocated opt blocks */ |
|||
#endif // BLK_INDX |
|||
int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */ |
|||
int Lrecl; /* Size of biggest record */ |
|||
int AvgLen; /* Average size of records */ |
|||
int Block; /* Number de blocks of FIX/VCT tables */ |
|||
int Last; /* Number of elements of last block */ |
|||
int Blksize; /* Size of padded blocks */ |
|||
int Maxerr; /* Maximum number of bad records (DBF) */ |
|||
int ReadMode; /* Specific to DBF */ |
|||
int Ending; /* Length of end of lines */ |
|||
}; // end of DOSDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* that are standard files with columns starting at fixed offset. */ |
|||
/* The last column (and record) is of variable length. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBDOS : public TDBASE { |
|||
//friend class KINDEX; |
|||
friend class XINDEX; |
|||
friend class DOSCOL; |
|||
friend class MAPCOL; |
|||
friend class TXTFAM; |
|||
friend class DOSFAM; |
|||
friend class VCTCOL; |
|||
//friend class TDBMUL; |
|||
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool); |
|||
public: |
|||
// Constructors |
|||
TDBDOS(PDOSDEF tdp, PTXF txfp); |
|||
TDBDOS(PGLOBAL g, PTDBDOS tdbp); |
|||
|
|||
// Inline functions |
|||
inline void SetTxfp(PTXF txfp) {Txfp = txfp; Txfp->SetTdbp(this);} |
|||
inline PTXF GetTxfp(void) {return Txfp;} |
|||
inline char *GetLine(void) {return To_Line;} |
|||
inline int GetCurBlk(void) {return Txfp->GetCurBlk();} |
|||
inline void SetLine(char *toline) {To_Line = toline;} |
|||
inline void IncLine(int inc) {To_Line += inc;} |
|||
inline bool IsRead(void) {return Txfp->IsRead;} |
|||
inline PXOB *GetLink(void) {return To_Link;} |
|||
//inline PCOL *GetKeyCol(void) {return To_Key_Col;} |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return Txfp->GetAmType();} |
|||
virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;} |
|||
virtual RECFM GetFtype(void) {return Ftype;} |
|||
virtual bool SkipHeader(PGLOBAL g) {return false;} |
|||
virtual void RestoreNrec(void) {Txfp->SetNrec(1);} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBDOS(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual void ResetDB(void) {Txfp->Reset();} |
|||
virtual bool IsUsingTemp(PGLOBAL g); |
|||
//virtual bool NeedIndexing(PGLOBAL g); |
|||
virtual void ResetSize(void) {MaxSize = Cardinal = -1;} |
|||
virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox); |
|||
#if defined(BLK_INDX) |
|||
virtual int MakeBlockValues(PGLOBAL g); |
|||
virtual bool SaveBlockValues(PGLOBAL g); |
|||
virtual bool GetBlockValues(PGLOBAL g); |
|||
virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp); |
|||
//virtual PBX InitBlockIndex(PGLOBAL g); |
|||
virtual int TestBlock(PGLOBAL g); |
|||
#endif // BLK_INDX |
|||
virtual void PrintAM(FILE *f, char *m); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;} |
|||
virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);} |
|||
virtual int GetProgMax(PGLOBAL g); |
|||
virtual int GetProgCur(void); |
|||
virtual int GetAffectedRows(void) {return Txfp->GetDelRows();} |
|||
virtual int GetRecpos(void) {return Txfp->GetPos();} |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos) |
|||
{return Txfp->SetPos(g, recpos);} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);} |
|||
|
|||
// Specific routine |
|||
virtual int EstimatedLength(PGLOBAL g); |
|||
|
|||
// Optimization routines |
|||
int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); |
|||
#if defined(BLK_INDX) |
|||
void ResetBlockFilter(PGLOBAL g); |
|||
bool GetDistinctColumnValues(PGLOBAL g, int nrec); |
|||
|
|||
protected: |
|||
PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv); |
|||
#endif // BLK_INDX |
|||
|
|||
// Members |
|||
PTXF Txfp; // To the File access method class |
|||
#if defined(BLK_INDX) |
|||
//PBX To_BlkIdx; // To index test block |
|||
PBF To_BlkFil; // To evaluation block filter |
|||
PFIL SavFil; // Saved hidden filter |
|||
#endif // BLK_INDX |
|||
char *To_Line; // Points to current processed line |
|||
int Cardinal; // Table Cardinality |
|||
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT) |
|||
int Lrecl; // Logical Record Length |
|||
int AvgLen; // Logical Record Average Length |
|||
#if defined(BLK_INDX) |
|||
//int Xeval; // BlockTest return value |
|||
int Beval; // BlockEval return value |
|||
#endif // BLK_INDX |
|||
}; // end of class TDBDOS |
|||
|
|||
/***********************************************************************/ |
|||
/* Class DOSCOL: DOS access method column descriptor. */ |
|||
/* This A.M. is used for text file tables under operating systems */ |
|||
/* DOS, OS2, UNIX, WIN16 and WIN32. */ |
|||
/***********************************************************************/ |
|||
class DllExport DOSCOL : public COLBLK { |
|||
friend class TDBDOS; |
|||
friend class TDBFIX; |
|||
public: |
|||
// Constructors |
|||
DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "DOS"); |
|||
DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_DOS;} |
|||
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} |
|||
#if defined(BLK_INDX) |
|||
virtual int GetClustered(void) {return Clustered;} |
|||
virtual int IsClustered(void) {return (Clustered && |
|||
((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());} |
|||
virtual int IsSorted(void) {return Sorted;} |
|||
virtual PVBLK GetMin(void) {return Min;} |
|||
virtual PVBLK GetMax(void) {return Max;} |
|||
virtual int GetNdv(void) {return Ndv;} |
|||
virtual int GetNbm(void) {return Nbm;} |
|||
virtual PVBLK GetBmap(void) {return Bmap;} |
|||
virtual PVBLK GetDval(void) {return Dval;} |
|||
#endif // BLK_INDX |
|||
|
|||
// Methods |
|||
#if defined(BLK_INDX) |
|||
virtual bool VarSize(void); |
|||
#endif // BLK_INDX |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual void Print(PGLOBAL g, FILE *, uint); |
|||
|
|||
protected: |
|||
#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 |
|||
/*************** TabDos H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABDOS.H Version 3.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ |
|||
/* */ |
|||
/* This file contains the DOS classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __TABDOS_H |
|||
#define __TABDOS_H |
|||
|
|||
#include "xtable.h" // Table base class declares |
|||
#include "colblk.h" // Column base class declares |
|||
#include "xindex.h" |
|||
#include "filter.h" |
|||
|
|||
//pedef struct _tabdesc *PTABD; // For friend setting |
|||
typedef class TXTFAM *PTXF; |
|||
typedef class BLOCKFILTER *PBF; |
|||
typedef class BLOCKINDEX *PBX; |
|||
|
|||
/***********************************************************************/ |
|||
/* DOS table. */ |
|||
/***********************************************************************/ |
|||
class DllExport DOSDEF : public TABDEF { /* Logical table description */ |
|||
friend class OEMDEF; |
|||
friend class TDBDOS; |
|||
friend class TDBFIX; |
|||
friend class TXTFAM; |
|||
friend class DBFBASE; |
|||
public: |
|||
// Constructor |
|||
DOSDEF(void); |
|||
|
|||
// Implementation |
|||
virtual AMT GetDefType(void) {return TYPE_AM_DOS;} |
|||
virtual const char *GetType(void) {return "DOS";} |
|||
virtual PIXDEF GetIndx(void) {return To_Indx;} |
|||
virtual void SetIndx(PIXDEF xdp) {To_Indx = xdp;} |
|||
virtual bool IsHuge(void) {return Huge;} |
|||
PSZ GetFn(void) {return Fn;} |
|||
PSZ GetOfn(void) {return Ofn;} |
|||
void SetBlock(int block) {Block = block;} |
|||
int GetBlock(void) {return Block;} |
|||
int GetLast(void) {return Last;} |
|||
void SetLast(int last) {Last = last;} |
|||
int GetLrecl(void) {return Lrecl;} |
|||
void SetLrecl(int lrecl) {Lrecl = lrecl;} |
|||
bool GetPadded(void) {return Padded;} |
|||
bool GetEof(void) {return Eof;} |
|||
int GetBlksize(void) {return Blksize;} |
|||
int GetEnding(void) {return Ending;} |
|||
bool IsOptimized(void) {return (Optimized == 1);} |
|||
void SetOptimized(int opt) {Optimized = opt;} |
|||
void SetAllocBlks(int blks) {AllocBlks = blks;} |
|||
int GetAllocBlks(void) {return AllocBlks;} |
|||
int *GetTo_Pos(void) {return To_Pos;} |
|||
|
|||
// Methods |
|||
virtual bool Indexable(void) {return Compressed != 1;} |
|||
virtual bool DeleteIndexFile(PGLOBAL g, PIXDEF pxdf); |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
bool InvalidateIndex(PGLOBAL g); |
|||
bool GetOptFileName(PGLOBAL g, char *filename); |
|||
void RemoveOptValues(PGLOBAL g); |
|||
|
|||
protected: |
|||
//virtual bool Erase(char *filename); |
|||
|
|||
// Members |
|||
PSZ Fn; /* Path/Name of corresponding file */ |
|||
PSZ Ofn; /* Base Path/Name of matching index files*/ |
|||
PIXDEF To_Indx; /* To index definitions blocks */ |
|||
RECFM Recfm; /* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */ |
|||
bool Mapped; /* 0: disk file, 1: memory mapped file */ |
|||
bool Padded; /* true for padded table file */ |
|||
bool Huge; /* true for files larger than 2GB */ |
|||
bool Accept; /* true if wrong lines are accepted (DBF)*/ |
|||
bool Eof; /* true if an EOF (0xA) character exists */ |
|||
int *To_Pos; /* To array of block starting positions */ |
|||
int Optimized; /* 0: No, 1:Yes, 2:Redo optimization */ |
|||
int AllocBlks; /* Number of suballocated opt blocks */ |
|||
int Compressed; /* 0: No, 1: gz, 2:zlib compressed file */ |
|||
int Lrecl; /* Size of biggest record */ |
|||
int AvgLen; /* Average size of records */ |
|||
int Block; /* Number de blocks of FIX/VCT tables */ |
|||
int Last; /* Number of elements of last block */ |
|||
int Blksize; /* Size of padded blocks */ |
|||
int Maxerr; /* Maximum number of bad records (DBF) */ |
|||
int ReadMode; /* Specific to DBF */ |
|||
int Ending; /* Length of end of lines */ |
|||
}; // end of DOSDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* that are standard files with columns starting at fixed offset. */ |
|||
/* The last column (and record) is of variable length. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBDOS : public TDBASE { |
|||
friend class XINDEX; |
|||
friend class DOSCOL; |
|||
friend class MAPCOL; |
|||
friend class TXTFAM; |
|||
friend class DOSFAM; |
|||
friend class VCTCOL; |
|||
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool); |
|||
public: |
|||
// Constructors |
|||
TDBDOS(PDOSDEF tdp, PTXF txfp); |
|||
TDBDOS(PGLOBAL g, PTDBDOS tdbp); |
|||
|
|||
// Inline functions |
|||
inline void SetTxfp(PTXF txfp) {Txfp = txfp; Txfp->SetTdbp(this);} |
|||
inline PTXF GetTxfp(void) {return Txfp;} |
|||
inline char *GetLine(void) {return To_Line;} |
|||
inline int GetCurBlk(void) {return Txfp->GetCurBlk();} |
|||
inline void SetLine(char *toline) {To_Line = toline;} |
|||
inline void IncLine(int inc) {To_Line += inc;} |
|||
inline bool IsRead(void) {return Txfp->IsRead;} |
|||
inline PXOB *GetLink(void) {return To_Link;} |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return Txfp->GetAmType();} |
|||
virtual PSZ GetFile(PGLOBAL g) {return Txfp->To_File;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {Txfp->To_File = fn;} |
|||
virtual RECFM GetFtype(void) {return Ftype;} |
|||
virtual bool SkipHeader(PGLOBAL g) {return false;} |
|||
virtual void RestoreNrec(void) {Txfp->SetNrec(1);} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBDOS(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual void ResetDB(void) {Txfp->Reset();} |
|||
virtual bool IsUsingTemp(PGLOBAL g); |
|||
virtual void ResetSize(void) {MaxSize = Cardinal = -1;} |
|||
virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox); |
|||
virtual int MakeBlockValues(PGLOBAL g); |
|||
virtual bool SaveBlockValues(PGLOBAL g); |
|||
virtual bool GetBlockValues(PGLOBAL g); |
|||
virtual PBF InitBlockFilter(PGLOBAL g, PFIL filp); |
|||
//virtual PBX InitBlockIndex(PGLOBAL g); |
|||
virtual int TestBlock(PGLOBAL g); |
|||
virtual void PrintAM(FILE *f, char *m); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual char *GetOpenMode(PGLOBAL g, char *opmode) {return NULL;} |
|||
virtual int GetFileLength(PGLOBAL g) {return Txfp->GetFileLength(g);} |
|||
virtual int GetProgMax(PGLOBAL g); |
|||
virtual int GetProgCur(void); |
|||
virtual int GetAffectedRows(void) {return Txfp->GetDelRows();} |
|||
virtual int GetRecpos(void) {return Txfp->GetPos();} |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos) |
|||
{return Txfp->SetPos(g, recpos);} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false); |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g) {return Txfp->ReadBuffer(g);} |
|||
|
|||
// Specific routine |
|||
virtual int EstimatedLength(PGLOBAL g); |
|||
|
|||
// Optimization routines |
|||
int MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add); |
|||
void ResetBlockFilter(PGLOBAL g); |
|||
bool GetDistinctColumnValues(PGLOBAL g, int nrec); |
|||
|
|||
protected: |
|||
PBF CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv); |
|||
|
|||
// Members |
|||
PTXF Txfp; // To the File access method class |
|||
//PBX To_BlkIdx; // To index test block |
|||
PBF To_BlkFil; // To evaluation block filter |
|||
PFIL SavFil; // Saved hidden filter |
|||
char *To_Line; // Points to current processed line |
|||
int Cardinal; // Table Cardinality |
|||
RECFM Ftype; // File type: 0-var 1-fixed 2-binary (VCT) |
|||
int Lrecl; // Logical Record Length |
|||
int AvgLen; // Logical Record Average Length |
|||
//int Xeval; // BlockTest return value |
|||
int Beval; // BlockEval return value |
|||
}; // end of class TDBDOS |
|||
|
|||
/***********************************************************************/ |
|||
/* Class DOSCOL: DOS access method column descriptor. */ |
|||
/* This A.M. is used for text file tables under operating systems */ |
|||
/* DOS, OS2, UNIX, WIN16 and WIN32. */ |
|||
/***********************************************************************/ |
|||
class DllExport DOSCOL : public COLBLK { |
|||
friend class TDBDOS; |
|||
friend class TDBFIX; |
|||
public: |
|||
// Constructors |
|||
DOSCOL(PGLOBAL g, PCOLDEF cdp, PTDB tp, PCOL cp, int i, PSZ am = "DOS"); |
|||
DOSCOL(DOSCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_DOS;} |
|||
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} |
|||
virtual int GetClustered(void) {return Clustered;} |
|||
virtual int IsClustered(void) {return (Clustered && |
|||
((PDOSDEF)(((PTDBDOS)To_Tdb)->To_Def))->IsOptimized());} |
|||
virtual int IsSorted(void) {return Sorted;} |
|||
virtual PVBLK GetMin(void) {return Min;} |
|||
virtual PVBLK GetMax(void) {return Max;} |
|||
virtual int GetNdv(void) {return Ndv;} |
|||
virtual int GetNbm(void) {return Nbm;} |
|||
virtual PVBLK GetBmap(void) {return Bmap;} |
|||
virtual PVBLK GetDval(void) {return Dval;} |
|||
|
|||
// Methods |
|||
virtual bool VarSize(void); |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual void Print(PGLOBAL g, FILE *, uint); |
|||
|
|||
protected: |
|||
virtual bool SetMinMax(PGLOBAL g); |
|||
virtual bool SetBitMap(PGLOBAL g); |
|||
bool CheckSorted(PGLOBAL g); |
|||
bool AddDistinctValue(PGLOBAL g); |
|||
|
|||
// Default constructor not to be used |
|||
DOSCOL(void) {} |
|||
|
|||
// Members |
|||
PVBLK Min; // Array of block min values |
|||
PVBLK Max; // Array of block max values |
|||
PVBLK Bmap; // Array of block bitmap values |
|||
PVBLK Dval; // Array of column distinct values |
|||
PVAL To_Val; // To value used for Update/Insert |
|||
PVAL OldVal; // The previous value of the object. |
|||
char *Buf; // Buffer used in write operations |
|||
bool Ldz; // True if field contains leading zeros |
|||
bool Nod; // True if no decimal point |
|||
int Dcm; // Last Dcm digits are decimals |
|||
int Deplac; // Offset in dos_buf |
|||
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 |
|||
}; // end of class DOSCOL |
|||
|
|||
#endif // __TABDOS_H |
|||
2865
storage/connect/tabfmt.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,192 +1,188 @@ |
|||
/*************** TabFmt H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABFMT.H Version 2.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ |
|||
/* */ |
|||
/* This file contains the CSV and FMT classes declares. */ |
|||
/***********************************************************************/ |
|||
#include "xtable.h" // Base class declares |
|||
#include "tabdos.h" |
|||
|
|||
//pedef struct _tabdesc *PTABD; // For friend setting |
|||
typedef class TDBFMT *PTDBFMT; |
|||
|
|||
/***********************************************************************/ |
|||
/* Functions used externally. */ |
|||
/***********************************************************************/ |
|||
PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q, |
|||
int hdr, int mxr, bool info); |
|||
|
|||
/***********************************************************************/ |
|||
/* CSV table. */ |
|||
/***********************************************************************/ |
|||
class DllExport CSVDEF : public DOSDEF { /* Logical table description */ |
|||
friend class TDBCSV; |
|||
friend class TDBCCL; |
|||
public: |
|||
// Constructor |
|||
CSVDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "CSV";} |
|||
char GetSep(void) {return Sep;} |
|||
char GetQot(void) {return Qot;} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
|
|||
protected: |
|||
// Members |
|||
bool Fmtd; /* true for formatted files */ |
|||
//bool Accept; /* true if wrong lines are accepted */ |
|||
bool Header; /* true if first line contains headers */ |
|||
//int Maxerr; /* Maximum number of bad records */ |
|||
int Quoted; /* Quoting level for quoted fields */ |
|||
char Sep; /* Separator for standard CSV files */ |
|||
char Qot; /* Character for quoted strings */ |
|||
}; // end of CSVDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* that are CSV files with columns separated by the Sep character. */ |
|||
/***********************************************************************/ |
|||
class TDBCSV : public TDBDOS { |
|||
friend class CSVCOL; |
|||
public: |
|||
// Constructor |
|||
TDBCSV(PCSVDEF tdp, PTXF txfp); |
|||
TDBCSV(PGLOBAL g, PTDBCSV tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_CSV;} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBCSV(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
//virtual bool IsUsingTemp(PGLOBAL g); |
|||
virtual int GetBadLines(void) {return (int)Nerr;} |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int CheckWrite(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); // Physical file read |
|||
|
|||
// Specific routines |
|||
virtual int EstimatedLength(PGLOBAL g); |
|||
virtual bool SkipHeader(PGLOBAL g); |
|||
virtual bool CheckErr(void); |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ *Field; // Field to write to current line |
|||
int *Offset; // Column offsets for current record |
|||
int *Fldlen; // Column field length for current record |
|||
bool *Fldtyp; // true for numeric fields |
|||
int Fields; // Number of fields to handle |
|||
int Nerr; // Number of bad records |
|||
int Maxerr; // Maximum number of bad records |
|||
int Quoted; // Quoting level for quoted fields |
|||
bool Accept; // true if bad lines are accepted |
|||
bool Header; // true if first line contains column headers |
|||
char Sep; // Separator |
|||
char Qot; // Quoting character |
|||
}; // end of class TDBCSV |
|||
|
|||
/***********************************************************************/ |
|||
/* Class CSVCOL: CSV access method column descriptor. */ |
|||
/* This A.M. is used for Comma Separated V(?) files. */ |
|||
/***********************************************************************/ |
|||
class CSVCOL : public DOSCOL { |
|||
friend class TDBCSV; |
|||
friend class TDBFMT; |
|||
public: |
|||
// Constructors |
|||
CSVCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); |
|||
CSVCOL(CSVCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType() {return TYPE_AM_CSV;} |
|||
|
|||
// Methods |
|||
#if defined(BLK_INDX) |
|||
virtual bool VarSize(void); |
|||
#endif // BLK_INDX |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
// void Print(FILE *, uint); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
CSVCOL(void) {} |
|||
|
|||
// Members |
|||
int Fldnum; // Field ordinal number (0 based) |
|||
}; // end of class CSVCOL |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* whose record format is described by a Format keyword. */ |
|||
/***********************************************************************/ |
|||
class TDBFMT : public TDBCSV { |
|||
friend class CSVCOL; |
|||
//friend class FMTCOL; |
|||
public: |
|||
// Standard constructor |
|||
TDBFMT(PCSVDEF tdp, PTXF txfp) : TDBCSV(tdp, txfp) |
|||
{FldFormat = NULL; To_Fld = NULL; FmtTest = NULL; Linenum = 0;} |
|||
|
|||
// Copy constructor |
|||
TDBFMT(PGLOBAL g, PTDBFMT tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_FMT;} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBFMT(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
//virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
//virtual int CheckWrite(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); // Physical file read |
|||
|
|||
// Specific routines |
|||
virtual int EstimatedLength(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ *FldFormat; // Field read format |
|||
void *To_Fld; // To field test buffer |
|||
int *FmtTest; // Test on ending by %n or %m |
|||
int Linenum; // Last read line |
|||
}; // end of class TDBFMT |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the CSV catalog table. */ |
|||
/***********************************************************************/ |
|||
class TDBCCL : public TDBCAT { |
|||
public: |
|||
// Constructor |
|||
TDBCCL(PCSVDEF tdp); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
virtual PQRYRES GetResult(PGLOBAL g); |
|||
|
|||
// Members |
|||
char *Fn; // The CSV file (path) name |
|||
bool Hdr; // true if first line contains headers |
|||
int Mxr; // Maximum number of bad records |
|||
int Qtd; // Quoting level for quoted fields |
|||
char Sep; // Separator for standard CSV files |
|||
}; // end of class TDBCCL |
|||
|
|||
/* ------------------------- End of TabFmt.H ------------------------- */ |
|||
/*************** TabFmt H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABFMT.H Version 2.4 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2001-2014 */ |
|||
/* */ |
|||
/* This file contains the CSV and FMT classes declares. */ |
|||
/***********************************************************************/ |
|||
#include "xtable.h" // Base class declares |
|||
#include "tabdos.h" |
|||
|
|||
typedef class TDBFMT *PTDBFMT; |
|||
|
|||
/***********************************************************************/ |
|||
/* Functions used externally. */ |
|||
/***********************************************************************/ |
|||
PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q, |
|||
int hdr, int mxr, bool info); |
|||
|
|||
/***********************************************************************/ |
|||
/* CSV table. */ |
|||
/***********************************************************************/ |
|||
class DllExport CSVDEF : public DOSDEF { /* Logical table description */ |
|||
friend class TDBCSV; |
|||
friend class TDBCCL; |
|||
public: |
|||
// Constructor |
|||
CSVDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "CSV";} |
|||
char GetSep(void) {return Sep;} |
|||
char GetQot(void) {return Qot;} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
|
|||
protected: |
|||
// Members |
|||
bool Fmtd; /* true for formatted files */ |
|||
//bool Accept; /* true if wrong lines are accepted */ |
|||
bool Header; /* true if first line contains headers */ |
|||
//int Maxerr; /* Maximum number of bad records */ |
|||
int Quoted; /* Quoting level for quoted fields */ |
|||
char Sep; /* Separator for standard CSV files */ |
|||
char Qot; /* Character for quoted strings */ |
|||
}; // end of CSVDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* that are CSV files with columns separated by the Sep character. */ |
|||
/***********************************************************************/ |
|||
class TDBCSV : public TDBDOS { |
|||
friend class CSVCOL; |
|||
public: |
|||
// Constructor |
|||
TDBCSV(PCSVDEF tdp, PTXF txfp); |
|||
TDBCSV(PGLOBAL g, PTDBCSV tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_CSV;} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBCSV(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
//virtual bool IsUsingTemp(PGLOBAL g); |
|||
virtual int GetBadLines(void) {return (int)Nerr;} |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int CheckWrite(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); // Physical file read |
|||
|
|||
// Specific routines |
|||
virtual int EstimatedLength(PGLOBAL g); |
|||
virtual bool SkipHeader(PGLOBAL g); |
|||
virtual bool CheckErr(void); |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ *Field; // Field to write to current line |
|||
int *Offset; // Column offsets for current record |
|||
int *Fldlen; // Column field length for current record |
|||
bool *Fldtyp; // true for numeric fields |
|||
int Fields; // Number of fields to handle |
|||
int Nerr; // Number of bad records |
|||
int Maxerr; // Maximum number of bad records |
|||
int Quoted; // Quoting level for quoted fields |
|||
bool Accept; // true if bad lines are accepted |
|||
bool Header; // true if first line contains column headers |
|||
char Sep; // Separator |
|||
char Qot; // Quoting character |
|||
}; // end of class TDBCSV |
|||
|
|||
/***********************************************************************/ |
|||
/* Class CSVCOL: CSV access method column descriptor. */ |
|||
/* This A.M. is used for Comma Separated V(?) files. */ |
|||
/***********************************************************************/ |
|||
class CSVCOL : public DOSCOL { |
|||
friend class TDBCSV; |
|||
friend class TDBFMT; |
|||
public: |
|||
// Constructors |
|||
CSVCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i); |
|||
CSVCOL(CSVCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType() {return TYPE_AM_CSV;} |
|||
|
|||
// Methods |
|||
virtual bool VarSize(void); |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
CSVCOL(void) {} |
|||
|
|||
// Members |
|||
int Fldnum; // Field ordinal number (0 based) |
|||
}; // end of class CSVCOL |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the DOS/UNIX Access Method class declaration for files */ |
|||
/* whose record format is described by a Format keyword. */ |
|||
/***********************************************************************/ |
|||
class TDBFMT : public TDBCSV { |
|||
friend class CSVCOL; |
|||
//friend class FMTCOL; |
|||
public: |
|||
// Standard constructor |
|||
TDBFMT(PCSVDEF tdp, PTXF txfp) : TDBCSV(tdp, txfp) |
|||
{FldFormat = NULL; To_Fld = NULL; FmtTest = NULL; Linenum = 0;} |
|||
|
|||
// Copy constructor |
|||
TDBFMT(PGLOBAL g, PTDBFMT tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_FMT;} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBFMT(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
//virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
//virtual int CheckWrite(PGLOBAL g); |
|||
virtual int ReadBuffer(PGLOBAL g); // Physical file read |
|||
|
|||
// Specific routines |
|||
virtual int EstimatedLength(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ *FldFormat; // Field read format |
|||
void *To_Fld; // To field test buffer |
|||
int *FmtTest; // Test on ending by %n or %m |
|||
int Linenum; // Last read line |
|||
}; // end of class TDBFMT |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the CSV catalog table. */ |
|||
/***********************************************************************/ |
|||
class TDBCCL : public TDBCAT { |
|||
public: |
|||
// Constructor |
|||
TDBCCL(PCSVDEF tdp); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
virtual PQRYRES GetResult(PGLOBAL g); |
|||
|
|||
// Members |
|||
char *Fn; // The CSV file (path) name |
|||
bool Hdr; // true if first line contains headers |
|||
int Mxr; // Maximum number of bad records |
|||
int Qtd; // Quoting level for quoted fields |
|||
char Sep; // Separator for standard CSV files |
|||
}; // end of class TDBCCL |
|||
|
|||
/* ------------------------- End of TabFmt.H ------------------------- */ |
|||
1182
storage/connect/table.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
3240
storage/connect/tabmysql.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,182 +1,181 @@ |
|||
/*************** TabSys H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABSYS.H Version 2.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2004-2013 */ |
|||
/* */ |
|||
/* This file contains the XDB system tables classes declares. */ |
|||
/***********************************************************************/ |
|||
typedef class INIDEF *PINIDEF; |
|||
typedef class TDBINI *PTDBINI; |
|||
typedef class INICOL *PINICOL; |
|||
typedef class TDBXIN *PTDBXIN; |
|||
typedef class XINCOL *PXINCOL; |
|||
|
|||
/* --------------------------- INI classes --------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* INI, XDB and XCL tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport INIDEF : public TABDEF { /* INI table description */ |
|||
friend class TDBINI; |
|||
friend class TDBXIN; |
|||
friend class TDBXTB; |
|||
friend class TDBRTB; |
|||
friend class TDBXCL; |
|||
public: |
|||
// Constructor |
|||
INIDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "INI";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
//virtual bool DeleteTableFile(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Fn; /* Path/Name of corresponding file */ |
|||
char *Xname; /* The eventual table name */ |
|||
char Layout; /* R: Row, C: Column */ |
|||
int Ln; /* Length of section list buffer */ |
|||
}; // end of INIDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the INI tables. */ |
|||
/* These are tables represented by a INI like file. */ |
|||
/***********************************************************************/ |
|||
class TDBINI : public TDBASE { |
|||
friend class INICOL; |
|||
public: |
|||
// Constructor |
|||
TDBINI(PINIDEF tdp); |
|||
TDBINI(PTDBINI tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_INI;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual int GetRecpos(void) {return N;} |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual int GetAffectedRows(void) {return 0;} |
|||
virtual PSZ GetFile(PGLOBAL g) {return Ifile;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;} |
|||
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;} |
|||
virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;} |
|||
char *GetSeclist(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Ifile; // The INI file |
|||
char *Seclist; // The section list |
|||
char *Section; // The current section |
|||
int Seclen; // Length of seclist buffer |
|||
int N; // The current section index |
|||
}; // end of class TDBINI |
|||
|
|||
/***********************************************************************/ |
|||
/* Class INICOL: XDB table access method column descriptor. */ |
|||
/***********************************************************************/ |
|||
class INICOL : public COLBLK { |
|||
public: |
|||
// Constructors |
|||
INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); |
|||
INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_INI;} |
|||
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} |
|||
|
|||
// Methods |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual void AllocBuf(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
INICOL(void) {} |
|||
|
|||
// Members |
|||
char *Valbuf; // To the key value buffer |
|||
int Flag; // Tells what set in value |
|||
int Long; // Buffer length |
|||
PVAL To_Val; // To value used for Update/Insert |
|||
}; // end of class INICOL |
|||
|
|||
/* --------------------------- XINI class ---------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the XINI tables. */ |
|||
/* These are tables represented by a INI like file */ |
|||
/* having 3 columns Section, Key, and Value. */ |
|||
/***********************************************************************/ |
|||
class TDBXIN : public TDBINI { |
|||
friend class XINCOL; |
|||
public: |
|||
// Constructor |
|||
TDBXIN(PINIDEF tdp); |
|||
TDBXIN(PTDBXIN tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_INI;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual int GetRecpos(void); |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos); |
|||
virtual void ResetDB(void) |
|||
{Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;} |
|||
char *GetKeylist(PGLOBAL g, char *sec); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Keylist; // The key list |
|||
char *Keycur; // The current key |
|||
int Keylen; // Length of keylist buffer |
|||
short Oldsec; // Last current section |
|||
}; // end of class TDBXIN |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XINCOL: XIN table access method column descriptor. */ |
|||
/***********************************************************************/ |
|||
class XINCOL : public INICOL { |
|||
public: |
|||
// Constructors |
|||
XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); |
|||
XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
XINCOL(void) {} |
|||
|
|||
// Members |
|||
}; // end of class XINICOL |
|||
/*************** TabSys H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABSYS.H Version 2.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2004-2013 */ |
|||
/* */ |
|||
/* This file contains the XDB system tables classes declares. */ |
|||
/***********************************************************************/ |
|||
typedef class INIDEF *PINIDEF; |
|||
typedef class TDBINI *PTDBINI; |
|||
typedef class INICOL *PINICOL; |
|||
typedef class TDBXIN *PTDBXIN; |
|||
typedef class XINCOL *PXINCOL; |
|||
|
|||
/* --------------------------- INI classes --------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* INI, XDB and XCL tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport INIDEF : public TABDEF { /* INI table description */ |
|||
friend class TDBINI; |
|||
friend class TDBXIN; |
|||
friend class TDBXTB; |
|||
friend class TDBRTB; |
|||
friend class TDBXCL; |
|||
public: |
|||
// Constructor |
|||
INIDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "INI";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Fn; /* Path/Name of corresponding file */ |
|||
char *Xname; /* The eventual table name */ |
|||
char Layout; /* R: Row, C: Column */ |
|||
int Ln; /* Length of section list buffer */ |
|||
}; // end of INIDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the INI tables. */ |
|||
/* These are tables represented by a INI like file. */ |
|||
/***********************************************************************/ |
|||
class TDBINI : public TDBASE { |
|||
friend class INICOL; |
|||
public: |
|||
// Constructor |
|||
TDBINI(PINIDEF tdp); |
|||
TDBINI(PTDBINI tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_INI;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBINI(this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual int GetRecpos(void) {return N;} |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual int GetAffectedRows(void) {return 0;} |
|||
virtual PSZ GetFile(PGLOBAL g) {return Ifile;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {Ifile = fn;} |
|||
virtual void ResetDB(void) {Seclist = Section = NULL; N = 0;} |
|||
virtual void ResetSize(void) {MaxSize = -1; Seclist = NULL;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false) {return N;} |
|||
char *GetSeclist(PGLOBAL g); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Ifile; // The INI file |
|||
char *Seclist; // The section list |
|||
char *Section; // The current section |
|||
int Seclen; // Length of seclist buffer |
|||
int N; // The current section index |
|||
}; // end of class TDBINI |
|||
|
|||
/***********************************************************************/ |
|||
/* Class INICOL: XDB table access method column descriptor. */ |
|||
/***********************************************************************/ |
|||
class INICOL : public COLBLK { |
|||
public: |
|||
// Constructors |
|||
INICOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); |
|||
INICOL(INICOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_INI;} |
|||
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} |
|||
|
|||
// Methods |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual void AllocBuf(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
INICOL(void) {} |
|||
|
|||
// Members |
|||
char *Valbuf; // To the key value buffer |
|||
int Flag; // Tells what set in value |
|||
int Long; // Buffer length |
|||
PVAL To_Val; // To value used for Update/Insert |
|||
}; // end of class INICOL |
|||
|
|||
/* --------------------------- XINI class ---------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the XINI tables. */ |
|||
/* These are tables represented by a INI like file */ |
|||
/* having 3 columns Section, Key, and Value. */ |
|||
/***********************************************************************/ |
|||
class TDBXIN : public TDBINI { |
|||
friend class XINCOL; |
|||
public: |
|||
// Constructor |
|||
TDBXIN(PINIDEF tdp); |
|||
TDBXIN(PTDBXIN tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_INI;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXIN(this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual int GetRecpos(void); |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos); |
|||
virtual void ResetDB(void) |
|||
{Seclist = Section = Keycur = NULL; N = 0; Oldsec = -1;} |
|||
char *GetKeylist(PGLOBAL g, char *sec); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Keylist; // The key list |
|||
char *Keycur; // The current key |
|||
int Keylen; // Length of keylist buffer |
|||
short Oldsec; // Last current section |
|||
}; // end of class TDBXIN |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XINCOL: XIN table access method column descriptor. */ |
|||
/***********************************************************************/ |
|||
class XINCOL : public INICOL { |
|||
public: |
|||
// Constructors |
|||
XINCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "INI"); |
|||
XINCOL(XINCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
XINCOL(void) {} |
|||
|
|||
// Members |
|||
}; // end of class XINICOL |
|||
@ -1,169 +1,159 @@ |
|||
/*************** TabTbl H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABTBL.H Version 1.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2008-2013 */ |
|||
/* */ |
|||
/* This file contains the TDBTBL classes declares. */ |
|||
/***********************************************************************/ |
|||
#include "block.h" |
|||
#include "colblk.h" |
|||
#include "tabutil.h" |
|||
|
|||
typedef class TBLDEF *PTBLDEF; |
|||
typedef class TDBTBL *PTDBTBL; |
|||
typedef class TDBTBM *PTDBTBM; |
|||
typedef class MYSQLC *PMYC; |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the structures used for distributed TBM tables. */ |
|||
/***********************************************************************/ |
|||
typedef struct _TBMtable *PTBMT; |
|||
|
|||
typedef struct _TBMtable { |
|||
PTBMT Next; // Points to next data table struct |
|||
PTABLE Tap; // Points to the sub table |
|||
PGLOBAL G; // Needed in thread routine |
|||
bool Complete; // TRUE when all results are read |
|||
bool Ready; // TRUE when results are there |
|||
int Rows; // Total number of rows read so far |
|||
int ProgCur; // Current pos |
|||
int ProgMax; // Max pos |
|||
int Rc; // Return code |
|||
THD *Thd; |
|||
pthread_attr_t attr; // ??? |
|||
pthread_t Tid; // CheckOpen thread ID |
|||
} TBMT; |
|||
|
|||
/***********************************************************************/ |
|||
/* TBL table. */ |
|||
/***********************************************************************/ |
|||
class DllExport TBLDEF : public PRXDEF { /* Logical table description */ |
|||
friend class TDBTBL; |
|||
friend class TDBTBC; |
|||
public: |
|||
// Constructor |
|||
TBLDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "TBL";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
|
|||
protected: |
|||
// Members |
|||
bool Accept; /* TRUE if bad tables are accepted */ |
|||
bool Thread; /* Use thread for remote tables */ |
|||
int Maxerr; /* Maximum number of bad tables */ |
|||
int Ntables; /* Number of tables */ |
|||
}; // end of TBLDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the TBL Access Method class declaration. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBTBL : public TDBPRX { |
|||
friend class TBTBLK; |
|||
public: |
|||
// Constructor |
|||
TDBTBL(PTBLDEF tdp = NULL); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_TBL;} |
|||
|
|||
// Methods |
|||
virtual void ResetDB(void); |
|||
virtual int GetRecpos(void) {return Rows;} |
|||
virtual int GetBadLines(void) {return (int)Nbc;} |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual int RowNumber(PGLOBAL g, bool b = FALSE); |
|||
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Internal functions |
|||
bool InitTableList(PGLOBAL g); |
|||
bool TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp); |
|||
|
|||
// Members |
|||
PTABLE Tablist; // Points to the table list |
|||
PTABLE CurTable; // Points to the current table |
|||
bool Accept; // TRUE if bad tables are accepted |
|||
int Maxerr; // Maximum number of bad tables |
|||
int Nbc; // Number of bad connections |
|||
int Rows; // Used for RowID |
|||
int Crp; // Used for CurPos |
|||
}; // end of class TDBTBL |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TBTBLK: TDBPLG TABID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class TBTBLK : public TIDBLK { |
|||
public: |
|||
// The constructor must restore Value because XOBJECT has a void |
|||
// constructor called by default that set Value to NULL |
|||
TBTBLK(PVAL valp) {Value = valp;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
// Fake operator new used to change TIDBLK into SDTBLK |
|||
void * operator new(size_t size, TIDBLK *sp) {return sp;} |
|||
|
|||
#if !defined(__BORLANDC__) |
|||
// Avoid warning C4291 by defining a matching dummy delete operator |
|||
void operator delete(void *, TIDBLK*) {} |
|||
void operator delete(void *, size_t size) {} |
|||
#endif |
|||
|
|||
protected: |
|||
// Must not have additional members |
|||
}; // end of class TBTBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the TBM Access Method class declaration. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBTBM : public TDBTBL { |
|||
friend class TBTBLK; |
|||
public: |
|||
// Constructor |
|||
TDBTBM(PTBLDEF tdp = NULL); |
|||
|
|||
// Implementation |
|||
//virtual AMT GetAmType(void) {return TYPE_AM_TBL;} |
|||
|
|||
// Methods |
|||
virtual void ResetDB(void); |
|||
//virtual int GetRecpos(void) {return Rows;} |
|||
//virtual int GetBadLines(void) {return (int)Nbc;} |
|||
|
|||
// Database routines |
|||
//virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary |
|||
virtual int RowNumber(PGLOBAL g, bool b = FALSE); |
|||
//virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Internal functions |
|||
//bool InitTableList(PGLOBAL g); |
|||
//bool TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp); |
|||
bool OpenTables(PGLOBAL g); |
|||
int ReadNextRemote(PGLOBAL g); |
|||
|
|||
// Members |
|||
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); |
|||
/*************** TabTbl H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABTBL.H Version 1.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2008-2013 */ |
|||
/* */ |
|||
/* This file contains the TDBTBL classes declares. */ |
|||
/***********************************************************************/ |
|||
#include "block.h" |
|||
#include "colblk.h" |
|||
#include "tabutil.h" |
|||
|
|||
typedef class TBLDEF *PTBLDEF; |
|||
typedef class TDBTBL *PTDBTBL; |
|||
typedef class TDBTBM *PTDBTBM; |
|||
typedef class MYSQLC *PMYC; |
|||
|
|||
/***********************************************************************/ |
|||
/* Defines the structures used for distributed TBM tables. */ |
|||
/***********************************************************************/ |
|||
typedef struct _TBMtable *PTBMT; |
|||
|
|||
typedef struct _TBMtable { |
|||
PTBMT Next; // Points to next data table struct |
|||
PTABLE Tap; // Points to the sub table |
|||
PGLOBAL G; // Needed in thread routine |
|||
bool Complete; // TRUE when all results are read |
|||
bool Ready; // TRUE when results are there |
|||
int Rows; // Total number of rows read so far |
|||
int ProgCur; // Current pos |
|||
int ProgMax; // Max pos |
|||
int Rc; // Return code |
|||
THD *Thd; |
|||
pthread_attr_t attr; // ??? |
|||
pthread_t Tid; // CheckOpen thread ID |
|||
} TBMT; |
|||
|
|||
/***********************************************************************/ |
|||
/* TBL table. */ |
|||
/***********************************************************************/ |
|||
class DllExport TBLDEF : public PRXDEF { /* Logical table description */ |
|||
friend class TDBTBL; |
|||
friend class TDBTBC; |
|||
public: |
|||
// Constructor |
|||
TBLDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "TBL";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
|
|||
protected: |
|||
// Members |
|||
bool Accept; /* TRUE if bad tables are accepted */ |
|||
bool Thread; /* Use thread for remote tables */ |
|||
int Maxerr; /* Maximum number of bad tables */ |
|||
int Ntables; /* Number of tables */ |
|||
}; // end of TBLDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the TBL Access Method class declaration. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBTBL : public TDBPRX { |
|||
friend class TBTBLK; |
|||
public: |
|||
// Constructor |
|||
TDBTBL(PTBLDEF tdp = NULL); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_TBL;} |
|||
|
|||
// Methods |
|||
virtual void ResetDB(void); |
|||
virtual int GetRecpos(void) {return Rows;} |
|||
virtual int GetBadLines(void) {return (int)Nbc;} |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual int RowNumber(PGLOBAL g, bool b = FALSE); |
|||
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Internal functions |
|||
bool InitTableList(PGLOBAL g); |
|||
bool TestFil(PGLOBAL g, PCFIL filp, PTABLE tabp); |
|||
|
|||
// Members |
|||
PTABLE Tablist; // Points to the table list |
|||
PTABLE CurTable; // Points to the current table |
|||
bool Accept; // TRUE if bad tables are accepted |
|||
int Maxerr; // Maximum number of bad tables |
|||
int Nbc; // Number of bad connections |
|||
int Rows; // Used for RowID |
|||
int Crp; // Used for CurPos |
|||
}; // end of class TDBTBL |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TBTBLK: TDBPLG TABID special column descriptor. */ |
|||
/***********************************************************************/ |
|||
class TBTBLK : public TIDBLK { |
|||
public: |
|||
// The constructor must restore Value because XOBJECT has a void |
|||
// constructor called by default that set Value to NULL |
|||
TBTBLK(PVAL valp) {Value = valp;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
// Fake operator new used to change TIDBLK into SDTBLK |
|||
void * operator new(size_t size, TIDBLK *sp) {return sp;} |
|||
|
|||
#if !defined(__BORLANDC__) |
|||
// Avoid warning C4291 by defining a matching dummy delete operator |
|||
void operator delete(void *, TIDBLK*) {} |
|||
void operator delete(void *, size_t size) {} |
|||
#endif |
|||
|
|||
protected: |
|||
// Must not have additional members |
|||
}; // end of class TBTBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the TBM Access Method class declaration. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBTBM : public TDBTBL { |
|||
friend class TBTBLK; |
|||
public: |
|||
// Constructor |
|||
TDBTBM(PTBLDEF tdp = NULL); |
|||
|
|||
// Methods |
|||
virtual void ResetDB(void); |
|||
|
|||
// Database routines |
|||
virtual int GetMaxSize(PGLOBAL g) {return 10;} // Temporary |
|||
virtual int RowNumber(PGLOBAL g, bool b = FALSE); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Internal functions |
|||
bool OpenTables(PGLOBAL g); |
|||
int ReadNextRemote(PGLOBAL g); |
|||
|
|||
// Members |
|||
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); |
|||
@ -1,123 +1,121 @@ |
|||
/*************** TabVct H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABVCT.H Version 3.4 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */ |
|||
/* */ |
|||
/* This file contains the TDBVCT class declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __TABVCT__ |
|||
#define __TABVCT__ |
|||
|
|||
#include "tabfix.h" |
|||
#if defined(UNIX) |
|||
//#include <string.h.SUNWCCh> |
|||
#endif |
|||
|
|||
typedef class TDBVCT *PTDBVCT; |
|||
typedef class VCTCOL *PVCTCOL; |
|||
|
|||
/***********************************************************************/ |
|||
/* VCT table. */ |
|||
/***********************************************************************/ |
|||
class DllExport VCTDEF : public DOSDEF { /* Logical table description */ |
|||
friend class VCTFAM; |
|||
friend class VECFAM; |
|||
friend class VMPFAM; |
|||
public: |
|||
// Constructor |
|||
VCTDEF(void) {Split = Estimate = Header = 0;} |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "VCT";} |
|||
int GetEstimate(void) {return Estimate;} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
|
|||
protected: |
|||
// Specific file erase routine for vertical tables |
|||
//virtual bool Erase(char *filename); |
|||
int MakeFnPattern(char *fpat); |
|||
|
|||
// Members |
|||
int Split; /* Columns in separate files */ |
|||
int Estimate; /* Estimated maximum size of table */ |
|||
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" */ |
|||
/* records, values of each columns are consecutively stored (vector). */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBVCT : public TDBFIX { |
|||
friend class VCTCOL; |
|||
friend class VCTFAM; |
|||
friend class VCMFAM; |
|||
friend class VECFAM; |
|||
friend class VMPFAM; |
|||
public: |
|||
// Constructors |
|||
TDBVCT(PVCTDEF tdp, PTXF txfp); |
|||
TDBVCT(PGLOBAL g, PTDBVCT tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBVCT(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
}; // end of class TDBVCT |
|||
|
|||
/***********************************************************************/ |
|||
/* 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; |
|||
friend class VCTFAM; |
|||
friend class VCMFAM; |
|||
friend class VECFAM; |
|||
friend class VMPFAM; |
|||
friend class BGVFAM; |
|||
public: |
|||
// Constructors |
|||
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;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void SetOk(void); |
|||
|
|||
protected: |
|||
virtual void ReadBlock(PGLOBAL g); |
|||
virtual void WriteBlock(PGLOBAL g); |
|||
|
|||
VCTCOL(void) {} // Default constructor not to be used |
|||
|
|||
// Members |
|||
PVBLK Blk; // Block buffer |
|||
int Clen; // Internal length in table |
|||
int ColBlk; // Block pointed by column |
|||
int ColPos; // Last position read |
|||
int Modif; // Number of modified lines in block |
|||
}; // end of class VCTCOL |
|||
|
|||
#endif // __TABVCT__ |
|||
|
|||
/*************** TabVct H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABVCT.H Version 3.4 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1999-2011 */ |
|||
/* */ |
|||
/* This file contains the TDBVCT class declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __TABVCT__ |
|||
#define __TABVCT__ |
|||
|
|||
#include "tabfix.h" |
|||
#if defined(UNIX) |
|||
//#include <string.h.SUNWCCh> |
|||
#endif |
|||
|
|||
typedef class TDBVCT *PTDBVCT; |
|||
typedef class VCTCOL *PVCTCOL; |
|||
|
|||
/***********************************************************************/ |
|||
/* VCT table. */ |
|||
/***********************************************************************/ |
|||
class DllExport VCTDEF : public DOSDEF { /* Logical table description */ |
|||
friend class VCTFAM; |
|||
friend class VECFAM; |
|||
friend class VMPFAM; |
|||
public: |
|||
// Constructor |
|||
VCTDEF(void) {Split = Estimate = Header = 0;} |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "VCT";} |
|||
int GetEstimate(void) {return Estimate;} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE mode); |
|||
|
|||
protected: |
|||
int MakeFnPattern(char *fpat); |
|||
|
|||
// Members |
|||
int Split; /* Columns in separate files */ |
|||
int Estimate; /* Estimated maximum size of table */ |
|||
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" */ |
|||
/* records, values of each columns are consecutively stored (vector). */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBVCT : public TDBFIX { |
|||
friend class VCTCOL; |
|||
friend class VCTFAM; |
|||
friend class VCMFAM; |
|||
friend class VECFAM; |
|||
friend class VMPFAM; |
|||
public: |
|||
// Constructors |
|||
TDBVCT(PVCTDEF tdp, PTXF txfp); |
|||
TDBVCT(PGLOBAL g, PTDBVCT tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_VCT;} |
|||
virtual PTDB Duplicate(PGLOBAL g) |
|||
{return (PTDB)new(g) TDBVCT(g, this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
}; // end of class TDBVCT |
|||
|
|||
/***********************************************************************/ |
|||
/* 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; |
|||
friend class VCTFAM; |
|||
friend class VCMFAM; |
|||
friend class VECFAM; |
|||
friend class VMPFAM; |
|||
friend class BGVFAM; |
|||
public: |
|||
// Constructors |
|||
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;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void SetOk(void); |
|||
|
|||
protected: |
|||
virtual void ReadBlock(PGLOBAL g); |
|||
virtual void WriteBlock(PGLOBAL g); |
|||
|
|||
VCTCOL(void) {} // Default constructor not to be used |
|||
|
|||
// Members |
|||
PVBLK Blk; // Block buffer |
|||
int Clen; // Internal length in table |
|||
int ColBlk; // Block pointed by column |
|||
int ColPos; // Last position read |
|||
int Modif; // Number of modified lines in block |
|||
}; // end of class VCTCOL |
|||
|
|||
#endif // __TABVCT__ |
|||
|
|||
@ -1,151 +1,150 @@ |
|||
// TABWMI.H Olivier Bertrand 2012 |
|||
// WMI: Virtual table to Get WMI information |
|||
#define _WIN32_DCOM |
|||
#include <wbemidl.h> |
|||
# pragma comment(lib, "wbemuuid.lib") |
|||
#include <iostream> |
|||
using namespace std; |
|||
#include <comdef.h> |
|||
|
|||
/***********************************************************************/ |
|||
/* Definitions. */ |
|||
/***********************************************************************/ |
|||
typedef class WMIDEF *PWMIDEF; |
|||
typedef class TDBWMI *PTDBWMI; |
|||
typedef class WMICOL *PWMICOL; |
|||
typedef class TDBWCL *PTDBWCL; |
|||
typedef class WCLCOL *PWCLCOL; |
|||
|
|||
/***********************************************************************/ |
|||
/* Structure used by WMI column info functions. */ |
|||
/***********************************************************************/ |
|||
typedef struct _WMIutil { |
|||
IWbemServices *Svc; |
|||
IWbemClassObject *Cobj; |
|||
} WMIUTIL, *PWMIUT; |
|||
|
|||
/***********************************************************************/ |
|||
/* Functions used externally. */ |
|||
/***********************************************************************/ |
|||
PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info); |
|||
|
|||
/* -------------------------- WMI classes ---------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* WMI: Virtual table to get the WMI information. */ |
|||
/***********************************************************************/ |
|||
class WMIDEF : public TABDEF { /* Logical table description */ |
|||
friend class TDBWMI; |
|||
friend class TDBWCL; |
|||
friend class TDBWCX; |
|||
public: |
|||
// Constructor |
|||
WMIDEF(void) {Pseudo = 3; Nspace = NULL; Wclass = NULL; Ems = 0;} |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "WMI";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
//virtual bool DeleteTableFile(PGLOBAL g) {return true;} |
|||
|
|||
protected: |
|||
// Members |
|||
char *Nspace; |
|||
char *Wclass; |
|||
int Ems; |
|||
}; // end of WMIDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the WMI table. */ |
|||
/***********************************************************************/ |
|||
class TDBWMI : public TDBASE { |
|||
friend class WMICOL; |
|||
public: |
|||
// Constructor |
|||
TDBWMI(PWMIDEF tdp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_WMI;} |
|||
|
|||
// Methods |
|||
virtual int GetRecpos(void); |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
bool Initialize(PGLOBAL g); |
|||
char *MakeWQL(PGLOBAL g); |
|||
void DoubleSlash(PGLOBAL g); |
|||
bool GetWMIInfo(PGLOBAL g); |
|||
|
|||
// Members |
|||
IWbemServices *Svc; // IWbemServices pointer |
|||
IEnumWbemClassObject *Enumerator; |
|||
IWbemClassObject *ClsObj; |
|||
char *Nspace; // Namespace |
|||
char *Wclass; // Class name |
|||
char *ObjPath; // Used for direct access |
|||
char *Kvp; // Itou |
|||
int Ems; // Estimated max size |
|||
PCOL Kcol; // Key column |
|||
HRESULT Res; |
|||
PVBLK Vbp; |
|||
bool Init; |
|||
bool Done; |
|||
ULONG Rc; |
|||
int N; // Row number |
|||
}; // end of class TDBWMI |
|||
|
|||
/***********************************************************************/ |
|||
/* Class WMICOL: WMI Address column. */ |
|||
/***********************************************************************/ |
|||
class WMICOL : public COLBLK { |
|||
friend class TDBWMI; |
|||
public: |
|||
// Constructors |
|||
WMICOL(PCOLDEF cdp, PTDB tdbp, int n); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_WMI;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
WMICOL(void) {} // Default constructor not to be used |
|||
|
|||
// Members |
|||
PTDBWMI Tdbp; // Points to WMI table block |
|||
VARIANT Prop; // Property value |
|||
CIMTYPE Ctype; // CIM Type |
|||
HRESULT Res; |
|||
}; // end of class WMICOL |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the WMI catalog table. */ |
|||
/***********************************************************************/ |
|||
class TDBWCL : public TDBCAT { |
|||
public: |
|||
// Constructor |
|||
TDBWCL(PWMIDEF tdp); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
virtual PQRYRES GetResult(PGLOBAL g); |
|||
|
|||
// Members |
|||
char *Nsp; // Name space |
|||
char *Cls; // Class |
|||
}; // end of class TDBWCL |
|||
// TABWMI.H Olivier Bertrand 2012 |
|||
// WMI: Virtual table to Get WMI information |
|||
#define _WIN32_DCOM |
|||
#include <wbemidl.h> |
|||
# pragma comment(lib, "wbemuuid.lib") |
|||
#include <iostream> |
|||
using namespace std; |
|||
#include <comdef.h> |
|||
|
|||
/***********************************************************************/ |
|||
/* Definitions. */ |
|||
/***********************************************************************/ |
|||
typedef class WMIDEF *PWMIDEF; |
|||
typedef class TDBWMI *PTDBWMI; |
|||
typedef class WMICOL *PWMICOL; |
|||
typedef class TDBWCL *PTDBWCL; |
|||
typedef class WCLCOL *PWCLCOL; |
|||
|
|||
/***********************************************************************/ |
|||
/* Structure used by WMI column info functions. */ |
|||
/***********************************************************************/ |
|||
typedef struct _WMIutil { |
|||
IWbemServices *Svc; |
|||
IWbemClassObject *Cobj; |
|||
} WMIUTIL, *PWMIUT; |
|||
|
|||
/***********************************************************************/ |
|||
/* Functions used externally. */ |
|||
/***********************************************************************/ |
|||
PQRYRES WMIColumns(PGLOBAL g, char *nsp, char *cls, bool info); |
|||
|
|||
/* -------------------------- WMI classes ---------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* WMI: Virtual table to get the WMI information. */ |
|||
/***********************************************************************/ |
|||
class WMIDEF : public TABDEF { /* Logical table description */ |
|||
friend class TDBWMI; |
|||
friend class TDBWCL; |
|||
friend class TDBWCX; |
|||
public: |
|||
// Constructor |
|||
WMIDEF(void) {Pseudo = 3; Nspace = NULL; Wclass = NULL; Ems = 0;} |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "WMI";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Nspace; |
|||
char *Wclass; |
|||
int Ems; |
|||
}; // end of WMIDEF |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the WMI table. */ |
|||
/***********************************************************************/ |
|||
class TDBWMI : public TDBASE { |
|||
friend class WMICOL; |
|||
public: |
|||
// Constructor |
|||
TDBWMI(PWMIDEF tdp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_WMI;} |
|||
|
|||
// Methods |
|||
virtual int GetRecpos(void); |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
bool Initialize(PGLOBAL g); |
|||
char *MakeWQL(PGLOBAL g); |
|||
void DoubleSlash(PGLOBAL g); |
|||
bool GetWMIInfo(PGLOBAL g); |
|||
|
|||
// Members |
|||
IWbemServices *Svc; // IWbemServices pointer |
|||
IEnumWbemClassObject *Enumerator; |
|||
IWbemClassObject *ClsObj; |
|||
char *Nspace; // Namespace |
|||
char *Wclass; // Class name |
|||
char *ObjPath; // Used for direct access |
|||
char *Kvp; // Itou |
|||
int Ems; // Estimated max size |
|||
PCOL Kcol; // Key column |
|||
HRESULT Res; |
|||
PVBLK Vbp; |
|||
bool Init; |
|||
bool Done; |
|||
ULONG Rc; |
|||
int N; // Row number |
|||
}; // end of class TDBWMI |
|||
|
|||
/***********************************************************************/ |
|||
/* Class WMICOL: WMI Address column. */ |
|||
/***********************************************************************/ |
|||
class WMICOL : public COLBLK { |
|||
friend class TDBWMI; |
|||
public: |
|||
// Constructors |
|||
WMICOL(PCOLDEF cdp, PTDB tdbp, int n); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_WMI;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
WMICOL(void) {} // Default constructor not to be used |
|||
|
|||
// Members |
|||
PTDBWMI Tdbp; // Points to WMI table block |
|||
VARIANT Prop; // Property value |
|||
CIMTYPE Ctype; // CIM Type |
|||
HRESULT Res; |
|||
}; // end of class WMICOL |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the WMI catalog table. */ |
|||
/***********************************************************************/ |
|||
class TDBWCL : public TDBCAT { |
|||
public: |
|||
// Constructor |
|||
TDBWCL(PWMIDEF tdp); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
virtual PQRYRES GetResult(PGLOBAL g); |
|||
|
|||
// Members |
|||
char *Nsp; // Name space |
|||
char *Cls; // Class |
|||
}; // end of class TDBWCL |
|||
@ -1,246 +1,240 @@ |
|||
|
|||
/*************** Tabxml H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABXML.H Version 1.6 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ |
|||
/* */ |
|||
/* This file contains the XML table classes declares. */ |
|||
/***********************************************************************/ |
|||
typedef class XMLDEF *PXMLDEF; |
|||
typedef class TDBXML *PTDBXML; |
|||
typedef class XMLCOL *PXMLCOL; |
|||
|
|||
// These functions are exported from the Extended.dll |
|||
//PTABDEF __stdcall GetXML(PGLOBAL g, void *memp); |
|||
|
|||
/* --------------------------- XML classes --------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* XML table. */ |
|||
/***********************************************************************/ |
|||
class DllExport XMLDEF : public TABDEF { /* Logical table description */ |
|||
friend class TDBXML; |
|||
public: |
|||
// Constructor |
|||
XMLDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "XML";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
//virtual bool DeleteTableFile(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Fn; /* Path/Name of corresponding file */ |
|||
char *Encoding; /* New XML table file encoding */ |
|||
char *Tabname; /* Name of Table node */ |
|||
char *Rowname; /* Name of first level nodes */ |
|||
char *Colname; /* Name of second level nodes */ |
|||
char *Mulnode; /* Name of multiple node */ |
|||
char *XmlDB; /* Name of XML DB node */ |
|||
char *Nslist; /* List of namespaces to register */ |
|||
char *DefNs; /* Dummy name of default namespace */ |
|||
char *Attrib; /* Table node attributes */ |
|||
char *Hdattr; /* Header node attributes */ |
|||
int Coltype; /* Default column type */ |
|||
int Limit; /* Limit of multiple values */ |
|||
int Header; /* n first rows are header rows */ |
|||
bool Xpand; /* Put multiple tags in several rows */ |
|||
bool Usedom; /* True: DOM, False: libxml2 */ |
|||
}; // end of XMLDEF |
|||
|
|||
#if defined(INCLUDE_TDBXML) |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the simple XML tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBXML : public TDBASE { |
|||
friend class XMLCOL; |
|||
friend class XMULCOL; |
|||
friend class XPOSCOL; |
|||
public: |
|||
// Constructor |
|||
TDBXML(PXMLDEF tdp); |
|||
TDBXML(PTDBXML tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_XML;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXML(this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual int GetRecpos(void); |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual PSZ GetFile(PGLOBAL g) {return Xfile;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {Xfile = fn;} |
|||
virtual void ResetDB(void) {N = 0;} |
|||
virtual void ResetSize(void) {MaxSize = -1;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false); |
|||
int LoadTableFile(PGLOBAL g, char *filename); |
|||
bool Initialize(PGLOBAL g); |
|||
bool SetTabNode(PGLOBAL g); |
|||
void SetNodeAttr(PGLOBAL g, char *attr, PXNODE node); |
|||
bool CheckRow(PGLOBAL g, bool b); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); |
|||
//virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;} |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
//virtual bool NeedIndexing(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;} |
|||
virtual const CHARSET_INFO *data_charset() |
|||
{return &my_charset_utf8_general_ci;} |
|||
|
|||
protected: |
|||
// Members |
|||
PXDOC Docp; |
|||
PXNODE Root; |
|||
PXNODE Curp; |
|||
PXNODE DBnode; |
|||
PXNODE TabNode; |
|||
PXNODE RowNode; |
|||
PXNODE ColNode; |
|||
PXLIST Nlist; |
|||
PXLIST Clist; |
|||
PFBLOCK To_Xb; // Pointer to XML file block |
|||
PCOL Colp; // The multiple column |
|||
bool Changed; // After Update, Insert or Delete |
|||
bool Checked; // After Update check pass |
|||
bool NextSame; // Same next row |
|||
bool Xpand; // Put multiple tags in several rows |
|||
bool NewRow; // True when inserting a new row |
|||
bool Hasnod; // True if rows have subnodes |
|||
bool Write; // True for Insert and Update |
|||
bool Usedom; // True for DOM, False for libxml2 |
|||
bool Bufdone; // True when column buffers allocated |
|||
bool Nodedone; // True when column nodes allocated |
|||
bool Void; // True if the file does not exist |
|||
char *Xfile; // The XML file |
|||
char *Enc; // New XML table file encoding |
|||
char *Tabname; // Name of Table node |
|||
char *Rowname; // Name of first level nodes |
|||
char *Colname; // Name of second level nodes |
|||
char *Mulnode; // Name of multiple node |
|||
char *XmlDB; // Name of XML DB node |
|||
char *Nslist; // List of namespaces to register |
|||
char *DefNs; // Dummy name of default namespace |
|||
char *Attrib; // Table node attribut(s) |
|||
char *Hdattr; // Header node attribut(s) |
|||
int Coltype; // Default column type |
|||
int Limit; // Limit of multiple values |
|||
int Header; // n first rows are header rows |
|||
int Multiple; // If multiple files |
|||
int Nrow; // The table cardinality |
|||
int Irow; // The current row index |
|||
int Nsub; // The current subrow index |
|||
int N; // The current Rowid |
|||
}; // end of class TDBXML |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XMLCOL: XDB table access method column descriptor. */ |
|||
/***********************************************************************/ |
|||
class XMLCOL : public COLBLK { |
|||
public: |
|||
// Constructors |
|||
XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "XML"); |
|||
XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_XML;} |
|||
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} |
|||
bool ParseXpath(PGLOBAL g, bool mode); |
|||
|
|||
// Methods |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
bool AllocBuf(PGLOBAL g, bool mode); |
|||
void AllocNodes(PGLOBAL g, PXDOC dp); |
|||
|
|||
protected: |
|||
//xmlNodePtr SelectSingleNode(xmlNodePtr node, char *name); |
|||
|
|||
// Default constructor not to be used |
|||
XMLCOL(void) : COLBLK(1) {} |
|||
|
|||
// Members |
|||
PXLIST Nl; |
|||
PXLIST Nlx; |
|||
PXNODE ColNode; |
|||
PXNODE ValNode; |
|||
PXNODE Cxnp; |
|||
PXNODE Vxnp; |
|||
PXATTR Vxap; |
|||
PXATTR AttNode; |
|||
PTDBXML Tdbp; |
|||
char *Valbuf; // To the node value buffer |
|||
char *Xname; // The node or attribute name |
|||
char* *Nodes; // The intermediate nodes |
|||
int Type; // 0: Attribute, 1: Tag, 2: position |
|||
int Nod; // The number of intermediate nodes |
|||
int Inod; // Index of multiple node |
|||
int Rank; // Position |
|||
bool Mul; // true for multiple column |
|||
bool Checked; // Was checked while Updating |
|||
int Long; // Buffer length |
|||
int Nx; // The last read row |
|||
int Sx; // The last read sub-row |
|||
PVAL To_Val; // To value used for Update/Insert |
|||
}; // end of class XMLCOL |
|||
|
|||
/***********************************************************************/ |
|||
/* Derived class XMLCOLX: used to replace a multiple XMLCOL by the */ |
|||
/* derived class XMULCOL that has specialize read and write functions.*/ |
|||
/* Note: this works only if the members of the derived class are the */ |
|||
/* same than the ones of the original class (NO added members). */ |
|||
/***********************************************************************/ |
|||
class XMLCOLX : public XMLCOL { |
|||
public: |
|||
// Fake operator new used to change a filter into a derived filter |
|||
void * operator new(size_t size, PXMLCOL colp) {return colp;} |
|||
#if !defined(__BORLANDC__) |
|||
// Avoid warning C4291 by defining a matching dummy delete operator |
|||
void operator delete(void *, size_t size) {} |
|||
void operator delete(void *, PXMLCOL) {} |
|||
#endif |
|||
}; // end of class XMLCOLX |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XMULCOL: XML table access method multiple column descriptor. */ |
|||
/***********************************************************************/ |
|||
class XMULCOL : public XMLCOLX { |
|||
public: |
|||
// The constructor must restore Value because XOBJECT has a void |
|||
// constructor called by default that set Value to NULL |
|||
XMULCOL(PVAL valp) {Value = valp; Mul = true;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
}; // end of class XMULCOL |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XPOSCOL: XML table column accessed by position. */ |
|||
/***********************************************************************/ |
|||
class XPOSCOL : public XMLCOLX { |
|||
public: |
|||
// The constructor must restore Value because XOBJECT has a void |
|||
// constructor called by default that set Value to NULL |
|||
XPOSCOL(PVAL valp) {Value = valp;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
}; // end of class XPOSCOL |
|||
|
|||
#endif // INCLUDE_TDBXML |
|||
|
|||
/*************** Tabxml H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABXML.H Version 1.6 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ |
|||
/* */ |
|||
/* This file contains the XML table classes declares. */ |
|||
/***********************************************************************/ |
|||
typedef class XMLDEF *PXMLDEF; |
|||
typedef class TDBXML *PTDBXML; |
|||
typedef class XMLCOL *PXMLCOL; |
|||
|
|||
/* --------------------------- XML classes --------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* XML table. */ |
|||
/***********************************************************************/ |
|||
class DllExport XMLDEF : public TABDEF { /* Logical table description */ |
|||
friend class TDBXML; |
|||
public: |
|||
// Constructor |
|||
XMLDEF(void); |
|||
|
|||
// Implementation |
|||
virtual const char *GetType(void) {return "XML";} |
|||
|
|||
// Methods |
|||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); |
|||
virtual PTDB GetTable(PGLOBAL g, MODE m); |
|||
|
|||
protected: |
|||
// Members |
|||
char *Fn; /* Path/Name of corresponding file */ |
|||
char *Encoding; /* New XML table file encoding */ |
|||
char *Tabname; /* Name of Table node */ |
|||
char *Rowname; /* Name of first level nodes */ |
|||
char *Colname; /* Name of second level nodes */ |
|||
char *Mulnode; /* Name of multiple node */ |
|||
char *XmlDB; /* Name of XML DB node */ |
|||
char *Nslist; /* List of namespaces to register */ |
|||
char *DefNs; /* Dummy name of default namespace */ |
|||
char *Attrib; /* Table node attributes */ |
|||
char *Hdattr; /* Header node attributes */ |
|||
int Coltype; /* Default column type */ |
|||
int Limit; /* Limit of multiple values */ |
|||
int Header; /* n first rows are header rows */ |
|||
bool Xpand; /* Put multiple tags in several rows */ |
|||
bool Usedom; /* True: DOM, False: libxml2 */ |
|||
}; // end of XMLDEF |
|||
|
|||
#if defined(INCLUDE_TDBXML) |
|||
/***********************************************************************/ |
|||
/* This is the class declaration for the simple XML tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBXML : public TDBASE { |
|||
friend class XMLCOL; |
|||
friend class XMULCOL; |
|||
friend class XPOSCOL; |
|||
public: |
|||
// Constructor |
|||
TDBXML(PXMLDEF tdp); |
|||
TDBXML(PTDBXML tdbp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_XML;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return (PTDB)new(g) TDBXML(this);} |
|||
|
|||
// Methods |
|||
virtual PTDB CopyOne(PTABS t); |
|||
virtual int GetRecpos(void); |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual PSZ GetFile(PGLOBAL g) {return Xfile;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {Xfile = fn;} |
|||
virtual void ResetDB(void) {N = 0;} |
|||
virtual void ResetSize(void) {MaxSize = -1;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false); |
|||
int LoadTableFile(PGLOBAL g, char *filename); |
|||
bool Initialize(PGLOBAL g); |
|||
bool SetTabNode(PGLOBAL g); |
|||
void SetNodeAttr(PGLOBAL g, char *attr, PXNODE node); |
|||
bool CheckRow(PGLOBAL g, bool b); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); |
|||
//virtual int GetMaxSame(PGLOBAL g) {return (Xpand) ? Limit : 1;} |
|||
virtual int Cardinality(PGLOBAL g); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
//virtual bool NeedIndexing(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;} |
|||
virtual const CHARSET_INFO *data_charset() |
|||
{return &my_charset_utf8_general_ci;} |
|||
|
|||
protected: |
|||
// Members |
|||
PXDOC Docp; |
|||
PXNODE Root; |
|||
PXNODE Curp; |
|||
PXNODE DBnode; |
|||
PXNODE TabNode; |
|||
PXNODE RowNode; |
|||
PXNODE ColNode; |
|||
PXLIST Nlist; |
|||
PXLIST Clist; |
|||
PFBLOCK To_Xb; // Pointer to XML file block |
|||
PCOL Colp; // The multiple column |
|||
bool Changed; // After Update, Insert or Delete |
|||
bool Checked; // After Update check pass |
|||
bool NextSame; // Same next row |
|||
bool Xpand; // Put multiple tags in several rows |
|||
bool NewRow; // True when inserting a new row |
|||
bool Hasnod; // True if rows have subnodes |
|||
bool Write; // True for Insert and Update |
|||
bool Usedom; // True for DOM, False for libxml2 |
|||
bool Bufdone; // True when column buffers allocated |
|||
bool Nodedone; // True when column nodes allocated |
|||
bool Void; // True if the file does not exist |
|||
char *Xfile; // The XML file |
|||
char *Enc; // New XML table file encoding |
|||
char *Tabname; // Name of Table node |
|||
char *Rowname; // Name of first level nodes |
|||
char *Colname; // Name of second level nodes |
|||
char *Mulnode; // Name of multiple node |
|||
char *XmlDB; // Name of XML DB node |
|||
char *Nslist; // List of namespaces to register |
|||
char *DefNs; // Dummy name of default namespace |
|||
char *Attrib; // Table node attribut(s) |
|||
char *Hdattr; // Header node attribut(s) |
|||
int Coltype; // Default column type |
|||
int Limit; // Limit of multiple values |
|||
int Header; // n first rows are header rows |
|||
int Multiple; // If multiple files |
|||
int Nrow; // The table cardinality |
|||
int Irow; // The current row index |
|||
int Nsub; // The current subrow index |
|||
int N; // The current Rowid |
|||
}; // end of class TDBXML |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XMLCOL: XDB table access method column descriptor. */ |
|||
/***********************************************************************/ |
|||
class XMLCOL : public COLBLK { |
|||
public: |
|||
// Constructors |
|||
XMLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "XML"); |
|||
XMLCOL(XMLCOL *colp, PTDB tdbp); // Constructor used in copy process |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_XML;} |
|||
virtual void SetTo_Val(PVAL valp) {To_Val = valp;} |
|||
bool ParseXpath(PGLOBAL g, bool mode); |
|||
|
|||
// Methods |
|||
virtual bool SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check); |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
bool AllocBuf(PGLOBAL g, bool mode); |
|||
void AllocNodes(PGLOBAL g, PXDOC dp); |
|||
|
|||
protected: |
|||
//xmlNodePtr SelectSingleNode(xmlNodePtr node, char *name); |
|||
|
|||
// Default constructor not to be used |
|||
XMLCOL(void) : COLBLK(1) {} |
|||
|
|||
// Members |
|||
PXLIST Nl; |
|||
PXLIST Nlx; |
|||
PXNODE ColNode; |
|||
PXNODE ValNode; |
|||
PXNODE Cxnp; |
|||
PXNODE Vxnp; |
|||
PXATTR Vxap; |
|||
PXATTR AttNode; |
|||
PTDBXML Tdbp; |
|||
char *Valbuf; // To the node value buffer |
|||
char *Xname; // The node or attribute name |
|||
char* *Nodes; // The intermediate nodes |
|||
int Type; // 0: Attribute, 1: Tag, 2: position |
|||
int Nod; // The number of intermediate nodes |
|||
int Inod; // Index of multiple node |
|||
int Rank; // Position |
|||
bool Mul; // true for multiple column |
|||
bool Checked; // Was checked while Updating |
|||
int Long; // Buffer length |
|||
int Nx; // The last read row |
|||
int Sx; // The last read sub-row |
|||
PVAL To_Val; // To value used for Update/Insert |
|||
}; // end of class XMLCOL |
|||
|
|||
/***********************************************************************/ |
|||
/* Derived class XMLCOLX: used to replace a multiple XMLCOL by the */ |
|||
/* derived class XMULCOL that has specialize read and write functions.*/ |
|||
/* Note: this works only if the members of the derived class are the */ |
|||
/* same than the ones of the original class (NO added members). */ |
|||
/***********************************************************************/ |
|||
class XMLCOLX : public XMLCOL { |
|||
public: |
|||
// Fake operator new used to change a filter into a derived filter |
|||
void * operator new(size_t size, PXMLCOL colp) {return colp;} |
|||
#if !defined(__BORLANDC__) |
|||
// Avoid warning C4291 by defining a matching dummy delete operator |
|||
void operator delete(void *, size_t size) {} |
|||
void operator delete(void *, PXMLCOL) {} |
|||
#endif |
|||
}; // end of class XMLCOLX |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XMULCOL: XML table access method multiple column descriptor. */ |
|||
/***********************************************************************/ |
|||
class XMULCOL : public XMLCOLX { |
|||
public: |
|||
// The constructor must restore Value because XOBJECT has a void |
|||
// constructor called by default that set Value to NULL |
|||
XMULCOL(PVAL valp) {Value = valp; Mul = true;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
}; // end of class XMULCOL |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XPOSCOL: XML table column accessed by position. */ |
|||
/***********************************************************************/ |
|||
class XPOSCOL : public XMLCOLX { |
|||
public: |
|||
// The constructor must restore Value because XOBJECT has a void |
|||
// constructor called by default that set Value to NULL |
|||
XPOSCOL(PVAL valp) {Value = valp;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
virtual void WriteColumn(PGLOBAL g); |
|||
}; // end of class XPOSCOL |
|||
#endif // INCLUDE_TDBXML |
|||
@ -1,163 +1,161 @@ |
|||
/* Copyright (C) Olivier Bertrand 2004 - 2012
|
|||
|
|||
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 |
|||
the Free Software Foundation; version 2 of the License. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
|||
|
|||
/**
|
|||
@file user_connect.cc |
|||
|
|||
@brief |
|||
Implements the user_connect class. |
|||
|
|||
@details |
|||
To support multi_threading, each query creates and use a PlugDB "user" |
|||
that is a connection with its personnal memory allocation. |
|||
|
|||
@note |
|||
|
|||
*/ |
|||
|
|||
/****************************************************************************/ |
|||
/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2012 */ |
|||
/****************************************************************************/ |
|||
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|||
#pragma implementation // gcc: Class implementation
|
|||
#endif
|
|||
|
|||
#define DONT_DEFINE_VOID
|
|||
#define MYSQL_SERVER
|
|||
#include "sql_class.h"
|
|||
#undef OFFSET
|
|||
|
|||
#define NOPARSE
|
|||
#include "osutil.h"
|
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "connect.h"
|
|||
#include "user_connect.h"
|
|||
#include "mycat.h"
|
|||
|
|||
extern "C" char plgxini[]; |
|||
extern int xtrace; |
|||
|
|||
/****************************************************************************/ |
|||
/* Initialize the user_connect static member. */ |
|||
/****************************************************************************/ |
|||
PCONNECT user_connect::to_users= NULL; |
|||
|
|||
/* -------------------------- class user_connect -------------------------- */ |
|||
|
|||
/****************************************************************************/ |
|||
/* Constructor. */ |
|||
/****************************************************************************/ |
|||
user_connect::user_connect(THD *thd, const char *dbn) |
|||
{ |
|||
thdp= thd; |
|||
next= NULL; |
|||
previous= NULL; |
|||
g= NULL; |
|||
last_query_id= 0; |
|||
count= 0; |
|||
|
|||
// Statistics
|
|||
nrd= fnd= nfd= 0; |
|||
tb1= 0; |
|||
} // end of user_connect constructor
|
|||
|
|||
|
|||
/****************************************************************************/ |
|||
/* Destructor. */ |
|||
/****************************************************************************/ |
|||
user_connect::~user_connect() |
|||
{ |
|||
// Terminate CONNECT and Plug-like environment, should return NULL
|
|||
g= CntExit(g); |
|||
} // end of user_connect destructor
|
|||
|
|||
|
|||
/****************************************************************************/ |
|||
/* Initialization. */ |
|||
/****************************************************************************/ |
|||
bool user_connect::user_init() |
|||
{ |
|||
// Initialize Plug-like environment
|
|||
PACTIVITY ap= NULL; |
|||
PDBUSER dup= NULL; |
|||
|
|||
// Areasize= 64M because of VEC tables. Should be parameterisable
|
|||
g= PlugInit(NULL, 67108864); |
|||
//g= PlugInit(NULL, 134217728); // 128M was because of old embedded tests
|
|||
|
|||
// Check whether the initialization is complete
|
|||
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size) |
|||
|| !(dup= PlgMakeUser(g))) { |
|||
if (g) |
|||
printf("%s\n", g->Message); |
|||
|
|||
int rc= PlugExit(g); |
|||
g= NULL; |
|||
free(dup); |
|||
return true; |
|||
} // endif g->
|
|||
|
|||
dup->Catalog= new MYCAT(NULL); |
|||
|
|||
ap= new ACTIVITY; |
|||
memset(ap, 0, sizeof(ACTIVITY)); |
|||
strcpy(ap->Ap_Name, "CONNECT"); |
|||
g->Activityp= ap; |
|||
g->Activityp->Aptr= dup; |
|||
next= to_users; |
|||
to_users= this; |
|||
|
|||
if (next) |
|||
next->previous= this; |
|||
|
|||
last_query_id= thdp->query_id; |
|||
count= 1; |
|||
return false; |
|||
} // end of user_init
|
|||
|
|||
|
|||
void user_connect::SetHandler(ha_connect *hc) |
|||
{ |
|||
PDBUSER dup= (PDBUSER)g->Activityp->Aptr; |
|||
MYCAT *mc= (MYCAT*)dup->Catalog; |
|||
mc->SetHandler(hc); |
|||
} |
|||
|
|||
/****************************************************************************/ |
|||
/* Check whether we begin a new query and if so cleanup the previous one. */ |
|||
/****************************************************************************/ |
|||
bool user_connect::CheckCleanup(void) |
|||
{ |
|||
if (thdp->query_id > last_query_id) { |
|||
PlugCleanup(g, true); |
|||
PlugSubSet(g, g->Sarea, g->Sarea_Size); |
|||
g->Xchk = NULL; |
|||
g->Createas = 0; |
|||
g->Alchecked = 0; |
|||
#if defined(MRRBKA_SUPPORT)
|
|||
g->Mrr = 0; |
|||
#endif // MRRBKA_SUPPORT
|
|||
last_query_id= thdp->query_id; |
|||
|
|||
if (xtrace) |
|||
printf("=====> Begin new query %llu\n", last_query_id); |
|||
|
|||
return true; |
|||
} // endif query_id
|
|||
|
|||
return false; |
|||
} // end of CheckCleanup
|
|||
|
|||
/* Copyright (C) Olivier Bertrand 2004 - 2012
|
|||
|
|||
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 |
|||
the Free Software Foundation; version 2 of the License. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
|||
|
|||
/**
|
|||
@file user_connect.cc |
|||
|
|||
@brief |
|||
Implements the user_connect class. |
|||
|
|||
@details |
|||
To support multi_threading, each query creates and use a PlugDB "user" |
|||
that is a connection with its personnal memory allocation. |
|||
|
|||
@note |
|||
|
|||
*/ |
|||
|
|||
/****************************************************************************/ |
|||
/* Author: Olivier Bertrand -- bertrandop@gmail.com -- 2004-2012 */ |
|||
/****************************************************************************/ |
|||
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|||
#pragma implementation // gcc: Class implementation
|
|||
#endif
|
|||
|
|||
#define DONT_DEFINE_VOID
|
|||
#define MYSQL_SERVER
|
|||
#include "sql_class.h"
|
|||
#undef OFFSET
|
|||
|
|||
#define NOPARSE
|
|||
#include "osutil.h"
|
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "connect.h"
|
|||
#include "user_connect.h"
|
|||
#include "mycat.h"
|
|||
|
|||
extern "C" char plgxini[]; |
|||
extern int xtrace; |
|||
|
|||
/****************************************************************************/ |
|||
/* Initialize the user_connect static member. */ |
|||
/****************************************************************************/ |
|||
PCONNECT user_connect::to_users= NULL; |
|||
|
|||
/* -------------------------- class user_connect -------------------------- */ |
|||
|
|||
/****************************************************************************/ |
|||
/* Constructor. */ |
|||
/****************************************************************************/ |
|||
user_connect::user_connect(THD *thd, const char *dbn) |
|||
{ |
|||
thdp= thd; |
|||
next= NULL; |
|||
previous= NULL; |
|||
g= NULL; |
|||
last_query_id= 0; |
|||
count= 0; |
|||
|
|||
// Statistics
|
|||
nrd= fnd= nfd= 0; |
|||
tb1= 0; |
|||
} // end of user_connect constructor
|
|||
|
|||
|
|||
/****************************************************************************/ |
|||
/* Destructor. */ |
|||
/****************************************************************************/ |
|||
user_connect::~user_connect() |
|||
{ |
|||
// Terminate CONNECT and Plug-like environment, should return NULL
|
|||
g= CntExit(g); |
|||
} // end of user_connect destructor
|
|||
|
|||
|
|||
/****************************************************************************/ |
|||
/* Initialization. */ |
|||
/****************************************************************************/ |
|||
bool user_connect::user_init() |
|||
{ |
|||
// Initialize Plug-like environment
|
|||
PACTIVITY ap= NULL; |
|||
PDBUSER dup= NULL; |
|||
|
|||
// Areasize= 64M because of VEC tables. Should be parameterisable
|
|||
g= PlugInit(NULL, 67108864); |
|||
//g= PlugInit(NULL, 134217728); // 128M was because of old embedded tests
|
|||
|
|||
// Check whether the initialization is complete
|
|||
if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size) |
|||
|| !(dup= PlgMakeUser(g))) { |
|||
if (g) |
|||
printf("%s\n", g->Message); |
|||
|
|||
int rc= PlugExit(g); |
|||
g= NULL; |
|||
free(dup); |
|||
return true; |
|||
} // endif g->
|
|||
|
|||
dup->Catalog= new MYCAT(NULL); |
|||
|
|||
ap= new ACTIVITY; |
|||
memset(ap, 0, sizeof(ACTIVITY)); |
|||
strcpy(ap->Ap_Name, "CONNECT"); |
|||
g->Activityp= ap; |
|||
g->Activityp->Aptr= dup; |
|||
next= to_users; |
|||
to_users= this; |
|||
|
|||
if (next) |
|||
next->previous= this; |
|||
|
|||
last_query_id= thdp->query_id; |
|||
count= 1; |
|||
return false; |
|||
} // end of user_init
|
|||
|
|||
|
|||
void user_connect::SetHandler(ha_connect *hc) |
|||
{ |
|||
PDBUSER dup= (PDBUSER)g->Activityp->Aptr; |
|||
MYCAT *mc= (MYCAT*)dup->Catalog; |
|||
mc->SetHandler(hc); |
|||
} |
|||
|
|||
/****************************************************************************/ |
|||
/* Check whether we begin a new query and if so cleanup the previous one. */ |
|||
/****************************************************************************/ |
|||
bool user_connect::CheckCleanup(void) |
|||
{ |
|||
if (thdp->query_id > last_query_id) { |
|||
PlugCleanup(g, true); |
|||
PlugSubSet(g, g->Sarea, g->Sarea_Size); |
|||
g->Xchk = NULL; |
|||
g->Createas = 0; |
|||
g->Alchecked = 0; |
|||
g->Mrr = 0; |
|||
last_query_id= thdp->query_id; |
|||
|
|||
if (xtrace) |
|||
printf("=====> Begin new query %llu\n", last_query_id); |
|||
|
|||
return true; |
|||
} // endif query_id
|
|||
|
|||
return false; |
|||
} // end of CheckCleanup
|
|||
|
|||
@ -1,351 +1,331 @@ |
|||
/*************** Valblk H Declares Source Code File (.H) ***************/ |
|||
/* Name: VALBLK.H Version 2.1 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ |
|||
/* */ |
|||
/* This file contains the VALBLK and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* assert.h is header required when using the assert function. */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#ifndef __VALBLK__H__ |
|||
#define __VALBLK__H__ |
|||
#include "value.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Utility used to allocate value blocks. */ |
|||
/***********************************************************************/ |
|||
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, |
|||
bool, bool, bool); |
|||
const char *GetFmt(int type, bool un = false); |
|||
|
|||
#if defined(BLK_INDX) |
|||
/***********************************************************************/ |
|||
/* DB static external variables. */ |
|||
/***********************************************************************/ |
|||
extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */ |
|||
|
|||
/***********************************************************************/ |
|||
/* Class MBVALS is a utility class for (re)allocating VALBLK's. */ |
|||
/***********************************************************************/ |
|||
class MBVALS : public BLOCK { |
|||
//friend class LSTBLK; |
|||
friend class ARRAY; |
|||
public: |
|||
// Constructors |
|||
MBVALS(void) {Vblk = NULL; Mblk = Nmblk;} |
|||
|
|||
// Methods |
|||
void *GetMemp(void) {return Mblk.Memp;} |
|||
PVBLK Allocate(PGLOBAL g, int type, int len, int prec, |
|||
int n, bool sub = FALSE); |
|||
bool ReAllocate(PGLOBAL g, int n); |
|||
void Free(void); |
|||
|
|||
protected: |
|||
// Members |
|||
PVBLK Vblk; // Pointer to VALBLK |
|||
MBLOCK Mblk; // The memory block |
|||
}; // end of class MBVALS |
|||
|
|||
typedef class MBVALS *PMBV; |
|||
#endif // BLK_INDX |
|||
|
|||
/***********************************************************************/ |
|||
/* Class VALBLK represent a base class for variable blocks. */ |
|||
/***********************************************************************/ |
|||
class VALBLK : public BLOCK { |
|||
//friend void SemColData(PGLOBAL g, PSEM semp); |
|||
public: |
|||
// Constructors |
|||
VALBLK(void *mp, int type, int nval, bool un = false); |
|||
|
|||
// Implementation |
|||
int GetNval(void) {return Nval;} |
|||
void SetNval(int n) {Nval = n;} |
|||
void *GetValPointer(void) {return Blkp;} |
|||
void SetValPointer(void *mp) {Blkp = mp;} |
|||
int GetType(void) {return Type;} |
|||
int GetPrec(void) {return Prec;} |
|||
void SetCheck(bool b) {Check = b;} |
|||
void MoveNull(int i, int j) |
|||
{if (To_Nulls) To_Nulls[j] = To_Nulls[j];} |
|||
virtual void SetNull(int n, bool b) |
|||
{if (To_Nulls) {To_Nulls[n] = (b) ? '*' : 0;}} |
|||
virtual bool IsNull(int n) {return To_Nulls && To_Nulls[n];} |
|||
virtual void SetNullable(bool b); |
|||
virtual bool IsUnsigned(void) {return Unsigned;} |
|||
virtual void Init(PGLOBAL g, bool check) = 0; |
|||
virtual int GetVlen(void) = 0; |
|||
virtual PSZ GetCharValue(int n); |
|||
virtual char GetTinyValue(int n) = 0; |
|||
virtual uchar GetUTinyValue(int n) = 0; |
|||
virtual short GetShortValue(int n) = 0; |
|||
virtual ushort GetUShortValue(int n) = 0; |
|||
virtual int GetIntValue(int n) = 0; |
|||
virtual uint GetUIntValue(int n) = 0; |
|||
virtual longlong GetBigintValue(int n) = 0; |
|||
virtual ulonglong GetUBigintValue(int n) = 0; |
|||
virtual double GetFloatValue(int n) = 0; |
|||
virtual char *GetCharString(char *p, int n) = 0; |
|||
virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;} |
|||
virtual void Reset(int n) = 0; |
|||
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); |
|||
virtual void SetPrec(int p) {} |
|||
virtual bool IsCi(void) {return false;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(short sval, int n) {assert(false);} |
|||
virtual void SetValue(ushort sval, int n) {assert(false);} |
|||
virtual void SetValue(int lval, int n) {assert(false);} |
|||
virtual void SetValue(uint lval, int n) {assert(false);} |
|||
virtual void SetValue(longlong lval, int n) {assert(false);} |
|||
virtual void SetValue(ulonglong lval, int n) {assert(false);} |
|||
virtual void SetValue(double fval, int n) {assert(false);} |
|||
virtual void SetValue(char cval, int n) {assert(false);} |
|||
virtual void SetValue(uchar cval, int n) {assert(false);} |
|||
virtual void SetValue(PSZ sp, int n) {assert(false);} |
|||
virtual void SetValue(char *sp, uint len, int n) {assert(false);} |
|||
virtual void SetValue(PVAL valp, int n) = 0; |
|||
virtual void SetValue(PVBLK pv, int n1, int n2) = 0; |
|||
#if defined(BLK_INDX) |
|||
virtual void SetMin(PVAL valp, int n) = 0; |
|||
virtual void SetMax(PVAL valp, int n) = 0; |
|||
#endif // BLK_INDX |
|||
#if 0 |
|||
virtual void SetValues(PVBLK pv, int i, int n) = 0; |
|||
virtual void AddMinus1(PVBLK pv, int n1, int n2) {assert(false);} |
|||
#endif // 0 |
|||
virtual void Move(int i, int j) = 0; |
|||
virtual int CompVal(PVAL vp, int n) = 0; |
|||
virtual int CompVal(int i1, int i2) = 0; |
|||
virtual void *GetValPtr(int n) = 0; |
|||
virtual void *GetValPtrEx(int n) = 0; |
|||
virtual int Find(PVAL vp) = 0; |
|||
virtual int GetMaxLength(void) = 0; |
|||
bool Locate(PVAL vp, int& i); |
|||
|
|||
protected: |
|||
void ChkIndx(int n); |
|||
void ChkTyp(PVAL v); |
|||
void ChkTyp(PVBLK vb); |
|||
|
|||
// Members |
|||
PGLOBAL Global; // Used for messages and allocation |
|||
char *To_Nulls; // Null values array |
|||
void *Blkp; // To value block |
|||
bool Check; // If true SetValue types must match |
|||
bool Nullable; // True if values can be null |
|||
bool Unsigned; // True if values are unsigned |
|||
int Type; // Type of individual values |
|||
int Nval; // Max number of values in block |
|||
int Prec; // Precision of float values |
|||
}; // end of class VALBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TYPBLK: represents a block of typed values. */ |
|||
/***********************************************************************/ |
|||
template <class TYPE> |
|||
class TYPBLK : public VALBLK { |
|||
public: |
|||
// Constructors |
|||
TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false); |
|||
//TYPBLK(void *mp, int size, int prec, int type); |
|||
|
|||
// Implementation |
|||
virtual void Init(PGLOBAL g, bool check); |
|||
virtual int GetVlen(void) {return sizeof(TYPE);} |
|||
//virtual PSZ GetCharValue(int n); |
|||
virtual char GetTinyValue(int n) {return (char)Typp[n];} |
|||
virtual uchar GetUTinyValue(int n) {return (uchar)Typp[n];} |
|||
virtual short GetShortValue(int n) {return (short)Typp[n];} |
|||
virtual ushort GetUShortValue(int n) {return (ushort)Typp[n];} |
|||
virtual int GetIntValue(int n) {return (int)Typp[n];} |
|||
virtual uint GetUIntValue(int n) {return (uint)Typp[n];} |
|||
virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];} |
|||
virtual ulonglong GetUBigintValue(int n) {return (ulonglong)Typp[n];} |
|||
virtual double GetFloatValue(int n) {return (double)Typp[n];} |
|||
virtual char *GetCharString(char *p, int n); |
|||
virtual void Reset(int n) {Typp[n] = 0;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(PSZ sp, int n); |
|||
virtual void SetValue(char *sp, uint len, int n); |
|||
virtual void SetValue(short sval, int n) |
|||
{Typp[n] = (TYPE)sval; SetNull(n, false);} |
|||
virtual void SetValue(ushort sval, int n) |
|||
{Typp[n] = (TYPE)sval; SetNull(n, false);} |
|||
virtual void SetValue(int lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(uint lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(longlong lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(ulonglong lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(double fval, int n) |
|||
{Typp[n] = (TYPE)fval; SetNull(n, false);} |
|||
virtual void SetValue(char cval, int n) |
|||
{Typp[n] = (TYPE)cval; SetNull(n, false);} |
|||
virtual void SetValue(uchar cval, int n) |
|||
{Typp[n] = (TYPE)cval; SetNull(n, false);} |
|||
virtual void SetValue(PVAL valp, int n); |
|||
virtual void SetValue(PVBLK pv, int n1, int n2); |
|||
//virtual void SetValues(PVBLK pv, int k, int n); |
|||
#if defined(BLK_INDX) |
|||
virtual void SetMin(PVAL valp, int n); |
|||
virtual void SetMax(PVAL valp, int n); |
|||
#endif // BLK_INDX |
|||
virtual void Move(int i, int j); |
|||
virtual int CompVal(PVAL vp, int n); |
|||
virtual int CompVal(int i1, int i2); |
|||
virtual void *GetValPtr(int n); |
|||
virtual void *GetValPtrEx(int n); |
|||
virtual int Find(PVAL vp); |
|||
virtual int GetMaxLength(void); |
|||
|
|||
protected: |
|||
// Specialized functions |
|||
static ulonglong MaxVal(void); |
|||
TYPE GetTypedValue(PVAL vp); |
|||
TYPE GetTypedValue(PVBLK blk, int n); |
|||
|
|||
// Members |
|||
TYPE* const &Typp; |
|||
const char *Fmt; |
|||
}; // end of class TYPBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class CHRBLK: represent a block of fixed length strings. */ |
|||
/***********************************************************************/ |
|||
class CHRBLK : public VALBLK { |
|||
public: |
|||
// Constructors |
|||
CHRBLK(void *mp, int size, int len, int prec, bool b); |
|||
|
|||
// Implementation |
|||
virtual void Init(PGLOBAL g, bool check); |
|||
virtual int GetVlen(void) {return Long;} |
|||
virtual PSZ GetCharValue(int n); |
|||
virtual char GetTinyValue(int n); |
|||
virtual uchar GetUTinyValue(int n); |
|||
virtual short GetShortValue(int n); |
|||
virtual ushort GetUShortValue(int n); |
|||
virtual int GetIntValue(int n); |
|||
virtual uint GetUIntValue(int n); |
|||
virtual longlong GetBigintValue(int n); |
|||
virtual ulonglong GetUBigintValue(int n); |
|||
virtual double GetFloatValue(int n); |
|||
virtual char *GetCharString(char *p, int n); |
|||
virtual void Reset(int n); |
|||
virtual void SetPrec(int p) {Ci = (p != 0);} |
|||
virtual bool IsCi(void) {return Ci;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(PSZ sp, int n); |
|||
virtual void SetValue(char *sp, uint len, int n); |
|||
virtual void SetValue(PVAL valp, int n); |
|||
virtual void SetValue(PVBLK pv, int n1, int n2); |
|||
//virtual void SetValues(PVBLK pv, int k, int n); |
|||
#if defined(BLK_INDX) |
|||
virtual void SetMin(PVAL valp, int n); |
|||
virtual void SetMax(PVAL valp, int n); |
|||
#endif // BLK_INDX |
|||
virtual void Move(int i, int j); |
|||
virtual int CompVal(PVAL vp, int n); |
|||
virtual int CompVal(int i1, int i2); |
|||
virtual void *GetValPtr(int n); |
|||
virtual void *GetValPtrEx(int n); |
|||
virtual int Find(PVAL vp); |
|||
virtual int GetMaxLength(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char* const &Chrp; // Pointer to char buffer |
|||
PSZ Valp; // Used to make a zero ended value |
|||
bool Blanks; // True for right filling with blanks |
|||
bool Ci; // True if case insensitive |
|||
int Long; // Length of each string |
|||
}; // end of class CHRBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class STRBLK: represent a block of string pointers. */ |
|||
/* Currently this class is used only by the DECODE scalar function */ |
|||
/* and by the MyColumn function to store date formats. */ |
|||
/***********************************************************************/ |
|||
class STRBLK : public VALBLK { |
|||
public: |
|||
// Constructors |
|||
STRBLK(PGLOBAL g, void *mp, int size); |
|||
|
|||
// Implementation |
|||
virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}} |
|||
virtual bool IsNull(int n) {return Strp[n] == NULL;} |
|||
virtual void SetNullable(bool b) {} // Always nullable |
|||
virtual void Init(PGLOBAL g, bool check); |
|||
virtual int GetVlen(void) {return sizeof(PSZ);} |
|||
virtual PSZ GetCharValue(int n) {return Strp[n];} |
|||
virtual char GetTinyValue(int n); |
|||
virtual uchar GetUTinyValue(int n); |
|||
virtual short GetShortValue(int n); |
|||
virtual ushort GetUShortValue(int n); |
|||
virtual int GetIntValue(int n); |
|||
virtual uint GetUIntValue(int n); |
|||
virtual longlong GetBigintValue(int n); |
|||
virtual ulonglong GetUBigintValue(int n); |
|||
virtual double GetFloatValue(int n) {return atof(Strp[n]);} |
|||
virtual char *GetCharString(char *p, int n) {return Strp[n];} |
|||
virtual void Reset(int n) {Strp[n] = NULL;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(PSZ sp, int n); |
|||
virtual void SetValue(char *sp, uint len, int n); |
|||
virtual void SetValue(PVAL valp, int n); |
|||
virtual void SetValue(PVBLK pv, int n1, int n2); |
|||
//virtual void SetValues(PVBLK pv, int k, int n); |
|||
#if defined(BLK_INDX) |
|||
virtual void SetMin(PVAL valp, int n); |
|||
virtual void SetMax(PVAL valp, int n); |
|||
#endif // BLK_INDX |
|||
virtual void Move(int i, int j); |
|||
virtual int CompVal(PVAL vp, int n); |
|||
virtual int CompVal(int i1, int i2); |
|||
virtual void *GetValPtr(int n); |
|||
virtual void *GetValPtrEx(int n); |
|||
virtual int Find(PVAL vp); |
|||
virtual int GetMaxLength(void); |
|||
|
|||
// Specific |
|||
void SetSorted(bool b) {Sorted = b;} |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ* const &Strp; // Pointer to PSZ buffer |
|||
bool Sorted; // Values are (semi?) sorted |
|||
}; // end of class STRBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* 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__ |
|||
|
|||
/*************** Valblk H Declares Source Code File (.H) ***************/ |
|||
/* Name: VALBLK.H Version 2.1 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ |
|||
/* */ |
|||
/* This file contains the VALBLK and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* assert.h is header required when using the assert function. */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#ifndef __VALBLK__H__ |
|||
#define __VALBLK__H__ |
|||
#include "value.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Utility used to allocate value blocks. */ |
|||
/***********************************************************************/ |
|||
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, |
|||
bool, bool, bool); |
|||
const char *GetFmt(int type, bool un = false); |
|||
|
|||
/***********************************************************************/ |
|||
/* DB static external variables. */ |
|||
/***********************************************************************/ |
|||
extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */ |
|||
|
|||
/***********************************************************************/ |
|||
/* Class MBVALS is a utility class for (re)allocating VALBLK's. */ |
|||
/***********************************************************************/ |
|||
class MBVALS : public BLOCK { |
|||
//friend class LSTBLK; |
|||
friend class ARRAY; |
|||
public: |
|||
// Constructors |
|||
MBVALS(void) {Vblk = NULL; Mblk = Nmblk;} |
|||
|
|||
// Methods |
|||
void *GetMemp(void) {return Mblk.Memp;} |
|||
PVBLK Allocate(PGLOBAL g, int type, int len, int prec, |
|||
int n, bool sub = FALSE); |
|||
bool ReAllocate(PGLOBAL g, int n); |
|||
void Free(void); |
|||
|
|||
protected: |
|||
// Members |
|||
PVBLK Vblk; // Pointer to VALBLK |
|||
MBLOCK Mblk; // The memory block |
|||
}; // end of class MBVALS |
|||
|
|||
typedef class MBVALS *PMBV; |
|||
|
|||
/***********************************************************************/ |
|||
/* Class VALBLK represent a base class for variable blocks. */ |
|||
/***********************************************************************/ |
|||
class VALBLK : public BLOCK { |
|||
public: |
|||
// Constructors |
|||
VALBLK(void *mp, int type, int nval, bool un = false); |
|||
|
|||
// Implementation |
|||
int GetNval(void) {return Nval;} |
|||
void SetNval(int n) {Nval = n;} |
|||
void *GetValPointer(void) {return Blkp;} |
|||
void SetValPointer(void *mp) {Blkp = mp;} |
|||
int GetType(void) {return Type;} |
|||
int GetPrec(void) {return Prec;} |
|||
void SetCheck(bool b) {Check = b;} |
|||
void MoveNull(int i, int j) |
|||
{if (To_Nulls) To_Nulls[j] = To_Nulls[j];} |
|||
virtual void SetNull(int n, bool b) |
|||
{if (To_Nulls) {To_Nulls[n] = (b) ? '*' : 0;}} |
|||
virtual bool IsNull(int n) {return To_Nulls && To_Nulls[n];} |
|||
virtual void SetNullable(bool b); |
|||
virtual bool IsUnsigned(void) {return Unsigned;} |
|||
virtual void Init(PGLOBAL g, bool check) = 0; |
|||
virtual int GetVlen(void) = 0; |
|||
virtual PSZ GetCharValue(int n); |
|||
virtual char GetTinyValue(int n) = 0; |
|||
virtual uchar GetUTinyValue(int n) = 0; |
|||
virtual short GetShortValue(int n) = 0; |
|||
virtual ushort GetUShortValue(int n) = 0; |
|||
virtual int GetIntValue(int n) = 0; |
|||
virtual uint GetUIntValue(int n) = 0; |
|||
virtual longlong GetBigintValue(int n) = 0; |
|||
virtual ulonglong GetUBigintValue(int n) = 0; |
|||
virtual double GetFloatValue(int n) = 0; |
|||
virtual char *GetCharString(char *p, int n) = 0; |
|||
virtual void ReAlloc(void *mp, int n) {Blkp = mp; Nval = n;} |
|||
virtual void Reset(int n) = 0; |
|||
virtual bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); |
|||
virtual void SetPrec(int p) {} |
|||
virtual bool IsCi(void) {return false;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(short sval, int n) {assert(false);} |
|||
virtual void SetValue(ushort sval, int n) {assert(false);} |
|||
virtual void SetValue(int lval, int n) {assert(false);} |
|||
virtual void SetValue(uint lval, int n) {assert(false);} |
|||
virtual void SetValue(longlong lval, int n) {assert(false);} |
|||
virtual void SetValue(ulonglong lval, int n) {assert(false);} |
|||
virtual void SetValue(double fval, int n) {assert(false);} |
|||
virtual void SetValue(char cval, int n) {assert(false);} |
|||
virtual void SetValue(uchar cval, int n) {assert(false);} |
|||
virtual void SetValue(PSZ sp, int n) {assert(false);} |
|||
virtual void SetValue(char *sp, uint len, int n) {assert(false);} |
|||
virtual void SetValue(PVAL valp, int n) = 0; |
|||
virtual void SetValue(PVBLK pv, int n1, int n2) = 0; |
|||
virtual void SetMin(PVAL valp, int n) = 0; |
|||
virtual void SetMax(PVAL valp, int n) = 0; |
|||
virtual void Move(int i, int j) = 0; |
|||
virtual int CompVal(PVAL vp, int n) = 0; |
|||
virtual int CompVal(int i1, int i2) = 0; |
|||
virtual void *GetValPtr(int n) = 0; |
|||
virtual void *GetValPtrEx(int n) = 0; |
|||
virtual int Find(PVAL vp) = 0; |
|||
virtual int GetMaxLength(void) = 0; |
|||
bool Locate(PVAL vp, int& i); |
|||
|
|||
protected: |
|||
void ChkIndx(int n); |
|||
void ChkTyp(PVAL v); |
|||
void ChkTyp(PVBLK vb); |
|||
|
|||
// Members |
|||
PGLOBAL Global; // Used for messages and allocation |
|||
char *To_Nulls; // Null values array |
|||
void *Blkp; // To value block |
|||
bool Check; // If true SetValue types must match |
|||
bool Nullable; // True if values can be null |
|||
bool Unsigned; // True if values are unsigned |
|||
int Type; // Type of individual values |
|||
int Nval; // Max number of values in block |
|||
int Prec; // Precision of float values |
|||
}; // end of class VALBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TYPBLK: represents a block of typed values. */ |
|||
/***********************************************************************/ |
|||
template <class TYPE> |
|||
class TYPBLK : public VALBLK { |
|||
public: |
|||
// Constructors |
|||
TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false); |
|||
|
|||
// Implementation |
|||
virtual void Init(PGLOBAL g, bool check); |
|||
virtual int GetVlen(void) {return sizeof(TYPE);} |
|||
virtual char GetTinyValue(int n) {return (char)Typp[n];} |
|||
virtual uchar GetUTinyValue(int n) {return (uchar)Typp[n];} |
|||
virtual short GetShortValue(int n) {return (short)Typp[n];} |
|||
virtual ushort GetUShortValue(int n) {return (ushort)Typp[n];} |
|||
virtual int GetIntValue(int n) {return (int)Typp[n];} |
|||
virtual uint GetUIntValue(int n) {return (uint)Typp[n];} |
|||
virtual longlong GetBigintValue(int n) {return (longlong)Typp[n];} |
|||
virtual ulonglong GetUBigintValue(int n) {return (ulonglong)Typp[n];} |
|||
virtual double GetFloatValue(int n) {return (double)Typp[n];} |
|||
virtual char *GetCharString(char *p, int n); |
|||
virtual void Reset(int n) {Typp[n] = 0;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(PSZ sp, int n); |
|||
virtual void SetValue(char *sp, uint len, int n); |
|||
virtual void SetValue(short sval, int n) |
|||
{Typp[n] = (TYPE)sval; SetNull(n, false);} |
|||
virtual void SetValue(ushort sval, int n) |
|||
{Typp[n] = (TYPE)sval; SetNull(n, false);} |
|||
virtual void SetValue(int lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(uint lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(longlong lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(ulonglong lval, int n) |
|||
{Typp[n] = (TYPE)lval; SetNull(n, false);} |
|||
virtual void SetValue(double fval, int n) |
|||
{Typp[n] = (TYPE)fval; SetNull(n, false);} |
|||
virtual void SetValue(char cval, int n) |
|||
{Typp[n] = (TYPE)cval; SetNull(n, false);} |
|||
virtual void SetValue(uchar cval, int n) |
|||
{Typp[n] = (TYPE)cval; SetNull(n, false);} |
|||
virtual void SetValue(PVAL valp, int n); |
|||
virtual void SetValue(PVBLK pv, int n1, int n2); |
|||
virtual void SetMin(PVAL valp, int n); |
|||
virtual void SetMax(PVAL valp, int n); |
|||
virtual void Move(int i, int j); |
|||
virtual int CompVal(PVAL vp, int n); |
|||
virtual int CompVal(int i1, int i2); |
|||
virtual void *GetValPtr(int n); |
|||
virtual void *GetValPtrEx(int n); |
|||
virtual int Find(PVAL vp); |
|||
virtual int GetMaxLength(void); |
|||
|
|||
protected: |
|||
// Specialized functions |
|||
static ulonglong MaxVal(void); |
|||
TYPE GetTypedValue(PVAL vp); |
|||
TYPE GetTypedValue(PVBLK blk, int n); |
|||
|
|||
// Members |
|||
TYPE* const &Typp; |
|||
const char *Fmt; |
|||
}; // end of class TYPBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class CHRBLK: represent a block of fixed length strings. */ |
|||
/***********************************************************************/ |
|||
class CHRBLK : public VALBLK { |
|||
public: |
|||
// Constructors |
|||
CHRBLK(void *mp, int size, int len, int prec, bool b); |
|||
|
|||
// Implementation |
|||
virtual void Init(PGLOBAL g, bool check); |
|||
virtual int GetVlen(void) {return Long;} |
|||
virtual PSZ GetCharValue(int n); |
|||
virtual char GetTinyValue(int n); |
|||
virtual uchar GetUTinyValue(int n); |
|||
virtual short GetShortValue(int n); |
|||
virtual ushort GetUShortValue(int n); |
|||
virtual int GetIntValue(int n); |
|||
virtual uint GetUIntValue(int n); |
|||
virtual longlong GetBigintValue(int n); |
|||
virtual ulonglong GetUBigintValue(int n); |
|||
virtual double GetFloatValue(int n); |
|||
virtual char *GetCharString(char *p, int n); |
|||
virtual void Reset(int n); |
|||
virtual void SetPrec(int p) {Ci = (p != 0);} |
|||
virtual bool IsCi(void) {return Ci;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(PSZ sp, int n); |
|||
virtual void SetValue(char *sp, uint len, int n); |
|||
virtual void SetValue(PVAL valp, int n); |
|||
virtual void SetValue(PVBLK pv, int n1, int n2); |
|||
virtual void SetMin(PVAL valp, int n); |
|||
virtual void SetMax(PVAL valp, int n); |
|||
virtual void Move(int i, int j); |
|||
virtual int CompVal(PVAL vp, int n); |
|||
virtual int CompVal(int i1, int i2); |
|||
virtual void *GetValPtr(int n); |
|||
virtual void *GetValPtrEx(int n); |
|||
virtual int Find(PVAL vp); |
|||
virtual int GetMaxLength(void); |
|||
|
|||
protected: |
|||
// Members |
|||
char* const &Chrp; // Pointer to char buffer |
|||
PSZ Valp; // Used to make a zero ended value |
|||
bool Blanks; // True for right filling with blanks |
|||
bool Ci; // True if case insensitive |
|||
int Long; // Length of each string |
|||
}; // end of class CHRBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* Class STRBLK: represent a block of string pointers. */ |
|||
/* Currently this class is used only by the DECODE scalar function */ |
|||
/* and by the MyColumn function to store date formats. */ |
|||
/***********************************************************************/ |
|||
class STRBLK : public VALBLK { |
|||
public: |
|||
// Constructors |
|||
STRBLK(PGLOBAL g, void *mp, int size); |
|||
|
|||
// Implementation |
|||
virtual void SetNull(int n, bool b) {if (b) {Strp[n] = NULL;}} |
|||
virtual bool IsNull(int n) {return Strp[n] == NULL;} |
|||
virtual void SetNullable(bool b) {} // Always nullable |
|||
virtual void Init(PGLOBAL g, bool check); |
|||
virtual int GetVlen(void) {return sizeof(PSZ);} |
|||
virtual PSZ GetCharValue(int n) {return Strp[n];} |
|||
virtual char GetTinyValue(int n); |
|||
virtual uchar GetUTinyValue(int n); |
|||
virtual short GetShortValue(int n); |
|||
virtual ushort GetUShortValue(int n); |
|||
virtual int GetIntValue(int n); |
|||
virtual uint GetUIntValue(int n); |
|||
virtual longlong GetBigintValue(int n); |
|||
virtual ulonglong GetUBigintValue(int n); |
|||
virtual double GetFloatValue(int n) {return atof(Strp[n]);} |
|||
virtual char *GetCharString(char *p, int n) {return Strp[n];} |
|||
virtual void Reset(int n) {Strp[n] = NULL;} |
|||
|
|||
// Methods |
|||
virtual void SetValue(PSZ sp, int n); |
|||
virtual void SetValue(char *sp, uint len, int n); |
|||
virtual void SetValue(PVAL valp, int n); |
|||
virtual void SetValue(PVBLK pv, int n1, int n2); |
|||
virtual void SetMin(PVAL valp, int n); |
|||
virtual void SetMax(PVAL valp, int n); |
|||
virtual void Move(int i, int j); |
|||
virtual int CompVal(PVAL vp, int n); |
|||
virtual int CompVal(int i1, int i2); |
|||
virtual void *GetValPtr(int n); |
|||
virtual void *GetValPtrEx(int n); |
|||
virtual int Find(PVAL vp); |
|||
virtual int GetMaxLength(void); |
|||
|
|||
// Specific |
|||
void SetSorted(bool b) {Sorted = b;} |
|||
|
|||
protected: |
|||
// Members |
|||
PSZ* const &Strp; // Pointer to PSZ buffer |
|||
bool Sorted; // Values are (semi?) sorted |
|||
}; // end of class STRBLK |
|||
|
|||
/***********************************************************************/ |
|||
/* 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__ |
|||
|
|||
4424
storage/connect/value.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,354 +1,333 @@ |
|||
/**************** Value H Declares Source Code File (.H) ***************/ |
|||
/* Name: VALUE.H Version 2.0 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ |
|||
/* */ |
|||
/* This file contains the VALUE and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __VALUE__H__ |
|||
#define __VALUE__H__ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* assert.h is header required when using the assert function. */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#include "assert.h" |
|||
#include "block.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Types used in some class definitions. */ |
|||
/***********************************************************************/ |
|||
enum CONV {CNV_ANY = 0, /* Convert to any type */ |
|||
CNV_CHAR = 1, /* Convert to character type */ |
|||
CNV_NUM = 2}; /* Convert to numeric type */ |
|||
|
|||
/***********************************************************************/ |
|||
/* Types used in some class definitions. */ |
|||
/***********************************************************************/ |
|||
class CONSTANT; // For friend setting |
|||
typedef struct _datpar *PDTP; // For DTVAL |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* Utilities used to test types and to allocated values. */ |
|||
/***********************************************************************/ |
|||
PVAL AllocateValue(PGLOBAL, void *, short); |
|||
|
|||
// Exported functions |
|||
DllExport PSZ GetTypeName(int); |
|||
DllExport int GetTypeSize(int, int); |
|||
#ifdef ODBC_SUPPORT |
|||
/* This function is exported for use in EOM table type DLLs */ |
|||
DllExport int TranslateSQLType(int stp, int prec, int& len, char& v); |
|||
#endif |
|||
DllExport char *GetFormatType(int); |
|||
DllExport int GetFormatType(char); |
|||
DllExport bool IsTypeChar(int type); |
|||
DllExport bool IsTypeNum(int type); |
|||
#if defined(BLK_INDX) |
|||
DllExport int ConvertType(int, int, CONV, bool match = false); |
|||
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0); |
|||
#endif // BLK_INDX |
|||
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0, |
|||
bool uns = false, PSZ fmt = 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 DllExport VALUE : public BLOCK { |
|||
friend class CONSTANT; // The only object allowed to use SetConstFormat |
|||
public: |
|||
// Constructors |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) = 0; |
|||
virtual bool IsZero(void) = 0; |
|||
virtual bool IsCi(void) {return false;} |
|||
virtual bool IsUnsigned(void) {return Unsigned;} |
|||
virtual void Reset(void) = 0; |
|||
virtual int GetSize(void) = 0; |
|||
virtual int GetValLen(void) = 0; |
|||
virtual int GetValPrec(void) = 0; |
|||
virtual int GetLength(void) {return 1;} |
|||
virtual PSZ GetCharValue(void) {assert(false); return NULL;} |
|||
virtual char GetTinyValue(void) {assert(false); return 0;} |
|||
virtual uchar GetUTinyValue(void) {assert(false); return 0;} |
|||
virtual short GetShortValue(void) {assert(false); return 0;} |
|||
virtual ushort GetUShortValue(void) {assert(false); return 0;} |
|||
virtual int GetIntValue(void) = 0; |
|||
virtual uint GetUIntValue(void) = 0; |
|||
virtual longlong GetBigintValue(void) = 0; |
|||
virtual ulonglong GetUBigintValue(void) = 0; |
|||
virtual double GetFloatValue(void) = 0; |
|||
virtual void *GetTo_Val(void) = 0; |
|||
virtual void SetPrec(int prec) {Prec = prec;} |
|||
bool IsNull(void) {return Null;} |
|||
void SetNull(bool b) {Null = b;} |
|||
bool GetNullable(void) {return Nullable;} |
|||
void SetNullable(bool b) {Nullable = b;} |
|||
int GetType(void) {return Type;} |
|||
int GetClen(void) {return Clen;} |
|||
void SetGlobal(PGLOBAL g) {Global = g;} |
|||
|
|||
// Methods |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; |
|||
virtual bool SetValue_char(char *p, int n) = 0; |
|||
virtual void SetValue_psz(PSZ s) = 0; |
|||
#if defined(BLK_INDX) |
|||
virtual void SetValue_bool(bool b) {assert(FALSE);} |
|||
virtual int CompareValue(PVAL vp) = 0; |
|||
virtual BYTE TestValue(PVAL vp); |
|||
#endif // BLK_INDX |
|||
virtual void SetValue(char c) {assert(false);} |
|||
virtual void SetValue(uchar c) {assert(false);} |
|||
virtual void SetValue(short i) {assert(false);} |
|||
virtual void SetValue(ushort i) {assert(false);} |
|||
virtual void SetValue(int n) {assert(false);} |
|||
virtual void SetValue(uint n) {assert(false);} |
|||
virtual void SetValue(longlong n) {assert(false);} |
|||
virtual void SetValue(ulonglong n) {assert(false);} |
|||
virtual void SetValue(double f) {assert(false);} |
|||
virtual void SetValue_pvblk(PVBLK blk, int n) = 0; |
|||
virtual void SetBinValue(void *p) = 0; |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0; |
|||
virtual char *ShowValue(char *buf, int len = 0) = 0; |
|||
virtual char *GetCharString(char *p) = 0; |
|||
virtual bool IsEqual(PVAL vp, bool chktype) = 0; |
|||
virtual bool FormatValue(PVAL vp, char *fmt) = 0; |
|||
|
|||
protected: |
|||
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0; |
|||
const char *GetXfmt(void); |
|||
|
|||
// Constructor used by derived classes |
|||
VALUE(int type, bool un = false); |
|||
|
|||
// Members |
|||
PGLOBAL Global; // To reduce arglist |
|||
const char *Fmt; |
|||
const char *Xfmt; |
|||
bool Nullable; // True if value can be null |
|||
bool Null; // True if value is null |
|||
bool Unsigned; // True if unsigned |
|||
int Type; // The value type |
|||
int Clen; // Internal value length |
|||
int Prec; |
|||
}; // end of class VALUE |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TYPVAL: represents a typed value. */ |
|||
/***********************************************************************/ |
|||
template <class TYPE> |
|||
class DllExport TYPVAL : public VALUE { |
|||
public: |
|||
// Constructor |
|||
TYPVAL(TYPE n, int type, int prec = 0, bool un = false); |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) {return true;} |
|||
virtual bool IsZero(void) {return Tval == 0;} |
|||
virtual void Reset(void) {Tval = 0;} |
|||
virtual int GetValLen(void); |
|||
virtual int GetValPrec() {return 0;} |
|||
virtual int GetSize(void) {return sizeof(TYPE);} |
|||
virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();} |
|||
virtual char GetTinyValue(void) {return (char)Tval;} |
|||
virtual uchar GetUTinyValue(void) {return (uchar)Tval;} |
|||
virtual short GetShortValue(void) {return (short)Tval;} |
|||
virtual ushort GetUShortValue(void) {return (ushort)Tval;} |
|||
virtual int GetIntValue(void) {return (int)Tval;} |
|||
virtual uint GetUIntValue(void) {return (uint)Tval;} |
|||
virtual longlong GetBigintValue(void) {return (longlong)Tval;} |
|||
virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;} |
|||
virtual double GetFloatValue(void) {return (double)Tval;} |
|||
virtual void *GetTo_Val(void) {return &Tval;} |
|||
|
|||
// Methods |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype); |
|||
virtual bool SetValue_char(char *p, int n); |
|||
virtual void SetValue_psz(PSZ s); |
|||
#if defined(BLK_INDX) |
|||
virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;} |
|||
virtual int CompareValue(PVAL vp); |
|||
#endif // BLK_INDX |
|||
virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;} |
|||
virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;} |
|||
virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;} |
|||
virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;} |
|||
virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;} |
|||
virtual void SetValue_pvblk(PVBLK blk, int n); |
|||
virtual void SetBinValue(void *p); |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go); |
|||
virtual char *ShowValue(char *buf, int); |
|||
virtual char *GetCharString(char *p); |
|||
virtual bool IsEqual(PVAL vp, bool chktype); |
|||
virtual bool SetConstFormat(PGLOBAL, FORMAT&); |
|||
virtual bool FormatValue(PVAL vp, char *fmt); |
|||
virtual void Print(PGLOBAL g, FILE *, uint); |
|||
virtual void Print(PGLOBAL g, char *, uint); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
TYPVAL(void) : VALUE(TYPE_ERROR) {} |
|||
|
|||
// Specialized functions |
|||
static ulonglong MaxVal(void); |
|||
TYPE GetTypedValue(PVAL vp); |
|||
TYPE GetTypedValue(PVBLK blk, int n); |
|||
// TYPE GetTypedValue(PSZ s); |
|||
|
|||
// Members |
|||
TYPE Tval; |
|||
}; // end of class TYPVAL |
|||
|
|||
/***********************************************************************/ |
|||
/* Specific STRING class. */ |
|||
/***********************************************************************/ |
|||
template <> |
|||
class DllExport TYPVAL<PSZ>: public VALUE { |
|||
public: |
|||
// Constructors |
|||
TYPVAL(PSZ s); |
|||
TYPVAL(PGLOBAL g, PSZ s, int n, int c); |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) {return false;} |
|||
virtual bool IsZero(void) {return *Strp == 0;} |
|||
virtual void Reset(void) {*Strp = 0;} |
|||
virtual int GetValLen(void) {return Len;}; |
|||
virtual int GetValPrec() {return (Ci) ? 1 : 0;} |
|||
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;} |
|||
virtual PSZ GetCharValue(void) {return Strp;} |
|||
virtual char GetTinyValue(void); |
|||
virtual uchar GetUTinyValue(void); |
|||
virtual short GetShortValue(void); |
|||
virtual ushort GetUShortValue(void); |
|||
virtual int GetIntValue(void); |
|||
virtual uint GetUIntValue(void); |
|||
virtual longlong GetBigintValue(void); |
|||
virtual ulonglong GetUBigintValue(void); |
|||
virtual double GetFloatValue(void) {return atof(Strp);} |
|||
virtual void *GetTo_Val(void) {return Strp;} |
|||
virtual void SetPrec(int prec) {Ci = prec != 0;} |
|||
|
|||
// Methods |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype); |
|||
virtual bool SetValue_char(char *p, int n); |
|||
virtual void SetValue_psz(PSZ s); |
|||
virtual void SetValue_pvblk(PVBLK blk, int n); |
|||
virtual void SetValue(char c); |
|||
virtual void SetValue(uchar c); |
|||
virtual void SetValue(short i); |
|||
virtual void SetValue(ushort i); |
|||
virtual void SetValue(int n); |
|||
virtual void SetValue(uint n); |
|||
virtual void SetValue(longlong n); |
|||
virtual void SetValue(ulonglong n); |
|||
virtual void SetValue(double f); |
|||
virtual void SetBinValue(void *p); |
|||
#if defined(BLK_INDX) |
|||
virtual int CompareValue(PVAL vp); |
|||
#endif // BLK_INDX |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go); |
|||
virtual char *ShowValue(char *buf, int); |
|||
virtual char *GetCharString(char *p); |
|||
virtual bool IsEqual(PVAL vp, bool chktype); |
|||
virtual bool FormatValue(PVAL vp, char *fmt); |
|||
virtual bool SetConstFormat(PGLOBAL, FORMAT&); |
|||
|
|||
// Members |
|||
PSZ Strp; |
|||
bool Ci; // true if case insensitive |
|||
int Len; |
|||
}; // end of class TYPVAL<PSZ> |
|||
|
|||
/***********************************************************************/ |
|||
/* Specific DECIMAL class. */ |
|||
/***********************************************************************/ |
|||
class DllExport DECVAL: public TYPVAL<PSZ> { |
|||
public: |
|||
// Constructors |
|||
DECVAL(PSZ s); |
|||
DECVAL(PGLOBAL g, PSZ s, int n, int prec, bool uns); |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) {return true;} |
|||
virtual bool IsZero(void); |
|||
virtual void Reset(void); |
|||
virtual int GetValPrec() {return Prec;} |
|||
|
|||
// Methods |
|||
//virtual bool SetValue_pval(PVAL valp, bool chktype); |
|||
//virtual bool SetValue_char(char *p, int n); |
|||
//virtual void SetValue_psz(PSZ s); |
|||
//virtual void SetValue_pvblk(PVBLK blk, int n); |
|||
//virtual void SetBinValue(void *p); |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go); |
|||
virtual char *ShowValue(char *buf, int); |
|||
//virtual char *GetCharString(char *p); |
|||
virtual bool IsEqual(PVAL vp, bool chktype); |
|||
#if defined(BLK_INDX) |
|||
virtual int CompareValue(PVAL vp); |
|||
#endif // BLK_INDX |
|||
//virtual bool FormatValue(PVAL vp, char *fmt); |
|||
//virtual bool SetConstFormat(PGLOBAL, FORMAT&); |
|||
|
|||
// Members |
|||
}; // end of class DECVAL |
|||
|
|||
/***********************************************************************/ |
|||
/* Class DTVAL: represents a time stamp value. */ |
|||
/***********************************************************************/ |
|||
class DllExport DTVAL : public TYPVAL<int> { |
|||
public: |
|||
// Constructors |
|||
DTVAL(PGLOBAL g, int n, int p, PSZ fmt); |
|||
DTVAL(PGLOBAL g, PSZ s, int n); |
|||
DTVAL(PGLOBAL g, short i); |
|||
DTVAL(PGLOBAL g, int n); |
|||
DTVAL(PGLOBAL g, longlong n); |
|||
DTVAL(PGLOBAL g, double f); |
|||
|
|||
// Implementation |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype); |
|||
virtual bool SetValue_char(char *p, int n); |
|||
virtual void SetValue_psz(PSZ s); |
|||
virtual void SetValue_pvblk(PVBLK blk, int n); |
|||
virtual char *GetCharString(char *p); |
|||
virtual char *ShowValue(char *buf, int); |
|||
virtual bool FormatValue(PVAL vp, char *fmt); |
|||
bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); |
|||
bool SetFormat(PGLOBAL g, PVAL valp); |
|||
bool IsFormatted(void) {return Pdtp != NULL;} |
|||
// bool GetTmMember(OPVAL op, int& mval); |
|||
// bool DateDiff(DTVAL *dtp, OPVAL op, int& tdif); |
|||
bool MakeTime(struct tm *ptm); |
|||
static void SetTimeShift(void); |
|||
static int GetShift(void) {return Shift;} |
|||
|
|||
// Methods |
|||
bool MakeDate(PGLOBAL g, int *val, int nval); |
|||
// bool WeekNum(PGLOBAL g, int& nval); |
|||
|
|||
struct tm *GetGmTime(struct tm *); |
|||
|
|||
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__ |
|||
/**************** Value H Declares Source Code File (.H) ***************/ |
|||
/* Name: VALUE.H Version 2.0 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 2001-2013 */ |
|||
/* */ |
|||
/* This file contains the VALUE and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
#ifndef __VALUE__H__ |
|||
#define __VALUE__H__ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* assert.h is header required when using the assert function. */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#include "assert.h" |
|||
#include "block.h" |
|||
|
|||
/***********************************************************************/ |
|||
/* Types used in some class definitions. */ |
|||
/***********************************************************************/ |
|||
enum CONV {CNV_ANY = 0, /* Convert to any type */ |
|||
CNV_CHAR = 1, /* Convert to character type */ |
|||
CNV_NUM = 2}; /* Convert to numeric type */ |
|||
|
|||
/***********************************************************************/ |
|||
/* Types used in some class definitions. */ |
|||
/***********************************************************************/ |
|||
class CONSTANT; // For friend setting |
|||
typedef struct _datpar *PDTP; // For DTVAL |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* Utilities used to test types and to allocated values. */ |
|||
/***********************************************************************/ |
|||
PVAL AllocateValue(PGLOBAL, void *, short); |
|||
|
|||
// Exported functions |
|||
DllExport PSZ GetTypeName(int); |
|||
DllExport int GetTypeSize(int, int); |
|||
#ifdef ODBC_SUPPORT |
|||
/* This function is exported for use in EOM table type DLLs */ |
|||
DllExport int TranslateSQLType(int stp, int prec, int& len, char& v); |
|||
#endif |
|||
DllExport char *GetFormatType(int); |
|||
DllExport int GetFormatType(char); |
|||
DllExport bool IsTypeChar(int type); |
|||
DllExport bool IsTypeNum(int type); |
|||
DllExport int ConvertType(int, int, CONV, bool match = false); |
|||
DllExport PVAL AllocateValue(PGLOBAL, PVAL, int = TYPE_VOID, int = 0); |
|||
DllExport PVAL AllocateValue(PGLOBAL, int, int len = 0, int prec = 0, |
|||
bool uns = false, PSZ fmt = NULL); |
|||
DllExport ulonglong CharToNumber(char *, int, ulonglong, bool, |
|||
bool *minus = NULL, bool *rc = NULL); |
|||
|
|||
/***********************************************************************/ |
|||
/* 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 |
|||
public: |
|||
// Constructors |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) = 0; |
|||
virtual bool IsZero(void) = 0; |
|||
virtual bool IsCi(void) {return false;} |
|||
virtual bool IsUnsigned(void) {return Unsigned;} |
|||
virtual void Reset(void) = 0; |
|||
virtual int GetSize(void) = 0; |
|||
virtual int GetValLen(void) = 0; |
|||
virtual int GetValPrec(void) = 0; |
|||
virtual int GetLength(void) {return 1;} |
|||
virtual PSZ GetCharValue(void) {assert(false); return NULL;} |
|||
virtual char GetTinyValue(void) {assert(false); return 0;} |
|||
virtual uchar GetUTinyValue(void) {assert(false); return 0;} |
|||
virtual short GetShortValue(void) {assert(false); return 0;} |
|||
virtual ushort GetUShortValue(void) {assert(false); return 0;} |
|||
virtual int GetIntValue(void) = 0; |
|||
virtual uint GetUIntValue(void) = 0; |
|||
virtual longlong GetBigintValue(void) = 0; |
|||
virtual ulonglong GetUBigintValue(void) = 0; |
|||
virtual double GetFloatValue(void) = 0; |
|||
virtual void *GetTo_Val(void) = 0; |
|||
virtual void SetPrec(int prec) {Prec = prec;} |
|||
bool IsNull(void) {return Null;} |
|||
void SetNull(bool b) {Null = b;} |
|||
bool GetNullable(void) {return Nullable;} |
|||
void SetNullable(bool b) {Nullable = b;} |
|||
int GetType(void) {return Type;} |
|||
int GetClen(void) {return Clen;} |
|||
void SetGlobal(PGLOBAL g) {Global = g;} |
|||
|
|||
// Methods |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype = false) = 0; |
|||
virtual bool SetValue_char(char *p, int n) = 0; |
|||
virtual void SetValue_psz(PSZ s) = 0; |
|||
virtual void SetValue_bool(bool b) {assert(FALSE);} |
|||
virtual int CompareValue(PVAL vp) = 0; |
|||
virtual BYTE TestValue(PVAL vp); |
|||
virtual void SetValue(char c) {assert(false);} |
|||
virtual void SetValue(uchar c) {assert(false);} |
|||
virtual void SetValue(short i) {assert(false);} |
|||
virtual void SetValue(ushort i) {assert(false);} |
|||
virtual void SetValue(int n) {assert(false);} |
|||
virtual void SetValue(uint n) {assert(false);} |
|||
virtual void SetValue(longlong n) {assert(false);} |
|||
virtual void SetValue(ulonglong n) {assert(false);} |
|||
virtual void SetValue(double f) {assert(false);} |
|||
virtual void SetValue_pvblk(PVBLK blk, int n) = 0; |
|||
virtual void SetBinValue(void *p) = 0; |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go) = 0; |
|||
virtual char *ShowValue(char *buf, int len = 0) = 0; |
|||
virtual char *GetCharString(char *p) = 0; |
|||
virtual bool IsEqual(PVAL vp, bool chktype) = 0; |
|||
virtual bool FormatValue(PVAL vp, char *fmt) = 0; |
|||
|
|||
protected: |
|||
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0; |
|||
const char *GetXfmt(void); |
|||
|
|||
// Constructor used by derived classes |
|||
VALUE(int type, bool un = false); |
|||
|
|||
// Members |
|||
PGLOBAL Global; // To reduce arglist |
|||
const char *Fmt; |
|||
const char *Xfmt; |
|||
bool Nullable; // True if value can be null |
|||
bool Null; // True if value is null |
|||
bool Unsigned; // True if unsigned |
|||
int Type; // The value type |
|||
int Clen; // Internal value length |
|||
int Prec; |
|||
}; // end of class VALUE |
|||
|
|||
/***********************************************************************/ |
|||
/* Class TYPVAL: represents a typed value. */ |
|||
/***********************************************************************/ |
|||
template <class TYPE> |
|||
class DllExport TYPVAL : public VALUE { |
|||
public: |
|||
// Constructor |
|||
TYPVAL(TYPE n, int type, int prec = 0, bool un = false); |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) {return true;} |
|||
virtual bool IsZero(void) {return Tval == 0;} |
|||
virtual void Reset(void) {Tval = 0;} |
|||
virtual int GetValLen(void); |
|||
virtual int GetValPrec() {return 0;} |
|||
virtual int GetSize(void) {return sizeof(TYPE);} |
|||
virtual PSZ GetCharValue(void) {return VALUE::GetCharValue();} |
|||
virtual char GetTinyValue(void) {return (char)Tval;} |
|||
virtual uchar GetUTinyValue(void) {return (uchar)Tval;} |
|||
virtual short GetShortValue(void) {return (short)Tval;} |
|||
virtual ushort GetUShortValue(void) {return (ushort)Tval;} |
|||
virtual int GetIntValue(void) {return (int)Tval;} |
|||
virtual uint GetUIntValue(void) {return (uint)Tval;} |
|||
virtual longlong GetBigintValue(void) {return (longlong)Tval;} |
|||
virtual ulonglong GetUBigintValue(void) {return (ulonglong)Tval;} |
|||
virtual double GetFloatValue(void) {return (double)Tval;} |
|||
virtual void *GetTo_Val(void) {return &Tval;} |
|||
|
|||
// Methods |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype); |
|||
virtual bool SetValue_char(char *p, int n); |
|||
virtual void SetValue_psz(PSZ s); |
|||
virtual void SetValue_bool(bool b) {Tval = (b) ? 1 : 0;} |
|||
virtual int CompareValue(PVAL vp); |
|||
virtual void SetValue(char c) {Tval = (TYPE)c; Null = false;} |
|||
virtual void SetValue(uchar c) {Tval = (TYPE)c; Null = false;} |
|||
virtual void SetValue(short i) {Tval = (TYPE)i; Null = false;} |
|||
virtual void SetValue(ushort i) {Tval = (TYPE)i; Null = false;} |
|||
virtual void SetValue(int n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(uint n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(longlong n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(ulonglong n) {Tval = (TYPE)n; Null = false;} |
|||
virtual void SetValue(double f) {Tval = (TYPE)f; Null = false;} |
|||
virtual void SetValue_pvblk(PVBLK blk, int n); |
|||
virtual void SetBinValue(void *p); |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go); |
|||
virtual char *ShowValue(char *buf, int); |
|||
virtual char *GetCharString(char *p); |
|||
virtual bool IsEqual(PVAL vp, bool chktype); |
|||
virtual bool SetConstFormat(PGLOBAL, FORMAT&); |
|||
virtual bool FormatValue(PVAL vp, char *fmt); |
|||
virtual void Print(PGLOBAL g, FILE *, uint); |
|||
virtual void Print(PGLOBAL g, char *, uint); |
|||
|
|||
protected: |
|||
// Default constructor not to be used |
|||
TYPVAL(void) : VALUE(TYPE_ERROR) {} |
|||
|
|||
// Specialized functions |
|||
static ulonglong MaxVal(void); |
|||
TYPE GetTypedValue(PVAL vp); |
|||
TYPE GetTypedValue(PVBLK blk, int n); |
|||
// TYPE GetTypedValue(PSZ s); |
|||
|
|||
// Members |
|||
TYPE Tval; |
|||
}; // end of class TYPVAL |
|||
|
|||
/***********************************************************************/ |
|||
/* Specific STRING class. */ |
|||
/***********************************************************************/ |
|||
template <> |
|||
class DllExport TYPVAL<PSZ>: public VALUE { |
|||
public: |
|||
// Constructors |
|||
TYPVAL(PSZ s); |
|||
TYPVAL(PGLOBAL g, PSZ s, int n, int c); |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) {return false;} |
|||
virtual bool IsZero(void) {return *Strp == 0;} |
|||
virtual void Reset(void) {*Strp = 0;} |
|||
virtual int GetValLen(void) {return Len;}; |
|||
virtual int GetValPrec() {return (Ci) ? 1 : 0;} |
|||
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;} |
|||
virtual PSZ GetCharValue(void) {return Strp;} |
|||
virtual char GetTinyValue(void); |
|||
virtual uchar GetUTinyValue(void); |
|||
virtual short GetShortValue(void); |
|||
virtual ushort GetUShortValue(void); |
|||
virtual int GetIntValue(void); |
|||
virtual uint GetUIntValue(void); |
|||
virtual longlong GetBigintValue(void); |
|||
virtual ulonglong GetUBigintValue(void); |
|||
virtual double GetFloatValue(void) {return atof(Strp);} |
|||
virtual void *GetTo_Val(void) {return Strp;} |
|||
virtual void SetPrec(int prec) {Ci = prec != 0;} |
|||
|
|||
// Methods |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype); |
|||
virtual bool SetValue_char(char *p, int n); |
|||
virtual void SetValue_psz(PSZ s); |
|||
virtual void SetValue_pvblk(PVBLK blk, int n); |
|||
virtual void SetValue(char c); |
|||
virtual void SetValue(uchar c); |
|||
virtual void SetValue(short i); |
|||
virtual void SetValue(ushort i); |
|||
virtual void SetValue(int n); |
|||
virtual void SetValue(uint n); |
|||
virtual void SetValue(longlong n); |
|||
virtual void SetValue(ulonglong n); |
|||
virtual void SetValue(double f); |
|||
virtual void SetBinValue(void *p); |
|||
virtual int CompareValue(PVAL vp); |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go); |
|||
virtual char *ShowValue(char *buf, int); |
|||
virtual char *GetCharString(char *p); |
|||
virtual bool IsEqual(PVAL vp, bool chktype); |
|||
virtual bool FormatValue(PVAL vp, char *fmt); |
|||
virtual bool SetConstFormat(PGLOBAL, FORMAT&); |
|||
|
|||
// Members |
|||
PSZ Strp; |
|||
bool Ci; // true if case insensitive |
|||
int Len; |
|||
}; // end of class TYPVAL<PSZ> |
|||
|
|||
/***********************************************************************/ |
|||
/* Specific DECIMAL class. */ |
|||
/***********************************************************************/ |
|||
class DllExport DECVAL: public TYPVAL<PSZ> { |
|||
public: |
|||
// Constructors |
|||
DECVAL(PSZ s); |
|||
DECVAL(PGLOBAL g, PSZ s, int n, int prec, bool uns); |
|||
|
|||
// Implementation |
|||
virtual bool IsTypeNum(void) {return true;} |
|||
virtual bool IsZero(void); |
|||
virtual void Reset(void); |
|||
virtual int GetValPrec() {return Prec;} |
|||
|
|||
// Methods |
|||
virtual bool GetBinValue(void *buf, int buflen, bool go); |
|||
virtual char *ShowValue(char *buf, int); |
|||
virtual bool IsEqual(PVAL vp, bool chktype); |
|||
virtual int CompareValue(PVAL vp); |
|||
|
|||
// Members |
|||
}; // end of class DECVAL |
|||
|
|||
/***********************************************************************/ |
|||
/* Class DTVAL: represents a time stamp value. */ |
|||
/***********************************************************************/ |
|||
class DllExport DTVAL : public TYPVAL<int> { |
|||
public: |
|||
// Constructors |
|||
DTVAL(PGLOBAL g, int n, int p, PSZ fmt); |
|||
DTVAL(PGLOBAL g, PSZ s, int n); |
|||
DTVAL(PGLOBAL g, short i); |
|||
DTVAL(PGLOBAL g, int n); |
|||
DTVAL(PGLOBAL g, longlong n); |
|||
DTVAL(PGLOBAL g, double f); |
|||
|
|||
// Implementation |
|||
virtual bool SetValue_pval(PVAL valp, bool chktype); |
|||
virtual bool SetValue_char(char *p, int n); |
|||
virtual void SetValue_psz(PSZ s); |
|||
virtual void SetValue_pvblk(PVBLK blk, int n); |
|||
virtual char *GetCharString(char *p); |
|||
virtual char *ShowValue(char *buf, int); |
|||
virtual bool FormatValue(PVAL vp, char *fmt); |
|||
bool SetFormat(PGLOBAL g, PSZ fmt, int len, int year = 0); |
|||
bool SetFormat(PGLOBAL g, PVAL valp); |
|||
bool IsFormatted(void) {return Pdtp != NULL;} |
|||
bool MakeTime(struct tm *ptm); |
|||
static void SetTimeShift(void); |
|||
static int GetShift(void) {return Shift;} |
|||
|
|||
// Methods |
|||
bool MakeDate(PGLOBAL g, int *val, 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__ |
|||
6056
storage/connect/xindex.cpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,188 +1,186 @@ |
|||
/************ Xobject C++ Functions Source Code File (.CPP) ************/ |
|||
/* Name: XOBJECT.CPP Version 2.2 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */ |
|||
/* */ |
|||
/* This file contains base XOBJECT class functions. */ |
|||
/* Also here is the implementation of the CONSTANT class. */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include mariaDB header file. */ |
|||
/***********************************************************************/ |
|||
#include "my_global.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* global.h is header containing all global Plug declarations. */ |
|||
/* plgdbsem.h is header containing the DB applic. declarations. */ |
|||
/***********************************************************************/ |
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "xobject.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* Macro definitions. */ |
|||
/***********************************************************************/ |
|||
#if defined(_DEBUG) || defined(DEBTRACE)
|
|||
#define ASSERT(B) assert(B);
|
|||
#else
|
|||
#define ASSERT(B)
|
|||
#endif
|
|||
|
|||
/***********************************************************************/ |
|||
/* The one and only needed void object. */ |
|||
/***********************************************************************/ |
|||
XVOID Xvoid; |
|||
PXOB const pXVOID = &Xvoid; // Pointer used by other classes
|
|||
|
|||
/* ------------------------- Class XOBJECT --------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* GetCharValue: returns the Result value as a char string. */ |
|||
/* Using GetCharValue provides no conversion from numeric types. */ |
|||
/***********************************************************************/ |
|||
PSZ XOBJECT::GetCharValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetCharValue(); |
|||
} // end of GetCharValue()
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetShortValue: returns the Result value as a short integer. */ |
|||
/***********************************************************************/ |
|||
short XOBJECT::GetShortValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetShortValue(); |
|||
} // end of GetShortValue
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetIntValue: returns the Result value as a int integer. */ |
|||
/***********************************************************************/ |
|||
int XOBJECT::GetIntValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetIntValue(); |
|||
} // end of GetIntValue
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetFloatValue: returns the Result value as a double float. */ |
|||
/***********************************************************************/ |
|||
double XOBJECT::GetFloatValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetFloatValue(); |
|||
} // end of GetFloatValue
|
|||
|
|||
/* ------------------------- Class CONSTANT -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* CONSTANT public constructor. */ |
|||
/***********************************************************************/ |
|||
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type) |
|||
{ |
|||
if (!(Value = AllocateValue(g, value, (int)type))) |
|||
longjmp(g->jumper[g->jump_level], TYPE_CONST); |
|||
|
|||
Constant = true; |
|||
} // end of CONSTANT constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* CONSTANT public constructor. */ |
|||
/***********************************************************************/ |
|||
CONSTANT::CONSTANT(PGLOBAL g, int n) |
|||
{ |
|||
if (!(Value = AllocateValue(g, &n, TYPE_INT))) |
|||
longjmp(g->jumper[g->jump_level], TYPE_CONST); |
|||
|
|||
Constant = true; |
|||
} // end of CONSTANT constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetLengthEx: returns an evaluation of the constant string length. */ |
|||
/* Note: When converting from token to string, length has to be */ |
|||
/* specified but we need the domain length, not the value length. */ |
|||
/***********************************************************************/ |
|||
int CONSTANT::GetLengthEx(void) |
|||
{ |
|||
return Value->GetValLen(); |
|||
} // end of GetLengthEx
|
|||
|
|||
#if defined(BLK_INDX)
|
|||
/***********************************************************************/ |
|||
/* Convert a constant to the given type. */ |
|||
/***********************************************************************/ |
|||
void CONSTANT::Convert(PGLOBAL g, int newtype) |
|||
{ |
|||
if (Value->GetType() != newtype) |
|||
if (!(Value = AllocateValue(g, Value, newtype))) |
|||
longjmp(g->jumper[g->jump_level], TYPE_CONST); |
|||
|
|||
} // end of Convert
|
|||
#endif // BLK_INDX
|
|||
|
|||
/***********************************************************************/ |
|||
/* Compare: returns true if this object is equivalent to xp. */ |
|||
/***********************************************************************/ |
|||
bool CONSTANT::Compare(PXOB xp) |
|||
{ |
|||
if (this == xp) |
|||
return true; |
|||
else if (xp->GetType() != TYPE_CONST) |
|||
return false; |
|||
else |
|||
return Value->IsEqual(xp->GetValue(), true); |
|||
|
|||
} // end of Compare
|
|||
|
|||
#if 0
|
|||
/***********************************************************************/ |
|||
/* Rephrase: temporary implementation used by PlugRephraseSQL. */ |
|||
/***********************************************************************/ |
|||
bool CONSTANT::Rephrase(PGLOBAL g, PSZ work) |
|||
{ |
|||
switch (Value->GetType()) { |
|||
case TYPE_STRING: |
|||
sprintf(work + strlen(work), "'%s'", Value->GetCharValue()); |
|||
break; |
|||
case TYPE_SHORT: |
|||
sprintf(work + strlen(work), "%hd", Value->GetShortValue()); |
|||
break; |
|||
case TYPE_INT: |
|||
case TYPE_DATE: |
|||
sprintf(work + strlen(work), "%d", Value->GetIntValue()); |
|||
break; |
|||
case TYPE_DOUBLE: |
|||
sprintf(work + strlen(work), "%lf", Value->GetFloatValue()); |
|||
break; |
|||
case TYPE_BIGINT: |
|||
sprintf(work + strlen(work), "%lld", Value->GetBigintValue()); |
|||
break; |
|||
case TYPE_TINY: |
|||
sprintf(work + strlen(work), "%d", Value->GetTinyValue()); |
|||
break; |
|||
default: |
|||
sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType()); |
|||
return false; |
|||
} // endswitch
|
|||
|
|||
return false; |
|||
} // end of Rephrase
|
|||
#endif // 0
|
|||
|
|||
/***********************************************************************/ |
|||
/* Make file output of a constant object. */ |
|||
/***********************************************************************/ |
|||
void CONSTANT::Print(PGLOBAL g, FILE *f, uint n) |
|||
{ |
|||
Value->Print(g, f, n); |
|||
} /* end of Print */ |
|||
|
|||
/***********************************************************************/ |
|||
/* Make string output of a constant object. */ |
|||
/***********************************************************************/ |
|||
void CONSTANT::Print(PGLOBAL g, char *ps, uint z) |
|||
{ |
|||
Value->Print(g, ps, z); |
|||
} /* end of Print */ |
|||
/************ Xobject C++ Functions Source Code File (.CPP) ************/ |
|||
/* Name: XOBJECT.CPP Version 2.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ |
|||
/* */ |
|||
/* This file contains base XOBJECT class functions. */ |
|||
/* Also here is the implementation of the CONSTANT class. */ |
|||
/***********************************************************************/ |
|||
|
|||
/***********************************************************************/ |
|||
/* Include mariaDB header file. */ |
|||
/***********************************************************************/ |
|||
#include "my_global.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* global.h is header containing all global Plug declarations. */ |
|||
/* plgdbsem.h is header containing the DB applic. declarations. */ |
|||
/***********************************************************************/ |
|||
#include "global.h"
|
|||
#include "plgdbsem.h"
|
|||
#include "xobject.h"
|
|||
|
|||
/***********************************************************************/ |
|||
/* Macro definitions. */ |
|||
/***********************************************************************/ |
|||
#if defined(_DEBUG) || defined(DEBTRACE)
|
|||
#define ASSERT(B) assert(B);
|
|||
#else
|
|||
#define ASSERT(B)
|
|||
#endif
|
|||
|
|||
/***********************************************************************/ |
|||
/* The one and only needed void object. */ |
|||
/***********************************************************************/ |
|||
XVOID Xvoid; |
|||
PXOB const pXVOID = &Xvoid; // Pointer used by other classes
|
|||
|
|||
/* ------------------------- Class XOBJECT --------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* GetCharValue: returns the Result value as a char string. */ |
|||
/* Using GetCharValue provides no conversion from numeric types. */ |
|||
/***********************************************************************/ |
|||
PSZ XOBJECT::GetCharValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetCharValue(); |
|||
} // end of GetCharValue()
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetShortValue: returns the Result value as a short integer. */ |
|||
/***********************************************************************/ |
|||
short XOBJECT::GetShortValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetShortValue(); |
|||
} // end of GetShortValue
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetIntValue: returns the Result value as a int integer. */ |
|||
/***********************************************************************/ |
|||
int XOBJECT::GetIntValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetIntValue(); |
|||
} // end of GetIntValue
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetFloatValue: returns the Result value as a double float. */ |
|||
/***********************************************************************/ |
|||
double XOBJECT::GetFloatValue(void) |
|||
{ |
|||
ASSERT(Value) |
|||
return Value->GetFloatValue(); |
|||
} // end of GetFloatValue
|
|||
|
|||
/* ------------------------- Class CONSTANT -------------------------- */ |
|||
|
|||
/***********************************************************************/ |
|||
/* CONSTANT public constructor. */ |
|||
/***********************************************************************/ |
|||
CONSTANT::CONSTANT(PGLOBAL g, void *value, short type) |
|||
{ |
|||
if (!(Value = AllocateValue(g, value, (int)type))) |
|||
longjmp(g->jumper[g->jump_level], TYPE_CONST); |
|||
|
|||
Constant = true; |
|||
} // end of CONSTANT constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* CONSTANT public constructor. */ |
|||
/***********************************************************************/ |
|||
CONSTANT::CONSTANT(PGLOBAL g, int n) |
|||
{ |
|||
if (!(Value = AllocateValue(g, &n, TYPE_INT))) |
|||
longjmp(g->jumper[g->jump_level], TYPE_CONST); |
|||
|
|||
Constant = true; |
|||
} // end of CONSTANT constructor
|
|||
|
|||
/***********************************************************************/ |
|||
/* GetLengthEx: returns an evaluation of the constant string length. */ |
|||
/* Note: When converting from token to string, length has to be */ |
|||
/* specified but we need the domain length, not the value length. */ |
|||
/***********************************************************************/ |
|||
int CONSTANT::GetLengthEx(void) |
|||
{ |
|||
return Value->GetValLen(); |
|||
} // end of GetLengthEx
|
|||
|
|||
/***********************************************************************/ |
|||
/* Convert a constant to the given type. */ |
|||
/***********************************************************************/ |
|||
void CONSTANT::Convert(PGLOBAL g, int newtype) |
|||
{ |
|||
if (Value->GetType() != newtype) |
|||
if (!(Value = AllocateValue(g, Value, newtype))) |
|||
longjmp(g->jumper[g->jump_level], TYPE_CONST); |
|||
|
|||
} // end of Convert
|
|||
|
|||
/***********************************************************************/ |
|||
/* Compare: returns true if this object is equivalent to xp. */ |
|||
/***********************************************************************/ |
|||
bool CONSTANT::Compare(PXOB xp) |
|||
{ |
|||
if (this == xp) |
|||
return true; |
|||
else if (xp->GetType() != TYPE_CONST) |
|||
return false; |
|||
else |
|||
return Value->IsEqual(xp->GetValue(), true); |
|||
|
|||
} // end of Compare
|
|||
|
|||
#if 0
|
|||
/***********************************************************************/ |
|||
/* Rephrase: temporary implementation used by PlugRephraseSQL. */ |
|||
/***********************************************************************/ |
|||
bool CONSTANT::Rephrase(PGLOBAL g, PSZ work) |
|||
{ |
|||
switch (Value->GetType()) { |
|||
case TYPE_STRING: |
|||
sprintf(work + strlen(work), "'%s'", Value->GetCharValue()); |
|||
break; |
|||
case TYPE_SHORT: |
|||
sprintf(work + strlen(work), "%hd", Value->GetShortValue()); |
|||
break; |
|||
case TYPE_INT: |
|||
case TYPE_DATE: |
|||
sprintf(work + strlen(work), "%d", Value->GetIntValue()); |
|||
break; |
|||
case TYPE_DOUBLE: |
|||
sprintf(work + strlen(work), "%lf", Value->GetFloatValue()); |
|||
break; |
|||
case TYPE_BIGINT: |
|||
sprintf(work + strlen(work), "%lld", Value->GetBigintValue()); |
|||
break; |
|||
case TYPE_TINY: |
|||
sprintf(work + strlen(work), "%d", Value->GetTinyValue()); |
|||
break; |
|||
default: |
|||
sprintf(g->Message, MSG(BAD_CONST_TYPE), Value->GetType()); |
|||
return false; |
|||
} // endswitch
|
|||
|
|||
return false; |
|||
} // end of Rephrase
|
|||
#endif // 0
|
|||
|
|||
/***********************************************************************/ |
|||
/* Make file output of a constant object. */ |
|||
/***********************************************************************/ |
|||
void CONSTANT::Print(PGLOBAL g, FILE *f, uint n) |
|||
{ |
|||
Value->Print(g, f, n); |
|||
} /* end of Print */ |
|||
|
|||
/***********************************************************************/ |
|||
/* Make string output of a constant object. */ |
|||
/***********************************************************************/ |
|||
void CONSTANT::Print(PGLOBAL g, char *ps, uint z) |
|||
{ |
|||
Value->Print(g, ps, z); |
|||
} /* end of Print */ |
|||
@ -1,137 +1,119 @@ |
|||
/*************** Xobject H Declares Source Code File (.H) **************/ |
|||
/* Name: XOBJECT.H Version 2.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1998-2012 */ |
|||
/* */ |
|||
/* This file contains the XOBJECT and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __XOBJECT__H |
|||
#define __XOBJECT__H |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#include "block.h" |
|||
#include "valblk.h" // includes value.h |
|||
|
|||
/***********************************************************************/ |
|||
/* Types used in some class definitions. */ |
|||
/***********************************************************************/ |
|||
//typedef struct _tabdesc *PTABD; // For friend setting |
|||
|
|||
/***********************************************************************/ |
|||
/* The pointer to the one and only needed void object. */ |
|||
/***********************************************************************/ |
|||
extern PXOB const pXVOID; |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XOBJECT is the base class for all classes that can be used */ |
|||
/* in evaluation operations: FILTER, EXPRESSION, SCALF, FNC, COLBLK, */ |
|||
/* SELECT, FILTER as well as all the constant object types. */ |
|||
/***********************************************************************/ |
|||
class DllExport XOBJECT : public BLOCK { |
|||
public: |
|||
XOBJECT(void) {Value = NULL; Constant = false;} |
|||
|
|||
// Implementation |
|||
PVAL GetValue(void) {return Value;} |
|||
bool IsConstant(void) {return Constant;} |
|||
virtual int GetType(void) {return TYPE_XOBJECT;} |
|||
virtual int GetResultType(void) {return TYPE_VOID;} |
|||
virtual int GetKey(void) {return 0;} |
|||
#if defined(_DEBUG) |
|||
virtual void SetKey(int k) {assert(false);} |
|||
#else // !_DEBUG |
|||
virtual void SetKey(int k) {} // Only defined for COLBLK |
|||
#endif // !_DEBUG |
|||
virtual int GetLength(void) = 0; |
|||
virtual int GetLengthEx(void) = 0; |
|||
virtual PSZ GetCharValue(void); |
|||
virtual short GetShortValue(void); |
|||
virtual int GetIntValue(void); |
|||
virtual double GetFloatValue(void); |
|||
virtual int GetScale(void) = 0; |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} |
|||
virtual bool Compare(PXOB) = 0; |
|||
virtual bool Init(PGLOBAL) {return false;} |
|||
virtual bool Eval(PGLOBAL) {return false;} |
|||
virtual bool SetFormat(PGLOBAL, FORMAT&) = 0; |
|||
virtual int CheckColumn(PGLOBAL, PSQL, PXOB &, int &) {return 0;} |
|||
virtual int RefNum(PSQL) {return 0;} |
|||
virtual void AddTdb(PSQL, PTDB *, int&) {} |
|||
virtual PXOB SetSelect(PGLOBAL, PSQL, bool) {return this;} |
|||
virtual PXOB CheckSubQuery(PGLOBAL, PSQL) {return this;} |
|||
virtual bool CheckLocal(PTDB) {return true;} |
|||
virtual int CheckSpcCol(PTDB, int) {return 2;} |
|||
virtual bool CheckSort(PTDB) {return false;} |
|||
virtual bool VerifyColumn(PTDB txp) {return false;} |
|||
virtual bool VerifyTdb(PTDB& tdbp) {return false;} |
|||
virtual bool IsColInside(PCOL colp) {return false;} |
|||
|
|||
protected: |
|||
PVAL Value; // The current value of the object. |
|||
bool Constant; // true for an object having a constant value. |
|||
}; // end of class XOBJECT |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XVOID: represent a void (null) object. */ |
|||
/* Used to represent a void parameter for count(*) or for a filter. */ |
|||
/***********************************************************************/ |
|||
class DllExport XVOID : public XOBJECT { |
|||
public: |
|||
XVOID(void) {Constant = true;} |
|||
|
|||
// Implementation |
|||
virtual int GetType(void) {return TYPE_VOID;} |
|||
virtual int GetLength(void) {return 0;} |
|||
virtual int GetLengthEx(void) {return 0;} |
|||
virtual PSZ GetCharValue(void) {return NULL;} |
|||
virtual int GetIntValue(void) {return 0;} |
|||
virtual double GetFloatValue(void) {return 0.0;} |
|||
virtual int GetScale() {return 0;} |
|||
|
|||
// Methods |
|||
virtual bool Compare(PXOB xp) {return xp->GetType() == TYPE_VOID;} |
|||
virtual bool SetFormat(PGLOBAL, FORMAT&) {return true;} |
|||
virtual int CheckSpcCol(PTDB, int) {return 0;} |
|||
}; // end of class XVOID |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* Class CONSTANT: represents a constant XOBJECT of any value type. */ |
|||
/* Note that the CONSTANT class is a friend of the VALUE class; */ |
|||
/***********************************************************************/ |
|||
class DllExport CONSTANT : public XOBJECT { |
|||
public: |
|||
CONSTANT(PGLOBAL g, void *value, short type); |
|||
CONSTANT(PGLOBAL g, int n); |
|||
CONSTANT(PVAL valp) {Value = valp; Constant = true;} |
|||
|
|||
// Implementation |
|||
virtual int GetType(void) {return TYPE_CONST;} |
|||
virtual int GetResultType(void) {return Value->Type;} |
|||
virtual int GetLength(void) {return Value->GetValLen();} |
|||
virtual int GetScale() {return Value->GetValPrec();} |
|||
virtual int GetLengthEx(void); |
|||
|
|||
// 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 |
|||
/*************** Xobject H Declares Source Code File (.H) **************/ |
|||
/* Name: XOBJECT.H Version 2.4 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1998-2014 */ |
|||
/* */ |
|||
/* This file contains the XOBJECT and derived classes declares. */ |
|||
/***********************************************************************/ |
|||
|
|||
#ifndef __XOBJECT__H |
|||
#define __XOBJECT__H |
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#include "block.h" |
|||
#include "valblk.h" // includes value.h |
|||
|
|||
/***********************************************************************/ |
|||
/* Types used in some class definitions. */ |
|||
/***********************************************************************/ |
|||
//typedef struct _tabdesc *PTABD; // For friend setting |
|||
|
|||
/***********************************************************************/ |
|||
/* The pointer to the one and only needed void object. */ |
|||
/***********************************************************************/ |
|||
extern PXOB const pXVOID; |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XOBJECT is the base class for all classes that can be used */ |
|||
/* in evaluation operations: FILTER, EXPRESSION, SCALF, FNC, COLBLK, */ |
|||
/* SELECT, FILTER as well as all the constant object types. */ |
|||
/***********************************************************************/ |
|||
class DllExport XOBJECT : public BLOCK { |
|||
public: |
|||
XOBJECT(void) {Value = NULL; Constant = false;} |
|||
|
|||
// Implementation |
|||
PVAL GetValue(void) {return Value;} |
|||
bool IsConstant(void) {return Constant;} |
|||
virtual int GetType(void) {return TYPE_XOBJECT;} |
|||
virtual int GetResultType(void) {return TYPE_VOID;} |
|||
virtual int GetKey(void) {return 0;} |
|||
#if defined(_DEBUG) |
|||
virtual void SetKey(int k) {assert(false);} |
|||
#else // !_DEBUG |
|||
virtual void SetKey(int k) {} // Only defined for COLBLK |
|||
#endif // !_DEBUG |
|||
virtual int GetLength(void) = 0; |
|||
virtual int GetLengthEx(void) = 0; |
|||
virtual PSZ GetCharValue(void); |
|||
virtual short GetShortValue(void); |
|||
virtual int GetIntValue(void); |
|||
virtual double GetFloatValue(void); |
|||
virtual int GetScale(void) = 0; |
|||
|
|||
// Methods |
|||
virtual void Reset(void) {} |
|||
virtual bool Compare(PXOB) = 0; |
|||
virtual bool Init(PGLOBAL) {return false;} |
|||
virtual bool Eval(PGLOBAL) {return false;} |
|||
virtual bool SetFormat(PGLOBAL, FORMAT&) = 0; |
|||
|
|||
protected: |
|||
PVAL Value; // The current value of the object. |
|||
bool Constant; // true for an object having a constant value. |
|||
}; // end of class XOBJECT |
|||
|
|||
/***********************************************************************/ |
|||
/* Class XVOID: represent a void (null) object. */ |
|||
/* Used to represent a void parameter for count(*) or for a filter. */ |
|||
/***********************************************************************/ |
|||
class DllExport XVOID : public XOBJECT { |
|||
public: |
|||
XVOID(void) {Constant = true;} |
|||
|
|||
// Implementation |
|||
virtual int GetType(void) {return TYPE_VOID;} |
|||
virtual int GetLength(void) {return 0;} |
|||
virtual int GetLengthEx(void) {return 0;} |
|||
virtual PSZ GetCharValue(void) {return NULL;} |
|||
virtual int GetIntValue(void) {return 0;} |
|||
virtual double GetFloatValue(void) {return 0.0;} |
|||
virtual int GetScale() {return 0;} |
|||
|
|||
// Methods |
|||
virtual bool Compare(PXOB xp) {return xp->GetType() == TYPE_VOID;} |
|||
virtual bool SetFormat(PGLOBAL, FORMAT&) {return true;} |
|||
}; // end of class XVOID |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* Class CONSTANT: represents a constant XOBJECT of any value type. */ |
|||
/* Note that the CONSTANT class is a friend of the VALUE class; */ |
|||
/***********************************************************************/ |
|||
class DllExport CONSTANT : public XOBJECT { |
|||
public: |
|||
CONSTANT(PGLOBAL g, void *value, short type); |
|||
CONSTANT(PGLOBAL g, int n); |
|||
CONSTANT(PVAL valp) {Value = valp; Constant = true;} |
|||
|
|||
// Implementation |
|||
virtual int GetType(void) {return TYPE_CONST;} |
|||
virtual int GetResultType(void) {return Value->Type;} |
|||
virtual int GetLength(void) {return Value->GetValLen();} |
|||
virtual int GetScale() {return Value->GetValPrec();} |
|||
virtual int GetLengthEx(void); |
|||
|
|||
// Methods |
|||
virtual bool Compare(PXOB xp); |
|||
virtual bool SetFormat(PGLOBAL g, FORMAT& fmt) |
|||
{return Value->SetConstFormat(g, fmt);} |
|||
void Convert(PGLOBAL g, int newtype); |
|||
void SetValue(PVAL vp) {Value = vp;} |
|||
virtual void Print(PGLOBAL g, FILE *, uint); |
|||
virtual void Print(PGLOBAL g, char *, uint); |
|||
}; // end of class CONSTANT |
|||
|
|||
#endif |
|||
@ -1,267 +1,259 @@ |
|||
/**************** Table H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABLE.H Version 2.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ |
|||
/* */ |
|||
/* This file contains the TBX, OPJOIN and TDB class definitions. */ |
|||
/***********************************************************************/ |
|||
#if !defined(TABLE_DEFINED) |
|||
#define TABLE_DEFINED |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#include "assert.h" |
|||
#include "block.h" |
|||
#include "colblk.h" |
|||
#include "m_ctype.h" |
|||
|
|||
typedef class CMD *PCMD; |
|||
|
|||
// Commands executed by XDBC and MYX tables |
|||
class CMD : public BLOCK { |
|||
public: |
|||
// Constructor |
|||
CMD(PGLOBAL g, char *cmd) { |
|||
Cmd = (char*)PlugSubAlloc(g, NULL, strlen(cmd) + 1); |
|||
strcpy(Cmd, cmd); Next = NULL; } |
|||
|
|||
// Members |
|||
PCMD Next; |
|||
char *Cmd; |
|||
}; // end of class CMD |
|||
|
|||
// Condition filter structure |
|||
typedef struct _cond_filter { |
|||
char *Body; |
|||
OPVAL Op; |
|||
PCMD Cmds; |
|||
} CONDFIL, *PCFIL; |
|||
|
|||
typedef class TDBCAT *PTDBCAT; |
|||
typedef class CATCOL *PCATCOL; |
|||
|
|||
/***********************************************************************/ |
|||
/* Definition of class TDB with all its method functions. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDB: public BLOCK { // Table Descriptor Block. |
|||
public: |
|||
// Constructors |
|||
TDB(PTABDEF tdp = NULL); |
|||
TDB(PTDB tdbp); |
|||
|
|||
// Implementation |
|||
static void SetTnum(int n) {Tnum = n;} |
|||
inline PTDB GetOrig(void) {return To_Orig;} |
|||
inline TUSE GetUse(void) {return Use;} |
|||
inline PCFIL GetCondFil(void) {return To_CondFil;} |
|||
inline LPCSTR GetName(void) {return Name;} |
|||
inline PTABLE GetTable(void) {return To_Table;} |
|||
inline PCOL GetColumns(void) {return Columns;} |
|||
inline int GetDegree(void) {return Degree;} |
|||
inline MODE GetMode(void) {return Mode;} |
|||
#if defined(BLK_INDX) |
|||
inline PFIL GetFilter(void) {return To_Filter;} |
|||
inline void SetFilter(PFIL fp) {To_Filter = fp;} |
|||
#endif // BLK_INDX |
|||
inline void SetOrig(PTDB txp) {To_Orig = txp;} |
|||
inline void SetUse(TUSE n) {Use = n;} |
|||
inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;} |
|||
inline void SetNext(PTDB tdbp) {Next = tdbp;} |
|||
inline void SetName(LPCSTR name) {Name = name;} |
|||
inline void SetTable(PTABLE tablep) {To_Table = tablep;} |
|||
inline void SetColumns(PCOL colp) {Columns = colp;} |
|||
inline void SetDegree(int degree) {Degree = degree;} |
|||
inline void SetMode(MODE mode) {Mode = mode;} |
|||
|
|||
//Properties |
|||
virtual AMT GetAmType(void) {return TYPE_AM_ERROR;} |
|||
virtual int GetTdb_No(void) {return Tdb_No;} |
|||
virtual PTDB GetNext(void) {return Next;} |
|||
virtual PCATLG GetCat(void) {return NULL;} |
|||
|
|||
// Methods |
|||
virtual bool IsSame(PTDB tp) {return tp == this;} |
|||
virtual bool GetBlockValues(PGLOBAL g) {return false;} |
|||
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} |
|||
virtual int GetMaxSize(PGLOBAL) = 0; |
|||
virtual int GetProgMax(PGLOBAL) = 0; |
|||
virtual int GetProgCur(void) = 0; |
|||
virtual int RowNumber(PGLOBAL g, bool b = false); |
|||
virtual bool IsReadOnly(void) {return true;} |
|||
virtual const CHARSET_INFO *data_charset() {return NULL;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return NULL;} |
|||
virtual PTDB CopyOne(PTABS t) {return this;} |
|||
virtual PTDB Copy(PTABS t); |
|||
virtual void PrintAM(FILE *f, char *m) |
|||
{fprintf(f, "%s AM(%d)\n", m, GetAmType());} |
|||
virtual void Print(PGLOBAL g, FILE *f, uint n); |
|||
virtual void Print(PGLOBAL g, char *ps, uint z); |
|||
virtual PSZ GetServer(void) = 0; |
|||
virtual int GetBadLines(void) {return 0;} |
|||
|
|||
// Database pure virtual routines |
|||
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num) = 0; |
|||
virtual void MarkDB(PGLOBAL, PTDB) = 0; |
|||
virtual bool OpenDB(PGLOBAL) = 0; |
|||
virtual int ReadDB(PGLOBAL) = 0; |
|||
virtual int WriteDB(PGLOBAL) = 0; |
|||
virtual int DeleteDB(PGLOBAL, int) = 0; |
|||
virtual void CloseDB(PGLOBAL) = 0; |
|||
virtual int CheckWrite(PGLOBAL g) {return 0;} |
|||
|
|||
// Database routines |
|||
bool OpenTable(PGLOBAL g, PSQL sqlp, MODE mode); |
|||
void CloseTable(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Members |
|||
PTDB To_Orig; // Pointer to original if it is a copy |
|||
TUSE Use; |
|||
#if defined(BLK_INDX) |
|||
PFIL To_Filter; |
|||
#endif // BLK_INDX |
|||
PCFIL To_CondFil; // To condition filter structure |
|||
static int Tnum; // Used to generate Tdb_no's |
|||
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 |
|||
LPCSTR Name; // Table name |
|||
PCOL Columns; // Points to the first column of the table |
|||
MODE Mode; // 10 Read, 30 Update, 40 Insert, 50 Delete |
|||
int Degree; // Number of columns |
|||
}; // end of class TDB |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the base class for all query tables (except decode). */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBASE : public TDB { |
|||
friend class INDEXDEF; |
|||
friend class XINDEX; |
|||
friend class XINDXS; |
|||
public: |
|||
// Constructor |
|||
TDBASE(PTABDEF tdp = NULL); |
|||
TDBASE(PTDBASE tdbp); |
|||
|
|||
// Implementation |
|||
inline int GetKnum(void) {return Knum;} |
|||
inline PTABDEF GetDef(void) {return To_Def;} |
|||
inline PKXBASE GetKindex(void) {return To_Kindex;} |
|||
inline PCOL GetSetCols(void) {return To_SetCols;} |
|||
inline void SetSetCols(PCOL colp) {To_SetCols = colp;} |
|||
|
|||
// Properties |
|||
void SetKindex(PKXBASE kxp); |
|||
PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;} |
|||
|
|||
// Methods |
|||
virtual bool IsUsingTemp(PGLOBAL g) {return false;} |
|||
virtual PCATLG GetCat(void); |
|||
virtual PSZ GetPath(void); |
|||
virtual void PrintAM(FILE *f, char *m); |
|||
virtual RECFM GetFtype(void) {return RECFM_NAF;} |
|||
virtual int GetAffectedRows(void) {return -1;} |
|||
virtual int GetRecpos(void) = 0; |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos); |
|||
virtual bool IsReadOnly(void) {return Read_Only;} |
|||
virtual bool IsView(void) {return FALSE;} |
|||
virtual CHARSET_INFO *data_charset(void); |
|||
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} |
|||
virtual int GetProgCur(void) {return GetRecpos();} |
|||
virtual PSZ GetFile(PGLOBAL g) {return "Not a file";} |
|||
virtual int GetRemote(void) {return 0;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {} |
|||
virtual void ResetDB(void) {} |
|||
virtual void ResetSize(void) {MaxSize = -1;} |
|||
virtual void RestoreNrec(void) {} |
|||
virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox); |
|||
virtual PSZ GetServer(void) {return "Current";} |
|||
|
|||
// Database routines |
|||
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); |
|||
virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int) |
|||
{assert(false); return NULL;} |
|||
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); |
|||
virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp); |
|||
virtual void MarkDB(PGLOBAL g, PTDB tdb2); |
|||
|
|||
protected: |
|||
// Members |
|||
PTABDEF To_Def; // Points to catalog description block |
|||
PXOB *To_Link; // Points to column of previous relations |
|||
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 |
|||
int MaxSize; // Max size in number of lines |
|||
int Knum; // Size of key arrays |
|||
bool Read_Only; // True for read only tables |
|||
const CHARSET_INFO *m_data_charset; |
|||
}; // end of class TDBASE |
|||
|
|||
/***********************************************************************/ |
|||
/* The abstract base class declaration for the catalog tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBCAT : public TDBASE { |
|||
friend class CATCOL; |
|||
public: |
|||
// Constructor |
|||
TDBCAT(PTABDEF tdp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_CAT;} |
|||
|
|||
// Methods |
|||
virtual int GetRecpos(void) {return N;} |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
virtual PQRYRES GetResult(PGLOBAL g) = 0; |
|||
bool Initialize(PGLOBAL g); |
|||
bool InitCol(PGLOBAL g); |
|||
|
|||
// Members |
|||
PQRYRES Qrp; |
|||
int N; // Row number |
|||
bool Init; |
|||
}; // end of class TDBCAT |
|||
|
|||
/***********************************************************************/ |
|||
/* Class CATCOL: ODBC info column. */ |
|||
/***********************************************************************/ |
|||
class DllExport CATCOL : public COLBLK { |
|||
friend class TDBCAT; |
|||
public: |
|||
// Constructors |
|||
CATCOL(PCOLDEF cdp, PTDB tdbp, int n); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_ODBC;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
CATCOL(void) {} // Default constructor not to be used |
|||
|
|||
// Members |
|||
PTDBCAT Tdbp; // Points to ODBC table block |
|||
PCOLRES Crp; // The column data array |
|||
int Flag; |
|||
}; // end of class CATCOL |
|||
|
|||
#endif // TABLE_DEFINED |
|||
/**************** Table H Declares Source Code File (.H) ***************/ |
|||
/* Name: TABLE.H Version 2.3 */ |
|||
/* */ |
|||
/* (C) Copyright to the author Olivier BERTRAND 1999-2014 */ |
|||
/* */ |
|||
/* This file contains the TBX, OPJOIN and TDB class definitions. */ |
|||
/***********************************************************************/ |
|||
#if !defined(TABLE_DEFINED) |
|||
#define TABLE_DEFINED |
|||
|
|||
|
|||
/***********************************************************************/ |
|||
/* Include required application header files */ |
|||
/* block.h is header containing Block global declarations. */ |
|||
/***********************************************************************/ |
|||
#include "assert.h" |
|||
#include "block.h" |
|||
#include "colblk.h" |
|||
#include "m_ctype.h" |
|||
|
|||
typedef class CMD *PCMD; |
|||
|
|||
// Commands executed by XDBC and MYX tables |
|||
class CMD : public BLOCK { |
|||
public: |
|||
// Constructor |
|||
CMD(PGLOBAL g, char *cmd) { |
|||
Cmd = (char*)PlugSubAlloc(g, NULL, strlen(cmd) + 1); |
|||
strcpy(Cmd, cmd); Next = NULL; } |
|||
|
|||
// Members |
|||
PCMD Next; |
|||
char *Cmd; |
|||
}; // end of class CMD |
|||
|
|||
// Condition filter structure |
|||
typedef struct _cond_filter { |
|||
char *Body; |
|||
OPVAL Op; |
|||
PCMD Cmds; |
|||
} CONDFIL, *PCFIL; |
|||
|
|||
typedef class TDBCAT *PTDBCAT; |
|||
typedef class CATCOL *PCATCOL; |
|||
|
|||
/***********************************************************************/ |
|||
/* Definition of class TDB with all its method functions. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDB: public BLOCK { // Table Descriptor Block. |
|||
public: |
|||
// Constructors |
|||
TDB(PTABDEF tdp = NULL); |
|||
TDB(PTDB tdbp); |
|||
|
|||
// Implementation |
|||
static void SetTnum(int n) {Tnum = n;} |
|||
inline PTDB GetOrig(void) {return To_Orig;} |
|||
inline TUSE GetUse(void) {return Use;} |
|||
inline PCFIL GetCondFil(void) {return To_CondFil;} |
|||
inline LPCSTR GetName(void) {return Name;} |
|||
inline PTABLE GetTable(void) {return To_Table;} |
|||
inline PCOL GetColumns(void) {return Columns;} |
|||
inline int GetDegree(void) {return Degree;} |
|||
inline MODE GetMode(void) {return Mode;} |
|||
inline PFIL GetFilter(void) {return To_Filter;} |
|||
inline void SetFilter(PFIL fp) {To_Filter = fp;} |
|||
inline void SetOrig(PTDB txp) {To_Orig = txp;} |
|||
inline void SetUse(TUSE n) {Use = n;} |
|||
inline void SetCondFil(PCFIL cfp) {To_CondFil = cfp;} |
|||
inline void SetNext(PTDB tdbp) {Next = tdbp;} |
|||
inline void SetName(LPCSTR name) {Name = name;} |
|||
inline void SetTable(PTABLE tablep) {To_Table = tablep;} |
|||
inline void SetColumns(PCOL colp) {Columns = colp;} |
|||
inline void SetDegree(int degree) {Degree = degree;} |
|||
inline void SetMode(MODE mode) {Mode = mode;} |
|||
|
|||
//Properties |
|||
virtual AMT GetAmType(void) {return TYPE_AM_ERROR;} |
|||
virtual int GetTdb_No(void) {return Tdb_No;} |
|||
virtual PTDB GetNext(void) {return Next;} |
|||
virtual PCATLG GetCat(void) {return NULL;} |
|||
|
|||
// Methods |
|||
virtual bool IsSame(PTDB tp) {return tp == this;} |
|||
virtual bool GetBlockValues(PGLOBAL g) {return false;} |
|||
virtual int Cardinality(PGLOBAL g) {return (g) ? -1 : 0;} |
|||
virtual int GetMaxSize(PGLOBAL) = 0; |
|||
virtual int GetProgMax(PGLOBAL) = 0; |
|||
virtual int GetProgCur(void) = 0; |
|||
virtual int RowNumber(PGLOBAL g, bool b = false); |
|||
virtual bool IsReadOnly(void) {return true;} |
|||
virtual const CHARSET_INFO *data_charset() {return NULL;} |
|||
virtual PTDB Duplicate(PGLOBAL g) {return NULL;} |
|||
virtual PTDB CopyOne(PTABS t) {return this;} |
|||
virtual PTDB Copy(PTABS t); |
|||
virtual void PrintAM(FILE *f, char *m) |
|||
{fprintf(f, "%s AM(%d)\n", m, GetAmType());} |
|||
virtual void Print(PGLOBAL g, FILE *f, uint n); |
|||
virtual void Print(PGLOBAL g, char *ps, uint z); |
|||
virtual PSZ GetServer(void) = 0; |
|||
virtual int GetBadLines(void) {return 0;} |
|||
|
|||
// Database pure virtual routines |
|||
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num) = 0; |
|||
virtual void MarkDB(PGLOBAL, PTDB) = 0; |
|||
virtual bool OpenDB(PGLOBAL) = 0; |
|||
virtual int ReadDB(PGLOBAL) = 0; |
|||
virtual int WriteDB(PGLOBAL) = 0; |
|||
virtual int DeleteDB(PGLOBAL, int) = 0; |
|||
virtual void CloseDB(PGLOBAL) = 0; |
|||
virtual int CheckWrite(PGLOBAL g) {return 0;} |
|||
|
|||
protected: |
|||
// Members |
|||
PTDB To_Orig; // Pointer to original if it is a copy |
|||
TUSE Use; |
|||
PFIL To_Filter; |
|||
PCFIL To_CondFil; // To condition filter structure |
|||
static int Tnum; // Used to generate Tdb_no's |
|||
const int Tdb_No; // GetTdb_No() is always 0 for OPJOIN |
|||
PTDB Next; // Next in linearized queries |
|||
PTABLE To_Table; // Points to the XTAB object |
|||
LPCSTR Name; // Table name |
|||
PCOL Columns; // Points to the first column of the table |
|||
MODE Mode; // 10 Read, 30 Update, 40 Insert, 50 Delete |
|||
int Degree; // Number of columns |
|||
}; // end of class TDB |
|||
|
|||
/***********************************************************************/ |
|||
/* This is the base class for all query tables (except decode). */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBASE : public TDB { |
|||
friend class INDEXDEF; |
|||
friend class XINDEX; |
|||
friend class XINDXS; |
|||
public: |
|||
// Constructor |
|||
TDBASE(PTABDEF tdp = NULL); |
|||
TDBASE(PTDBASE tdbp); |
|||
|
|||
// Implementation |
|||
inline int GetKnum(void) {return Knum;} |
|||
inline PTABDEF GetDef(void) {return To_Def;} |
|||
inline PKXBASE GetKindex(void) {return To_Kindex;} |
|||
inline PCOL GetSetCols(void) {return To_SetCols;} |
|||
inline void SetSetCols(PCOL colp) {To_SetCols = colp;} |
|||
|
|||
// Properties |
|||
void SetKindex(PKXBASE kxp); |
|||
PCOL Key(int i) {return (To_Key_Col) ? To_Key_Col[i] : NULL;} |
|||
|
|||
// Methods |
|||
virtual bool IsUsingTemp(PGLOBAL g) {return false;} |
|||
virtual PCATLG GetCat(void); |
|||
virtual PSZ GetPath(void); |
|||
virtual void PrintAM(FILE *f, char *m); |
|||
virtual RECFM GetFtype(void) {return RECFM_NAF;} |
|||
virtual int GetAffectedRows(void) {return -1;} |
|||
virtual int GetRecpos(void) = 0; |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos); |
|||
virtual bool IsReadOnly(void) {return Read_Only;} |
|||
virtual bool IsView(void) {return FALSE;} |
|||
virtual CHARSET_INFO *data_charset(void); |
|||
virtual int GetProgMax(PGLOBAL g) {return GetMaxSize(g);} |
|||
virtual int GetProgCur(void) {return GetRecpos();} |
|||
virtual PSZ GetFile(PGLOBAL g) {return "Not a file";} |
|||
virtual int GetRemote(void) {return 0;} |
|||
virtual void SetFile(PGLOBAL g, PSZ fn) {} |
|||
virtual void ResetDB(void) {} |
|||
virtual void ResetSize(void) {MaxSize = -1;} |
|||
virtual void RestoreNrec(void) {} |
|||
virtual int ResetTableOpt(PGLOBAL g, bool dop, bool dox); |
|||
virtual PSZ GetServer(void) {return "Current";} |
|||
|
|||
// Database routines |
|||
virtual PCOL ColDB(PGLOBAL g, PSZ name, int num); |
|||
virtual PCOL MakeCol(PGLOBAL, PCOLDEF, PCOL, int) |
|||
{assert(false); return NULL;} |
|||
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL colp); |
|||
virtual PCOL InsertSpcBlk(PGLOBAL g, PCOLDEF cdp); |
|||
virtual void MarkDB(PGLOBAL g, PTDB tdb2); |
|||
|
|||
protected: |
|||
// Members |
|||
PTABDEF To_Def; // Points to catalog description block |
|||
PXOB *To_Link; // Points to column of previous relations |
|||
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 |
|||
int MaxSize; // Max size in number of lines |
|||
int Knum; // Size of key arrays |
|||
bool Read_Only; // True for read only tables |
|||
const CHARSET_INFO *m_data_charset; |
|||
}; // end of class TDBASE |
|||
|
|||
/***********************************************************************/ |
|||
/* The abstract base class declaration for the catalog tables. */ |
|||
/***********************************************************************/ |
|||
class DllExport TDBCAT : public TDBASE { |
|||
friend class CATCOL; |
|||
public: |
|||
// Constructor |
|||
TDBCAT(PTABDEF tdp); |
|||
|
|||
// Implementation |
|||
virtual AMT GetAmType(void) {return TYPE_AM_CAT;} |
|||
|
|||
// Methods |
|||
virtual int GetRecpos(void) {return N;} |
|||
virtual int GetProgCur(void) {return N;} |
|||
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;} |
|||
virtual bool SetRecpos(PGLOBAL g, int recpos); |
|||
|
|||
// Database routines |
|||
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); |
|||
virtual int GetMaxSize(PGLOBAL g); |
|||
virtual bool OpenDB(PGLOBAL g); |
|||
virtual int ReadDB(PGLOBAL g); |
|||
virtual int WriteDB(PGLOBAL g); |
|||
virtual int DeleteDB(PGLOBAL g, int irc); |
|||
virtual void CloseDB(PGLOBAL g); |
|||
|
|||
protected: |
|||
// Specific routines |
|||
virtual PQRYRES GetResult(PGLOBAL g) = 0; |
|||
bool Initialize(PGLOBAL g); |
|||
bool InitCol(PGLOBAL g); |
|||
|
|||
// Members |
|||
PQRYRES Qrp; |
|||
int N; // Row number |
|||
bool Init; |
|||
}; // end of class TDBCAT |
|||
|
|||
/***********************************************************************/ |
|||
/* Class CATCOL: ODBC info column. */ |
|||
/***********************************************************************/ |
|||
class DllExport CATCOL : public COLBLK { |
|||
friend class TDBCAT; |
|||
public: |
|||
// Constructors |
|||
CATCOL(PCOLDEF cdp, PTDB tdbp, int n); |
|||
|
|||
// Implementation |
|||
virtual int GetAmType(void) {return TYPE_AM_ODBC;} |
|||
|
|||
// Methods |
|||
virtual void ReadColumn(PGLOBAL g); |
|||
|
|||
protected: |
|||
CATCOL(void) {} // Default constructor not to be used |
|||
|
|||
// Members |
|||
PTDBCAT Tdbp; // Points to ODBC table block |
|||
PCOLRES Crp; // The column data array |
|||
int Flag; |
|||
}; // end of class CATCOL |
|||
|
|||
#endif // TABLE_DEFINED |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue