1
0
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:
Roman Nozdrin
2019-08-28 12:22:11 -05:00
committed by root
parent 2c63258537
commit cb36041587
3 changed files with 52 additions and 20 deletions

View File

@ -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
{ {
@ -4078,12 +4080,12 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
else if (lock_type == 2) else if (lock_type == 2)
{ {
std::set<TABLE*>::iterator iter = ci->physTablesList.find(table); std::set<TABLE*>::iterator iter = ci->physTablesList.find(table);
if ( iter != ci->physTablesList.end() ) if (iter != ci->physTablesList.end())
{ {
ci->physTablesList.erase(table); ci->physTablesList.erase(table);
} }
if ( iter != ci->physTablesList.end() && ci->physTablesList.empty() ) if (iter != ci->physTablesList.end() && ci->physTablesList.empty())
{ {
if (!ci->cal_conn_hndl) if (!ci->cal_conn_hndl)
return 0; return 0;
@ -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)

View File

@ -394,7 +394,7 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived)
// Select_handler use the short-cut that effectively disables // Select_handler use the short-cut that effectively disables
// INSERT..SELECT and LDI // INSERT..SELECT and LDI
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)
{ {
unsupported_feature = true; unsupported_feature = true;
} }
@ -642,29 +642,40 @@ 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;
} }
// Impossible HAVING or WHERE JOIN *join= select_lex->join;
// TODO replace with function call
if ( unsupported_feature
|| select_lex->having_value == Item::COND_FALSE
|| select_lex->cond_value == Item::COND_FALSE )
{
unsupported_feature = true;
}
// Next block tries to execute the query using SH very early to fallback // Next block tries to execute the query using SH very early to fallback
// if execution fails. // if execution fails.
if (!unsupported_feature) if (!unsupported_feature)
{ {
handler= new ha_columnstore_select_handler(thd, select_lex); // TODO This part must explicitly call a list of needed optimizations
mutate_optimizer_flags(thd); mutate_optimizer_flags(thd);
join->optimization_state= JOIN::OPTIMIZATION_IN_PROGRESS;
join->optimize_inner();
// Impossible HAVING or WHERE
// TODO replace with function call
if (unsupported_feature
|| select_lex->having_value == Item::COND_FALSE
|| select_lex->cond_value == Item::COND_FALSE )
{
unsupported_feature = true;
restore_optimizer_flags(thd);
}
}
if (!unsupported_feature)
{
handler= new ha_columnstore_select_handler(thd, select_lex);
// 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;
} }
} }

View File

@ -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