diff options
Diffstat (limited to 'storage/connect/tabtbl.cpp')
-rw-r--r-- | storage/connect/tabtbl.cpp | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index b567e9aecd4..a2b041b64d8 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -578,10 +578,19 @@ pthread_handler_t ThreadOpen(void *p) // Try to open the connection if (!cmp->Tap->GetTo_Tdb()->OpenDB(cmp->G)) { pthread_mutex_lock(&tblmut); + if (trace) + htrc("Table %s ready\n", cmp->Tap->GetName()); + cmp->Ready = true; pthread_mutex_unlock(&tblmut); - } else - cmp->Rc = RC_FX; + } else { + pthread_mutex_lock(&tblmut); + if (trace) + htrc("Opening %s failed\n", cmp->Tap->GetName()); + + cmp->Rc = RC_FX; + pthread_mutex_unlock(&tblmut); + } // endif OpenDB my_thread_end(); } else @@ -633,6 +642,18 @@ int TDBTBM::RowNumber(PGLOBAL g, bool b) } // end of RowNumber /***********************************************************************/ +/* Returns true if this MYSQL table refers to a local table. */ +/***********************************************************************/ +bool TDBTBM::IsLocal(PTABLE tbp) +{ + TDBMYSQL *tdbp = (TDBMYSQL*)tbp->GetTo_Tdb(); + + return ((!stricmp(tdbp->Host, "localhost") || + !strcmp(tdbp->Host, "127.0.0.1")) && + tdbp->Port == GetDefaultPort()); +} // end of IsLocal + +/***********************************************************************/ /* Initialyze table parallel processing. */ /***********************************************************************/ bool TDBTBM::OpenTables(PGLOBAL g) @@ -644,7 +665,7 @@ bool TDBTBM::OpenTables(PGLOBAL g) // Allocates the TBMT blocks for the tables for (tabp = Tablist; tabp; tabp = tabp->Next) - if (tabp->GetTo_Tdb()->GetAmType() == TYPE_AM_MYSQL) { + if (tabp->GetTo_Tdb()->GetAmType() == TYPE_AM_MYSQL && !IsLocal(tabp)) { // Remove remote table from the local list *ptabp = tabp->Next; @@ -788,7 +809,7 @@ int TDBTBM::ReadDB(PGLOBAL g) /***********************************************************************/ int TDBTBM::ReadNextRemote(PGLOBAL g) { - bool b = false; + bool b; if (Tdbp) Tdbp->CloseDB(g); @@ -796,17 +817,22 @@ int TDBTBM::ReadNextRemote(PGLOBAL g) Cmp = NULL; retry: - // Search for a remote table having its result set + b = false; + + // Search for a remote table having its result set pthread_mutex_lock(&tblmut); for (PTBMT tp = Tmp; tp; tp = tp->Next) - if (tp->Ready) { - if (!tp->Complete) { - Cmp = tp; - break; - } // endif Complete + if (tp->Rc != RC_FX) { + if (tp->Ready) { + if (!tp->Complete) { + Cmp = tp; + break; + } // endif Complete - } else - b = true; + } else + b = true; + + } // endif Rc pthread_mutex_unlock(&tblmut); |