Commit 38a5bb2c authored by Olivier Bertrand's avatar Olivier Bertrand

- Save and restore srcdef when getting a sub-table (could stay in cache)

modified:
  storage/connect/tabutil.cpp

- Change order of tests when looking for valid tdbp. In rare cases an invalid
  tdbp was still existing causing a crash of the server.

modified:
  storage/connect/ha_connect.cc
parent aacd6f55
...@@ -1094,8 +1094,9 @@ PTDB ha_connect::GetTDB(PGLOBAL g) ...@@ -1094,8 +1094,9 @@ PTDB ha_connect::GetTDB(PGLOBAL g)
table_name= GetTableName(); table_name= GetTableName();
if (tdbp && !stricmp(tdbp->GetName(), table_name) if (!xp->CheckQuery(valid_query_id && tdbp
&& tdbp->GetMode() == xmod && !xp->CheckQuery(valid_query_id)) { && !stricmp(tdbp->GetName(), table_name)
&& tdbp->GetMode() == xmod)) {
tp= tdbp; tp= tdbp;
tp->SetMode(xmod); tp->SetMode(xmod);
} else if ((tp= CntGetTDB(g, table_name, xmod, this))) } else if ((tp= CntGetTDB(g, table_name, xmod, this)))
......
...@@ -313,6 +313,7 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp) ...@@ -313,6 +313,7 @@ TDBPRX::TDBPRX(PPRXDEF tdp) : TDBASE(tdp)
/***********************************************************************/ /***********************************************************************/
PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
{ {
const char *sp;
char *db, *name; char *db, *name;
bool mysql = true; bool mysql = true;
PTDB tdbp = NULL; PTDB tdbp = NULL;
...@@ -349,6 +350,9 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) ...@@ -349,6 +350,9 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
// Don't use caller's columns // Don't use caller's columns
fp = hc->get_table()->field; fp = hc->get_table()->field;
hc->get_table()->field = NULL; 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(); hc->get_table()->s->option_struct->srcdef = tabp->GetSrc();
} // endif srcdef } // endif srcdef
...@@ -379,8 +383,11 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) ...@@ -379,8 +383,11 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
s->field = NULL; s->field = NULL;
hc->tshp = 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()->field = fp;
hc->get_table()->s->option_struct->srcdef = sp;
} // endif s
if (trace && tdbp) if (trace && tdbp)
htrc("Subtable %s in %s\n", htrc("Subtable %s in %s\n",
......
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