You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-02 17:22:27 +03:00
MCOL-2178 CS now explicitly calls MDB's optimizer using JOIN::optimizer_inner
call. CS doesn't use SH for SELECT..INTO OUTFILE queries. Clean up gwi::physTableList when processing Storage API request. SH now explicitly set an execution error in THD::stmt_da. SH now set queryState in select_next() to mark a begging of the execution.
This commit is contained in:
@ -4065,7 +4065,9 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
|
|||||||
|
|
||||||
// MCOL-2178 Check for tableMap size to set this only once.
|
// MCOL-2178 Check for tableMap size to set this only once.
|
||||||
ci->queryState = 0;
|
ci->queryState = 0;
|
||||||
|
// Clean up the tableMap and physTablesList
|
||||||
ci->tableMap.erase(table);
|
ci->tableMap.erase(table);
|
||||||
|
ci->physTablesList.erase(table);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -5132,12 +5134,14 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
|
|||||||
{
|
{
|
||||||
// CS resets error in create_SH() if fallback is enabled
|
// CS resets error in create_SH() if fallback is enabled
|
||||||
setError(thd, ER_INTERNAL_ERROR, emsgStr);
|
setError(thd, ER_INTERNAL_ERROR, emsgStr);
|
||||||
return ER_INTERNAL_ERROR;
|
goto internal_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ci->rmParms.clear();
|
ci->rmParms.clear();
|
||||||
|
|
||||||
ci->queryState = 1;
|
// SH will initiate SM in select_next() only
|
||||||
|
if (!sh)
|
||||||
|
ci->queryState= sm::QUERY_IN_PROCESS;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -5315,8 +5319,6 @@ int ha_cs_impl_select_next(uchar* buf, TABLE* table)
|
|||||||
sm::tableid_t tableid= execplan::IDB_VTABLE_ID;
|
sm::tableid_t tableid= execplan::IDB_VTABLE_ID;
|
||||||
sm::cpsm_conhdl_t* hndl= ci->cal_conn_hndl;
|
sm::cpsm_conhdl_t* hndl= ci->cal_conn_hndl;
|
||||||
|
|
||||||
if (!ti.tpl_ctx || !ti.tpl_scan_ctx || (hndl && hndl->queryState == sm::NO_QUERY))
|
|
||||||
{
|
|
||||||
if (ti.tpl_ctx == 0)
|
if (ti.tpl_ctx == 0)
|
||||||
{
|
{
|
||||||
ti.tpl_ctx = new sm::cpsm_tplh_t();
|
ti.tpl_ctx = new sm::cpsm_tplh_t();
|
||||||
@ -5362,6 +5364,7 @@ int ha_cs_impl_select_next(uchar* buf, TABLE* table)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ci->tableMap[table] = ti;
|
ci->tableMap[table] = ti;
|
||||||
|
hndl->queryState= sm::QUERY_IN_PROCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ti.tpl_ctx || !ti.tpl_scan_ctx)
|
if (!ti.tpl_ctx || !ti.tpl_scan_ctx)
|
||||||
|
@ -642,14 +642,25 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|
|||||||
|
|
||||||
bool unsupported_feature = false;
|
bool unsupported_feature = false;
|
||||||
// Select_handler use the short-cut that effectively disables
|
// Select_handler use the short-cut that effectively disables
|
||||||
// INSERT..SELECT and LDI
|
// INSERT..SELECT, LDI, SELECT..INTO OUTFILE
|
||||||
if ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT
|
if ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT
|
||||||
|| (thd->lex)->sql_command == SQLCOM_CREATE_TABLE )
|
|| (thd->lex)->sql_command == SQLCOM_CREATE_TABLE
|
||||||
|
|| (thd->lex)->exchange)
|
||||||
|
|
||||||
{
|
{
|
||||||
unsupported_feature = true;
|
unsupported_feature = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JOIN *join= select_lex->join;
|
||||||
|
// Next block tries to execute the query using SH very early to fallback
|
||||||
|
// if execution fails.
|
||||||
|
if (!unsupported_feature)
|
||||||
|
{
|
||||||
|
// TODO This part must explicitly call a list of needed optimizations
|
||||||
|
mutate_optimizer_flags(thd);
|
||||||
|
join->optimization_state= JOIN::OPTIMIZATION_IN_PROGRESS;
|
||||||
|
join->optimize_inner();
|
||||||
|
|
||||||
// Impossible HAVING or WHERE
|
// Impossible HAVING or WHERE
|
||||||
// TODO replace with function call
|
// TODO replace with function call
|
||||||
if (unsupported_feature
|
if (unsupported_feature
|
||||||
@ -657,14 +668,14 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|
|||||||
|| select_lex->cond_value == Item::COND_FALSE )
|
|| select_lex->cond_value == Item::COND_FALSE )
|
||||||
{
|
{
|
||||||
unsupported_feature = true;
|
unsupported_feature = true;
|
||||||
|
restore_optimizer_flags(thd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next block tries to execute the query using SH very early to fallback
|
|
||||||
// if execution fails.
|
|
||||||
if (!unsupported_feature)
|
if (!unsupported_feature)
|
||||||
{
|
{
|
||||||
handler= new ha_columnstore_select_handler(thd, select_lex);
|
handler= new ha_columnstore_select_handler(thd, select_lex);
|
||||||
mutate_optimizer_flags(thd);
|
// This is an ugly hack to call simplify_joins()
|
||||||
mcs_handler_info mhi= mcs_handler_info(reinterpret_cast<void*>(handler), SELECT);
|
mcs_handler_info mhi= mcs_handler_info(reinterpret_cast<void*>(handler), SELECT);
|
||||||
// this::table is the place for the result set
|
// this::table is the place for the result set
|
||||||
int rc= ha_cs_impl_pushdown_init(&mhi, handler->table);
|
int rc= ha_cs_impl_pushdown_init(&mhi, handler->table);
|
||||||
@ -679,6 +690,23 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
|
|||||||
{
|
{
|
||||||
thd->get_stmt_da()->reset_diagnostics_area();
|
thd->get_stmt_da()->reset_diagnostics_area();
|
||||||
restore_optimizer_flags(thd);
|
restore_optimizer_flags(thd);
|
||||||
|
unsupported_feature = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (join->optimization_state != JOIN::NOT_OPTIMIZED)
|
||||||
|
{
|
||||||
|
if (!join->with_two_phase_optimization)
|
||||||
|
{
|
||||||
|
if (unsupported_feature && join->have_query_plan != JOIN::QEP_DELETED)
|
||||||
|
{
|
||||||
|
join->build_explain();
|
||||||
|
}
|
||||||
|
join->optimization_state= JOIN::OPTIMIZATION_DONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
join->optimization_state= JOIN::OPTIMIZATION_PHASE_1_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ thread_stack = 512K
|
|||||||
lower_case_table_names=1
|
lower_case_table_names=1
|
||||||
group_concat_max_len=512
|
group_concat_max_len=512
|
||||||
sql_mode="ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
|
sql_mode="ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
|
||||||
|
#columnstore_processing_handlers_fallback = OFF;
|
||||||
|
|
||||||
# Enable compression by default on create, set to 0 to turn off
|
# Enable compression by default on create, set to 0 to turn off
|
||||||
#columnstore_compression_type=2
|
#columnstore_compression_type=2
|
||||||
|
Reference in New Issue
Block a user