From f3e944099e1d7369bbf84e0b1087b45506279034 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 2 May 2013 16:33:15 +0200 Subject: - 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 --- storage/connect/taboccur.cpp | 65 +++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) (limited to 'storage/connect/taboccur.cpp') 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 @@ -145,6 +131,24 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) return colp; } // 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. */ /***********************************************************************/ @@ -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 -- cgit v1.2.1