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
feat(plugin): All InnoDB queries are pushed down to Columnstore if columnstore_innodb_queries_uses_mcs = ON in the configuration before server start
This commit is contained in:
@ -1808,6 +1808,8 @@ static handler* ha_mcs_cache_create_handler(handlerton* hton, TABLE_SHARE* table
|
|||||||
return new (mem_root) ha_mcs_cache(hton, table, mem_root);
|
return new (mem_root) ha_mcs_cache(hton, table, mem_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_innodb_queries_uses_mcs(THD* thd);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
ha_mcs Plugin code
|
ha_mcs Plugin code
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@ -1858,16 +1860,17 @@ static int columnstore_init_func(void* p)
|
|||||||
mcs_hton->create_unit = create_columnstore_unit_handler;
|
mcs_hton->create_unit = create_columnstore_unit_handler;
|
||||||
mcs_hton->db_type = DB_TYPE_AUTOASSIGN;
|
mcs_hton->db_type = DB_TYPE_AUTOASSIGN;
|
||||||
|
|
||||||
{
|
if (get_innodb_queries_uses_mcs(current_thd))
|
||||||
auto* innodb_hton = plugin_hton(plugin_innodb);
|
|
||||||
int error = innodb_hton == nullptr; // Engine must exists!
|
|
||||||
if (error)
|
|
||||||
{
|
{
|
||||||
my_error(HA_ERR_INITIALIZATION, MYF(0), "Could not find storage engine %s", name.str);
|
auto* innodb_hton = plugin_hton(plugin_innodb);
|
||||||
|
int error = innodb_hton == nullptr; // Engine must exists!
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
my_error(HA_ERR_INITIALIZATION, MYF(0), "Could not find storage engine %s", name.str);
|
||||||
|
}
|
||||||
|
innodb_hton->create_select = create_columnstore_select_handler;
|
||||||
|
innodb_hton->create_unit = create_columnstore_unit_handler;
|
||||||
}
|
}
|
||||||
innodb_hton->create_select = create_columnstore_select_handler;
|
|
||||||
innodb_hton->create_unit = create_columnstore_unit_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_PSI_INTERFACE
|
#ifdef HAVE_PSI_INTERFACE
|
||||||
uint count = sizeof(all_mutexes) / sizeof(all_mutexes[0]);
|
uint count = sizeof(all_mutexes) / sizeof(all_mutexes[0]);
|
||||||
|
@ -4077,9 +4077,9 @@ int ha_mcs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table, bool
|
|||||||
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
|
||||||
csc->identity(CalpontSystemCatalog::FE);
|
csc->identity(CalpontSystemCatalog::FE);
|
||||||
|
|
||||||
if (!get_fe_conn_info_ptr())
|
if (!get_fe_conn_info_ptr())
|
||||||
{
|
{
|
||||||
set_fe_conn_info_ptr(reinterpret_cast<void*>(new cal_connection_info(), thd));
|
set_fe_conn_info_ptr((void*)new cal_connection_info());
|
||||||
thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr());
|
thd_set_ha_data(thd, mcs_hton, get_fe_conn_info_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4127,33 +4127,33 @@ int ha_mcs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table, bool
|
|||||||
bool localQuery = (get_local_query(thd) > 0 ? true : false);
|
bool localQuery = (get_local_query(thd) > 0 ? true : false);
|
||||||
|
|
||||||
{
|
{
|
||||||
// ci->stats.reset(); // reset query stats
|
ci->stats.reset(); // reset query stats
|
||||||
// ci->stats.setStartTime();
|
ci->stats.setStartTime();
|
||||||
// if (thd->main_security_ctx.user)
|
if (thd->main_security_ctx.user)
|
||||||
// {
|
{
|
||||||
// ci->stats.fUser = thd->main_security_ctx.user;
|
ci->stats.fUser = thd->main_security_ctx.user;
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// ci->stats.fUser = "";
|
ci->stats.fUser = "";
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (thd->main_security_ctx.host)
|
if (thd->main_security_ctx.host)
|
||||||
// ci->stats.fHost = thd->main_security_ctx.host;
|
ci->stats.fHost = thd->main_security_ctx.host;
|
||||||
// else if (thd->main_security_ctx.host_or_ip)
|
else if (thd->main_security_ctx.host_or_ip)
|
||||||
// ci->stats.fHost = thd->main_security_ctx.host_or_ip;
|
ci->stats.fHost = thd->main_security_ctx.host_or_ip;
|
||||||
// else
|
else
|
||||||
// ci->stats.fHost = "unknown";
|
ci->stats.fHost = "unknown";
|
||||||
|
|
||||||
// try
|
try
|
||||||
// {
|
{
|
||||||
// ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser);
|
ci->stats.userPriority(ci->stats.fHost, ci->stats.fUser);
|
||||||
// }
|
}
|
||||||
// catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
// {
|
{
|
||||||
// string msg = string("Columnstore User Priority - ") + e.what();
|
string msg = string("Columnstore User Priority - ") + e.what();
|
||||||
// ci->warningMsg = msg;
|
ci->warningMsg = msg;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if the previous query has error, re-establish the connection
|
// if the previous query has error, re-establish the connection
|
||||||
if (ci->queryState != 0)
|
if (ci->queryState != 0)
|
||||||
|
@ -220,6 +220,9 @@ static MYSQL_THDVAR_ULONG(max_allowed_in_values, PLUGIN_VAR_RQCMDARG,
|
|||||||
"The maximum length of the entries in the IN query clause.", NULL, NULL, 6000, 1,
|
"The maximum length of the entries in the IN query clause.", NULL, NULL, 6000, 1,
|
||||||
~0U, 1);
|
~0U, 1);
|
||||||
|
|
||||||
|
static MYSQL_THDVAR_BOOL(innodb_queries_uses_mcs, PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
|
||||||
|
"Direct all InnoDB-only queries into MCS via Select Handler.", NULL, NULL, 0);
|
||||||
|
|
||||||
st_mysql_sys_var* mcs_system_variables[] = {MYSQL_SYSVAR(compression_type),
|
st_mysql_sys_var* mcs_system_variables[] = {MYSQL_SYSVAR(compression_type),
|
||||||
MYSQL_SYSVAR(fe_conn_info_ptr),
|
MYSQL_SYSVAR(fe_conn_info_ptr),
|
||||||
MYSQL_SYSVAR(original_optimizer_flags),
|
MYSQL_SYSVAR(original_optimizer_flags),
|
||||||
@ -260,6 +263,7 @@ st_mysql_sys_var* mcs_system_variables[] = {MYSQL_SYSVAR(compression_type),
|
|||||||
MYSQL_SYSVAR(s3_region),
|
MYSQL_SYSVAR(s3_region),
|
||||||
MYSQL_SYSVAR(pron),
|
MYSQL_SYSVAR(pron),
|
||||||
MYSQL_SYSVAR(max_allowed_in_values),
|
MYSQL_SYSVAR(max_allowed_in_values),
|
||||||
|
MYSQL_SYSVAR(innodb_queries_uses_mcs),
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
st_mysql_show_var mcs_status_variables[] = {{"columnstore_version", (char*)&cs_version, SHOW_CHAR},
|
st_mysql_show_var mcs_status_variables[] = {{"columnstore_version", (char*)&cs_version, SHOW_CHAR},
|
||||||
@ -654,4 +658,14 @@ ulong get_max_allowed_in_values(THD* thd)
|
|||||||
void set_max_allowed_in_values(THD* thd, ulong value)
|
void set_max_allowed_in_values(THD* thd, ulong value)
|
||||||
{
|
{
|
||||||
THDVAR(thd, max_allowed_in_values) = value;
|
THDVAR(thd, max_allowed_in_values) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_innodb_queries_uses_mcs(THD* thd)
|
||||||
|
{
|
||||||
|
return THDVAR(thd, innodb_queries_uses_mcs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_innodb_queries_uses_mcs(THD* thd, bool value)
|
||||||
|
{
|
||||||
|
THDVAR(thd, innodb_queries_uses_mcs) = value;
|
||||||
|
}
|
||||||
|
@ -96,6 +96,14 @@ int LibMySQL::init(const char* h, unsigned int p, const char* u, const char* w,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable Select Handler to avoid recursive SH execution path for CES.
|
||||||
|
static const std::string disableSelectHandler = "SET SESSION columnstore_select_handler = OFF";
|
||||||
|
if (mysql_real_query(fCon, disableSelectHandler.c_str(), disableSelectHandler.length()) != 0)
|
||||||
|
{
|
||||||
|
fErrStr = "fatal error setting columnstore_select_handler=OFF in libmysql_client lib";
|
||||||
|
ret = -1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user