1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-2178 Cleanup of MIGR:: singleton from the plugin code.

Disable SP execution by the smart handlers for now.

    Add session variables to Enable/Disable select/derived/group_by
    handlers. Defaulted to Enable.
This commit is contained in:
Gagan Goel
2019-08-04 21:50:50 -04:00
parent d62b66ecf7
commit 1c460f3ba5
11 changed files with 284 additions and 726 deletions

View File

@ -23,8 +23,6 @@
#include "ha_calpont_impl.h" #include "ha_calpont_impl.h"
#include "ha_mcs_pushdown.h" #include "ha_mcs_pushdown.h"
MIGR::INFINIDB_VTABLE MIGR::infinidb_vtable;
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);

View File

@ -2306,17 +2306,6 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
bool schemaSyncOnly = false; bool schemaSyncOnly = false;
bool isCreate = true; bool isCreate = true;
// relate to bug 1793. Make sure this is not for a select statement because
if (db == "calpontsys" && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT
&& tbl != "systable"
&& tbl != "syscolumn" && tbl != "sysindex"
&& tbl != "sysconstraint" && tbl != "sysindexcol"
&& tbl != "sysconstraintcol" )
{
setError(thd, ER_INTERNAL_ERROR, "Cannot create non-system Calpont tables in calpontsys database");
return 1;
}
regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", regex_constants::extended); regex pat("[[:space:]]*SCHEMA[[:space:]]+SYNC[[:space:]]+ONLY", regex_constants::extended);
if (regex_search(tablecomment, pat)) if (regex_search(tablecomment, pat))
@ -2336,11 +2325,6 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
#endif #endif
return 0; return 0;
} }
if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE) //check if it is select
{
return 0;
}
} }
else else
{ {

View File

@ -2117,10 +2117,6 @@ int ha_calpont_impl_commit_ (handlerton* hton, THD* thd, bool all, cal_connectio
{ {
int rc = 0; int rc = 0;
if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE ||
MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE )
return rc;
if (thd->slave_thread && !ci.replicationEnabled) if (thd->slave_thread && !ci.replicationEnabled)
return 0; return 0;

View File

@ -1321,8 +1321,9 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex)
{ {
if (gwi.thd->derived_tables_processing) if (gwi.thd->derived_tables_processing)
{ {
MIGR::infinidb_vtable.isUnion = false; // TODO MCOL-2178 isUnion member only assigned, never used
MIGR::infinidb_vtable.isUpdateWithDerive = true; // MIGR::infinidb_vtable.isUnion = false;
gwi.cs_vtable_is_update_with_derive = true;
return -1; return -1;
} }
} }
@ -2645,8 +2646,6 @@ void setError(THD* thd, uint32_t errcode, string errmsg)
} }
thd->raise_error_printf(errcode, errmsg.c_str()); thd->raise_error_printf(errcode, errmsg.c_str());
MIGR::infinidb_vtable.isNewQuery = true;
MIGR::infinidb_vtable.override_largeside_estimate = false;
// reset expressionID // reset expressionID
if (get_fe_conn_info_ptr() == NULL) if (get_fe_conn_info_ptr() == NULL)
@ -5623,7 +5622,8 @@ void gp_walk(const Item* item, void* arg)
gwip->hasSubSelect = true; gwip->hasSubSelect = true;
gwip->subQuery = existsSub; gwip->subQuery = existsSub;
gwip->ptWorkStack.push(existsSub->transform()); gwip->ptWorkStack.push(existsSub->transform());
MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. // TODO MCOL-2178 isUnion member only assigned, never used
// MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase.
// recover original // recover original
gwip->subQuery = orig; gwip->subQuery = orig;
gwip->lastSub = existsSub; gwip->lastSub = existsSub;
@ -5983,7 +5983,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ||
((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) && gwi.thd->derived_tables_processing) ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) ) && gwi.thd->derived_tables_processing)
{ {
MIGR::infinidb_vtable.isUnion = false; // TODO MCOL-2178 isUnion member only assigned, never used
// MIGR::infinidb_vtable.isUnion = false;
return -1; return -1;
} }
@ -6031,7 +6032,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// @bug 2123. Override large table estimate if infinidb_ordered hint was used. // @bug 2123. Override large table estimate if infinidb_ordered hint was used.
// @bug 2404. Always override if the infinidb_ordered_only variable is turned on. // @bug 2404. Always override if the infinidb_ordered_only variable is turned on.
if (MIGR::infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) if (get_ordered_only(gwi.thd))
csep->overrideLargeSideEstimate(true); csep->overrideLargeSideEstimate(true);
// @bug 5741. Set a flag when in Local PM only query mode // @bug 5741. Set a flag when in Local PM only query mode
@ -6117,7 +6118,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
gwi.tbList.push_back(tn); gwi.tbList.push_back(tn);
CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias);
gwi.tableMap[tan] = make_pair(0, table_ptr); gwi.tableMap[tan] = make_pair(0, table_ptr);
MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init // TODO MCOL-2178 isUnion member only assigned, never used
// MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init
} }
else if (table_ptr->view) else if (table_ptr->view)
{ {
@ -6188,7 +6190,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// is_unit_op() give a segv for derived_handler's SELECT_LEX // is_unit_op() give a segv for derived_handler's SELECT_LEX
if (!isUnion && select_lex.master_unit()->is_unit_op()) if (!isUnion && select_lex.master_unit()->is_unit_op())
{ {
MIGR::infinidb_vtable.isUnion = true; // TODO MCOL-2178 isUnion member only assigned, never used
// MIGR::infinidb_vtable.isUnion = true;
CalpontSelectExecutionPlan::SelectList unionVec; CalpontSelectExecutionPlan::SelectList unionVec;
SELECT_LEX* select_cursor = select_lex.master_unit()->first_select(); SELECT_LEX* select_cursor = select_lex.master_unit()->first_select();
unionSel = true; unionSel = true;
@ -6247,7 +6250,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
csep->distinctUnionNum(distUnionNum); csep->distinctUnionNum(distUnionNum);
if (unionVec.empty()) if (unionVec.empty())
MIGR::infinidb_vtable.impossibleWhereOnUnion = true; gwi.cs_vtable_impossible_where_on_union = true;
} }
gwi.clauseType = WHERE; gwi.clauseType = WHERE;
@ -6280,8 +6283,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// processing. // processing.
if (gwi.thd->derived_tables_processing) if (gwi.thd->derived_tables_processing)
{ {
MIGR::infinidb_vtable.isUnion = false; // TODO MCOL-2178 isUnion member only assigned, never used
MIGR::infinidb_vtable.isUpdateWithDerive = true; // MIGR::infinidb_vtable.isUnion = false;
gwi.cs_vtable_is_update_with_derive = true;
return -1; return -1;
} }
@ -7094,7 +7098,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
SRCP minSc; // min width projected column. for count(*) use SRCP minSc; // min width projected column. for count(*) use
// Group by list. not valid for union main query // Group by list. not valid for union main query
if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && !unionSel) if (!unionSel)
{ {
gwi.clauseType = GROUP_BY; gwi.clauseType = GROUP_BY;
Item* nonSupportItem = NULL; Item* nonSupportItem = NULL;
@ -7374,7 +7378,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
} }
} }
if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
{ {
SQL_I_List<ORDER> order_list = select_lex.order_list; SQL_I_List<ORDER> order_list = select_lex.order_list;
ORDER* ordercol = reinterpret_cast<ORDER*>(order_list.first); ORDER* ordercol = reinterpret_cast<ORDER*>(order_list.first);
@ -7861,10 +7864,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// relate to bug4848. let mysql drive limit when limit session variable set. // relate to bug4848. let mysql drive limit when limit session variable set.
// do not set in csep. @bug5096. ignore session limit setting for dml // do not set in csep. @bug5096. ignore session limit setting for dml
if ((gwi.thd->variables.select_limit == (uint64_t) - 1 || if (gwi.thd->variables.select_limit == (uint64_t) - 1 &&
(gwi.thd->variables.select_limit != (uint64_t) - 1 && !csep->hasOrderBy())
MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_CREATE_VTABLE)) &&
!csep->hasOrderBy())
{ {
csep->limitStart(limitOffset); csep->limitStart(limitOffset);
csep->limitNum(limitNum); csep->limitNum(limitNum);
@ -7977,7 +7978,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
csep->derivedTableList(gwi.derivedTbList); csep->derivedTableList(gwi.derivedTbList);
csep->selectSubList(selectSubList); csep->selectSubList(selectSubList);
csep->subSelectList(gwi.subselectList); csep->subSelectList(gwi.subselectList);
MIGR::infinidb_vtable.duplicate_field_name = false;
clearStacks(gwi); clearStacks(gwi);
return 0; return 0;
} }
@ -7987,10 +7987,11 @@ int cp_get_plan(THD* thd, SCSEP& csep)
LEX* lex = thd->lex; LEX* lex = thd->lex;
idbassert(lex != 0); idbassert(lex != 0);
// WIP MCOL-2178 A questionable replacement.
SELECT_LEX select_lex = *lex->first_select_lex();
gp_walk_info gwi; gp_walk_info gwi;
gwi.thd = thd; gwi.thd = thd;
// WIP MCOL-2178 A questionable replacement.
SELECT_LEX select_lex = *lex->first_select_lex();
int status = getSelectPlan(gwi, select_lex, csep); int status = getSelectPlan(gwi, select_lex, csep);
if (status > 0) if (status > 0)
@ -8126,16 +8127,14 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
else if (status < 0) else if (status < 0)
return status; return status;
// Derived table projection and filter optimization. // Derived table projection and filter optimization.
derivedTableOptimization(csep); derivedTableOptimization(thd, csep);
return 0; return 0;
} }
int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep) int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep, gp_walk_info& gwi)
{ {
SELECT_LEX select_lex = *handler->select; SELECT_LEX select_lex = *handler->select;
gp_walk_info gwi;
gwi.thd = thd;
int status = getSelectPlan(gwi, select_lex, csep, false, true); int status = getSelectPlan(gwi, select_lex, csep, false, true);
if (status > 0) if (status > 0)
@ -8149,15 +8148,13 @@ int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep)
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
#endif #endif
// Derived table projection and filter optimization. // Derived table projection and filter optimization.
derivedTableOptimization(csep); derivedTableOptimization(thd, csep);
return 0; return 0;
} }
int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep) int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep, gp_walk_info& gwi)
{ {
SELECT_LEX select_lex = *handler->select; SELECT_LEX select_lex = *handler->select;
gp_walk_info gwi;
gwi.thd = thd;
int status = getSelectPlan(gwi, select_lex, csep, false, true); int status = getSelectPlan(gwi, select_lex, csep, false, true);
if (status > 0) if (status > 0)
@ -8171,7 +8168,7 @@ int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep)
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl; cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
#endif #endif
// Derived table projection and filter optimization. // Derived table projection and filter optimization.
derivedTableOptimization(csep); derivedTableOptimization(thd, csep);
return 0; return 0;
} }
@ -8268,7 +8265,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// @bug 2123. Override large table estimate if infinidb_ordered hint was used. // @bug 2123. Override large table estimate if infinidb_ordered hint was used.
// @bug 2404. Always override if the infinidb_ordered_only variable is turned on. // @bug 2404. Always override if the infinidb_ordered_only variable is turned on.
if (MIGR::infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) if (get_ordered_only(gwi.thd))
csep->overrideLargeSideEstimate(true); csep->overrideLargeSideEstimate(true);
// @bug 5741. Set a flag when in Local PM only query mode // @bug 5741. Set a flag when in Local PM only query mode
@ -8355,6 +8352,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.tbList.push_back(tn); gwi.tbList.push_back(tn);
CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias); CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias);
gwi.tableMap[tan] = make_pair(0, table_ptr); gwi.tableMap[tan] = make_pair(0, table_ptr);
// TODO MCOL-2178 isUnion member only assigned, never used
// MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init // MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init
} }
else if (table_ptr->view) else if (table_ptr->view)
@ -8453,8 +8451,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// processing. // processing.
if (gwi.thd->derived_tables_processing) if (gwi.thd->derived_tables_processing)
{ {
MIGR::infinidb_vtable.isUnion = false; // TODO MCOL-2178 isUnion member only assigned, never used
MIGR::infinidb_vtable.isUpdateWithDerive = true; // MIGR::infinidb_vtable.isUnion = false;
return -1; return -1;
} }
@ -9248,7 +9246,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
SRCP minSc; // min width projected column. for count(*) use SRCP minSc; // min width projected column. for count(*) use
// Group by list. not valid for union main query // Group by list. not valid for union main query
if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE && !unionSel) if (!unionSel)
{ {
gwi.clauseType = GROUP_BY; gwi.clauseType = GROUP_BY;
Item* nonSupportItem = NULL; Item* nonSupportItem = NULL;
@ -9531,7 +9529,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// ORDER BY processing starts here // ORDER BY processing starts here
if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
{ {
ORDER* ordercol = reinterpret_cast<ORDER*>(gi.groupByOrder); ORDER* ordercol = reinterpret_cast<ORDER*>(gi.groupByOrder);
@ -10071,7 +10068,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
csep->derivedTableList(gwi.derivedTbList); csep->derivedTableList(gwi.derivedTbList);
csep->selectSubList(selectSubList); csep->selectSubList(selectSubList);
csep->subSelectList(gwi.subselectList); csep->subSelectList(gwi.subselectList);
MIGR::infinidb_vtable.duplicate_field_name = false;
clearStacks(gwi); clearStacks(gwi);
return 0; return 0;
} }

File diff suppressed because it is too large Load Diff

View File

@ -150,6 +150,8 @@ struct gp_walk_info
// Kludge for MCOL-1472 // Kludge for MCOL-1472
bool inCaseStmt; bool inCaseStmt;
bool cs_vtable_is_update_with_derive;
bool cs_vtable_impossible_where_on_union;
gp_walk_info() : sessionid(0), gp_walk_info() : sessionid(0),
fatalParseError(false), fatalParseError(false),
@ -166,8 +168,10 @@ struct gp_walk_info
lastSub(0), lastSub(0),
derivedTbCnt(0), derivedTbCnt(0),
recursionLevel(-1), recursionLevel(-1),
recursionHWM(0), recursionHWM(0),
inCaseStmt(false) inCaseStmt(false),
cs_vtable_is_update_with_derive(false),
cs_vtable_impossible_where_on_union(false)
{} {}
~gp_walk_info() {} ~gp_walk_info() {}
@ -338,8 +342,8 @@ const std::string infinidb_err_msg = "\nThe query includes syntax that is not su
int cp_get_plan(THD* thd, execplan::SCSEP& csep); int cp_get_plan(THD* thd, execplan::SCSEP& csep);
int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti); int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti);
int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_group_info& gi); int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_group_info& gi);
int cs_get_derived_plan(derived_handler* handler, THD* thd, execplan::SCSEP& csep); int cs_get_derived_plan(derived_handler* handler, THD* thd, execplan::SCSEP& csep, gp_walk_info& gwi);
int cs_get_select_plan(select_handler* handler, THD* thd, execplan::SCSEP& csep); int cs_get_select_plan(select_handler* handler, THD* thd, execplan::SCSEP& csep, gp_walk_info& gwi);
int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false, bool isPushdownHand = false); int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false, bool isPushdownHand = false);
int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, cal_group_info& gi, bool isUnion = false); int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, cal_group_info& gi, bool isUnion = false);
void setError(THD* thd, uint32_t errcode, const std::string errmsg, gp_walk_info* gwi); void setError(THD* thd, uint32_t errcode, const std::string errmsg, gp_walk_info* gwi);

View File

@ -148,15 +148,20 @@ static group_by_handler*
create_calpont_group_by_handler(THD* thd, Query* query) create_calpont_group_by_handler(THD* thd, Query* query)
{ {
ha_calpont_group_by_handler* handler = NULL; ha_calpont_group_by_handler* handler = NULL;
// MCOL-2178 Disable SP support in the group_by_handler for now
// Check the session variable value to enable/disable use of
// group_by_handler
if (!get_group_by_handler(thd) || (thd->lex)->sphead)
{
return handler;
}
// same as thd->lex->current_select // same as thd->lex->current_select
SELECT_LEX *select_lex = query->from->select_lex; SELECT_LEX *select_lex = query->from->select_lex;
// Create a handler if query is valid. See comments for details. // Create a handler if query is valid. See comments for details.
if //( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE if ( query->group_by || select_lex->with_sum_func )
// WIP MCOL-2178
//&& ( MIGR::infinidb_vtable_mode == 0
// || MIGR::infinidb_vtable_mode == 2 )
( query->group_by || select_lex->with_sum_func ) //)
{ {
bool unsupported_feature = false; bool unsupported_feature = false;
// revisit SELECT_LEX for all units // revisit SELECT_LEX for all units
@ -234,6 +239,14 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived)
{ {
ha_columnstore_derived_handler* handler = NULL; ha_columnstore_derived_handler* handler = NULL;
// MCOL-2178 Disable SP support in the derived_handler for now
// Check the session variable value to enable/disable use of
// derived_handler
if (!get_derived_handler(thd) || (thd->lex)->sphead)
{
return handler;
}
SELECT_LEX_UNIT *unit= derived->derived; SELECT_LEX_UNIT *unit= derived->derived;
bool unsupported_feature = false; bool unsupported_feature = false;
@ -287,8 +300,6 @@ ha_columnstore_derived_handler::~ha_columnstore_derived_handler()
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Execute the query and saves derived table query. * Execute the query and saves derived table query.
* ATM this function sets vtable_state and restores it afterwards
* since it reuses existed vtable code internally.
* PARAMETERS: * PARAMETERS:
* *
* RETURN: * RETURN:
@ -305,16 +316,10 @@ int ha_columnstore_derived_handler::init_scan()
derived_query.length(0); derived_query.length(0);
derived->derived->print(&derived_query, QT_ORDINARY); derived->derived->print(&derived_query, QT_ORDINARY);
// Save vtable_state to restore the after we inited.
MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE;
mcs_handler_info mhi = mcs_handler_info(static_cast<void*>(this), DERIVED); mcs_handler_info mhi = mcs_handler_info(static_cast<void*>(this), DERIVED);
// 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, table); int rc = ha_cs_impl_pushdown_init(&mhi, table);
MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -322,8 +327,6 @@ int ha_columnstore_derived_handler::init_scan()
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Fetches next row and saves it in the temp table * Fetches next row and saves it in the temp table
* ATM this function sets vtable_state and restores it
* afterwards since it reuses existed vtable code internally.
* PARAMETERS: * PARAMETERS:
* *
* RETURN: * RETURN:
@ -334,15 +337,8 @@ int ha_columnstore_derived_handler::next_row()
{ {
DBUG_ENTER("ha_columnstore_derived_handler::next_row"); DBUG_ENTER("ha_columnstore_derived_handler::next_row");
// Save vtable_state to restore the after we inited.
MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE;
int rc = ha_calpont_impl_rnd_next(table->record[0], table); int rc = ha_calpont_impl_rnd_next(table->record[0], table);
MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -350,8 +346,6 @@ int ha_columnstore_derived_handler::next_row()
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Finishes the scan for derived handler * Finishes the scan for derived handler
* ATM this function sets vtable_state and restores it
* afterwards since it reuses existed vtable code internally.
* PARAMETERS: * PARAMETERS:
* *
* RETURN: * RETURN:
@ -362,13 +356,8 @@ int ha_columnstore_derived_handler::end_scan()
{ {
DBUG_ENTER("ha_columnstore_derived_handler::end_scan"); DBUG_ENTER("ha_columnstore_derived_handler::end_scan");
MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE;
int rc = ha_calpont_impl_rnd_end(table, true); int rc = ha_calpont_impl_rnd_end(table, true);
MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -413,12 +402,7 @@ int ha_calpont_group_by_handler::init_scan()
{ {
DBUG_ENTER("ha_calpont_group_by_handler::init_scan"); DBUG_ENTER("ha_calpont_group_by_handler::init_scan");
// Save vtable_state to restore the after we inited.
MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
// MCOL-1052 Should be removed after cleaning the code up.
MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE;
int rc = ha_calpont_impl_group_by_init(this, table); int rc = ha_calpont_impl_group_by_init(this, table);
MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -470,6 +454,14 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
{ {
ha_columnstore_select_handler* handler = NULL; ha_columnstore_select_handler* handler = NULL;
// MCOL-2178 Disable SP support in the select_handler for now.
// Check the session variable value to enable/disable use of
// select_handler
if (!get_select_handler(thd) || (thd->lex)->sphead)
{
return handler;
}
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 and LDI
@ -563,8 +555,6 @@ ha_columnstore_select_handler::~ha_columnstore_select_handler()
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Execute the query and saves select table query. * Execute the query and saves select table query.
* ATM this function sets vtable_state and restores it afterwards
* since it reuses existed vtable code internally.
* PARAMETERS: * PARAMETERS:
* *
* RETURN: * RETURN:
@ -581,16 +571,10 @@ int ha_columnstore_select_handler::init_scan()
select_query.length(0); select_query.length(0);
select->print(thd, &select_query, QT_ORDINARY); select->print(thd, &select_query, QT_ORDINARY);
// Save vtable_state to restore the after we inited.
MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE;
mcs_handler_info mhi = mcs_handler_info(static_cast<void*>(this), SELECT); mcs_handler_info mhi = mcs_handler_info(static_cast<void*>(this), 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, table); int rc = ha_cs_impl_pushdown_init(&mhi, table);
MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -598,8 +582,6 @@ int ha_columnstore_select_handler::init_scan()
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Fetches next row and saves it in the temp table * Fetches next row and saves it in the temp table
* ATM this function sets vtable_state and restores it
* afterwards since it reuses existed vtable code internally.
* PARAMETERS: * PARAMETERS:
* *
* RETURN: * RETURN:
@ -610,15 +592,8 @@ int ha_columnstore_select_handler::next_row()
{ {
DBUG_ENTER("ha_columnstore_select_handler::next_row"); DBUG_ENTER("ha_columnstore_select_handler::next_row");
// Save vtable_state to restore the after we inited.
MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE;
int rc = ha_calpont_impl_rnd_next(table->record[0], table); int rc = ha_calpont_impl_rnd_next(table->record[0], table);
MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -626,8 +601,6 @@ int ha_columnstore_select_handler::next_row()
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Finishes the scan for select handler * Finishes the scan for select handler
* ATM this function sets vtable_state and restores it
* afterwards since it reuses existed vtable code internally.
* PARAMETERS: * PARAMETERS:
* *
* RETURN: * RETURN:
@ -638,13 +611,8 @@ int ha_columnstore_select_handler::end_scan()
{ {
DBUG_ENTER("ha_columnstore_select_handler::end_scan"); DBUG_ENTER("ha_columnstore_select_handler::end_scan");
MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE;
int rc = ha_calpont_impl_rnd_end(table, true); int rc = ha_calpont_impl_rnd_end(table, true);
MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }

View File

@ -71,6 +71,33 @@ static MYSQL_THDVAR_ULONGLONG(
1 1
); );
static MYSQL_THDVAR_BOOL(
select_handler,
PLUGIN_VAR_NOCMDARG,
"Enable/Disable the MCS select_handler",
NULL,
NULL,
1
);
static MYSQL_THDVAR_BOOL(
derived_handler,
PLUGIN_VAR_NOCMDARG,
"Enable/Disable the MCS derived_handler",
NULL,
NULL,
1
);
static MYSQL_THDVAR_BOOL(
group_by_handler,
PLUGIN_VAR_NOCMDARG,
"Enable/Disable the MCS group_by_handler",
NULL,
NULL,
1
);
// legacy system variables // legacy system variables
@ -256,6 +283,9 @@ st_mysql_sys_var* mcs_system_variables[] =
MYSQL_SYSVAR(compression_type), 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),
MYSQL_SYSVAR(select_handler),
MYSQL_SYSVAR(derived_handler),
MYSQL_SYSVAR(group_by_handler),
MYSQL_SYSVAR(decimal_scale), MYSQL_SYSVAR(decimal_scale),
MYSQL_SYSVAR(use_decimal_scale), MYSQL_SYSVAR(use_decimal_scale),
MYSQL_SYSVAR(ordered_only), MYSQL_SYSVAR(ordered_only),
@ -307,6 +337,33 @@ void set_original_optimizer_flags(ulonglong ptr, THD* thd)
THDVAR(current_thd, original_optimizer_flags) = (uint64_t)(ptr); THDVAR(current_thd, original_optimizer_flags) = (uint64_t)(ptr);
} }
bool get_select_handler(THD* thd)
{
return ( thd == NULL ) ? false : THDVAR(thd, select_handler);
}
void set_select_handler(THD* thd, bool value)
{
THDVAR(thd, select_handler) = value;
}
bool get_derived_handler(THD* thd)
{
return ( thd == NULL ) ? false : THDVAR(thd, derived_handler);
}
void set_derived_handler(THD* thd, bool value)
{
THDVAR(thd, derived_handler) = value;
}
bool get_group_by_handler(THD* thd)
{
return ( thd == NULL ) ? false : THDVAR(thd, group_by_handler);
}
void set_group_by_handler(THD* thd, bool value)
{
THDVAR(thd, group_by_handler) = value;
}
void set_compression_type(THD* thd, ulong value) void set_compression_type(THD* thd, ulong value)
{ {
THDVAR(thd, compression_type) = value; THDVAR(thd, compression_type) = value;

View File

@ -43,6 +43,15 @@ void set_fe_conn_info_ptr(void* ptr, THD* thd = NULL);
ulonglong get_original_optimizer_flags(THD* thd = NULL); ulonglong get_original_optimizer_flags(THD* thd = NULL);
void set_original_optimizer_flags(ulonglong ptr, THD* thd = NULL); void set_original_optimizer_flags(ulonglong ptr, THD* thd = NULL);
bool get_select_handler(THD* thd);
void set_select_handler(THD* thd, bool value);
bool get_derived_handler(THD* thd);
void set_derived_handler(THD* thd, bool value);
bool get_group_by_handler(THD* thd);
void set_group_by_handler(THD* thd, bool value);
bool get_use_decimal_scale(THD* thd); bool get_use_decimal_scale(THD* thd);
void set_use_decimal_scale(THD* thd, bool value); void set_use_decimal_scale(THD* thd, bool value);

View File

@ -102,7 +102,8 @@ void View::transform()
CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName); CalpontSystemCatalog::TableAliasName tn = make_aliasview("", "", alias, viewName);
gwi.tbList.push_back(tn); gwi.tbList.push_back(tn);
gwi.tableMap[tn] = make_pair(0, table_ptr); gwi.tableMap[tn] = make_pair(0, table_ptr);
MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init // TODO MCOL-2178 isUnion member only assigned, never used
// MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init
} }
else if (table_ptr->view) else if (table_ptr->view)
{ {

View File

@ -111,70 +111,6 @@ inline char* idb_mysql_query_str(THD* thd)
} }
} }
class MIGR
{
public:
enum infinidb_state
{
INFINIDB_INIT_CONNECT = 0, // intend to use to drop leftover vtable when logon. not being used now.
INFINIDB_INIT,
INFINIDB_CREATE_VTABLE,
INFINIDB_ALTER_VTABLE,
INFINIDB_SELECT_VTABLE,
INFINIDB_DROP_VTABLE,
INFINIDB_DISABLE_VTABLE,
INFINIDB_REDO_PHASE1, // post process requires to re-create vtable
INFINIDB_ORDER_BY, // for InfiniDB handler to ignore the 2nd scan for order by
INFINIDB_REDO_QUERY, // redo query with the normal mysql path
INFINIDB_ERROR_REDO_PHASE1,
INFINIDB_ERROR = 32,
};
struct INFINIDB_VTABLE
{
String original_query;
String create_vtable_query;
String alter_vtable_query;
String select_vtable_query;
String drop_vtable_query;
String insert_vtable_query;
infinidb_state vtable_state; // flag for InfiniDB MySQL virtual table structure
bool autoswitch;
bool has_order_by;
bool duplicate_field_name; // @bug 1928. duplicate field name in create_phase will be ingored.
bool call_sp;
bool override_largeside_estimate;
void* cal_conn_info;
bool isUnion;
bool impossibleWhereOnUnion;
bool isInsertSelect;
bool isUpdateWithDerive;
bool isInfiniDBDML; // default false
bool hasInfiniDBTable; // default false
bool isNewQuery;
INFINIDB_VTABLE() : cal_conn_info(NULL) {init();}
void init()
{
//vtable_state = INFINIDB_INIT_CONNECT;
vtable_state = INFINIDB_DISABLE_VTABLE;
autoswitch = false;
has_order_by = false;
duplicate_field_name = false;
call_sp = false;
override_largeside_estimate = false;
isUnion = false;
impossibleWhereOnUnion = false;
isUpdateWithDerive = false;
isInfiniDBDML = false;
hasInfiniDBTable = false;
isNewQuery = true;
}
};
static INFINIDB_VTABLE infinidb_vtable; // InfiniDB custom structure
};
#endif #endif
// vim:ts=4 sw=4: // vim:ts=4 sw=4: