Commit 3329fbae authored by Olivier Bertrand's avatar Olivier Bertrand

-- Suppress the GetPlug function causing memory leak

  modified:   storage/connect/ha_connect.h
  modified:   storage/connect/ha_connect.cc

-- Trace work storage allocation and freeing in DEVELOPMENT mode
   (Fix a compile error)
  modified:   storage/connect/plugutil.cpp
parent 6fdd5cda
...@@ -237,7 +237,7 @@ extern "C" const char *msglang(void); ...@@ -237,7 +237,7 @@ extern "C" const char *msglang(void);
static void PopUser(PCONNECT xp); static void PopUser(PCONNECT xp);
static PCONNECT GetUser(THD *thd, PCONNECT xp); static PCONNECT GetUser(THD *thd, PCONNECT xp);
static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp); //static PGLOBAL GetPlug(THD *thd, PCONNECT lxp);
static handler *connect_create_handler(handlerton *hton, static handler *connect_create_handler(handlerton *hton,
TABLE_SHARE *table, TABLE_SHARE *table,
...@@ -950,11 +950,11 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp) ...@@ -950,11 +950,11 @@ static PCONNECT GetUser(THD *thd, PCONNECT xp)
/****************************************************************************/ /****************************************************************************/
/* Get the global pointer of the user of this handler. */ /* Get the global pointer of the user of this handler. */
/****************************************************************************/ /****************************************************************************/
static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp) //static PGLOBAL GetPlug(THD *thd, PCONNECT lxp)
{ //{
lxp= GetUser(thd, lxp); // PCONNECT nxp= GetUser(thd, lxp);
return (lxp) ? lxp->g : NULL; // return (nxp) ? nxp->g : NULL;
} // end of GetPlug //} // end of GetPlug
/****************************************************************************/ /****************************************************************************/
/* Get the implied table type. */ /* Get the implied table type. */
...@@ -1529,8 +1529,9 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf) ...@@ -1529,8 +1529,9 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
if (pcf->Datefmt) { if (pcf->Datefmt) {
// Find the (max) length produced by the date format // Find the (max) length produced by the date format
char buf[256]; char buf[256];
PGLOBAL g= GetPlug(table->in_use, xp); // PGLOBAL g= GetPlug(table->in_use, xp);
PDTP pdtp= MakeDateFormat(g, pcf->Datefmt, false, true, 0); DBUG_ASSERT(xp && xp->thdp == ha_thd());
PDTP pdtp= MakeDateFormat(xp->g, pcf->Datefmt, false, true, 0);
struct tm datm; struct tm datm;
bzero(&datm, sizeof(datm)); bzero(&datm, sizeof(datm));
datm.tm_mday= 12; datm.tm_mday= 12;
...@@ -3868,8 +3869,10 @@ int ha_connect::index_next_same(uchar *buf, const uchar *, uint) ...@@ -3868,8 +3869,10 @@ int ha_connect::index_next_same(uchar *buf, const uchar *, uint)
*/ */
int ha_connect::rnd_init(bool scan) int ha_connect::rnd_init(bool scan)
{ {
PGLOBAL g= ((table && table->in_use) ? GetPlug(table->in_use, xp) : //PGLOBAL g= ((table && table->in_use) ? GetPlug(table->in_use, xp) :
(xp) ? xp->g : NULL); // (xp) ? xp->g : NULL);
DBUG_ASSERT(xp && xp->thdp == ha_thd());
PGLOBAL g= xp->g;
DBUG_ENTER("ha_connect::rnd_init"); DBUG_ENTER("ha_connect::rnd_init");
// This is not tested yet // This is not tested yet
...@@ -4064,9 +4067,10 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos) ...@@ -4064,9 +4067,10 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
tdbp->SetFilter(NULL); tdbp->SetFilter(NULL);
rc= rnd_next(buf); rc= rnd_next(buf);
} else { } else {
PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp); // PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp);
strcpy(g->Message, "Not supported by this table type"); DBUG_ASSERT(xp && xp->thdp == ha_thd());
my_message(ER_ILLEGAL_HA, g->Message, MYF(0)); strcpy(xp->g->Message, "Not supported by this table type");
my_message(ER_ILLEGAL_HA, xp->g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR; rc= HA_ERR_INTERNAL_ERROR;
} // endif SetRecpos } // endif SetRecpos
...@@ -4115,7 +4119,10 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos) ...@@ -4115,7 +4119,10 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
int ha_connect::info(uint flag) int ha_connect::info(uint flag)
{ {
bool pure= false; bool pure= false;
PGLOBAL g= GetPlug((table) ? table->in_use : NULL, xp); //PGLOBAL g= GetPlug((table) ? table->in_use : NULL, xp);
//xp= GetUser((table) ? table->in_use : NULL, xp); // Usefull ???
DBUG_ASSERT(xp && xp->thdp == ha_thd());
PGLOBAL g= xp->g;
DBUG_ENTER("ha_connect::info"); DBUG_ENTER("ha_connect::info");
...@@ -4533,7 +4540,9 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type) ...@@ -4533,7 +4540,9 @@ int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
int rc= 0; int rc= 0;
bool chk=false, cras= false; bool chk=false, cras= false;
MODE newmode; MODE newmode;
PGLOBAL g= GetPlug(thd, xp); //PGLOBAL g= GetPlug(thd, xp);
xp = GetUser(thd, xp);
PGLOBAL g= xp->g;
DBUG_ENTER("ha_connect::start_stmt"); DBUG_ENTER("ha_connect::start_stmt");
if (check_privileges(thd, GetTableOptionStruct(), table->s->db.str, true)) if (check_privileges(thd, GetTableOptionStruct(), table->s->db.str, true))
...@@ -4595,8 +4604,10 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -4595,8 +4604,10 @@ int ha_connect::external_lock(THD *thd, int lock_type)
bool xcheck=false, cras= false; bool xcheck=false, cras= false;
MODE newmode; MODE newmode;
PTOS options= GetTableOptionStruct(); PTOS options= GetTableOptionStruct();
PGLOBAL g= GetPlug(thd, xp); //PGLOBAL g= GetPlug(thd, xp);
DBUG_ENTER("ha_connect::external_lock"); xp= GetUser(thd, xp);
PGLOBAL g= xp->g;
DBUG_ENTER("ha_connect::external_lock");
DBUG_ASSERT(thd == current_thd); DBUG_ASSERT(thd == current_thd);
...@@ -5376,8 +5387,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5376,8 +5387,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
TABTYPE ttp= TAB_UNDEF; TABTYPE ttp= TAB_UNDEF;
PQRYRES qrp= NULL; PQRYRES qrp= NULL;
PCOLRES crp; PCOLRES crp;
PCONNECT xp= NULL; PCONNECT xp= GetUser(thd, NULL);
PGLOBAL g= GetPlug(thd, xp); PGLOBAL g= xp->g;
if (!g) if (!g)
return HA_ERR_INTERNAL_ERROR; return HA_ERR_INTERNAL_ERROR;
...@@ -6130,8 +6141,8 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -6130,8 +6141,8 @@ int ha_connect::create(const char *name, TABLE *table_arg,
#if defined(WITH_PARTITION_STORAGE_ENGINE) #if defined(WITH_PARTITION_STORAGE_ENGINE)
partition_info *part_info= table_arg->part_info; partition_info *part_info= table_arg->part_info;
#endif // WITH_PARTITION_STORAGE_ENGINE #endif // WITH_PARTITION_STORAGE_ENGINE
xp= GetUser(thd, xp); xp= GetUser(thd, xp);
PGLOBAL g= xp->g; PGLOBAL g= xp->g;
DBUG_ENTER("ha_connect::create"); DBUG_ENTER("ha_connect::create");
/* /*
...@@ -6719,7 +6730,7 @@ bool ha_connect::FileExists(const char *fn, bool bf) ...@@ -6719,7 +6730,7 @@ bool ha_connect::FileExists(const char *fn, bool bf)
} // end of FileExists } // end of FileExists
// Called by SameString and NoFieldOptionChange // Called by SameString and NoFieldOptionChange
bool ha_connect::CheckString(const char *str1, const char *str2) bool ha_connect::CheckString(PCSZ str1, PCSZ str2)
{ {
bool b1= (!str1 || !*str1), b2= (!str2 || !*str2); bool b1= (!str1 || !*str1), b2= (!str2 || !*str2);
......
...@@ -166,8 +166,8 @@ class ha_connect: public handler ...@@ -166,8 +166,8 @@ class ha_connect: public handler
~ha_connect(); ~ha_connect();
// CONNECT Implementation // CONNECT Implementation
static bool connect_init(void); //static bool connect_init(void);
static bool connect_end(void); //static bool connect_end(void);
TABTYPE GetRealType(PTOS pos= NULL); TABTYPE GetRealType(PTOS pos= NULL);
char *GetRealString(PCSZ s); char *GetRealString(PCSZ s);
PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL); PCSZ GetStringOption(PCSZ opname, PCSZ sdef= NULL);
......
...@@ -185,7 +185,7 @@ int PlugExit(PGLOBAL g) ...@@ -185,7 +185,7 @@ int PlugExit(PGLOBAL g)
if (g->Sarea) { if (g->Sarea) {
#if !defined(DEVELOPMENT) #if !defined(DEVELOPMENT)
if (trace) { if (trace)
#endif #endif
htrc("Freeing Sarea at %p size=%d\n", g->Sarea, g->Sarea_Size); htrc("Freeing Sarea at %p size=%d\n", g->Sarea, g->Sarea_Size);
......
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