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 {
// Implementation
void *GetDescp(void) {return Descp;}
PRELDEF GetTo_Desc(void) {return To_Desc;}
//PRELDEF GetTo_Desc(void) {return To_Desc;}
//PSZ GetDescFile(void) {return DescFile;}
int GetCblen(void) {return Cblen;}
bool GetDefHuge(void) {return DefHuge;}
......@@ -115,7 +115,7 @@ class DllExport CATALOG {
virtual PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am) {return NULL;}
// Members
PRELDEF To_Desc; /* To chain of relation desc. */
//PRELDEF To_Desc; /* To chain of relation desc. */
void *Descp; /* To DB description area */
//AREADEF DescArea; /* Table desc. area size */
char *Cbuf; /* Buffer used for col section */
......
......@@ -253,7 +253,7 @@ uint GetFuncID(const char *func)
/***********************************************************************/
CATALOG::CATALOG(void)
{
To_Desc= NULL;
//To_Desc= NULL;
//*DescFile= '\0';
#if defined(WIN32)
DataPath= ".\\";
......@@ -276,7 +276,7 @@ CATALOG::CATALOG(void)
MYCAT::MYCAT(PHC hc) : CATALOG()
{
Hc= hc;
To_Desc= NULL;
//To_Desc= NULL;
DefHuge= false;
//SepIndex= true; // Temporay until we can store offet and size
} // end of MYCAT constructor
......@@ -286,7 +286,7 @@ MYCAT::MYCAT(PHC hc) : CATALOG()
/***********************************************************************/
void MYCAT::Reset(void)
{
To_Desc= NULL;
//To_Desc= NULL;
} // end of Reset
/***********************************************************************/
......@@ -586,9 +586,7 @@ bool MYCAT::GetIndexInfo(PGLOBAL g, PTABDEF defp)
/***********************************************************************/
/* GetTableDesc: retrieve a table descriptor. */
/* Look for a table descriptor matching the name and type. If found */
/* 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. */
/* Look for a table descriptor matching the name and type. */
/***********************************************************************/
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
LPCSTR type, PRELDEF *prp)
......@@ -597,8 +595,8 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
// Firstly check whether this table descriptor is in memory
if (To_Desc)
return To_Desc;
//if (To_Desc)
// return To_Desc;
// If not specified get the type of this table
if (!type && !(type= Hc->GetStringOption("Type")))
......@@ -707,7 +705,7 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
/***********************************************************************/
void MYCAT::ClearDB(PGLOBAL g)
{
To_Desc= NULL;
//To_Desc= NULL;
} // end of ClearDB
/* ------------------------ End of MYCAT --------------------------- */
......@@ -161,7 +161,7 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g)
// Count the number of columns and change separator into null char
for (pn = Colist; ; pn += (strlen(pn) + 1))
if ((p = strchr(pn, ';'))) {
if ((p = strchr(pn, ',')) || (p = strchr(pn, ';'))) {
*p++ = '\0';
n++;
} else {
......
......@@ -9,12 +9,11 @@ typedef class OCCURDEF *POCCURDEF;
typedef class TDBOCCUR *PTDBOCCUR;
typedef class OCCURCOL *POCCURCOL;
typedef class RANKCOL *PRANKCOL;
typedef class SRTCOL *PSRTCOL;
/* -------------------------- 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 */
/* one column, the OCCUR column, this resulting into several rows. */
/***********************************************************************/
......@@ -48,7 +47,6 @@ class OCCURDEF : public PRXDEF { /* Logical table description */
class TDBOCCUR : public TDBPRX {
friend class OCCURCOL;
friend class RANKCOL;
friend class SRTCOL;
public:
// Constructor
TDBOCCUR(POCCURDEF tdp);
......
/************* Tabutil cpp Declares Source Code File (.H) **************/
/************* Tabutil cpp Declares Source Code File (.CPP) ************/
/* Name: TABUTIL.CPP Version 1.0 */
/* */
/* (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,
/************************************************************************/
/* TabColumns: constructs the result blocks containing all the columns */
/* 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,
const char *name, bool info)
......@@ -264,7 +263,11 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
char *pn, *db, *tab;
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
if ((pn = strchr(tab, '.'))) {
......@@ -414,7 +417,7 @@ int TDBPRX::RowNumber(PGLOBAL g, bool b)
} // end of RowNumber
/***********************************************************************/
/* XCV Access Method opening routine. */
/* PROXY Access Method opening routine. */
/***********************************************************************/
bool TDBPRX::OpenDB(PGLOBAL g)
{
......@@ -453,7 +456,7 @@ bool TDBPRX::OpenDB(PGLOBAL g)
} // end of OpenDB
/***********************************************************************/
/* Data Base read routine for XCV access method. */
/* Data Base read routine for PROY access method. */
/***********************************************************************/
int TDBPRX::ReadDB(PGLOBAL g)
{
......@@ -464,7 +467,7 @@ int TDBPRX::ReadDB(PGLOBAL g)
} // 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)
{
......@@ -473,7 +476,7 @@ int TDBPRX::WriteDB(PGLOBAL g)
} // 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)
{
......@@ -561,29 +564,6 @@ void PRXCOL::ReadColumn(PGLOBAL g)
} // 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 --------------------------- */
/***********************************************************************/
......@@ -591,31 +571,9 @@ PTDB TBCDEF::GetTable(PGLOBAL g, MODE m)
/***********************************************************************/
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();
Tab = (PSZ)tdp->Tablep->GetName();
} // end of TDBTBC constructor
#endif // 0
/***********************************************************************/
/* GetResult: Get the list the MYSQL table columns. */
......
......@@ -132,34 +132,6 @@ class DllExport PRXCOL : public COLBLK {
int Colnum; // Used when retrieving columns by number
}; // 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. */
/***********************************************************************/
......
......@@ -73,7 +73,7 @@ XCLDEF::XCLDEF(void)
} // 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)
{
......@@ -106,7 +106,7 @@ PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode)
TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp)
{
Xcolumn = tdp->Xcol; // CSV column name
Xcolp = NULL; // To the XCVCOL column
Xcolp = NULL; // To the XCLCOL column
Mult = tdp->Mult; // Multiplication factor
N = 0; // The current table index
M = 0; // The occurence rank
......@@ -115,33 +115,6 @@ TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp)
Sep = tdp->Sep; // The Xcol separator
} // 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. */
/***********************************************************************/
......@@ -165,7 +138,7 @@ int TDBXCL::GetMaxSize(PGLOBAL g)
{
if (MaxSize < 0) {
if (InitTable(g))
return NULL;
return 0;
MaxSize = Mult * Tdbp->GetMaxSize(g);
} // endif MaxSize
......@@ -174,8 +147,8 @@ int TDBXCL::GetMaxSize(PGLOBAL g)
} // end of GetMaxSize
/***********************************************************************/
/* In this sample, ROWID will be the (virtual) row number, */
/* while ROWNUM will be the occurence rank in the multiple column. */
/* For this table type, ROWID is the (virtual) row number, */
/* while ROWNUM is be the occurence rank in the multiple column. */
/***********************************************************************/
int TDBXCL::RowNumber(PGLOBAL g, bool b)
{
......@@ -183,7 +156,7 @@ int TDBXCL::RowNumber(PGLOBAL g, bool b)
} // end of RowNumber
/***********************************************************************/
/* XCV Access Method opening routine. */
/* XCL Access Method opening routine. */
/***********************************************************************/
bool TDBXCL::OpenDB(PGLOBAL g)
{
......@@ -206,7 +179,7 @@ bool TDBXCL::OpenDB(PGLOBAL g)
} // endif Mode
if (InitTable(g))
return NULL;
return TRUE;
/*********************************************************************/
/* Check and initialize the subtable columns. */
......@@ -225,7 +198,7 @@ bool TDBXCL::OpenDB(PGLOBAL g)
} // end of OpenDB
/***********************************************************************/
/* Data Base read routine for XCV access method. */
/* Data Base read routine for XCL access method. */
/***********************************************************************/
int TDBXCL::ReadDB(PGLOBAL g)
{
......
......@@ -45,7 +45,7 @@ class XCLDEF : public PRXDEF { /* Logical table description */
}; // 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 {
friend class XCLDEF;
......@@ -64,7 +64,6 @@ class TDBXCL : public TDBPRX {
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual bool InitTable(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
......@@ -77,7 +76,7 @@ class TDBXCL : public TDBPRX {
int N; // The current table index
int M; // The occurence rank
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
}; // 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