summaryrefslogtreecommitdiff
path: root/storage/connect/taboccur.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-05-02 16:33:15 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2013-05-02 16:33:15 +0200
commitf3e944099e1d7369bbf84e0b1087b45506279034 (patch)
treef074e2938194c8fe5480df4a0e36aad42bda764d /storage/connect/taboccur.cpp
parent3d4adc3fdfa1238efb9cd1b6335a397527c24da2 (diff)
downloadmariadb-git-f3e944099e1d7369bbf84e0b1087b45506279034.tar.gz
- 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
Diffstat (limited to 'storage/connect/taboccur.cpp')
-rw-r--r--storage/connect/taboccur.cpp65
1 files changed, 28 insertions, 37 deletions
diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp
index e1b83c06422..8b7e10f2e34 100644
--- a/storage/connect/taboccur.cpp
+++ b/storage/connect/taboccur.cpp
@@ -60,7 +60,6 @@ extern "C" int trace;
/***********************************************************************/
bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
-//Tabname = Cat->GetStringCatInfo(g, "SrcTable", "");
Xcol = Cat->GetStringCatInfo(g, "OccurCol", "");
Rcol = Cat->GetStringCatInfo(g, "RankCol", "");
Colist = Cat->GetStringCatInfo(g, "Colist", "");
@@ -72,22 +71,9 @@ bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
/***********************************************************************/
PTDB OCCURDEF::GetTable(PGLOBAL g, MODE m)
{
- if (Catfunc != FNC_COL) {
- PTDB tdbp;
- PTDBOCCUR tocp = new(g) TDBOCCUR(this);
-
- // 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
+ if (Catfunc != FNC_COL)
+ return new(g) TDBOCCUR(this);
+ else
return new(g) TDBTBC(this);
} // end of GetTable
@@ -146,6 +132,24 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
} // 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. */
/***********************************************************************/
int TDBOCCUR::MakeColumnList(PGLOBAL g)
@@ -199,7 +203,9 @@ int TDBOCCUR::MakeColumnList(PGLOBAL g)
int TDBOCCUR::GetMaxSize(PGLOBAL g)
{
if (MaxSize < 0) {
-// Mult = MakeColumnList(g);
+ if (InitTable(g))
+ return NULL;
+
MaxSize = Mult * Tdbp->GetMaxSize(g);
} // endif MaxSize
@@ -233,12 +239,7 @@ bool TDBOCCUR::OpenDB(PGLOBAL g)
return Tdbp->OpenDB(g);
} // endif use
- /*********************************************************************/
- /* Do it here if not done yet. */
- /*********************************************************************/
-// if (MakeColumnList(g) < 0)
-// return TRUE;
-
+
if (Mode != MODE_READ) {
/*******************************************************************/
/* Currently OCCUR tables cannot be modified. */
@@ -247,21 +248,11 @@ bool TDBOCCUR::OpenDB(PGLOBAL g)
return TRUE;
} // endif Mode
-#if 0
/*********************************************************************/
- /* Be sure OCCUR column exist. */
+ /* Do it here if not done yet. */
/*********************************************************************/
- if (!Xcolp) {
- if (!(Xcolp = (POCCURCOL)ColDB(g, Xcolumn, 0))) {
- 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 (InitTable(g))
+ return NULL;
if (Xcolp)
// Lock this column so it is evaluated by its table only