Commit f3e94409 authored by Olivier Bertrand's avatar Olivier Bertrand

- Adding a loop test to prevent PROXY based table to loop when repointing on itself.

- Fix bug causing PROXY on non CONNECT tables to sometimes use the wrong DB.
- Making some more tests in create that were in pre_create not called anymore
  when columns are defined.
- Updating some test results to reflect new warnings.

modified:
  storage/connect/ha_connect.cc
  storage/connect/mysql-test/connect/r/tbl.result
  storage/connect/mysql-test/connect/r/upd.result
  storage/connect/tabcol.h
  storage/connect/tabmysql.cpp
  storage/connect/taboccur.cpp
  storage/connect/taboccur.h
  storage/connect/tabtbl.cpp
  storage/connect/tabtbl.h
  storage/connect/tabutil.cpp
  storage/connect/tabutil.h
  storage/connect/tabxcl.cpp
  storage/connect/tabxcl.h
parent 3d4adc3f
...@@ -3392,21 +3392,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -3392,21 +3392,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
} // endif tab } // endif tab
// Check whether a table is defined on itself
switch (ttp) {
case TAB_PRX:
case TAB_XCL:
case TAB_TBL:
case TAB_OCCUR:
if (!stricmp(tab, create_info->alias) &&
!stricmp(db, thd->db)) {
sprintf(g->Message, "A %s table cannot refer to itself", topt->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
return HA_ERR_INTERNAL_ERROR;
} // endif tab
} // endswitch ttp
switch (ttp) { switch (ttp) {
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
case TAB_ODBC: case TAB_ODBC:
...@@ -3758,7 +3743,8 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3758,7 +3743,8 @@ int ha_connect::create(const char *name, TABLE *table_arg,
Field *fp; Field *fp;
TABTYPE type; TABTYPE type;
TABLE *st= table; // Probably unuseful TABLE *st= table; // Probably unuseful
xp= GetUser(ha_thd(), xp); THD *thd= ha_thd();
xp= GetUser(thd, xp);
PGLOBAL g= xp->g; PGLOBAL g= xp->g;
DBUG_ENTER("ha_connect::create"); DBUG_ENTER("ha_connect::create");
...@@ -3768,7 +3754,27 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3768,7 +3754,27 @@ int ha_connect::create(const char *name, TABLE *table_arg,
DBUG_ASSERT(options); DBUG_ASSERT(options);
type= GetTypeID(options->type); type= GetTypeID(options->type);
if (check_privileges(ha_thd(), options)) // Check table type
if (type == TAB_UNDEF) {
if (!options->tabname) {
strcpy(g->Message, "No table_type. Will be set to DOS");
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
type= TAB_DOS;
options->type= "DOS";
} else {
strcpy(g->Message, "No table_type. Will be set to PROXY");
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
type= TAB_PRX;
options->type= "PROXY";
} // endif fnc
} else if (type == TAB_NIY) {
sprintf(g->Message, "Unsupported table type %s", options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endif ttp
if (check_privileges(thd, options))
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
if (options->data_charset) { if (options->data_charset) {
...@@ -3795,6 +3801,21 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3795,6 +3801,21 @@ int ha_connect::create(const char *name, TABLE *table_arg,
} else } else
dbf= (GetTypeID(options->type) == TAB_DBF && !options->catfunc); dbf= (GetTypeID(options->type) == TAB_DBF && !options->catfunc);
// Check whether a table is defined on itself
switch (type) {
case TAB_PRX:
case TAB_XCL:
case TAB_OCCUR:
if (!stricmp(options->tabname, create_info->alias) &&
(!options->dbname || !stricmp(options->dbname, thd->db))) {
sprintf(g->Message, "A %s table cannot refer to itself",
options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
return HA_ERR_INTERNAL_ERROR;
} // endif tab
} // endswitch ttp
if (type == TAB_XML) { if (type == TAB_XML) {
bool dom; // True: MS-DOM, False libxml2 bool dom; // True: MS-DOM, False libxml2
char *xsup= GetListOption(g, "Xmlsup", options->oplist, "*"); char *xsup= GetListOption(g, "Xmlsup", options->oplist, "*");
...@@ -3964,8 +3985,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3964,8 +3985,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
strcat(strcat(buf, "."), lwt); strcat(strcat(buf, "."), lwt);
sprintf(g->Message, "No file name. Table will use %s", buf); sprintf(g->Message, "No file name. Table will use %s", buf);
push_warning(table->in_use, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/"); strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
PlugSetPath(fn, buf, dbpath); PlugSetPath(fn, buf, dbpath);
...@@ -3994,7 +4014,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3994,7 +4014,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
// We should be in CREATE TABLE // We should be in CREATE TABLE
if (table->in_use->lex->sql_command != SQLCOM_CREATE_TABLE) if (table->in_use->lex->sql_command != SQLCOM_CREATE_TABLE)
push_warning(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, 0, push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Wrong command in create, please contact CONNECT team"); "Wrong command in create, please contact CONNECT team");
// Get the index definitions // Get the index definitions
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
CREATE TABLE t1 ( CREATE TABLE t1 (
a INT NOT NULL, a INT NOT NULL,
message CHAR(10)) ENGINE=connect; message CHAR(10)) ENGINE=connect;
Warnings:
Warning 1105 No table_type. Will be set to DOS
Warning 1105 No file name. Table will use t1.dos
INSERT INTO t1 VALUES (1,'Testing'),(2,'dos table'),(3,'t1'); INSERT INTO t1 VALUES (1,'Testing'),(2,'dos table'),(3,'t1');
SELECT * FROM t1; SELECT * FROM t1;
a message a message
......
...@@ -59,6 +59,9 @@ END// ...@@ -59,6 +59,9 @@ END//
# Testing DOS table changes # Testing DOS table changes
# #
CREATE TABLE t1 ENGINE=connect AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect AS SELECT * FROM employee;
Warnings:
Warning 1105 No table_type. Will be set to DOS
Warning 1105 No file name. Table will use t1.dos
CALL test.tst_up(); CALL test.tst_up();
serialno name sex title manager department secretary salary serialno name sex title manager department secretary salary
74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00 74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00
...@@ -154,6 +157,9 @@ serialno name sex title manager department secretary salary ...@@ -154,6 +157,9 @@ serialno name sex title manager department secretary salary
# Testing DOS table changes # Testing DOS table changes
# #
CREATE TABLE t1 ENGINE=connect mapped=yes AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect mapped=yes AS SELECT * FROM employee;
Warnings:
Warning 1105 No table_type. Will be set to DOS
Warning 1105 No file name. Table will use t1.dos
CALL test.tst_up(); CALL test.tst_up();
serialno name sex title manager department secretary salary serialno name sex title manager department secretary salary
74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00 74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
/***********************************************************************/ /***********************************************************************/
/* Definition of class XTAB with all its method functions. */ /* Definition of class XTAB with all its method functions. */
/***********************************************************************/ /***********************************************************************/
class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block. class DllExport XTAB: public BLOCK { // Table Name-Owner-Correl block.
friend class TDBPRX;
public: public:
// Constructors // Constructors
XTAB(LPCSTR name, LPCSTR correl = NULL); XTAB(LPCSTR name, LPCSTR correl = NULL);
......
...@@ -283,11 +283,8 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -283,11 +283,8 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Desc = "MySQL Table"; Desc = "MySQL Table";
if (!stricmp(am, "MYPRX")) if (!stricmp(am, "MYPRX")) {
// MYSQL access from a PROXY table, // Normal case of specific MYSQL table
// we must get parms from the calling table
Remove_tshp(Cat);
if (!url || !*url) { if (!url || !*url) {
// Not using the connection URL // Not using the connection URL
Hostname = Cat->GetStringCatInfo(g, "Host", "localhost"); Hostname = Cat->GetStringCatInfo(g, "Host", "localhost");
...@@ -302,6 +299,20 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -302,6 +299,20 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Bind = !!Cat->GetIntCatInfo("Bind", 0); Bind = !!Cat->GetIntCatInfo("Bind", 0);
Delayed = !!Cat->GetIntCatInfo("Delayed", 0); Delayed = !!Cat->GetIntCatInfo("Delayed", 0);
} else {
// MYSQL access from a PROXY table, not using URL
Database = Cat->GetStringCatInfo(g, "Database", "*");
Tabname = Cat->GetStringCatInfo(g, "Name", Name); // Deprecated
Tabname = Cat->GetStringCatInfo(g, "Tabname", Tabname);
// We must get connection parms from the calling table
Remove_tshp(Cat);
Hostname = Cat->GetStringCatInfo(g, "Host", "localhost");
Username = Cat->GetStringCatInfo(g, "User", "*");
Password = Cat->GetStringCatInfo(g, "Password", NULL);
Portnumber = Cat->GetIntCatInfo("Port", mysqld_port);
} // endif am
return FALSE; return FALSE;
} // end of DefineAM } // end of DefineAM
......
...@@ -60,7 +60,6 @@ extern "C" int trace; ...@@ -60,7 +60,6 @@ extern "C" int trace;
/***********************************************************************/ /***********************************************************************/
bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
//Tabname = Cat->GetStringCatInfo(g, "SrcTable", "");
Xcol = Cat->GetStringCatInfo(g, "OccurCol", ""); Xcol = Cat->GetStringCatInfo(g, "OccurCol", "");
Rcol = Cat->GetStringCatInfo(g, "RankCol", ""); Rcol = Cat->GetStringCatInfo(g, "RankCol", "");
Colist = Cat->GetStringCatInfo(g, "Colist", ""); Colist = Cat->GetStringCatInfo(g, "Colist", "");
...@@ -72,22 +71,9 @@ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -72,22 +71,9 @@ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/ /***********************************************************************/
PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m) PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m)
{ {
if (Catfunc != FNC_COL) { if (Catfunc != FNC_COL)
PTDB tdbp; return new(g) TDBOCCUR(this);
PTDBOCCUR tocp = new(g) TDBOCCUR(this); else
// Check that the source table is available
if (!tocp || !(tdbp = tocp->GetSubTable(g, Tablep)))
return NULL;
// Set Tdbp now
tocp->SetTdbp((PTDBASE)tdbp);
if (tocp->MakeColumnList(g) < 0)
return NULL;
return tocp;
} else
return new(g) TDBTBC(this); return new(g) TDBTBC(this);
} // end of GetTable } // end of GetTable
...@@ -145,6 +131,24 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) ...@@ -145,6 +131,24 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
return colp; return colp;
} // end of MakeCol } // end of MakeCol
/***********************************************************************/
/* Initializes the table. */
/***********************************************************************/
bool TDBOCCUR::InitTable(PGLOBAL g)
{
if (!Tdbp) {
// Get the table description block of this table
if (!(Tdbp = (PTDBASE)GetSubTable(g, ((POCCURDEF)To_Def)->Tablep)))
return TRUE;
if (MakeColumnList(g) < 0)
return TRUE;
} // endif Tdbp
return FALSE;
} // end of InitTable
/***********************************************************************/ /***********************************************************************/
/* Allocate OCCUR column description block. */ /* Allocate OCCUR column description block. */
/***********************************************************************/ /***********************************************************************/
...@@ -199,7 +203,9 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g) ...@@ -199,7 +203,9 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g)
int TDBOCCUR::GetMaxSize(PGLOBAL g) int TDBOCCUR::GetMaxSize(PGLOBAL g)
{ {
if (MaxSize < 0) { if (MaxSize < 0) {
// Mult = MakeColumnList(g); if (InitTable(g))
return NULL;
MaxSize = Mult * Tdbp->GetMaxSize(g); MaxSize = Mult * Tdbp->GetMaxSize(g);
} // endif MaxSize } // endif MaxSize
...@@ -233,11 +239,6 @@ bool TDBOCCUR::OpenDB(PGLOBAL g) ...@@ -233,11 +239,6 @@ bool TDBOCCUR::OpenDB(PGLOBAL g)
return Tdbp->OpenDB(g); return Tdbp->OpenDB(g);
} // endif use } // endif use
/*********************************************************************/
/* Do it here if not done yet. */
/*********************************************************************/
// if (MakeColumnList(g) < 0)
// return TRUE;
if (Mode != MODE_READ) { if (Mode != MODE_READ) {
/*******************************************************************/ /*******************************************************************/
...@@ -247,21 +248,11 @@ bool TDBOCCUR::OpenDB(PGLOBAL g) ...@@ -247,21 +248,11 @@ bool TDBOCCUR::OpenDB(PGLOBAL g)
return TRUE; return TRUE;
} // endif Mode } // endif Mode
#if 0
/*********************************************************************/ /*********************************************************************/
/* Be sure OCCUR column exist. */ /* Do it here if not done yet. */
/*********************************************************************/ /*********************************************************************/
if (!Xcolp) { if (InitTable(g))
if (!(Xcolp = (POCCURCOL)ColDB(g, Xcolumn, 0))) { return NULL;
sprintf(g->Message, "OCCUR column %s definition error", Xcolumn);
return TRUE;
} else if (Xcolp->InitValue(g)) {
strcpy(g->Message, "OCCUR InitValue failed");
return TRUE;
} // endif's Xcolp
} // endif Xcolp
#endif // 0
if (Xcolp) if (Xcolp)
// Lock this column so it is evaluated by its table only // Lock this column so it is evaluated by its table only
......
...@@ -37,7 +37,6 @@ class OCCURDEF : public PRXDEF { /* Logical table description */ ...@@ -37,7 +37,6 @@ class OCCURDEF : public PRXDEF { /* Logical table description */
protected: protected:
// Members // Members
//char *Tabname; /* The source table name */
char *Colist; /* The source column list */ char *Colist; /* The source column list */
char *Xcol; /* The multiple occurence column */ char *Xcol; /* The multiple occurence column */
char *Rcol; /* The rank column */ char *Rcol; /* The rank column */
...@@ -59,15 +58,14 @@ class TDBOCCUR : public TDBPRX { ...@@ -59,15 +58,14 @@ class TDBOCCUR : public TDBPRX {
void SetTdbp(PTDBASE tdbp) {Tdbp = tdbp;} void SetTdbp(PTDBASE tdbp) {Tdbp = tdbp;}
// Methods // Methods
//virtual int GetRecpos(void) {return N;}
virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();}
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
PTDB GetSourceTable(PGLOBAL g); PTDB GetSourceTable(PGLOBAL g);
int MakeColumnList(PGLOBAL g); int MakeColumnList(PGLOBAL g);
// Database routines // Database routines
//virtual PCOL ColDB(PGLOBAL g, PSZ colname, int num);
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);
...@@ -94,7 +92,6 @@ class OCCURCOL : public COLBLK { ...@@ -94,7 +92,6 @@ class OCCURCOL : public COLBLK {
public: public:
// Constructors // Constructors
OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n); OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n);
//OCCURCOL(OCCURCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_OCCUR;} virtual int GetAmType(void) {return TYPE_AM_OCCUR;}
...@@ -120,7 +117,6 @@ class RANKCOL : public COLBLK { ...@@ -120,7 +117,6 @@ class RANKCOL : public COLBLK {
public: public:
// Constructors // Constructors
RANKCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) : COLBLK(cdp, tdbp, n) {} RANKCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n) : COLBLK(cdp, tdbp, n) {}
//RANKCOL(RANKCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation // Implementation
virtual int GetAmType(void) {return TYPE_AM_OCCUR;} virtual int GetAmType(void) {return TYPE_AM_OCCUR;}
......
This diff is collapsed.
...@@ -24,8 +24,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ ...@@ -24,8 +24,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */
// Implementation // Implementation
virtual const char *GetType(void) {return "TBL";} virtual const char *GetType(void) {return "TBL";}
//PTABLE GetTables(void) {return Tablep;}
//int GetNtables(void) {return Ntables;}
// Methods // Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff); virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
...@@ -33,7 +31,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ ...@@ -33,7 +31,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */
protected: protected:
// Members // Members
//PTABLE To_Tables; /* To the list of tables */
bool Accept; /* TRUE if bad tables are accepted */ bool Accept; /* TRUE if bad tables are accepted */
int Maxerr; /* Maximum number of bad tables */ int Maxerr; /* Maximum number of bad tables */
int Ntables; /* Number of tables */ int Ntables; /* Number of tables */
...@@ -43,7 +40,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */ ...@@ -43,7 +40,6 @@ class DllExport TBLDEF : public PRXDEF { /* Logical table description */
/* This is the TBL Access Method class declaration. */ /* This is the TBL Access Method class declaration. */
/***********************************************************************/ /***********************************************************************/
class DllExport TDBTBL : public TDBPRX { class DllExport TDBTBL : public TDBPRX {
//friend class TBLCOL;
friend class TBTBLK; friend class TBTBLK;
friend class TDBPLG; friend class TDBPLG;
public: public:
...@@ -55,33 +51,25 @@ class DllExport TDBTBL : public TDBPRX { ...@@ -55,33 +51,25 @@ class DllExport TDBTBL : public TDBPRX {
// Methods // Methods
virtual void ResetDB(void); virtual void ResetDB(void);
//virtual PTABLE GetTablist(void) {return (PSZ)Tablist;}
virtual int GetRecpos(void) {return Rows;} virtual int GetRecpos(void) {return Rows;}
virtual int GetBadLines(void) {return (int)Nbf;} virtual int GetBadLines(void) {return (int)Nbf;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
virtual int GetMaxSize(PGLOBAL g); virtual int GetMaxSize(PGLOBAL g);
//virtual int GetProgMax(PGLOBAL g);
//virtual int GetProgCur(void);
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp); virtual PCOL InsertSpecialColumn(PGLOBAL g, PCOL scp);
virtual bool OpenDB(PGLOBAL g); virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g); virtual int ReadDB(PGLOBAL g);
//virtual int WriteDB(PGLOBAL g);
//virtual int DeleteDB(PGLOBAL g, int irc);
//virtual void CloseDB(PGLOBAL g);
protected: protected:
// Internal functions // Internal functions
//PTDB GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp);
bool InitTableList(PGLOBAL g); bool InitTableList(PGLOBAL g);
bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp); bool TestFil(PGLOBAL g, PFIL filp, PTABLE tabp);
// Members // Members
PTABLE Tablist; // Points to the table list PTABLE Tablist; // Points to the table list
PTABLE CurTable; // Points to the current table PTABLE CurTable; // Points to the current table
//PTDBASE Tdbp; // Current table PTDB
bool Accept; // TRUE if bad tables are accepted bool Accept; // TRUE if bad tables are accepted
int Maxerr; // Maximum number of bad tables int Maxerr; // Maximum number of bad tables
int Nbf; // Number of bad connections int Nbf; // Number of bad connections
...@@ -89,41 +77,6 @@ class DllExport TDBTBL : public TDBPRX { ...@@ -89,41 +77,6 @@ class DllExport TDBTBL : public TDBPRX {
int Crp; // Used for CurPos int Crp; // Used for CurPos
}; // end of class TDBTBL }; // end of class TDBTBL
#if 0
/***********************************************************************/
/* Class TBLCOL: TBL access method column descriptor. */
/* This A.M. is used for TBL tables. */
/***********************************************************************/
class DllExport TBLCOL : public COLBLK {
friend class TDBTBL;
public:
// Constructors
TBLCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "TBL");
TBLCOL(TBLCOL *colp, PTDB tdbp); // Constructor used in copy process
//TBLCOL(SPCBLK *colp, PTDB tdbp); // Constructor used for pseudo columns
// Implementation
virtual int GetAmType(void) {return TYPE_AM_TBL;}
// Methods
virtual bool IsSpecial(void) {return Pseudo;}
virtual void ReadColumn(PGLOBAL g);
//virtual void WriteColumn(PGLOBAL g);
// void Print(PGLOBAL g, FILE *, UINT);
bool Init(PGLOBAL g);
protected:
// Default constructor not to be used
TBLCOL(void) {}
// Members
PCOL Colp; // Points to matching table column
PVAL To_Val; // To the matching column value
bool Pseudo; // TRUE for special columns
int Colnum; // Used when retrieving columns by number
}; // end of class TBLCOL
#endif // 0
/***********************************************************************/ /***********************************************************************/
/* Class TBTBLK: TDBPLG TABID special column descriptor. */ /* Class TBTBLK: TDBPLG TABID special column descriptor. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -245,7 +245,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, ...@@ -245,7 +245,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
return qrp; return qrp;
} // end of TabColumns } // end of TabColumns
/* -------------- Implementation of the XCOL classes ---------------- */ /* -------------- Implementation of the PROXY classes ---------------- */
/***********************************************************************/ /***********************************************************************/
/* PRXDEF constructor. */ /* PRXDEF constructor. */
...@@ -311,11 +311,23 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) ...@@ -311,11 +311,23 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp)
TABLE_SHARE *s; TABLE_SHARE *s;
PCATLG cat = To_Def->GetCat(); PCATLG cat = To_Def->GetCat();
PHC hc = ((MYCAT*)cat)->GetHandler(); PHC hc = ((MYCAT*)cat)->GetHandler();
LPCSTR cdb, curdb = hc->GetDBName(NULL);
THD *thd = (hc->GetTable())->in_use; THD *thd = (hc->GetTable())->in_use;
db = (char*)tabp->GetQualifier(); db = (char*)tabp->GetQualifier();
name = (char*)tabp->GetName(); name = (char*)tabp->GetName();
// Check for eventual loop
for (PTABLE tp = To_Table; tp; tp = tp->Next) {
cdb = (tp->Qualifier) ? tp->Qualifier : curdb;
if (!stricmp(name, tp->Name) && !stricmp(db, cdb)) {
sprintf(g->Message, "Table %s.%s pointing on itself", db, name);
return NULL;
} // endif
} // endfor tp
if (!(s = GetTableShare(g, thd, db, name, mysql))) if (!(s = GetTableShare(g, thd, db, name, mysql)))
return NULL; return NULL;
...@@ -337,9 +349,11 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp) ...@@ -337,9 +349,11 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp)
db, tblp->Name); db, tblp->Name);
goto err; goto err;
#endif // MYSQL_SUPPORT #endif // MYSQL_SUPPORT
} else } else {
// Sub-table is a CONNECT table // Sub-table is a CONNECT table
tabp->Next = To_Table; // For loop checking
tdbp = cat->GetTable(g, tabp); tdbp = cat->GetTable(g, tabp);
} // endif mysql
hc->tshp = NULL; hc->tshp = NULL;
...@@ -420,7 +434,7 @@ bool TDBPRX::OpenDB(PGLOBAL g) ...@@ -420,7 +434,7 @@ bool TDBPRX::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. */
...@@ -468,6 +482,14 @@ int TDBPRX::DeleteDB(PGLOBAL g, int irc) ...@@ -468,6 +482,14 @@ int TDBPRX::DeleteDB(PGLOBAL g, int irc)
return RC_FX; return RC_FX;
} // end of DeleteDB } // end of DeleteDB
/***********************************************************************/
/* Used by the TBL tables. */
/***********************************************************************/
void TDBPRX::RemoveNext(PTABLE tp)
{
tp->Next = NULL;
} // end of RemoveNext
/* ---------------------------- PRXCOL ------------------------------- */ /* ---------------------------- PRXCOL ------------------------------- */
/***********************************************************************/ /***********************************************************************/
......
...@@ -95,6 +95,7 @@ class DllExport TDBPRX : public TDBASE { ...@@ -95,6 +95,7 @@ class DllExport TDBPRX : public TDBASE {
virtual int DeleteDB(PGLOBAL g, int irc); virtual int DeleteDB(PGLOBAL g, int irc);
virtual void CloseDB(PGLOBAL g) {if (Tdbp) Tdbp->CloseDB(g);} virtual void CloseDB(PGLOBAL g) {if (Tdbp) Tdbp->CloseDB(g);}
PTDB GetSubTable(PGLOBAL g, PTABLE tabp); PTDB GetSubTable(PGLOBAL g, PTABLE tabp);
void RemoveNext(PTABLE tp);
protected: protected:
// Members // Members
......
...@@ -105,7 +105,6 @@ PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode) ...@@ -105,7 +105,6 @@ PTDB XCLDEF::GetTable(PGLOBAL g, MODE mode)
/***********************************************************************/ /***********************************************************************/
TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp) TDBXCL::TDBXCL(PXCLDEF tdp) : TDBPRX(tdp)
{ {
//Tdbp = NULL; // The physical table
Xcolumn = tdp->Xcol; // CSV column name Xcolumn = tdp->Xcol; // CSV column name
Xcolp = NULL; // To the XCVCOL column Xcolp = NULL; // To the XCVCOL column
Mult = tdp->Mult; // Multiplication factor Mult = tdp->Mult; // Multiplication factor
...@@ -222,28 +221,6 @@ bool TDBXCL::OpenDB(PGLOBAL g) ...@@ -222,28 +221,6 @@ bool TDBXCL::OpenDB(PGLOBAL g)
if (Tdbp->OpenDB(g)) if (Tdbp->OpenDB(g))
return TRUE; return TRUE;
#if 0
/*********************************************************************/
/* Check for direct access. */
/*********************************************************************/
if (To_Key_Col)
if (!Tdbp->GetDef()->Indexable()) {
strcpy(g->Message, "Object table is not indexable");
return TRUE;
} else {
((PTDBX)Tdbp)->To_Key_Col = To_Key_Col;
((PTDBX)Tdbp)->To_Link = To_Link;
((PTDBX)Tdbp)->Knum = Knum;
To_Kindex = (PKXBASE)new(g) KINDEX(Tdbp);
if (To_Kindex->Init(g))
return TRUE;
((PKINDEX)To_Kindex)->SetMult(Mult);
Tdbp->SetKindex(To_Kindex);
} // endif Indexable
#endif // 0
return FALSE; return FALSE;
} // end of OpenDB } // end of OpenDB
...@@ -332,45 +309,3 @@ void XCLCOL::ReadColumn(PGLOBAL g) ...@@ -332,45 +309,3 @@ void XCLCOL::ReadColumn(PGLOBAL g)
((PTDBXCL)To_Tdb)->RowFlag = 1; ((PTDBXCL)To_Tdb)->RowFlag = 1;
} // end of ReadColumn } // end of ReadColumn
#if 0
/* -------------- Implementation of the MULINDX class ---------------- */
/***********************************************************************/
/* Returns FALSE if Ok, TRUE if there are no more equal values. */
/***********************************************************************/
bool MULINDX::HaveSame(void)
{
return (Op == OP_SAME || Txlp->RowFlag == 1);
} // end of HaveSame
/***********************************************************************/
/* Returns FALSE if Ok, TRUE if there are no more equal values. */
/***********************************************************************/
bool MULINDX::NextVal(bool eq)
{
return (Pof) ? KINDEX::NextVal(eq) : TRUE;
} // end of NextVal
/***********************************************************************/
/* Returns TRUE if there are more same values. */
/***********************************************************************/
bool MULINDX::MoreVal(void)
{
Op = OP_SAME; // There may be more equal values
return (Pof) ? Pof[Val_K] : Val_K;
} // end of MoreVal
/***********************************************************************/
/* Change the index multiple status. */
/***********************************************************************/
bool MULINDX::Init(PGLOBAL g)
{
if (KINDEX::Init(g))
return TRUE;
Mul = TRUE;
MaxSame *= Txlp->Mult;
return FALSE;
} // end of Init
#endif // 0
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
typedef class XCLDEF *PXCLDEF; typedef class XCLDEF *PXCLDEF;
typedef class TDBXCL *PTDBXCL; typedef class TDBXCL *PTDBXCL;
typedef class XCLCOL *PXCLCOL; typedef class XCLCOL *PXCLCOL;
//pedef class MULINDX *PMINDX;
/* -------------------------- XCOL classes --------------------------- */ /* -------------------------- XCOL classes --------------------------- */
...@@ -49,7 +48,6 @@ class XCLDEF : public PRXDEF { /* Logical table description */ ...@@ -49,7 +48,6 @@ class XCLDEF : public PRXDEF { /* Logical table description */
/* This is the class declaration for the XCSV table. */ /* This is the class declaration for the XCSV table. */
/***********************************************************************/ /***********************************************************************/
class TDBXCL : public TDBPRX { class TDBXCL : public TDBPRX {
//friend class MULINDX;
friend class XCLDEF; friend class XCLDEF;
friend class PRXCOL; friend class PRXCOL;
friend class XCLCOL; friend class XCLCOL;
...@@ -63,7 +61,6 @@ class TDBXCL : public TDBPRX { ...@@ -63,7 +61,6 @@ class TDBXCL : public TDBPRX {
// Methods // Methods
virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();} virtual void ResetDB(void) {N = 0; Tdbp->ResetDB();}
virtual int RowNumber(PGLOBAL g, bool b = FALSE); virtual int RowNumber(PGLOBAL g, bool b = FALSE);
//virtual bool HaveSame(void) {return RowFlag == 1;}
// Database routines // Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n); virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
...@@ -106,28 +103,3 @@ class XCLCOL : public PRXCOL { ...@@ -106,28 +103,3 @@ class XCLCOL : public PRXCOL {
char *Cp; // Pointer to current position char *Cp; // Pointer to current position
char Sep; // The separator char Sep; // The separator
}; // end of class XCLCOL }; // end of class XCLCOL
#if 0
/* ------------------------- MULINDX classes ------------------------- */
/***********************************************************************/
/* This represents a KINDEX class for an XCOL table. */
/***********************************************************************/
class MULINDX : public KINDEX {
public:
// Constructor
MULINDX(PTDBXCL txlp) : KINDEX(txlp->Tdbp) {Txlp = txlp;}
// Implementation
virtual BOOL HaveSame(void);
// Methods
virtual BOOL Init(PGLOBAL g);
virtual BOOL NextVal(BOOL eq);
virtual int MoreVal(void);
protected:
//Member
PTDBXCL Txlp;
}; // end of class MULINDX
#endif // 0
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