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

MCOL-2178 Merging with 10.4

SELECT_LEX had been moved in THD so changed all references.
        Avoid writing CS decimal scales into MDB decimal fields
            d-only dec attribute. WIP
        Replaced infinidb_vtable with a singleton MIGR.
        Merged with MCOL-2121.
        Added new wsrep include paths needed by UDaF code.
        Removed .vcxproj from Connector code.
This commit is contained in:
Roman Nozdrin
2019-02-19 20:37:44 +03:00
committed by Gagan Goel
parent 2071716ebd
commit 6fd5b2f22d
9 changed files with 335 additions and 359 deletions

View File

@ -283,11 +283,13 @@ SET (ENGINE_WE_CONFIGCPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/writeengine/x
SET (ENGINE_SERVER_SQL_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/sql") SET (ENGINE_SERVER_SQL_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/sql")
SET (ENGINE_SERVER_INCLUDE_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/include") SET (ENGINE_SERVER_INCLUDE_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/include")
SET (ENGINE_SERVER_PCRE_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../pcre") SET (ENGINE_SERVER_PCRE_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../pcre")
SET (ENGINE_SERVER_WSREP_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../wsrep-lib/include")
SET (ENGINE_SERVER_WSREP_API_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../wsrep-lib/wsrep-API/v26/")
SET (ENGINE_UTILS_UDFSDK_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/udfsdk") SET (ENGINE_UTILS_UDFSDK_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/udfsdk")
SET (ENGINE_DEFAULT_INCLUDES ${CMAKE_BINARY_DIR} "." "../" "../../" ${SERVER_BUILD_INCLUDE_DIR}) SET (ENGINE_DEFAULT_INCLUDES ${CMAKE_BINARY_DIR} "." "../" "../../" ${SERVER_BUILD_INCLUDE_DIR})
SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_OAMAPPS_ALARMMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE} ${ENGINE_UTILS_UDFSDK_INCLUDE} ${ENGINE_UTILS_LIBMYSQL_CL_INCLUDE}) SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_OAMAPPS_ALARMMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE} ${ENGINE_SERVER_WSREP_API_INCLUDE} ${ENGINE_SERVER_WSREP_INCLUDE} ${ENGINE_UTILS_UDFSDK_INCLUDE} ${ENGINE_UTILS_LIBMYSQL_CL_INCLUDE})
ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(oam/oamcpp) ADD_SUBDIRECTORY(oam/oamcpp)

View File

@ -2307,7 +2307,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
bool isCreate = true; bool isCreate = true;
// relate to bug 1793. Make sure this is not for a select statement because // relate to bug 1793. Make sure this is not for a select statement because
if (db == "calpontsys" && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT if (db == "calpontsys" && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT
&& tbl != "systable" && tbl != "systable"
&& tbl != "syscolumn" && tbl != "sysindex" && tbl != "syscolumn" && tbl != "sysindex"
&& tbl != "sysconstraint" && tbl != "sysindexcol" && tbl != "sysconstraint" && tbl != "sysindexcol"
@ -2337,7 +2337,7 @@ int ha_calpont_impl_create_(const char* name, TABLE* table_arg, HA_CREATE_INFO*
return 0; return 0;
} }
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE) //check if it is select if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE) //check if it is select
{ {
return 0; return 0;
} }

View File

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

View File

@ -1304,8 +1304,8 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex)
{ {
if (gwi.thd->derived_tables_processing) if (gwi.thd->derived_tables_processing)
{ {
gwi.thd->infinidb_vtable.isUnion = false; MIGR::infinidb_vtable.isUnion = false;
gwi.thd->infinidb_vtable.isUpdateWithDerive = true; MIGR::infinidb_vtable.isUpdateWithDerive = true;
return -1; return -1;
} }
} }
@ -2628,8 +2628,8 @@ 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());
thd->infinidb_vtable.isNewQuery = true; MIGR::infinidb_vtable.isNewQuery = true;
thd->infinidb_vtable.override_largeside_estimate = false; 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)
@ -5556,7 +5556,7 @@ 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());
current_thd->infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase. current_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;
@ -5913,7 +5913,7 @@ 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)
{ {
gwi.thd->infinidb_vtable.isUnion = false; MIGR::infinidb_vtable.isUnion = false;
return -1; return -1;
} }
@ -5961,7 +5961,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 (gwi.thd->infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) if (MIGR::infinidb_vtable.override_largeside_estimate || 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
@ -6047,7 +6047,7 @@ 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);
gwi.thd->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)
{ {
@ -6118,7 +6118,7 @@ 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())
{ {
gwi.thd->infinidb_vtable.isUnion = true; 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;
@ -6177,7 +6177,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
csep->distinctUnionNum(distUnionNum); csep->distinctUnionNum(distUnionNum);
if (unionVec.empty()) if (unionVec.empty())
gwi.thd->infinidb_vtable.impossibleWhereOnUnion = true; MIGR::infinidb_vtable.impossibleWhereOnUnion = true;
} }
gwi.clauseType = WHERE; gwi.clauseType = WHERE;
@ -6210,8 +6210,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// processing. // processing.
if (gwi.thd->derived_tables_processing) if (gwi.thd->derived_tables_processing)
{ {
gwi.thd->infinidb_vtable.isUnion = false; MIGR::infinidb_vtable.isUnion = false;
gwi.thd->infinidb_vtable.isUpdateWithDerive = true; MIGR::infinidb_vtable.isUpdateWithDerive = true;
return -1; return -1;
} }
@ -7068,7 +7068,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 (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel)
{ {
gwi.clauseType = GROUP_BY; gwi.clauseType = GROUP_BY;
Item* nonSupportItem = NULL; Item* nonSupportItem = NULL;
@ -7345,14 +7345,14 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
} }
} }
if (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == THD::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);
string create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); string create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr());
string select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); string select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr());
string lower_create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); string lower_create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr());
string lower_select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); string lower_select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr());
boost::algorithm::to_lower(lower_create_query); boost::algorithm::to_lower(lower_create_query);
boost::algorithm::to_lower(lower_select_query); boost::algorithm::to_lower(lower_select_query);
@ -7923,9 +7923,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
} }
gwi.thd->infinidb_vtable.create_vtable_query.free(); MIGR::infinidb_vtable.create_vtable_query.free();
gwi.thd->infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length());
gwi.thd->infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 MIGR::infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1
// turn off select distinct from post process unless there're post process functions // turn off select distinct from post process unless there're post process functions
// on the select list. // on the select list.
@ -8090,7 +8090,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
if (ord_cols.length() > 0) // has order by if (ord_cols.length() > 0) // has order by
{ {
gwi.thd->infinidb_vtable.has_order_by = true; MIGR::infinidb_vtable.has_order_by = true;
csep->hasOrderBy(true); csep->hasOrderBy(true);
// To activate LimitedOrderBy // To activate LimitedOrderBy
if(isPushdownHand) if(isPushdownHand)
@ -8196,7 +8196,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// 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 && (gwi.thd->variables.select_limit != (uint64_t) - 1 &&
gwi.thd->infinidb_vtable.vtable_state != THD::INFINIDB_CREATE_VTABLE)) && MIGR::infinidb_vtable.vtable_state != THD::INFINIDB_CREATE_VTABLE)) &&
!csep->hasOrderBy()) !csep->hasOrderBy())
{ {
csep->limitStart(limitOffset); csep->limitStart(limitOffset);
@ -8222,8 +8222,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
csep->limitNum((uint64_t) - 2); csep->limitNum((uint64_t) - 2);
} }
gwi.thd->infinidb_vtable.select_vtable_query.free(); MIGR::infinidb_vtable.select_vtable_query.free();
gwi.thd->infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); MIGR::infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length());
// We don't currently support limit with correlated subquery // We don't currently support limit with correlated subquery
if (csep->limitNum() != (uint64_t) - 1 && if (csep->limitNum() != (uint64_t) - 1 &&
@ -8319,7 +8319,7 @@ 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);
gwi.thd->infinidb_vtable.duplicate_field_name = false; MIGR::infinidb_vtable.duplicate_field_name = false;
clearStacks(gwi); clearStacks(gwi);
return 0; return 0;
} }
@ -8603,7 +8603,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 (gwi.thd->infinidb_vtable.override_largeside_estimate || get_ordered_only(gwi.thd)) if (MIGR::infinidb_vtable.override_largeside_estimate || 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
@ -8689,7 +8689,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);
// gwi.thd->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)
{ {
@ -8786,8 +8786,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)
{ {
gwi.thd->infinidb_vtable.isUnion = false; MIGR::infinidb_vtable.isUnion = false;
gwi.thd->infinidb_vtable.isUpdateWithDerive = true; MIGR::infinidb_vtable.isUpdateWithDerive = true;
return -1; return -1;
} }
@ -9606,7 +9606,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 (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel) if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && !unionSel)
{ {
gwi.clauseType = GROUP_BY; gwi.clauseType = GROUP_BY;
Item* nonSupportItem = NULL; Item* nonSupportItem = NULL;
@ -9885,13 +9885,13 @@ 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 (gwi.thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE)
{ {
ORDER* ordercol = reinterpret_cast<ORDER*>(gi.groupByOrder); ORDER* ordercol = reinterpret_cast<ORDER*>(gi.groupByOrder);
string create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); string create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr());
string select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); string select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr());
string lower_create_query(gwi.thd->infinidb_vtable.create_vtable_query.c_ptr()); string lower_create_query(MIGR::infinidb_vtable.create_vtable_query.c_ptr());
string lower_select_query(gwi.thd->infinidb_vtable.select_vtable_query.c_ptr()); string lower_select_query(MIGR::infinidb_vtable.select_vtable_query.c_ptr());
boost::algorithm::to_lower(lower_create_query); boost::algorithm::to_lower(lower_create_query);
boost::algorithm::to_lower(lower_select_query); boost::algorithm::to_lower(lower_select_query);
@ -10219,9 +10219,9 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
} }
gwi.thd->infinidb_vtable.create_vtable_query.free(); MIGR::infinidb_vtable.create_vtable_query.free();
gwi.thd->infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length()); MIGR::infinidb_vtable.create_vtable_query.append(create_query.c_str(), create_query.length());
gwi.thd->infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1 MIGR::infinidb_vtable.vtable_state = THD::INFINIDB_REDO_PHASE1; // redo phase 1
// turn off select distinct from post process unless there're post process functions // turn off select distinct from post process unless there're post process functions
// on the select list. // on the select list.
@ -10391,7 +10391,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
if ( gwi.orderByCols.size() ) // has order by if ( gwi.orderByCols.size() ) // has order by
{ {
gwi.thd->infinidb_vtable.has_order_by = true; MIGR::infinidb_vtable.has_order_by = true;
csep->hasOrderBy(true); csep->hasOrderBy(true);
csep->specHandlerProcessed(true); csep->specHandlerProcessed(true);
} }
@ -10418,8 +10418,9 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
csep->limitStart(((Item_int*)gi.groupByTables->select_lex->offset_limit)->val_int()); csep->limitStart(((Item_int*)gi.groupByTables->select_lex->offset_limit)->val_int());
} }
//gwi.thd->infinidb_vtable.select_vtable_query.free(); // WIP MCOL-2178
//gwi.thd->infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length()); //MIGR::infinidb_vtable.select_vtable_query.free();
//MIGR::infinidb_vtable.select_vtable_query.append(select_query.c_str(), select_query.length());
// We don't currently support limit with correlated subquery // We don't currently support limit with correlated subquery
if (csep->limitNum() != (uint64_t) - 1 && if (csep->limitNum() != (uint64_t) - 1 &&
@ -10516,7 +10517,7 @@ 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);
gwi.thd->infinidb_vtable.duplicate_field_name = false; MIGR::infinidb_vtable.duplicate_field_name = false;
clearStacks(gwi); clearStacks(gwi);
return 0; return 0;
} }

