diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 9020220f5d0..f41b584a377 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -1094,8 +1094,9 @@ PTDB ha_connect::GetTDB(PGLOBAL g) table_name= GetTableName(); - if (tdbp && !stricmp(tdbp->GetName(), table_name) - && tdbp->GetMode() == xmod && !xp->CheckQuery(valid_query_id)) { + if (!xp->CheckQuery(valid_query_id && tdbp + && !stricmp(tdbp->GetName(), table_name) + && tdbp->GetMode() == xmod)) { tp= tdbp; tp->SetMode(xmod); } else if ((tp= CntGetTDB(g, table_name, xmod, this))) diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 93c0a8a83ea..5c4b428b09a 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -313,6 +313,7 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) /***********************************************************************/ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) { + const char *sp; char *db, *name; bool mysql = true; PTDB tdbp = NULL; @@ -349,6 +350,9 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) // Don't use caller's columns fp = hc->get_table()->field; hc->get_table()->field = NULL; + + // Make caller use the source definition + sp = hc->get_table()->s->option_struct->srcdef; hc->get_table()->s->option_struct->srcdef = tabp->GetSrc(); } // endif srcdef @@ -379,8 +383,11 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) s->field = NULL; hc->tshp = NULL; - } else if (b) + } else if (b) { + // Restore s structure that can be in cache hc->get_table()->field = fp; + hc->get_table()->s->option_struct->srcdef = sp; + } // endif s if (trace && tdbp) htrc("Subtable %s in %s\n",