You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-3247 CS uses thread plugin variables since MCOL-1101 that aren't
good for transmiting cal_connection_info to handler::close_connection(). This variables are then erased in THD::cleanup() and the cal_connection_info is replaced in handler::delete_table with an empty structure. handler::close_connection() recevies cal_connection_info with empty cal_conn_hndl. This patch uses THD::ha_data that is supposed to be used in such occasions.
This commit is contained in:
@ -181,87 +181,6 @@ static int infinidb_done_func(void* p)
|
|||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/**
|
|
||||||
@brief
|
|
||||||
Example of simple lock controls. The "share" it creates is a
|
|
||||||
structure we will pass to each example handler. Do you have to have
|
|
||||||
one of these? Well, you have pieces that are used for locking, and
|
|
||||||
they are needed to function.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static CALPONT_SHARE* get_share(const char* table_name, TABLE* table)
|
|
||||||
{
|
|
||||||
CALPONT_SHARE* share;
|
|
||||||
uint32_t length;
|
|
||||||
char* tmp_name;
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
pthread_mutex_lock(&calpont_mutex);
|
|
||||||
#endif
|
|
||||||
length = (uint32_t) strlen(table_name);
|
|
||||||
|
|
||||||
if (!(share = (CALPONT_SHARE*) hash_search(&calpont_open_tables,
|
|
||||||
(uchar*) table_name,
|
|
||||||
length)))
|
|
||||||
{
|
|
||||||
if (!(share = (CALPONT_SHARE*)
|
|
||||||
my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
|
|
||||||
&share, sizeof(*share),
|
|
||||||
&tmp_name, length + 1,
|
|
||||||
NullS)))
|
|
||||||
{
|
|
||||||
pthread_mutex_unlock(&calpont_mutex);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
share->use_count = 0;
|
|
||||||
share->table_name_length = length;
|
|
||||||
share->table_name = tmp_name;
|
|
||||||
strmov(share->table_name, table_name);
|
|
||||||
|
|
||||||
if (my_hash_insert(&calpont_open_tables, (uchar*) share))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
thr_lock_init(&share->lock);
|
|
||||||
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
|
|
||||||
}
|
|
||||||
|
|
||||||
share->use_count++;
|
|
||||||
pthread_mutex_unlock(&calpont_mutex);
|
|
||||||
|
|
||||||
return share;
|
|
||||||
|
|
||||||
error:
|
|
||||||
pthread_mutex_destroy(&share->mutex);
|
|
||||||
my_free(share, MYF(0));
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@brief
|
|
||||||
Free lock controls. We call this whenever we close a table. If the table had
|
|
||||||
the last reference to the share, then we free memory associated with it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int free_share(CALPONT_SHARE* share)
|
|
||||||
{
|
|
||||||
pthread_mutex_lock(&calpont_mutex);
|
|
||||||
|
|
||||||
if (!--share->use_count)
|
|
||||||
{
|
|
||||||
hash_delete(&calpont_open_tables, (uchar*) share);
|
|
||||||
thr_lock_delete(&share->lock);
|
|
||||||
pthread_mutex_destroy(&share->mutex);
|
|
||||||
my_free(share, MYF(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&calpont_mutex);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static handler* calpont_create_handler(handlerton* hton,
|
static handler* calpont_create_handler(handlerton* hton,
|
||||||
TABLE_SHARE* table,
|
TABLE_SHARE* table,
|
||||||
MEM_ROOT* mem_root)
|
MEM_ROOT* mem_root)
|
||||||
|
@ -3969,10 +3969,16 @@ int ha_calpont_impl_close_connection (handlerton* hton, THD* thd)
|
|||||||
|
|
||||||
execplan::CalpontSystemCatalog::removeCalpontSystemCatalog(tid2sid(thd->thread_id));
|
execplan::CalpontSystemCatalog::removeCalpontSystemCatalog(tid2sid(thd->thread_id));
|
||||||
|
|
||||||
if (get_fe_conn_info_ptr() == NULL)
|
// MCOL-3247 Use THD::ha_data as a per-plugin per-session
|
||||||
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
// storage. Filled in external_lock when we remove a lock
|
||||||
|
// from vtable(lock_type = 2)
|
||||||
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
|
// An ugly way. I will use ha_data w/o external_lock.
|
||||||
|
// This in MCOL-2178
|
||||||
|
cal_connection_info* ci = NULL;
|
||||||
|
if(thd_get_ha_data(thd, hton))
|
||||||
|
{
|
||||||
|
ci = reinterpret_cast<cal_connection_info*>(thd_get_ha_data(thd, hton));
|
||||||
|
}
|
||||||
|
|
||||||
if (!ci) return 0;
|
if (!ci) return 0;
|
||||||
|
|
||||||
@ -4195,6 +4201,9 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
|
|||||||
ci->miniStats = ci->cal_conn_hndl->miniStats;
|
ci->miniStats = ci->cal_conn_hndl->miniStats;
|
||||||
ci->queryState = 0;
|
ci->queryState = 0;
|
||||||
thd->infinidb_vtable.override_largeside_estimate = false;
|
thd->infinidb_vtable.override_largeside_estimate = false;
|
||||||
|
// MCOL-3247 Use THD::ha_data as a per-plugin per-session
|
||||||
|
// storage for cal_conn_hndl to use it later in close_connection
|
||||||
|
thd_set_ha_data(thd, calpont_hton, get_fe_conn_info_ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user