View File

@ -169,8 +169,6 @@ static const string interval_names[] =
const unsigned NONSUPPORTED_ERR_THRESH = 2000; const unsigned NONSUPPORTED_ERR_THRESH = 2000;
//TODO: make this session-safe (put in connMap?)
//vector<RMParam> rmParms;
ResourceManager* rm = ResourceManager::instance(); ResourceManager* rm = ResourceManager::instance();
bool useHdfs = rm->useHdfs(); bool useHdfs = rm->useHdfs();
@ -273,8 +271,8 @@ void storeNumericField(Field** f, int64_t value, CalpontSystemCatalog::ColType&
// @bug4388 stick to InfiniDB's scale in case mysql gives wrong scale due // @bug4388 stick to InfiniDB's scale in case mysql gives wrong scale due
// to create vtable limitation. // to create vtable limitation.
if (f2->dec < ct.scale) //if (f2->dec < ct.scale)
f2->dec = ct.scale; // f2->dec = ct.scale;
char buf[256]; char buf[256];
dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, buf, 256, ct.colDataType); dataconvert::DataConvert::decimalToString(value, (unsigned)ct.scale, buf, 256, ct.colDataType);
@ -755,7 +753,8 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
//float float_val = *(float*)(&value); //float float_val = *(float*)(&value);
//f2->store(float_val); //f2->store(float_val);
if (f2->decimals() < (uint32_t)row.getScale(s)) if (f2->decimals() < (uint32_t)row.getScale(s))
f2->dec = (uint32_t)row.getScale(s); // WIP MCOL-2178
//f2->dec = (uint32_t)row.getScale(s);
f2->store(dl); f2->store(dl);
@ -784,11 +783,15 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
//double double_val = *(double*)(&value); //double double_val = *(double*)(&value);
//f2->store(double_val); //f2->store(double_val);
// WIP MCOL-2178
/*
if ((f2->decimals() == DECIMAL_NOT_SPECIFIED && row.getScale(s) > 0) if ((f2->decimals() == DECIMAL_NOT_SPECIFIED && row.getScale(s) > 0)
|| f2->decimals() < row.getScale(s)) || f2->decimals() < row.getScale(s))
{ {
f2->dec = row.getScale(s); f2->dec = row.getScale(s);
} }*/
f2->store(dl); f2->store(dl);
@ -1235,7 +1238,7 @@ uint32_t doUpdateDelete(THD* thd)
//@Bug 4387. Check BRM status before start statement. //@Bug 4387. Check BRM status before start statement.
boost::scoped_ptr<DBRM> dbrmp(new DBRM()); boost::scoped_ptr<DBRM> dbrmp(new DBRM());
int rc = dbrmp->isReadWrite(); int rc = dbrmp->isReadWrite();
thd->infinidb_vtable.isInfiniDBDML = true; MIGR::infinidb_vtable.isInfiniDBDML = true;
if (rc != 0 ) if (rc != 0 )
{ {
@ -1335,8 +1338,8 @@ uint32_t doUpdateDelete(THD* thd)
{ {
ColumnAssignment* columnAssignmentPtr; ColumnAssignment* columnAssignmentPtr;
Item_field* item; Item_field* item;
// TABLE_LIST* table_ptr = thd->lex->select_lex.get_table_list(); // TABLE_LIST* table_ptr = thd->lex->thd->lex->first_select_lex()->get_table_list();
List_iterator_fast<Item> field_it(thd->lex->select_lex.item_list); List_iterator_fast<Item> field_it(thd->lex->thd->lex->first_select_lex()->item_list);
List_iterator_fast<Item> value_it(thd->lex->value_list); List_iterator_fast<Item> value_it(thd->lex->value_list);
// dmlStmt += "update "; // dmlStmt += "update ";
updateCP->queryType(CalpontSelectExecutionPlan::UPDATE); updateCP->queryType(CalpontSelectExecutionPlan::UPDATE);
@ -1587,7 +1590,7 @@ uint32_t doUpdateDelete(THD* thd)
} }
colAssignmentListPtr->push_back ( columnAssignmentPtr ); colAssignmentListPtr->push_back ( columnAssignmentPtr );
// if (cnt < thd->lex->select_lex.item_list.elements) // if (cnt < thd->lex->thd->lex->first_select_lex()->item_list.elements)
// dmlStmt += ", "; // dmlStmt += ", ";
} }
@ -1636,7 +1639,7 @@ uint32_t doUpdateDelete(THD* thd)
} }
else else
{ {
first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first;
aTableName.schema = first_table->table->s->db.str; aTableName.schema = first_table->table->s->db.str;
aTableName.table = first_table->table->s->table_name.str; aTableName.table = first_table->table->s->table_name.str;
} }
@ -1687,9 +1690,9 @@ uint32_t doUpdateDelete(THD* thd)
} }
else if ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) //@Bug 6121 error out on multi tables delete. else if ((thd->lex)->sql_command == SQLCOM_DELETE_MULTI) //@Bug 6121 error out on multi tables delete.
{ {
if ( (thd->lex->select_lex.join) != 0) if ( (thd->lex->thd->lex->first_select_lex()->join) != 0)
{ {
multi_delete* deleteTable = (multi_delete*)((thd->lex->select_lex.join)->result); multi_delete* deleteTable = (multi_delete*)((thd->lex->thd->lex->first_select_lex()->join)->result);
first_table = (TABLE_LIST*) deleteTable->get_tables(); first_table = (TABLE_LIST*) deleteTable->get_tables();
if (deleteTable->get_num_of_tables() == 1) if (deleteTable->get_num_of_tables() == 1)
@ -1712,7 +1715,7 @@ uint32_t doUpdateDelete(THD* thd)
} }
else else
{ {
first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first;
schemaName = first_table->table->s->db.str; schemaName = first_table->table->s->db.str;
tableName = first_table->table->s->table_name.str; tableName = first_table->table->s->table_name.str;
aliasName = first_table->alias.str; aliasName = first_table->alias.str;
@ -1723,7 +1726,7 @@ uint32_t doUpdateDelete(THD* thd)
} }
else else
{ {
first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first;
schemaName = first_table->table->s->db.str; schemaName = first_table->table->s->db.str;
tableName = first_table->table->s->table_name.str; tableName = first_table->table->s->table_name.str;
aliasName = first_table->alias.str; aliasName = first_table->alias.str;
@ -1756,16 +1759,16 @@ uint32_t doUpdateDelete(THD* thd)
if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) )
{ {
items = (thd->lex->select_lex.item_list); items = (thd->lex->thd->lex->first_select_lex()->item_list);
thd->lex->select_lex.item_list = thd->lex->value_list; thd->lex->thd->lex->first_select_lex()->item_list = thd->lex->value_list;
} }
select_lex = lex->select_lex; select_lex = *lex->first_select_lex();
//@Bug 2808 Error out on order by or limit clause //@Bug 2808 Error out on order by or limit clause
//@bug5096. support dml limit. //@bug5096. support dml limit.
if (/*( select_lex.explicit_limit ) || */( select_lex.order_list.elements != 0 ) ) if (/*( thd->lex->first_select_lex()->explicit_limit ) || */( thd->lex->first_select_lex()->order_list.elements != 0 ) )
{ {
string emsg("DML Statement with order by clause is not currently supported."); string emsg("DML Statement with order by clause is not currently supported.");
thd->raise_error_printf(ER_INTERNAL_ERROR, emsg.c_str()); thd->raise_error_printf(ER_INTERNAL_ERROR, emsg.c_str());
@ -1774,12 +1777,12 @@ uint32_t doUpdateDelete(THD* thd)
return 0; return 0;
} }
//thd->infinidb_vtable.isInfiniDBDML = true; //MIGR::infinidb_vtable.isInfiniDBDML = true;
THD::infinidb_state origState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state origState = MIGR::infinidb_vtable.vtable_state;
//if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) //if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) )
{ {
gp_walk_info gwi; gp_walk_info gwi;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_CREATE_VTABLE;
gwi.thd = thd; gwi.thd = thd;
//updateCP->subType (CalpontSelectExecutionPlan::SINGLEROW_SUBS); //set scalar //updateCP->subType (CalpontSelectExecutionPlan::SINGLEROW_SUBS); //set scalar
updateCP->subType (CalpontSelectExecutionPlan::SELECT_SUBS); updateCP->subType (CalpontSelectExecutionPlan::SELECT_SUBS);
@ -1816,13 +1819,13 @@ uint32_t doUpdateDelete(THD* thd)
if (getSelectPlan(gwi, select_lex, updateCP) != 0) //@Bug 3030 Modify the error message for unsupported functions if (getSelectPlan(gwi, select_lex, updateCP) != 0) //@Bug 3030 Modify the error message for unsupported functions
{ {
if (thd->infinidb_vtable.isUpdateWithDerive) if (MIGR::infinidb_vtable.isUpdateWithDerive)
{ {
// @bug 4457. MySQL inconsistence! for some queries, some structures are only available // @bug 4457. MySQL inconsistence! for some queries, some structures are only available
// in the derived_tables_processing phase. So by pass the phase for DML only when the // in the derived_tables_processing phase. So by pass the phase for DML only when the
// execution plan can not be successfully generated. recover lex before returning; // execution plan can not be successfully generated. recover lex before returning;
thd->lex->select_lex.item_list = items; thd->lex->thd->lex->first_select_lex()->item_list = items;
thd->infinidb_vtable.vtable_state = origState; MIGR::infinidb_vtable.vtable_state = origState;
return 0; return 0;
} }
@ -1972,7 +1975,7 @@ uint32_t doUpdateDelete(THD* thd)
//cout<< "Plan is " << endl << *updateCP << endl; //cout<< "Plan is " << endl << *updateCP << endl;
if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ) if (( (thd->lex)->sql_command == SQLCOM_UPDATE ) || ( (thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) )
thd->lex->select_lex.item_list = items; thd->lex->thd->lex->first_select_lex()->item_list = items;
} }
//cout<< "Plan is " << endl << *updateCP << endl; //cout<< "Plan is " << endl << *updateCP << endl;
@ -1989,7 +1992,7 @@ uint32_t doUpdateDelete(THD* thd)
updateCP->rmParms(ci->rmParms); updateCP->rmParms(ci->rmParms);
updateCP->serialize(*plan); updateCP->serialize(*plan);
// recover original vtable state // recover original vtable state
thd->infinidb_vtable.vtable_state = origState; MIGR::infinidb_vtable.vtable_state = origState;
//cout << "plan has bytes " << plan->length() << endl; //cout << "plan has bytes " << plan->length() << endl;
pDMLPackage->write(bytestream); pDMLPackage->write(bytestream);
@ -2368,20 +2371,20 @@ int ha_calpont_impl_rnd_init(TABLE* table)
{ {
// Still not ready // Still not ready
setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
else if (bSystemQueryReady < 0) else if (bSystemQueryReady < 0)
{ {
// Still not ready // Still not ready
setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
#endif #endif
// prevent "create table as select" from running on slave // prevent "create table as select" from running on slave
thd->infinidb_vtable.hasInfiniDBTable = true; MIGR::infinidb_vtable.hasInfiniDBTable = true;
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr()); cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
@ -2398,30 +2401,30 @@ int ha_calpont_impl_rnd_init(TABLE* table)
// @bug 3005. if the table is not $vtable, then this could be a UDF defined on the connector. // @bug 3005. if the table is not $vtable, then this could be a UDF defined on the connector.
// watch this for other complications // watch this for other complications
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE && if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE &&
string(table->s->table_name.str).find("$vtable") != 0) string(table->s->table_name.str).find("$vtable") != 0)
return 0; return 0;
// return error is error status is already set // return error is error status is already set
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
// by pass the extra union trips. return 0 // by pass the extra union trips. return 0
if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) if (MIGR::infinidb_vtable.isUnion && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
return 0; return 0;
// @bug 2232. Basic SP support. Error out non support sp cases. // @bug 2232. Basic SP support. Error out non support sp cases.
// @bug 3939. Only error out for sp with select. Let pass for alter table in sp. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp.
if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE)
{ {
setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
// mysql reads table twice for order by // mysql reads table twice for order by
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1 || if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 ||
thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY) MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY)
return 0; return 0;
if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE )
@ -2442,8 +2445,8 @@ int ha_calpont_impl_rnd_init(TABLE* table)
// MySQL sometimes calls rnd_init multiple times, plan should only be // MySQL sometimes calls rnd_init multiple times, plan should only be
// generated and sent once. // generated and sent once.
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE &&
!thd->infinidb_vtable.isNewQuery) !MIGR::infinidb_vtable.isNewQuery)
return 0; return 0;
if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD)
@ -2459,11 +2462,11 @@ int ha_calpont_impl_rnd_init(TABLE* table)
// update traceFlags according to the autoswitch state. replication query // update traceFlags according to the autoswitch state. replication query
// on slave are in table mode (create table as...) // on slave are in table mode (create table as...)
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE || if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE ||
(thd->slave_thread && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT)) (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT))
{ {
ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_DISABLE_VTABLE; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE;
} }
else else
{ {
@ -2474,7 +2477,7 @@ int ha_calpont_impl_rnd_init(TABLE* table)
bool localQuery = get_local_query(thd); bool localQuery = get_local_query(thd);
// table mode // table mode
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
ti = ci->tableMap[table]; ti = ci->tableMap[table];
@ -2544,8 +2547,8 @@ int ha_calpont_impl_rnd_init(TABLE* table)
// vtable mode // vtable mode
else else
{ {
//if (!ci->cal_conn_hndl || thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) //if (!ci->cal_conn_hndl || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
{ {
ci->stats.reset(); // reset query stats ci->stats.reset(); // reset query stats
ci->stats.setStartTime(); ci->stats.setStartTime();
@ -2601,7 +2604,7 @@ int ha_calpont_impl_rnd_init(TABLE* table)
hndl = ci->cal_conn_hndl; hndl = ci->cal_conn_hndl;
if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE)
{ {
//CalpontSelectExecutionPlan csep; //CalpontSelectExecutionPlan csep;
if (!csep) if (!csep)
@ -2629,7 +2632,7 @@ int ha_calpont_impl_rnd_init(TABLE* table)
csep->traceFlags(ci->traceFlags); csep->traceFlags(ci->traceFlags);
if (thd->infinidb_vtable.isInsertSelect) if (MIGR::infinidb_vtable.isInsertSelect)
csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT); csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT);
//get plan //get plan
@ -2642,12 +2645,12 @@ int ha_calpont_impl_rnd_init(TABLE* table)
return 0; return 0;
// @bug 2547. don't need to send the plan if it's impossible where for all unions. // @bug 2547. don't need to send the plan if it's impossible where for all unions.
if (thd->infinidb_vtable.impossibleWhereOnUnion) if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
return 0; return 0;
string query; string query;
query.assign(thd->infinidb_vtable.original_query.ptr(), query.assign(MIGR::infinidb_vtable.original_query.ptr(),
thd->infinidb_vtable.original_query.length()); MIGR::infinidb_vtable.original_query.length());
csep->data(query); csep->data(query);
try try
@ -2686,7 +2689,7 @@ int ha_calpont_impl_rnd_init(TABLE* table)
} }
}// end of execution plan generation }// end of execution plan generation
if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE)
{ {
ByteStream msg; ByteStream msg;
ByteStream emsgBs; ByteStream emsgBs;
@ -2761,7 +2764,7 @@ int ha_calpont_impl_rnd_init(TABLE* table)
ci->rmParms.clear(); ci->rmParms.clear();
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
ci->tableMap[table] = ti; ci->tableMap[table] = ti;
} }
@ -2781,7 +2784,7 @@ int ha_calpont_impl_rnd_init(TABLE* table)
idbassert(hndl != 0); idbassert(hndl != 0);
hndl->csc = csc; hndl->csc = csc;
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
ti.conn_hndl = hndl; ti.conn_hndl = hndl;
else else
ci->cal_conn_hndl = hndl; ci->cal_conn_hndl = hndl;
@ -2805,15 +2808,15 @@ int ha_calpont_impl_rnd_init(TABLE* table)
// set query state to be in_process. Sometimes mysql calls rnd_init multiple // set query state to be in_process. Sometimes mysql calls rnd_init multiple
// times, this makes sure plan only being generated and sent once. It will be // times, this makes sure plan only being generated and sent once. It will be
// reset when query finishes in sm::end_query // reset when query finishes in sm::end_query
thd->infinidb_vtable.isNewQuery = false; MIGR::infinidb_vtable.isNewQuery = false;
// common path for both vtable select phase and table mode -- open scan handle // common path for both vtable select phase and table mode -- open scan handle
ti = ci->tableMap[table]; ti = ci->tableMap[table];
ti.msTablePtr = table; ti.msTablePtr = table;
if ((thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE) || if ((MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) ||
(thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) || (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) ||
(thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_QUERY)) (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_QUERY))
{ {
if (ti.tpl_ctx == 0) if (ti.tpl_ctx == 0)
{ {
@ -2870,7 +2873,7 @@ int ha_calpont_impl_rnd_init(TABLE* table)
} }
// populate coltypes here for table mode because tableband gives treeoid for dictionary column // populate coltypes here for table mode because tableband gives treeoid for dictionary column
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true);
@ -2934,11 +2937,11 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table)
thd->lex->sql_command == SQLCOM_LOAD)) thd->lex->sql_command == SQLCOM_LOAD))
return 0; return 0;
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
// @bug 3005 // @bug 3005
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE && if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE &&
string(table->s->table_name.str).find("$vtable") != 0) string(table->s->table_name.str).find("$vtable") != 0)
return HA_ERR_END_OF_FILE; return HA_ERR_END_OF_FILE;
@ -2947,15 +2950,15 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table)
return HA_ERR_END_OF_FILE; return HA_ERR_END_OF_FILE;
// @bug 2547 // @bug 2547
if (thd->infinidb_vtable.impossibleWhereOnUnion) if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
return HA_ERR_END_OF_FILE; return HA_ERR_END_OF_FILE;
// @bug 2232. Basic SP support // @bug 2232. Basic SP support
// @bug 3939. Only error out for sp with select. Let pass for alter table in sp. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp.
if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE)
{ {
setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
@ -3027,8 +3030,8 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
cal_connection_info* ci = NULL; cal_connection_info* ci = NULL;
bool replicationEnabled = false; bool replicationEnabled = false;
if (thd->infinidb_vtable.cal_conn_info) if (get_fe_conn_info_ptr() != NULL)
ci = reinterpret_cast<cal_connection_info*>(thd->infinidb_vtable.cal_conn_info); ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
if (ci && ci->replicationEnabled) if (ci && ci->replicationEnabled)
{ {
@ -3046,23 +3049,23 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
thd->lex->sql_command == SQLCOM_LOAD)) thd->lex->sql_command == SQLCOM_LOAD))
return 0; return 0;
thd->infinidb_vtable.isNewQuery = true; MIGR::infinidb_vtable.isNewQuery = true;
// Workaround because CS doesn't reset isUnion in a normal way. // Workaround because CS doesn't reset isUnion in a normal way.
if (is_pushdown_hand) if (is_pushdown_hand)
{ {
thd->infinidb_vtable.isUnion = false; MIGR::infinidb_vtable.isUnion = false;
} }
if (get_fe_conn_info_ptr() != NULL) if (get_fe_conn_info_ptr() != NULL)
ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr()); ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY ) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY )
{ {
thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; // flip back to normal state MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE; // flip back to normal state
return rc; return rc;
} }
// if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1) // if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1)
// return rc; // return rc;
if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE )
@ -3103,7 +3106,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
cal_table_info ti = ci->tableMap[table]; cal_table_info ti = ci->tableMap[table];
sm::cpsm_conhdl_t* hndl; sm::cpsm_conhdl_t* hndl;
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
hndl = ti.conn_hndl; hndl = ti.conn_hndl;
else else
hndl = ci->cal_conn_hndl; hndl = ci->cal_conn_hndl;
@ -3129,7 +3132,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
sm::tpl_close(ti.tpl_ctx, &hndl, ci->stats); sm::tpl_close(ti.tpl_ctx, &hndl, ci->stats);
// set conn hndl back. could be changed in tpl_close // set conn hndl back. could be changed in tpl_close
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
ti.conn_hndl = hndl; ti.conn_hndl = hndl;
else else
ci->cal_conn_hndl = hndl; ci->cal_conn_hndl = hndl;
@ -3163,9 +3166,9 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
ti.tpl_ctx = 0; ti.tpl_ctx = 0;
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE && if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE &&
thd->infinidb_vtable.has_order_by) MIGR::infinidb_vtable.has_order_by)
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ORDER_BY; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ORDER_BY;
ci->tableMap[table] = ti; ci->tableMap[table] = ti;
@ -3190,7 +3193,7 @@ int ha_calpont_impl_create(const char* name, TABLE* table_arg, HA_CREATE_INFO* c
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr()); cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
// @bug1940 Do nothing for select query. Support of set default engine to IDB. // @bug1940 Do nothing for select query. Support of set default engine to IDB.
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE || if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE ||
string(name).find("@0024vtable") != string::npos) string(name).find("@0024vtable") != string::npos)
return 0; return 0;
@ -3250,7 +3253,7 @@ int ha_calpont_impl_delete_table(const char* name)
} }
else else
{ {
TABLE_LIST* first_table = (TABLE_LIST*) thd->lex->select_lex.table_list.first; TABLE_LIST* first_table = (TABLE_LIST*) thd->lex->thd->lex->first_select_lex()->table_list.first;
dbName = const_cast<char*>(first_table->db.str); dbName = const_cast<char*>(first_table->db.str);
} }
@ -3391,14 +3394,14 @@ void ha_calpont_impl_start_bulk_insert(ha_rows rows, TABLE* table)
if (ci->alterTableState > 0) return; if (ci->alterTableState > 0) return;
if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_ALTER_VTABLE) if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_ALTER_VTABLE)
thd->infinidb_vtable.isInfiniDBDML = true; MIGR::infinidb_vtable.isInfiniDBDML = true;
if (thd->slave_thread && !ci->replicationEnabled) if (thd->slave_thread && !ci->replicationEnabled)
return; return;
//@bug 5660. Error out DDL/DML on slave node, or on local query node //@bug 5660. Error out DDL/DML on slave node, or on local query node
if (ci->isSlaveNode && thd->infinidb_vtable.vtable_state != THD::INFINIDB_ALTER_VTABLE) if (ci->isSlaveNode && MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_ALTER_VTABLE)
{ {
string emsg = logging::IDBErrorInfo::instance()->errorMsg(ERR_DML_DDL_SLAVE); string emsg = logging::IDBErrorInfo::instance()->errorMsg(ERR_DML_DDL_SLAVE);
setError(current_thd, ER_CHECK_NOT_IMPLEMENTED, emsg); setError(current_thd, ER_CHECK_NOT_IMPLEMENTED, emsg);
@ -4166,10 +4169,10 @@ int ha_calpont_impl_end_bulk_insert(bool abort, TABLE* table)
int ha_calpont_impl_commit (handlerton* hton, THD* thd, bool all) int ha_calpont_impl_commit (handlerton* hton, THD* thd, bool all)
{ {
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE || if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE ||
thd->infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE ||
thd->infinidb_vtable.vtable_state == THD::INFINIDB_DROP_VTABLE || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DROP_VTABLE ||
thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1) MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1)
return 0; return 0;
if (get_fe_conn_info_ptr() == NULL) if (get_fe_conn_info_ptr() == NULL)
@ -4297,7 +4300,7 @@ int ha_calpont_impl_rename_table(const char* from, const char* to)
IDEBUG( cout << "ha_calpont_impl_rename_table: was in state ALTER_SECOND_RENAME, now in NOT_ALTER" << endl ); IDEBUG( cout << "ha_calpont_impl_rename_table: was in state ALTER_SECOND_RENAME, now in NOT_ALTER" << endl );
return 0; return 0;
} }
else if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_ALTER_VTABLE ) else if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ALTER_VTABLE )
return 0; return 0;
int rc = ha_calpont_impl_rename_table_(from, to, *ci); int rc = ha_calpont_impl_rename_table_(from, to, *ci);
@ -4314,10 +4317,10 @@ COND* ha_calpont_impl_cond_push(COND* cond, TABLE* table)
{ {
THD* thd = current_thd; THD* thd = current_thd;
if (thd->slave_thread && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT) if (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT)
thd->infinidb_vtable.vtable_state = THD::INFINIDB_DISABLE_VTABLE; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE;
if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE)
return cond; return cond;
if (((thd->lex)->sql_command == SQLCOM_UPDATE) || if (((thd->lex)->sql_command == SQLCOM_UPDATE) ||
@ -4404,11 +4407,11 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
string alias; string alias;
alias.assign(table->alias.ptr(), table->alias.length()); alias.assign(table->alias.ptr(), table->alias.length());
IDEBUG( cout << "external_lock for " << alias << endl ); IDEBUG( cout << "external_lock for " << alias << endl );
idbassert((thd->infinidb_vtable.vtable_state >= THD::INFINIDB_INIT_CONNECT && idbassert((MIGR::infinidb_vtable.vtable_state >= MIGR::INFINIDB_INIT_CONNECT &&
thd->infinidb_vtable.vtable_state <= THD::INFINIDB_REDO_QUERY) || MIGR::infinidb_vtable.vtable_state <= MIGR::INFINIDB_REDO_QUERY) ||
thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR); MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR);
if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT ) if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT )
return 0; return 0;
if (get_fe_conn_info_ptr() == NULL) if (get_fe_conn_info_ptr() == NULL)
@ -4432,7 +4435,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
#endif #endif
{ {
// table mode // table mode
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
if (mapiter->second.conn_hndl) if (mapiter->second.conn_hndl)
{ {
@ -4454,7 +4457,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
// only push this warning for once // only push this warning for once
if (ci->tableMap.size() == 1 && if (ci->tableMap.size() == 1 &&
thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE && thd->infinidb_vtable.autoswitch) MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE && MIGR::infinidb_vtable.autoswitch)
{ {
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, infinidb_autoswitch_warning.c_str()); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, infinidb_autoswitch_warning.c_str());
} }
@ -4462,7 +4465,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
} }
else // vtable mode else // vtable mode
{ {
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE)
{ {
if (!ci->cal_conn_hndl) if (!ci->cal_conn_hndl)
return 0; return 0;
@ -4474,7 +4477,7 @@ int ha_calpont_impl_external_lock(THD* thd, TABLE* table, int lock_type)
ci->extendedStats = ci->cal_conn_hndl->extendedStats; ci->extendedStats = ci->cal_conn_hndl->extendedStats;
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; MIGR::infinidb_vtable.override_largeside_estimate = false;
// MCOL-3247 Use THD::ha_data as a per-plugin per-session // MCOL-3247 Use THD::ha_data as a per-plugin per-session
// storage for cal_conn_hndl to use it later in close_connection // storage for cal_conn_hndl to use it later in close_connection
thd_set_ha_data(thd, calpont_hton, get_fe_conn_info_ptr()); thd_set_ha_data(thd, calpont_hton, get_fe_conn_info_ptr());
@ -4523,36 +4526,36 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
{ {
// Still not ready // Still not ready
setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
else if (bSystemQueryReady < 0) else if (bSystemQueryReady < 0)
{ {
// Still not ready // Still not ready
setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
#endif #endif
// prevent "create table as select" from running on slave // prevent "create table as select" from running on slave
thd->infinidb_vtable.hasInfiniDBTable = true; MIGR::infinidb_vtable.hasInfiniDBTable = true;
// return error if error status has been already set // return error if error status has been already set
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
// MCOL-1052 // MCOL-1052
// by pass the extra union trips. return 0 // by pass the extra union trips. return 0
//if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) //if (MIGR::infinidb_vtable.isUnion && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
// return 0; // return 0;
// @bug 2232. Basic SP support. Error out non support sp cases. // @bug 2232. Basic SP support. Error out non support sp cases.
// @bug 3939. Only error out for sp with select. Let pass for alter table in sp. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp.
if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE)
{ {
setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
@ -4570,8 +4573,8 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
// MySQL sometimes calls rnd_init multiple times, plan should only be // MySQL sometimes calls rnd_init multiple times, plan should only be
// generated and sent once. // generated and sent once.
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE && if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE &&
!thd->infinidb_vtable.isNewQuery) !MIGR::infinidb_vtable.isNewQuery)
return 0; return 0;
if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD)
@ -4713,7 +4716,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
return 0; return 0;
// @bug 2547. don't need to send the plan if it's impossible where for all unions. // @bug 2547. don't need to send the plan if it's impossible where for all unions.
if (thd->infinidb_vtable.impossibleWhereOnUnion) if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
return 0; return 0;
string query; string query;
@ -4834,7 +4837,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
ci->rmParms.clear(); ci->rmParms.clear();
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
ci->tableMap[table] = ti; ci->tableMap[table] = ti;
} }
@ -4855,7 +4858,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
hndl->csc = csc; hndl->csc = csc;
// The next section is useless // The next section is useless
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
ti.conn_hndl = hndl; ti.conn_hndl = hndl;
else else
{ {
@ -4882,18 +4885,18 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
// set query state to be in_process. Sometimes mysql calls rnd_init multiple // set query state to be in_process. Sometimes mysql calls rnd_init multiple
// times, this makes sure plan only being generated and sent once. It will be // times, this makes sure plan only being generated and sent once. It will be
// reset when query finishes in sm::end_query // reset when query finishes in sm::end_query
thd->infinidb_vtable.isNewQuery = false; MIGR::infinidb_vtable.isNewQuery = false;
// common path for both vtable select phase and table mode -- open scan handle // common path for both vtable select phase and table mode -- open scan handle
ti = ci->tableMap[table]; ti = ci->tableMap[table];
ti.msTablePtr = table; ti.msTablePtr = table;
// MCOL-1052 // MCOL-1052
thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_SELECT_VTABLE;
if ((thd->infinidb_vtable.vtable_state == THD::INFINIDB_SELECT_VTABLE) || if ((MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_SELECT_VTABLE) ||
(thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) || (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE) ||
(thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_QUERY)) (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_QUERY))
{ {
// MCOL-1601 Using stacks of ExeMgr conn hndls, table and scan contexts. // MCOL-1601 Using stacks of ExeMgr conn hndls, table and scan contexts.
ti.tpl_ctx = new sm::cpsm_tplh_t(); ti.tpl_ctx = new sm::cpsm_tplh_t();
@ -4950,7 +4953,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
} }
// populate coltypes here for table mode because tableband gives treeoid for dictionary column // populate coltypes here for table mode because tableband gives treeoid for dictionary column
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true);
@ -5017,7 +5020,7 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE
{ {
THD* thd = current_thd; THD* thd = current_thd;
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
if (((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) || if (((thd->lex)->sql_command == SQLCOM_UPDATE) || ((thd->lex)->sql_command == SQLCOM_DELETE) ||
@ -5025,15 +5028,15 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE
return HA_ERR_END_OF_FILE; return HA_ERR_END_OF_FILE;
// @bug 2547 // @bug 2547
if (thd->infinidb_vtable.impossibleWhereOnUnion) if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
return HA_ERR_END_OF_FILE; return HA_ERR_END_OF_FILE;
// @bug 2232. Basic SP support // @bug 2232. Basic SP support
// @bug 3939. Only error out for sp with select. Let pass for alter table in sp. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp.
/*if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) /*if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE)
{ {
setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
*/ */
@ -5118,18 +5121,6 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE*
THD* thd = current_thd; THD* thd = current_thd;
cal_connection_info* ci = NULL; cal_connection_info* ci = NULL;
thd->infinidb_vtable.isNewQuery = true;
thd->infinidb_vtable.isUnion = false;
if (get_fe_conn_info_ptr() != NULL)
ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
if (!ci)
{
thd->infinidb_vtable.cal_conn_info = (void*)(new cal_connection_info());
ci = reinterpret_cast<cal_connection_info*>(thd->infinidb_vtable.cal_conn_info);
}
if (thd->slave_thread && !ci->replicationEnabled && ( if (thd->slave_thread && !ci->replicationEnabled && (
thd->lex->sql_command == SQLCOM_INSERT || thd->lex->sql_command == SQLCOM_INSERT ||
thd->lex->sql_command == SQLCOM_INSERT_SELECT || thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
@ -5141,7 +5132,13 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE*
thd->lex->sql_command == SQLCOM_LOAD)) thd->lex->sql_command == SQLCOM_LOAD))
return 0; return 0;
if (((thd->lex)->sql_command == SQLCOM_INSERT) || MIGR::infinidb_vtable.isNewQuery = true;
MIGR::infinidb_vtable.isUnion = false;
if (get_fe_conn_info_ptr() != NULL)
ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
if (((thd->lex)->sql_command == SQLCOM_INSERT) ||
((thd->lex)->sql_command == SQLCOM_INSERT_SELECT) ) ((thd->lex)->sql_command == SQLCOM_INSERT_SELECT) )
{ {
force_close_fep_conn(thd, ci, true); // with checking prev command rc force_close_fep_conn(thd, ci, true); // with checking prev command rc
@ -5332,20 +5329,20 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
{ {
// Still not ready // Still not ready
setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries"); setError(thd, ER_INTERNAL_ERROR, "The system is not yet ready to accept queries");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
else if (bSystemQueryReady < 0) else if (bSystemQueryReady < 0)
{ {
// Still not ready // Still not ready
setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries"); setError(thd, ER_INTERNAL_ERROR, "DBRM is not responding. Cannot accept queries");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
#endif #endif
// prevent "create table as select" from running on slave // prevent "create table as select" from running on slave
thd->infinidb_vtable.hasInfiniDBTable = true; MIGR::infinidb_vtable.hasInfiniDBTable = true;
/* If this node is the slave, ignore DML to IDB tables */ /* If this node is the slave, ignore DML to IDB tables */
if (thd->slave_thread && ( if (thd->slave_thread && (
@ -5360,21 +5357,21 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
return 0; return 0;
// return error is error status is already set // return error is error status is already set
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_ERROR) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ERROR)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
// @bug 2232. Basic SP support. Error out non support sp cases. // @bug 2232. Basic SP support. Error out non support sp cases.
// @bug 3939. Only error out for sp with select. Let pass for alter table in sp. // @bug 3939. Only error out for sp with select. Let pass for alter table in sp.
if (thd->infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE) if (MIGR::infinidb_vtable.call_sp && (thd->lex)->sql_command != SQLCOM_ALTER_TABLE)
{ {
setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version"); setError(thd, ER_CHECK_NOT_IMPLEMENTED, "This stored procedure syntax is not supported by Columnstore in this version");
thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
// mysql reads table twice for order by // mysql reads table twice for order by
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_REDO_PHASE1 || if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_REDO_PHASE1 ||
thd->infinidb_vtable.vtable_state == THD::INFINIDB_ORDER_BY) MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_ORDER_BY)
return 0; return 0;
if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE ) if ( (thd->lex)->sql_command == SQLCOM_ALTER_TABLE )
@ -5388,17 +5385,17 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
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 (!thd->infinidb_vtable.cal_conn_info) if (!get_fe_conn_info_ptr())
thd->infinidb_vtable.cal_conn_info = (void*)(new cal_connection_info()); set_fe_conn_info_ptr(reinterpret_cast<void*>(new cal_connection_info(), thd));
cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(thd->infinidb_vtable.cal_conn_info); cal_connection_info* ci = reinterpret_cast<cal_connection_info*>(get_fe_conn_info_ptr());
idbassert(ci != 0); idbassert(ci != 0);
// MySQL sometimes calls rnd_init multiple times, plan should only be // MySQL sometimes calls rnd_init multiple times, plan should only be
// generated and sent once. // generated and sent once.
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE && if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE &&
!thd->infinidb_vtable.isNewQuery) !MIGR::infinidb_vtable.isNewQuery)
return 0; return 0;
if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD) if (thd->killed == KILL_QUERY || thd->killed == KILL_QUERY_HARD)
@ -5436,11 +5433,11 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
// update traceFlags according to the autoswitch state. replication query // update traceFlags according to the autoswitch state. replication query
// on slave are in table mode (create table as...) // on slave are in table mode (create table as...)
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE || if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE ||
(thd->slave_thread && thd->infinidb_vtable.vtable_state == THD::INFINIDB_INIT)) (thd->slave_thread && MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_INIT))
{ {
ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; ci->traceFlags |= CalpontSelectExecutionPlan::TRACE_TUPLE_OFF;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_DISABLE_VTABLE; MIGR::infinidb_vtable.vtable_state = MIGR::INFINIDB_DISABLE_VTABLE;
} }
else else
{ {
@ -5448,11 +5445,11 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
CalpontSelectExecutionPlan::TRACE_TUPLE_OFF; CalpontSelectExecutionPlan::TRACE_TUPLE_OFF;
} }
bool localQuery = (thd->variables.infinidb_local_query > 0 ? true : false); bool localQuery = (get_local_query(thd) > 0 ? true : false);
{ {
//if (!ci->cal_conn_hndl || thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) //if (!ci->cal_conn_hndl || MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE) if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_CREATE_VTABLE)
{ {
ci->stats.reset(); // reset query stats ci->stats.reset(); // reset query stats
ci->stats.setStartTime(); ci->stats.setStartTime();
@ -5501,7 +5498,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
hndl = ci->cal_conn_hndl; hndl = ci->cal_conn_hndl;
if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE)
{ {
if (!csep) if (!csep)
csep.reset(new CalpontSelectExecutionPlan()); csep.reset(new CalpontSelectExecutionPlan());
@ -5528,7 +5525,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
csep->traceFlags(ci->traceFlags); csep->traceFlags(ci->traceFlags);
if (thd->infinidb_vtable.isInsertSelect) if (MIGR::infinidb_vtable.isInsertSelect)
csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT); csep->queryType(CalpontSelectExecutionPlan::INSERT_SELECT);
// cast the handler and get a plan. // cast the handler and get a plan.
@ -5552,13 +5549,13 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
return 0; return 0;
// @bug 2547. don't need to send the plan if it's impossible where for all unions. // @bug 2547. don't need to send the plan if it's impossible where for all unions.
if (thd->infinidb_vtable.impossibleWhereOnUnion) if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
return 0; return 0;
string query; string query;
query.assign(idb_mysql_query_str(thd)); query.assign(idb_mysql_query_str(thd));
//query.assign(thd->infinidb_vtable.original_query.ptr(), //query.assign(MIGR::infinidb_vtable.original_query.ptr(),
// thd->infinidb_vtable.original_query.length()); // MIGR::infinidb_vtable.original_query.length());
csep->data(query); csep->data(query);
try try
@ -5595,7 +5592,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
} }
}// end of execution plan generation }// end of execution plan generation
if (thd->infinidb_vtable.vtable_state != THD::INFINIDB_SELECT_VTABLE) if (MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_SELECT_VTABLE)
{ {
ByteStream msg; ByteStream msg;
ByteStream emsgBs; ByteStream emsgBs;
@ -5608,7 +5605,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
msg << qb; msg << qb;
hndl->exeMgr->write(msg); hndl->exeMgr->write(msg);
msg.restart(); msg.restart();
csep->rmParms(rmParms); csep->rmParms(ci->rmParms);
//send plan //send plan
csep->serialize(msg); csep->serialize(msg);
@ -5668,9 +5665,9 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
rmParms.clear(); ci->rmParms.clear();
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
ci->tableMap[table] = ti; ci->tableMap[table] = ti;
} }
@ -5690,7 +5687,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
idbassert(hndl != 0); idbassert(hndl != 0);
hndl->csc = csc; hndl->csc = csc;
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
ti.conn_hndl = hndl; ti.conn_hndl = hndl;
else else
ci->cal_conn_hndl = hndl; ci->cal_conn_hndl = hndl;
@ -5714,7 +5711,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
// set query state to be in_process. Sometimes mysql calls rnd_init multiple // set query state to be in_process. Sometimes mysql calls rnd_init multiple
// times, this makes sure plan only being generated and sent once. It will be // times, this makes sure plan only being generated and sent once. It will be
// reset when query finishes in sm::end_query // reset when query finishes in sm::end_query
thd->infinidb_vtable.isNewQuery = false; MIGR::infinidb_vtable.isNewQuery = false;
// common path for both vtable select phase and table mode -- open scan handle // common path for both vtable select phase and table mode -- open scan handle
ti = ci->tableMap[table]; ti = ci->tableMap[table];
@ -5784,7 +5781,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
} }
// populate coltypes here for table mode because tableband gives treeoid for dictionary column // populate coltypes here for table mode because tableband gives treeoid for dictionary column
if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE) if (MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE)
{ {
CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true); CalpontSystemCatalog::RIDList oidlist = csc->columnRIDs(make_table(table->s->db.str, table->s->table_name.str), true);

View File

@ -129,9 +129,10 @@ create_calpont_group_by_handler(THD* thd, Query* query)
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 ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE if ( MIGR::infinidb_vtable.vtable_state == MIGR::INFINIDB_DISABLE_VTABLE
&& ( thd->variables.infinidb_vtable_mode == 0 // WIP MCOL-2178
|| thd->variables.infinidb_vtable_mode == 2 ) //&& ( MIGR::infinidb_vtable_mode == 0
// || MIGR::infinidb_vtable_mode == 2 )
&& ( query->group_by || select_lex->with_sum_func ) ) && ( query->group_by || select_lex->with_sum_func ) )
{ {
bool unsupported_feature = false; bool unsupported_feature = false;
@ -213,8 +214,9 @@ create_columnstore_derived_handler(THD* thd, TABLE_LIST *derived)
SELECT_LEX_UNIT *unit= derived->derived; SELECT_LEX_UNIT *unit= derived->derived;
if ( thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE )
&& thd->variables.infinidb_vtable_mode != 0 ) // WIP MCOL-2178
// && MIGR::infinidb_vtable_mode != 0 )
{ {
return 0; return 0;
} }
@ -305,14 +307,14 @@ int ha_columnstore_derived_handler::init_scan()
derived->derived->print(&derived_query, QT_ORDINARY); derived->derived->print(&derived_query, QT_ORDINARY);
// Save vtable_state to restore the after we inited. // Save vtable_state to restore the after we inited.
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; 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);
thd->infinidb_vtable.vtable_state = oldState; MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -334,13 +336,13 @@ 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. // Save vtable_state to restore the after we inited.
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; 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);
thd->infinidb_vtable.vtable_state = oldState; MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -361,12 +363,12 @@ int ha_columnstore_derived_handler::end_scan()
{ {
DBUG_ENTER("ha_columnstore_derived_handler::end_scan"); DBUG_ENTER("ha_columnstore_derived_handler::end_scan");
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; 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);
thd->infinidb_vtable.vtable_state = oldState; MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -413,11 +415,11 @@ 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. // Save vtable_state to restore the after we inited.
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
// MCOL-1052 Should be removed after cleaning the code up. // MCOL-1052 Should be removed after cleaning the code up.
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; 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);
thd->infinidb_vtable.vtable_state = oldState; MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -471,8 +473,9 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
handlerton *ht= 0; handlerton *ht= 0;
// Return if vtable enabled. // Return if vtable enabled.
if ( thd->infinidb_vtable.vtable_state != THD::INFINIDB_DISABLE_VTABLE if ( MIGR::infinidb_vtable.vtable_state != MIGR::INFINIDB_DISABLE_VTABLE )
&& thd->variables.infinidb_vtable_mode != 0 ) // WIP MCOL-2178
// && MIGR::infinidb_vtable_mode != 0 )
{ {
return 0; return 0;
} }
@ -591,14 +594,14 @@ int ha_columnstore_select_handler::init_scan()
select->print(thd, &select_query, QT_ORDINARY); select->print(thd, &select_query, QT_ORDINARY);
// Save vtable_state to restore the after we inited. // Save vtable_state to restore the after we inited.
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; 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);
thd->infinidb_vtable.vtable_state = oldState; MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -620,13 +623,13 @@ 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. // Save vtable_state to restore the after we inited.
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE; 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);
thd->infinidb_vtable.vtable_state = oldState; MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
@ -647,12 +650,12 @@ int ha_columnstore_select_handler::end_scan()
{ {
DBUG_ENTER("ha_columnstore_select_handler::end_scan"); DBUG_ENTER("ha_columnstore_select_handler::end_scan");
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state; MIGR::infinidb_state oldState = MIGR::infinidb_vtable.vtable_state;
thd->infinidb_vtable.vtable_state = THD::INFINIDB_SELECT_VTABLE; 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);
thd->infinidb_vtable.vtable_state = oldState; MIGR::infinidb_vtable.vtable_state = oldState;
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }

View File

@ -296,225 +296,135 @@ mcs_compression_type_t get_compression_type(THD* thd) {
bool get_use_decimal_scale(THD* thd) bool get_use_decimal_scale(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? false : THDVAR(thd, use_decimal_scale);
return ( thd == NULL ) ? false : thd->variables.infinidb_use_decimal_scale;
else
return ( thd == NULL ) ? false : THDVAR(thd, use_decimal_scale);
} }
void set_use_decimal_scale(THD* thd, bool value) void set_use_decimal_scale(THD* thd, bool value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, use_decimal_scale) = value;
thd->variables.infinidb_use_decimal_scale = value;
else
THDVAR(thd, use_decimal_scale) = value;
} }
ulong get_decimal_scale(THD* thd) ulong get_decimal_scale(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, decimal_scale);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_decimal_scale;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, decimal_scale);
} }
void set_decimal_scale(THD* thd, ulong value) void set_decimal_scale(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, decimal_scale) = value;
thd->variables.infinidb_decimal_scale = value;
else
THDVAR(thd, decimal_scale) = value;
} }
bool get_ordered_only(THD* thd) bool get_ordered_only(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? false : THDVAR(thd, ordered_only);
return ( thd == NULL ) ? false : thd->variables.infinidb_ordered_only;
else
return ( thd == NULL ) ? false : THDVAR(thd, ordered_only);
} }
void set_ordered_only(THD* thd, bool value) void set_ordered_only(THD* thd, bool value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, ordered_only) = value;
thd->variables.infinidb_ordered_only = value;
else
THDVAR(thd, ordered_only) = value;
} }
ulong get_string_scan_threshold(THD* thd) ulong get_string_scan_threshold(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, string_scan_threshold);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_string_scan_threshold;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, string_scan_threshold);
} }
void set_string_scan_threshold(THD* thd, ulong value) void set_string_scan_threshold(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, string_scan_threshold) = value;
thd->variables.infinidb_string_scan_threshold = value;
else
THDVAR(thd, string_scan_threshold) = value;
} }
ulong get_stringtable_threshold(THD* thd) ulong get_stringtable_threshold(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, stringtable_threshold);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_stringtable_threshold;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, stringtable_threshold);
} }
void set_stringtable_threshold(THD* thd, ulong value) void set_stringtable_threshold(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, stringtable_threshold) = value;
thd->variables.infinidb_stringtable_threshold = value;
else
THDVAR(thd, stringtable_threshold) = value;
} }
ulong get_diskjoin_smallsidelimit(THD* thd) ulong get_diskjoin_smallsidelimit(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_smallsidelimit);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_diskjoin_smallsidelimit;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_smallsidelimit);
} }
void set_diskjoin_smallsidelimit(THD* thd, ulong value) void set_diskjoin_smallsidelimit(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, diskjoin_smallsidelimit) = value;
thd->variables.infinidb_diskjoin_smallsidelimit = value;
else
THDVAR(thd, diskjoin_smallsidelimit) = value;
} }
ulong get_diskjoin_largesidelimit(THD* thd) ulong get_diskjoin_largesidelimit(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_largesidelimit);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_diskjoin_largesidelimit;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_largesidelimit);
} }
void set_diskjoin_largesidelimit(THD* thd, ulong value) void set_diskjoin_largesidelimit(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, diskjoin_largesidelimit) = value;
thd->variables.infinidb_diskjoin_largesidelimit = value;
else
THDVAR(thd, diskjoin_largesidelimit) = value;
} }
ulong get_diskjoin_bucketsize(THD* thd) ulong get_diskjoin_bucketsize(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_bucketsize);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_diskjoin_bucketsize;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, diskjoin_bucketsize);
} }
void set_diskjoin_bucketsize(THD* thd, ulong value) void set_diskjoin_bucketsize(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, diskjoin_bucketsize) = value;
thd->variables.infinidb_diskjoin_bucketsize = value;
else
THDVAR(thd, diskjoin_bucketsize) = value;
} }
ulong get_um_mem_limit(THD* thd) ulong get_um_mem_limit(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, um_mem_limit);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_um_mem_limit;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, um_mem_limit);
} }
void set_um_mem_limit(THD* thd, ulong value) void set_um_mem_limit(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, um_mem_limit) = value;
thd->variables.infinidb_um_mem_limit = value;
else
THDVAR(thd, um_mem_limit) = value;
} }
bool get_varbin_always_hex(THD* thd) bool get_varbin_always_hex(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? false : THDVAR(thd, varbin_always_hex);
return ( thd == NULL ) ? false : thd->variables.infinidb_varbin_always_hex;
else
return ( thd == NULL ) ? false : THDVAR(thd, varbin_always_hex);
} }
void set_varbin_always_hex(THD* thd, bool value) void set_varbin_always_hex(THD* thd, bool value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, varbin_always_hex) = value;
thd->variables.infinidb_varbin_always_hex = value;
else
THDVAR(thd, varbin_always_hex) = value;
} }
bool get_double_for_decimal_math(THD* thd) bool get_double_for_decimal_math(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? false : THDVAR(thd, double_for_decimal_math);
return ( thd == NULL ) ? false : thd->variables.infinidb_double_for_decimal_math;
else
return ( thd == NULL ) ? false : THDVAR(thd, double_for_decimal_math);
} }
void set_double_for_decimal_math(THD* thd, bool value) void set_double_for_decimal_math(THD* thd, bool value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, double_for_decimal_math) = value;
thd->variables.infinidb_double_for_decimal_math = value;
else
THDVAR(thd, double_for_decimal_math) = value;
} }
ulong get_local_query(THD* thd) ulong get_local_query(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, local_query);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_local_query;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, local_query);
} }
void set_local_query(THD* thd, ulong value) void set_local_query(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, local_query) = value;
thd->variables.infinidb_local_query = value;
else
THDVAR(thd, local_query) = value;
} }
bool get_use_import_for_batchinsert(THD* thd) bool get_use_import_for_batchinsert(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? false : THDVAR(thd, use_import_for_batchinsert);
return ( thd == NULL ) ? false : thd->variables.infinidb_use_import_for_batchinsert;
else
return ( thd == NULL ) ? false : THDVAR(thd, use_import_for_batchinsert);
} }
void set_use_import_for_batchinsert(THD* thd, bool value) void set_use_import_for_batchinsert(THD* thd, bool value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, use_import_for_batchinsert) = value;
thd->variables.infinidb_use_import_for_batchinsert = value;
else
THDVAR(thd, use_import_for_batchinsert) = value;
} }
ulong get_import_for_batchinsert_delimiter(THD* thd) ulong get_import_for_batchinsert_delimiter(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_delimiter);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_import_for_batchinsert_delimiter;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_delimiter);
} }
void set_import_for_batchinsert_delimiter(THD* thd, ulong value) void set_import_for_batchinsert_delimiter(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, import_for_batchinsert_delimiter) = value;
thd->variables.infinidb_import_for_batchinsert_delimiter = value;
else
THDVAR(thd, import_for_batchinsert_delimiter) = value;
} }
ulong get_import_for_batchinsert_enclosed_by(THD* thd) ulong get_import_for_batchinsert_enclosed_by(THD* thd)
{ {
if(get_use_legacy_sysvars(thd)) return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_enclosed_by);
return ( thd == NULL ) ? 0 : thd->variables.infinidb_import_for_batchinsert_enclosed_by;
else
return ( thd == NULL ) ? 0 : THDVAR(thd, import_for_batchinsert_enclosed_by);
} }
void set_import_for_batchinsert_enclosed_by(THD* thd, ulong value) void set_import_for_batchinsert_enclosed_by(THD* thd, ulong value)
{ {
if(get_use_legacy_sysvars(thd)) THDVAR(thd, import_for_batchinsert_enclosed_by) = value;
thd->variables.infinidb_import_for_batchinsert_enclosed_by = value;
else
THDVAR(thd, import_for_batchinsert_enclosed_by) = value;
} }

View File

@ -102,7 +102,7 @@ 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);
gwi.thd->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)
{ {

View File

@ -111,6 +111,69 @@ 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;
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: