Commit 49598114 authored by Olivier Bertrand's avatar Olivier Bertrand

- General code cleaning, eliminating a few potential bugs

modified:
  storage/connect/catalog.h
  storage/connect/mycat.cc
  storage/connect/taboccur.cpp
  storage/connect/taboccur.h
  storage/connect/tabutil.cpp
  storage/connect/tabutil.h
  storage/connect/tabxcl.cpp
  storage/connect/tabxcl.h
parent 5fc19f8d
...@@ -63,7 +63,7 @@ class DllExport CATALOG { ...@@ -63,7 +63,7 @@ class DllExport CATALOG {
// Implementation // Implementation
void *GetDescp(void) {return Descp;} void *GetDescp(void) {return Descp;}
PRELDEF GetTo_Desc(void) {return To_Desc;} //PRELDEF GetTo_Desc(void) {return To_Desc;}
//PSZ GetDescFile(void) {return DescFile;} //PSZ GetDescFile(void) {return DescFile;}
int GetCblen(void) {return Cblen;} int GetCblen(void) {return Cblen;}
bool GetDefHuge(void) {return DefHuge;} bool GetDefHuge(void) {return DefHuge;}
...@@ -115,7 +115,7 @@ class DllExport CATALOG { ...@@ -115,7 +115,7 @@ class DllExport CATALOG {
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;} virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
// Members // Members
PRELDEF To_Desc; /* To chain of relation desc. */ //PRELDEF To_Desc; /* To chain of relation desc. */
void *Descp; /* To DB description area */ void *Descp; /* To DB description area */
//AREADEF DescArea; /* Table desc. area size */ //AREADEF DescArea; /* Table desc. area size */
char *Cbuf; /* Buffer used for col section */ char *Cbuf; /* Buffer used for col section */
......
...@@ -253,7 +253,7 @@ uint GetFuncID(const char *func) ...@@ -253,7 +253,7 @@ uint GetFuncID(const char *func)
/***********************************************************************/ /***********************************************************************/
CATALOG::CATALOG(void) CATALOG::CATALOG(void)
{ {
To_Desc= NULL; //To_Desc= NULL;
//*DescFile= '\0'; //*DescFile= '\0';
#if defined(WIN32) #if defined(WIN32)
DataPath= ".\\"; DataPath= ".\\";
...@@ -276,7 +276,7 @@ CATALOG::CATALOG(void) ...@@ -276,7 +276,7 @@ CATALOG::CATALOG(void)
MYCAT::MYCAT(PHC hc) : CATALOG() MYCAT::MYCAT(PHC hc) : CATALOG()
{ {
Hc= hc; Hc= hc;
To_Desc= NULL; //To_Desc= NULL;
DefHuge= false; DefHuge= false;
//SepIndex= true; // Temporay until we can store offet and size //SepIndex= true; // Temporay until we can store offet and size
} // end of MYCAT constructor } // end of MYCAT constructor
...@@ -286,7 +286,7 @@ MYCAT::MYCAT(PHC hc) : CATALOG() ...@@ -286,7 +286,7 @@ MYCAT::MYCAT(PHC hc) : CATALOG()
/***********************************************************************/ /***********************************************************************/
void MYCAT::Reset(void) void MYCAT::Reset(void)
{ {
To_Desc= NULL; //To_Desc= NULL;
} // end of Reset } // end of Reset
/***********************************************************************/ /***********************************************************************/
...@@ -586,9 +586,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp) ...@@ -586,9 +586,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
/***********************************************************************/ /***********************************************************************/
/* GetTableDesc: retrieve a table descriptor. */ /* GetTableDesc: retrieve a table descriptor. */
/* Look for a table descriptor matching the name and type. If found */ /* Look for a table descriptor matching the name and type. */
/* in storage, return a pointer to it, else look in the XDB file. If */
/* found, make and add the descriptor and return a pointer to it. */
/***********************************************************************/ /***********************************************************************/
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp) LPCSTR type, PRELDEF *prp)
...@@ -597,8 +595,8 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name, ...@@ -597,8 +595,8 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type)); printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
// Firstly check whether this table descriptor is in memory // Firstly check whether this table descriptor is in memory
if (To_Desc) //if (To_Desc)
return To_Desc; // return To_Desc;
// If not specified get the type of this table // If not specified get the type of this table
if (!type && !(type= Hc->GetStringOption("Type"))) if (!type && !(type= Hc->GetStringOption("Type")))
...@@ -707,7 +705,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type) ...@@ -707,7 +705,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
/***********************************************************************/ /***********************************************************************/
void MYCAT::ClearDB(PGLOBAL g) void MYCAT::ClearDB(PGLOBAL g)
{ {
To_Desc= NULL; //To_Desc= NULL;
} // end of ClearDB } // end of ClearDB
/* ------------------------ End of MYCAT --------------------------- */ /* ------------------------ End of MYCAT --------------------------- */
...@@ -161,7 +161,7 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g) ...@@ -161,7 +161,7 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g)
// Count the number of columns and change separator into null char // Count the number of columns and change separator into null char
for (pn = Colist; ; pn += (strlen(pn) + 1)) for (pn = Colist; ; pn += (strlen(pn) + 1))
if ((p = strchr(pn, ';'))) { if ((p = strchr(pn, ',')) || (p = strchr(pn, ';'))) {
*p++ = '\0'; *p++ = '\0';
n++; n++;
} else { } else {
......
...@@ -9,12 +9,11 @@ typedef class OCCURDEF *POCCURDEF; ...@@ -9,12 +9,11 @@ typedef class OCCURDEF *POCCURDEF;
typedef class TDBOCCUR *PTDBOCCUR; typedef class TDBOCCUR *PTDBOCCUR;
typedef class OCCURCOL *POCCURCOL; typedef class OCCURCOL *POCCURCOL;
typedef class RANKCOL *PRANKCOL; typedef class RANKCOL *PRANKCOL;
typedef class SRTCOL *PSRTCOL;
/* -------------------------- OCCUR classes -------------------------- */ /* -------------------------- OCCUR classes -------------------------- */
/***********************************************************************/ /***********************************************************************/
/* OCCUR: OEM table that provides a view of a source table where the */ /* OCCUR: Table that provides a view of a source table where the */
/* contain of several columns of the source table is placed in only */ /* contain of several columns of the source table is placed in only */
/* one column, the OCCUR column, this resulting into several rows. */ /* one column, the OCCUR column, this resulting into several rows. */
/***********************************************************************/ /***********************************************************************/
...@@ -48,7 +47,6 @@ class OCCURDEF : public PRXDEF { /* Logical table description */ ...@@ -48,7 +47,6 @@ class OCCURDEF : public PRXDEF { /* Logical table description */
class TDBOCCUR : public TDBPRX { class TDBOCCUR : public TDBPRX {
friend class OCCURCOL; friend class OCCURCOL;
friend class RANKCOL; friend class RANKCOL;
friend class SRTCOL;
public: public:
// Constructor // Constructor
TDBOCCUR(POCCURDEF tdp); TDBOCCUR(POCCURDEF tdp);
......
/************* Tabutil cpp Declares Source Code File (.H) **************/ /************* Tabutil cpp Declares Source Code File (.CPP) ************/
/* Name: TABUTIL.CPP Version 1.0 */ /* Name: TABUTIL.CPP Version 1.0 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2013 */ /* (C) Copyright to the author Olivier BERTRAND 2013 */
/* */ /* */
/* Utility function used by TBL and PRX tables. */ /* Utility function used by the PROXY, XCOL, OCCUR, and TBL tables. */
/***********************************************************************/ /***********************************************************************/
/***********************************************************************/ /***********************************************************************/
...@@ -117,7 +117,6 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, ...@@ -117,7 +117,6 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
/************************************************************************/ /************************************************************************/
/* TabColumns: constructs the result blocks containing all the columns */ /* TabColumns: constructs the result blocks containing all the columns */
/* of the object table that will be retrieved by GetData commands. */ /* of the object table that will be retrieved by GetData commands. */
/* key = TRUE when called from Create Table to get key informations. */
/************************************************************************/ /************************************************************************/
PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
const char *name, bool info) const char *name, bool info)
...@@ -264,7 +263,11 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -264,7 +263,11 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
char *pn, *db, *tab; char *pn, *db, *tab;
db = Cat->GetStringCatInfo(g, "Dbname", "*"); db = Cat->GetStringCatInfo(g, "Dbname", "*");
tab = Cat->GetStringCatInfo(g, "Tabname", NULL);
if (!(tab = Cat->GetStringCatInfo(g, "Tabname", NULL))) {
strcpy(g->Message, "Missing object table name");
return TRUE;
} // endif tab
// Analyze the table name, it may have the format: [dbname.]tabname // Analyze the table name, it may have the format: [dbname.]tabname
if ((pn = strchr(tab, '.'))) { if ((pn = strchr(tab, '.'))) {
...@@ -414,7 +417,7 @@ int TDBPRX::RowNumber(PGLOBAL g, bool b) ...@@ -414,7 +417,7 @@ int TDBPRX::RowNumber(PGLOBAL g, bool b)
} // end of RowNumber } // end of RowNumber
/***********************************************************************/ /***********************************************************************/
/* XCV Access Method opening routine. */ /* PROXY Access Method opening routine. */
/***********************************************************************/ /***********************************************************************/
bool TDBPRX::OpenDB(PGLOBAL g) bool TDBPRX::OpenDB(PGLOBAL g)
{ {
...@@ -453,7 +456,7 @@ bool TDBPRX::OpenDB(PGLOBAL g) ...@@ -453,7 +456,7 @@ bool TDBPRX::OpenDB(PGLOBAL g)
} // end of OpenDB } // end of OpenDB
/***********************************************************************/ /***********************************************************************/
/* Data Base read routine for XCV access method. */ /* Data Base read routine for PROY access method. */
/***********************************************************************/ /***********************************************************************/
int TDBPRX::ReadDB(PGLOBAL g) int TDBPRX::ReadDB(PGLOBAL g)
{ {
...@@ -464,7 +467,7 @@ int TDBPRX::ReadDB(PGLOBAL g) ...@@ -464,7 +467,7 @@ int TDBPRX::ReadDB(PGLOBAL g)
} // end of ReadDB } // end of ReadDB
/***********************************************************************/ /***********************************************************************/
/* WriteDB: Data Base write routine for XCV access methods. */ /* WriteDB: Data Base write routine for PROXY access methods. */
/***********************************************************************/ /***********************************************************************/
int TDBPRX::WriteDB(PGLOBAL g) int TDBPRX::WriteDB(PGLOBAL g)
{ {
...@@ -473,7 +476,7 @@ int TDBPRX::WriteDB(PGLOBAL g) ...@@ -473,7 +476,7 @@ int TDBPRX::WriteDB(PGLOBAL g)
} // end of WriteDB } // end of WriteDB
/***********************************************************************/ /***********************************************************************/
/* Data Base delete line routine for XCV access methods. */ /* Data Base delete line routine for PROXY access methods. */
/***********************************************************************/ /***********************************************************************/
int TDBPRX::DeleteDB(PGLOBAL g, int irc) int TDBPRX::DeleteDB(PGLOBAL g, int irc)
{ {
...@@ -561,29 +564,6 @@ void PRXCOL::ReadColumn(PGLOBAL g) ...@@ -561,29 +564,6 @@ void PRXCOL::ReadColumn(PGLOBAL g)
} // end of ReadColumn } // end of ReadColumn
#if 0
/* ---------------------------TBCDEF class --------------------------- */
/***********************************************************************/
/* DefineAM: define specific AM block values from CATLG table. */
/***********************************************************************/
bool TBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
Desc = "Catalog Table";
Database = Cat->GetStringCatInfo(g, "Database", "*");
Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname);
return FALSE;
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new TDB of the proper type. */
/***********************************************************************/
PTDB TBCDEF::GetTable(PGLOBAL g, MODE m)
{
return new(g) TDBTBC(this);
} // end of GetTable
#endif // 0
/* ---------------------------TDBTBC class --------------------------- */ /* ---------------------------TDBTBC class --------------------------- */
/***********************************************************************/ /***********************************************************************/
...@@ -591,31 +571,9 @@ PTDB TBCDEF::GetTable(PGLOBAL g, MODE m) ...@@ -591,31 +571,9 @@ PTDB TBCDEF::GetTable(PGLOBAL g, MODE m)
/***********************************************************************/ /***********************************************************************/
TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp) TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp)
{ {
// Db = tdp->Database;
// Tab = tdp->Tabname;
Db = (PSZ)tdp->Tablep->GetQualifier();
Tab = (PSZ)tdp->Tablep->GetName();
} // end of TDBTBC constructor
#if 0
/***********************************************************************/
/* TDBTBC class constructor from TBL table. */
/***********************************************************************/
TDBTBC::TDBTBC(PTBLDEF tdp) : TDBCAT(tdp)
{
Db = tdp->To_Tables->DB;
Tab = tdp->To_Tables->Name;
} // end of TDBTBC constructor
/***********************************************************************/
/* TDBTBC class constructor from PRX table. */
/***********************************************************************/
TDBTBC::TDBTBC(PXCLDEF tdp) : TDBCAT(tdp)
{
Db = (PSZ)tdp->Tablep->GetQualifier(); Db = (PSZ)tdp->Tablep->GetQualifier();
Tab = (PSZ)tdp->Tablep->GetName(); Tab = (PSZ)tdp->Tablep->GetName();
} // end of TDBTBC constructor } // end of TDBTBC constructor
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* GetResult: Get the list the MYSQL table columns. */ /* GetResult: Get the list the MYSQL table columns. */
......
...@@ -132,34 +132,6 @@ class DllExport PRXCOL : public COLBLK { ...@@ -132,34 +132,6 @@ class DllExport PRXCOL : public COLBLK {
int Colnum; // Used when retrieving columns by number int Colnum; // Used when retrieving columns by number
}; // end of class PRXCOL }; // end of class PRXCOL
#if 0
/***********************************************************************/
/* TBC table. */
/***********************************************************************/
class TBCDEF : public TABDEF {/* Logical table description */
friend class TDBTBC;
friend class ha_connect;
public:
// Constructor
TBCDEF(void) {Database = NULL; Tabname = NULL;}
// Implementation
virtual const char *GetType(void) {return "TBC";}
inline PSZ GetDatabase(void) {return Database;};
inline PSZ GetTabname(void) {return Tabname;}
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PSZ Database; /* Database to be used by server */
PSZ Tabname; /* External table name */
}; // end of TBCDEF
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the TBC column catalog table. */ /* This is the class declaration for the TBC column catalog table. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -73,7 +73,7 @@ XCLDEF::XCLDEF(void) ...@@ -73,7 +73,7 @@ XCLDEF::XCLDEF(void)
} // end of XCLDEF constructor } // end of XCLDEF constructor
/***********************************************************************/ /***********************************************************************/
/* DefineAM: define specific AM block values from XCOL file. */ /* DefineAM: define specific AM block values from XCOL table. */
/***********************************************************************/ /***********************************************************************/
bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool XCLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
...@@ -106,7 +106,7 @@ PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -106,7 +106,7 @@ PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode)
TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp) TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp)
{ {
Xcolumn = tdp->Xcol; // CSV column name Xcolumn = tdp->Xcol; // CSV column name
Xcolp = NULL; // To the XCVCOL column Xcolp = NULL; // To the XCLCOL column
Mult = tdp->Mult; // Multiplication factor Mult = tdp->Mult; // Multiplication factor
N = 0; // The current table index N = 0; // The current table index
M = 0; // The occurence rank M = 0; // The occurence rank
...@@ -115,33 +115,6 @@ TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp) ...@@ -115,33 +115,6 @@ TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp)
Sep = tdp->Sep; // The Xcol separator Sep = tdp->Sep; // The Xcol separator
} // end of TDBXCL constructor } // end of TDBXCL constructor
/***********************************************************************/
/* Initializes the table. */
/***********************************************************************/
bool TDBXCL::InitTable(PGLOBAL g)
{
if (!Tdbp) {
PCOLDEF cdp;
// Get the table description block of this table
if (!(Tdbp = (PTDBASE)GetSubTable(g, ((PXCLDEF)To_Def)->Tablep)))
return TRUE;
for (cdp = Tdbp->GetDef()->GetCols(); cdp; cdp = cdp->GetNext())
if (!stricmp(cdp->GetName(), Xcolumn))
break;
if (!cdp) {
sprintf(g->Message, "%s is not a %s column",
Xcolumn, Tdbp->GetName());
return TRUE;
} // endif cdp
} // endif Tdbp
return FALSE;
} // end of InitTable
/***********************************************************************/ /***********************************************************************/
/* Allocate XCL column description block. */ /* Allocate XCL column description block. */
/***********************************************************************/ /***********************************************************************/
...@@ -165,7 +138,7 @@ int TDBXCL::GetMaxSize(PGLOBAL g) ...@@ -165,7 +138,7 @@ int TDBXCL::GetMaxSize(PGLOBAL g)
{ {
if (MaxSize < 0) { if (MaxSize < 0) {
if (InitTable(g)) if (InitTable(g))
return NULL; return 0;
MaxSize = Mult * Tdbp->GetMaxSize(g); MaxSize = Mult * Tdbp->GetMaxSize(g);
} // endif MaxSize } // endif MaxSize
...@@ -174,8 +147,8 @@ int TDBXCL::GetMaxSize(PGLOBAL g) ...@@ -174,8 +147,8 @@ int TDBXCL::GetMaxSize(PGLOBAL g)
} // end of GetMaxSize } // end of GetMaxSize
/***********************************************************************/ /***********************************************************************/
/* In this sample, ROWID will be the (virtual) row number, */ /* For this table type, ROWID is the (virtual) row number, */
/* while ROWNUM will be the occurence rank in the multiple column. */ /* while ROWNUM is be the occurence rank in the multiple column. */
/***********************************************************************/ /***********************************************************************/
int TDBXCL::RowNumber(PGLOBAL g, bool b) int TDBXCL::RowNumber(PGLOBAL g, bool b)
{ {
...@@ -183,7 +156,7 @@ int TDBXCL::RowNumber(PGLOBAL g, bool b) ...@@ -183,7 +156,7 @@ int TDBXCL::RowNumber(PGLOBAL g, bool b)
} // end of RowNumber } // end of RowNumber
/***********************************************************************/ /***********************************************************************/
/* XCV Access Method opening routine. */ /* XCL Access Method opening routine. */
/***********************************************************************/ /***********************************************************************/
bool TDBXCL::OpenDB(PGLOBAL g) bool TDBXCL::OpenDB(PGLOBAL g)
{ {
...@@ -206,7 +179,7 @@ bool TDBXCL::OpenDB(PGLOBAL g) ...@@ -206,7 +179,7 @@ bool TDBXCL::OpenDB(PGLOBAL g)
} // endif Mode } // endif Mode
if (InitTable(g)) if (InitTable(g))
return NULL; return TRUE;
/*********************************************************************/ /*********************************************************************/
/* Check and initialize the subtable columns. */ /* Check and initialize the subtable columns. */
...@@ -225,7 +198,7 @@ bool TDBXCL::OpenDB(PGLOBAL g) ...@@ -225,7 +198,7 @@ bool TDBXCL::OpenDB(PGLOBAL g)
} // end of OpenDB } // end of OpenDB
/***********************************************************************/ /***********************************************************************/
/* Data Base read routine for XCV access method. */ /* Data Base read routine for XCL access method. */
/***********************************************************************/ /***********************************************************************/
int TDBXCL::ReadDB(PGLOBAL g) int TDBXCL::ReadDB(PGLOBAL g)
{ {
......
...@@ -45,7 +45,7 @@ class XCLDEF : public PRXDEF { /* Logical table description */ ...@@ -45,7 +45,7 @@ class XCLDEF : public PRXDEF { /* Logical table description */
}; // end of XCLDEF }; // end of XCLDEF
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the XCSV table. */ /* This is the class declaration for the XCOL table. */
/***********************************************************************/ /***********************************************************************/
class TDBXCL : public TDBPRX { class TDBXCL : public TDBPRX {
friend class XCLDEF; friend class XCLDEF;
...@@ -64,7 +64,6 @@ class TDBXCL : public TDBPRX { ...@@ -64,7 +64,6 @@ class TDBXCL : public TDBPRX {
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool InitTable(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
...@@ -77,7 +76,7 @@ class TDBXCL : public TDBPRX { ...@@ -77,7 +76,7 @@ class TDBXCL : public TDBPRX {
int N; // The current table index int N; // The current table index
int M; // The occurence rank int M; // The occurence rank
BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip BYTE RowFlag; // 0: Ok, 1: Same, 2: Skip
BOOL New; // TRUE for new line bool New; // TRUE for new line
char Sep; // The Xcol separator char Sep; // The Xcol separator
}; // end of class TDBXCL }; // end of class TDBXCL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment