1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

MCOL-2178 Enable GBH by default.

We preserve union related condition blocks until UNION-capable smart handler.

    Removed a number of commented code blocks.

    Add projection list REAL and TIME constants, e.g
        SELECT TIME'10:20:30',  TIMESTAMP'2001-01-01 10:20:30',  DATE'2001-01-01' FROM cs1;

    Marked potentially useless block in ORDER BY processing for future removal.

    Removed string variables used for reconstructed query in the pre-1.4 fork.

    Removed cp_get_plan().

    GBH doesn't step in if SH processes the query.

    All smart handlers now correctly processes impossible WHERE and HAVING.
This commit is contained in:
Roman Nozdrin
2019-08-12 21:02:32 +03:00
parent a1d1bd7392
commit f0c83a4a1f
6 changed files with 82 additions and 403 deletions

View File

@ -22,8 +22,6 @@ SET ( libcalmysql_SRCS
ha_pseudocolumn.cpp)
add_definitions(-DMYSQL_DYNAMIC_PLUGIN)
add_definitions(-DEBUG_WALK_COND)
add_definitions(-DINFINIDB_DEBUG)
set_source_files_properties(ha_calpont.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti -fno-implicit-templates")

View File

@ -143,7 +143,7 @@ static int columnstore_init_func(void* p)
mcs_hton->commit = calpont_commit;
mcs_hton->rollback = calpont_rollback;
mcs_hton->close_connection = calpont_close_connection;
//mcs_hton->create_group_by = create_calpont_group_by_handler;
mcs_hton->create_group_by = create_calpont_group_by_handler;
mcs_hton->create_derived = create_columnstore_derived_handler;
mcs_hton->create_select = create_columnstore_select_handler;
DBUG_RETURN(0);

View File

@ -207,7 +207,6 @@ bool nonConstFunc(Item_func* ifp)
***********************************************************/
void getColNameFromItem(std::ostringstream& ostream, Item* item)
{
// MCOL-2121 WIP
// Item_func doesn't have proper db.table.field values
// inherited from Item_ident. TBD what is the valid output.
// !!!dynamic_cast fails compilation
@ -1321,7 +1320,7 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex)
{
if (gwi.thd->derived_tables_processing)
{
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = false;
gwi.cs_vtable_is_update_with_derive = true;
return -1;
@ -5149,12 +5148,6 @@ void gp_walk(const Item* item, void* arg)
gwip->rcWorkStack.push(buildReturnedColumn(itp, *gwip, gwip->fatalParseError));
break;
}
/*case Item::VARBIN_ITEM:
{
Item_hex_string* hdp = (Item_hex_string*)item;
gwip->rcWorkStack.push(buildReturnedColumn(hdp, *gwip, gwip->fatalParseError));
break;
}*/
default:
{
if (gwip->condPush)
@ -5622,7 +5615,7 @@ void gp_walk(const Item* item, void* arg)
gwip->hasSubSelect = true;
gwip->subQuery = existsSub;
gwip->ptWorkStack.push(existsSub->transform());
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = true; // only temp. bypass the 2nd phase.
// recover original
gwip->subQuery = orig;
@ -5718,19 +5711,6 @@ void gp_walk(const Item* item, void* arg)
printf("********** received TRIGGER_FIELD_ITEM *********\n");
break;
/* WIP MCOL-2178
case Item::XPATH_NODESET:
printf("********** received XPATH_NODESET *********\n");
break;
case Item::XPATH_NODESET_CMP:
printf("********** received XPATH_NODESET_CMP *********\n");
break;
case Item::VIEW_FIXER_ITEM:
printf("********** received VIEW_FIXER_ITEM *********\n");
break;
*/
case Item::TYPE_HOLDER:
std::cerr << "********** received TYPE_HOLDER *********" << std::endl;
break;
@ -5983,7 +5963,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_DELETE_MULTI ) ) && gwi.thd->derived_tables_processing)
{
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = false;
return -1;
}
@ -6118,7 +6098,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
gwi.tbList.push_back(tn);
CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias);
gwi.tableMap[tan] = make_pair(0, table_ptr);
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init
}
else if (table_ptr->view)
@ -6190,7 +6170,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// is_unit_op() give a segv for derived_handler's SELECT_LEX
if (!isUnion && select_lex.master_unit()->is_unit_op())
{
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = true;
CalpontSelectExecutionPlan::SelectList unionVec;
SELECT_LEX* select_cursor = select_lex.master_unit()->first_select();
@ -6283,7 +6263,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// processing.
if (gwi.thd->derived_tables_processing)
{
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = false;
gwi.cs_vtable_is_update_with_derive = true;
return -1;
@ -6442,9 +6422,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
Item* item;
vector <Item_field*> funcFieldVec;
string sel_cols_in_select;
bool redo = false;
// empty rcWorkStack and ptWorkStack. They should all be empty by now.
clearStacks(gwi);
@ -6509,12 +6486,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
}
if (ifp->is_autogenerated_name)
gwi.selectCols.push_back("`" + escapeBackTick(fullname.c_str()) + "`" + " `" +
escapeBackTick(itemAlias.empty() ? ifp->name.str : itemAlias.c_str()) + "`");
else
gwi.selectCols.push_back("`" + escapeBackTick((itemAlias.empty() ? ifp->name.str : itemAlias.c_str())) + "`");
gwi.returnedCols.push_back(spsc);
gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(ifp->field_name.str), spsc));
@ -6552,10 +6523,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
// add this agg col to returnedColumnList
boost::shared_ptr<ReturnedColumn> spac(ac);
gwi.returnedCols.push_back(spac);
gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`');
String str(256);
item->print(&str, QT_ORDINARY);
break;
}
@ -6717,11 +6684,17 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
break;
} // End of FUNC_ITEM
// DRRTUY Replace the whole section with typeid() checks or use
// reinterpret_cast here
case Item::CONST_ITEM:
{
switch(item->cmp_type())
{
case INT_RESULT:
case STRING_RESULT:
case DECIMAL_RESULT:
case REAL_RESULT:
case TIME_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
{ }
@ -6738,71 +6711,15 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
srcp->alias(item->name.str);
gwi.returnedCols.push_back(srcp);
Item_int* isp = reinterpret_cast<Item_int*>(item);
ostringstream oss;
oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`";
gwi.selectCols.push_back(oss.str());
}
break;
}
case STRING_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
{ }
else
{
SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError));
gwi.returnedCols.push_back(srcp);
if (item->name.length)
srcp->alias(item->name.str);
Item_string* isp = reinterpret_cast<Item_string*>(item);
String val, *str = isp->val_str(&val);
string valStr;
valStr.assign(str->ptr(), str->length());
string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`";
gwi.selectCols.push_back(name);
}
break;
}
case DECIMAL_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
{ }
else
{
SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError));
gwi.returnedCols.push_back(srcp);
if (item->name.length)
srcp->alias(item->name.str);
Item_decimal* isp = reinterpret_cast<Item_decimal*>(item);
String val, *str = isp->val_str(&val);
string valStr;
valStr.assign(str->ptr(), str->length());
ostringstream oss;
oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`";
gwi.selectCols.push_back(oss.str());
}
break;
}
// WIP MCOL-2178 This switch doesn't handl
// ROW_, TIME_, REAL_RESULT and if one couldn't
// project the former two REAL is possible.
// Need to test before commit.
// MCOL-2178 This switch doesn't handl
// ROW_
default:
{
IDEBUG(cerr << "Warning unsupported cmp_type() in projection" << endl);
//noop
}
}
@ -6820,10 +6737,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
if (item->name.length)
srcp->alias(item->name.str);
string name = string("null `") + escapeBackTick(srcp->alias().c_str()) + string("`") ;
gwi.selectCols.push_back("null");
}
break;
@ -6880,17 +6793,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
rc->alias(sub->name.str);
gwi.returnedCols.push_back(SRCP(rc));
String str;
sub->get_select_lex()->print(gwi.thd, &str, QT_ORDINARY);
if (sub->name.length)
{
gwi.selectCols.push_back(sub->name.str);
}
else
{
gwi.selectCols.push_back("`" + escapeBackTick(str.c_ptr()) + "`");
}
break;
}
@ -7442,8 +7344,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
else if (ord_item->type() == Item::CONST_ITEM
&& ord_item->cmp_type() == INT_RESULT)
{
// WIP MCOL-2178. We should seek smallest
// column here and not just previous.
// DRRTUY This section looks useless b/c there is no
// way to put constant INT into an ORDER BY list
rc = gwi.returnedCols[((Item_int*)ord_item)->val_int() - 1]->clone();
}
else if (ord_item->type() == Item::SUBSELECT_ITEM)
@ -7484,6 +7386,8 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
gwi.orderByCols.push_back(SRCP(rc));
}
}
// DRRTUY The whole block is marked for removal in 1.4.1
#if 0
else if (!isUnion)
{
vector <Item_field*> fieldVec;
@ -7590,12 +7494,9 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
}
}
}
}
redo = (redo || fieldVec.size() != 0);
// populate string to be added to the select list for order by
for (uint32_t i = 0; i < fieldVec.size(); i++)
{
@ -7635,6 +7536,7 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
}
}
}
#endif
// make sure columnmap, returnedcols and count(*) arg_list are not empty
TableMap::iterator tb_iter = gwi.tableMap.begin();
@ -7715,9 +7617,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
if (!isUnion && !gwi.hasWindowFunc
&& gwi.subSelectType == CalpontSelectExecutionPlan::MAIN_SELECT )
{
std::ostringstream vtb;
vtb << "infinidb_vtable.$vtable_" << gwi.thd->thread_id;
{
if (unionSel)
order_list = select_lex.master_unit()->global_parameters()->order_list;
@ -7760,12 +7659,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
}
}
}
else
{
String str;
ord_item->print(&str, QT_ORDINARY);
}
}
}
@ -7982,35 +7875,6 @@ int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex,
return 0;
}
int cp_get_plan(THD* thd, SCSEP& csep)
{
LEX* lex = thd->lex;
idbassert(lex != 0);
gp_walk_info gwi;
gwi.thd = thd;
// WIP MCOL-2178 A questionable replacement.
SELECT_LEX select_lex = *lex->first_select_lex();
int status = getSelectPlan(gwi, select_lex, csep);
if (status > 0)
return ER_INTERNAL_ERROR;
else if (status < 0)
return status;
#ifdef DEBUG_WALK_COND
cerr << "---------------- cp_get_plan EXECUTION PLAN ----------------" << endl;
cerr << *csep << endl ;
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
#endif
// Derived table projection and filter optimization.
derivedTableOptimization(thd, csep);
return 0;
}
int cp_get_table_plan(THD* thd, SCSEP& csep, cal_table_info& ti)
{
gp_walk_info* gwi = ti.condInfo;
@ -8143,7 +8007,7 @@ int cs_get_derived_plan(derived_handler* handler, THD* thd, SCSEP& csep, gp_walk
return status;
#ifdef DEBUG_WALK_COND
cerr << "---------------- cp_get_derived_plan EXECUTION PLAN ----------------" << endl;
cerr << "---------------- cs_get_derived_plan EXECUTION PLAN ----------------" << endl;
cerr << *csep << endl ;
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
#endif
@ -8163,7 +8027,7 @@ int cs_get_select_plan(select_handler* handler, THD* thd, SCSEP& csep, gp_walk_i
return status;
#ifdef DEBUG_WALK_COND
cerr << "---------------- cp_get_select_plan EXECUTION PLAN ----------------" << endl;
cerr << "---------------- cs_get_select_plan EXECUTION PLAN ----------------" << endl;
cerr << *csep << endl ;
cerr << "-------------- EXECUTION PLAN END --------------\n" << endl;
#endif
@ -8352,12 +8216,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.tbList.push_back(tn);
CalpontSystemCatalog::TableAliasName tan = make_aliastable("", alias, alias);
gwi.tableMap[tan] = make_pair(0, table_ptr);
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init
}
else if (table_ptr->view)
{
// WIP MCOL-2178 A questionable replacement.
View* view = new View(*table_ptr->view->first_select_lex(), &gwi);
CalpontSystemCatalog::TableAliasName tn = make_aliastable(table_ptr->db.str, table_ptr->table_name.str, table_ptr->alias.str);
view->viewName(tn);
@ -8451,7 +8314,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// processing.
if (gwi.thd->derived_tables_processing)
{
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
//MIGR::infinidb_vtable.isUnion = false;
return -1;
}
@ -8622,12 +8485,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
}
if (ifp->is_autogenerated_name)
gwi.selectCols.push_back("`" + escapeBackTick(fullname.c_str()) + "`" + " `" +
escapeBackTick(itemAlias.empty() ? ifp->name.str : itemAlias.c_str()) + "`");
else
gwi.selectCols.push_back("`" + escapeBackTick((itemAlias.empty() ? ifp->name.str : itemAlias.c_str())) + "`");
// MCOL-1052 Replace SimpleColumn with ConstantColumn,
// since it must have a single value only.
if (constCol)
@ -8678,10 +8535,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// This item could be used in projection or HAVING later.
gwi.extSelAggColsItems.push_back(item);
gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`');
String str(256);
item->print(&str, QT_ORDINARY);
break;
}
@ -8741,34 +8594,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
continue;
}
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) ||
((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) ||
((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ||
((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) )
{ }
else
{
redo = true;
String str;
ifp->print(&str, QT_ORDINARY);
gwi.selectCols.push_back(string(str.c_ptr()) + " " + "`" + escapeBackTick(item->name.str) + "`");
}
break;
}
//SRCP srcp(rc);
gwi.returnedCols.push_back(srcp);
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
{ }
else
{
String str(256);
ifp->print(&str, QT_ORDINARY);
gwi.selectCols.push_back("`" + escapeBackTick(ifp->name.str) + "`");
}
}
else // InfiniDB Non support functions still go through post process for now
{
@ -8860,18 +8690,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
return -1;
}
}
//@Bug 3021. Bypass postprocess for update and delete.
//if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
//{}
else
{
// @bug 3881. Here is the real redo part.
redo = true;
// @bug 1706
String funcStr;
ifp->print(&funcStr, QT_ORDINARY);
gwi.selectCols.push_back(string(funcStr.c_ptr()) + " `" + escapeBackTick(ifp->name.str) + "`");
// clear the error set by buildFunctionColumn
gwi.fatalParseError = false;
gwi.parseErrorText = "";
@ -8881,11 +8701,17 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
break;
}
// DRRTUY Replace the whole section with typeid() checks or use
// reinterpret_cast here
case Item::CONST_ITEM:
{
switch(item->cmp_type())
{
case INT_RESULT:
case STRING_RESULT:
case DECIMAL_RESULT:
case REAL_RESULT:
case TIME_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
{ }
@ -8902,69 +8728,16 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
srcp->alias(item->name.str);
gwi.returnedCols.push_back(srcp);
Item_int* isp = reinterpret_cast<Item_int*>(item);
ostringstream oss;
oss << isp->value << " `" << escapeBackTick(srcp->alias().c_str()) << "`";
gwi.selectCols.push_back(oss.str());
}
break;
}
case STRING_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
{ }
else
{
SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError));
gwi.returnedCols.push_back(srcp);
if (item->name.length)
srcp->alias(item->name.str);
Item_string* isp = reinterpret_cast<Item_string*>(item);
String val, *str = isp->val_str(&val);
string valStr;
valStr.assign(str->ptr(), str->length());
string name = "'" + valStr + "'" + " " + "`" + escapeBackTick(srcp->alias().c_str()) + "`";
gwi.selectCols.push_back(name);
}
break;
}
case DECIMAL_RESULT:
{
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ))
{ }
else
{
SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError));
gwi.returnedCols.push_back(srcp);
if (item->name.length)
srcp->alias(item->name.str);
Item_decimal* isp = reinterpret_cast<Item_decimal*>(item);
String val, *str = isp->val_str(&val);
string valStr;
valStr.assign(str->ptr(), str->length());
ostringstream oss;
oss << valStr.c_str() << " `" << escapeBackTick(srcp->alias().c_str()) << "`";
gwi.selectCols.push_back(oss.str());
}
break;
}
// MCOL-2178 This switch doesn't handl
// ROW_
default:
// WIP MCOL-2178 Same thing as for getSelectPlan
{
// noop
IDEBUG(cerr << "Warning unsupported cmp_type() in projection" << endl);
}
}
break;
@ -8972,25 +8745,16 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
case Item::NULL_ITEM:
{
// WIP MCOL-2178 Check for NULL in projection.
/*if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) )
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE_MULTI ) )
{ }
else
{
SRCP srcp(buildReturnedColumn(item, gwi, gwi.fatalParseError));
gwi.returnedCols.push_back(srcp);
if (item->name)
srcp->alias(item->name);
string name = string("null `") + escapeBackTick(srcp->alias().c_str()) + string("`") ;
if (sel_cols_in_create.length() != 0)
sel_cols_in_create += ", ";
sel_cols_in_create += name;
gwi.selectCols.push_back("null");
}*/
if (item->name.length)
srcp->alias(item->name.str);
}
break;
}
@ -9047,14 +8811,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.returnedCols.push_back(SRCP(rc));
if (sub->name.length)
{
gwi.selectCols.push_back(sub->name.str);
}
else
{
}
break;
}
@ -9764,9 +9520,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
if (!isUnion && !gwi.hasWindowFunc && gwi.subSelectType == CalpontSelectExecutionPlan::MAIN_SELECT)
{
std::ostringstream vtb;
vtb << "infinidb_vtable.$vtable_" << gwi.thd->thread_id;
// re-construct the select query and redo phase 1
if (redo)
{

View File

@ -764,7 +764,7 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
// bug 3483, reserve enough space for the longest double value
// -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and
// 2.2250738585072014E-308 to 1.7976931348623157E+308.
(*f)->field_length = 40;
(*f)->field_length = 310;
f2->store(dl);
@ -2262,26 +2262,6 @@ int ha_calpont_impl_discover_existence(const char* schema, const char* name)
int ha_calpont_impl_rnd_init(TABLE* table)
{
#ifdef DEBUG_SETENV
string home(getenv("HOME"));
if (!getenv("COLUMNSTORE_HOME"))
{
string calpontHome(home + "/Calpont/etc/");
setenv("COLUMNSTORE_HOME", calpontHome.c_str(), 1);
}
if (!getenv("COLUMNSTORE_CONFIG_FILE"))
{
string calpontConfigFile(home + "/mariadb/columnstore/etc/Columnstore.xml");
setenv("COLUMNSTORE_CONFIG_FILE", calpontConfigFile.c_str(), 1);
}
if (!getenv("CALPONT_CSC_IDENT"))
setenv("CALPONT_CSC_IDENT", "dm", 1);
#endif
IDEBUG( cout << "rnd_init for table " << table->s->table_name.str << endl );
THD* thd = current_thd;
@ -2664,7 +2644,7 @@ int ha_calpont_impl_rnd_next(uchar* buf, TABLE* table)
return HA_ERR_END_OF_FILE;
// @bug 2547
// TODO MCOL-2178 This variable can never be true in the scope of this function
// MCOL-2178 This variable can never be true in the scope of this function
// if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
// return HA_ERR_END_OF_FILE;
@ -2756,9 +2736,7 @@ int ha_calpont_impl_rnd_end(TABLE* table, bool is_pushdown_hand)
return 0;
// WIP MCOL-2178
// Workaround because CS doesn't reset isUnion in a normal way.
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
// if (is_pushdown_hand)
// {
// MIGR::infinidb_vtable.isUnion = false;
@ -2891,10 +2869,6 @@ 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());
// @bug1940 Do nothing for select query. Support of set default engine to IDB.
if (string(name).find("@0024vtable") != string::npos)
return 0;
//@Bug 1948. Mysql calls create table to create a new table with new signature.
if (ci->alterTableState > 0) return 0;
@ -2930,10 +2904,6 @@ int ha_calpont_impl_delete_table(const char* name)
//if this is an InfiniDB tmp table ('#sql*.frm') just leave...
if (!memcmp((uchar*)name, tmp_file_prefix, tmp_file_prefix_length)) return 0;
// @bug1940 Do nothing for select query. Support of set default engine to IDB.
if (string(name).find("@0024vtable") != string::npos)
return 0;
if (get_fe_conn_info_ptr() == NULL)
set_fe_conn_info_ptr((void*)new cal_connection_info());
@ -2970,22 +2940,6 @@ int ha_calpont_impl_delete_table(const char* name)
return 0;
}
// @bug 1793. make vtable droppable in calpontsys. "$vtable" ==> "@0024vtable" passed in as name.
if (strcmp(dbName, "calpontsys") == 0 && string(name).find("@0024vtable") == string::npos)
{
std::string stmt(idb_mysql_query_str(thd));
boost::algorithm::to_upper(stmt);
//@Bug 2432. systables can be dropped with restrict
if (stmt.find(" RESTRICT") != string::npos)
{
return 0;
}
setError(thd, ER_INTERNAL_ERROR, "Calpont system tables can only be dropped with restrict.");
return 1;
}
int rc = ha_calpont_impl_delete_table_(dbName, name, *ci);
return rc;
}
@ -4355,14 +4309,13 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
// send plan whenever group_init is called
int status = cp_get_group_plan(thd, csep, gi);
// WIP MCOL-2178 This could be a problem
if (status > 0)
// Never proceed if status != 0 to avoid empty DA
// crashes on later stages
if (status != 0)
goto internal_error;
else if (status < 0)
return 0;
// @bug 2547. don't need to send the plan if it's impossible where for all unions.
// TODO MCOL-2178 commenting the below out since cp_get_group_plan does not modify this variable
// MCOL-2178 commenting the below out since cp_get_group_plan does not modify this variable
// which has a default value of false
//if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
// return 0;
@ -4632,7 +4585,7 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE
return HA_ERR_END_OF_FILE;
// @bug 2547
// TODO MCOL-2178
// MCOL-2178
// if (MIGR::infinidb_vtable.impossibleWhereOnUnion)
// return HA_ERR_END_OF_FILE;
@ -4728,7 +4681,7 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE*
thd->lex->sql_command == SQLCOM_LOAD))
return 0;
// TODO MCOL-2178 isUnion member only assigned, never used
// MCOL-2178 isUnion member only assigned, never used
// MIGR::infinidb_vtable.isUnion = false;
if (get_fe_conn_info_ptr() != NULL)
@ -4894,26 +4847,6 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE*
***********************************************************/
int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
{
#ifdef DEBUG_SETENV
string home(getenv("HOME"));
if (!getenv("CALPONT_HOME"))
{
string calpontHome(home + "/Calpont/etc/");
setenv("CALPONT_HOME", calpontHome.c_str(), 1);
}
if (!getenv("CALPONT_CONFIG_FILE"))
{
string calpontConfigFile(home + "/Calpont/etc/Columnstore.xml");
setenv("CALPONT_CONFIG_FILE", calpontConfigFile.c_str(), 1);
}
if (!getenv("CALPONT_CSC_IDENT"))
setenv("CALPONT_CSC_IDENT", "dm", 1);
#endif
IDEBUG( cout << "pushdown_init for table " << endl );
THD* thd = current_thd;
@ -5052,8 +4985,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
hndl = ci->cal_conn_hndl;
// WIP MCOL-2178
std::cout << idb_mysql_query_str(thd) << std::endl;
IDEBUG( std::cout << idb_mysql_query_str(thd) << std::endl );
{
if (!csep)
@ -5094,15 +5026,10 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
status = cs_get_derived_plan(dh, thd, csep, gwi);
}
// WIP MCOL-2178 Remove this
std::cout << "pushdown_init get_plan status " << status << std::endl;
// Return an error to avoid MDB crash later in end_statement
if (status != 0)
goto internal_error;
// WIP MCOL-2178 Remove this
std::cout << "pushdown_init impossibleWhereOnUnion " << status << std::endl;
// @bug 2547. don't need to send the plan if it's impossible where for all unions.
if (gwi.cs_vtable_impossible_where_on_union)
{
@ -5123,6 +5050,7 @@ int ha_cs_impl_pushdown_init(mcs_handler_info* handler_info, TABLE* table)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str());
}
// DRRTUY Make this runtime configureable
#ifdef PLAN_HEX_FILE
// plan serialization
ifstream ifs("/tmp/li1-plan.hex");

View File

@ -94,6 +94,7 @@ typedef std::map<execplan::CalpontSystemCatalog::TableAliasName, std::pair<int,
struct gp_walk_info
{
// MCOL-2178 Marked for removal after 1.4
std::vector <std::string> selectCols;
execplan::CalpontSelectExecutionPlan::ReturnedColumnList returnedCols;
execplan::CalpontSelectExecutionPlan::ReturnedColumnList groupByCols;

View File

@ -149,17 +149,17 @@ create_calpont_group_by_handler(THD* thd, Query* query)
{
ha_calpont_group_by_handler* handler = NULL;
// same as thd->lex->current_select
SELECT_LEX *select_lex = query->from->select_lex;
// MCOL-2178 Disable SP support in the group_by_handler for now
// Check the session variable value to enable/disable use of
// group_by_handler
if (!get_group_by_handler(thd) || (thd->lex)->sphead)
// group_by_handler. There is no GBH if SH works for the query.
if (select_lex->select_h || !get_group_by_handler(thd) || (thd->lex)->sphead)
{
return handler;
}
// same as thd->lex->current_select
SELECT_LEX *select_lex = query->from->select_lex;
// Create a handler if query is valid. See comments for details.
if ( query->group_by || select_lex->with_sum_func )
{
@ -172,7 +172,7 @@ create_calpont_group_by_handler(THD* thd, Query* query)
unsupported_feature = select_lex->is_correlated;
// Impossible HAVING or WHERE
if ( ( !unsupported_feature && query->having && select_lex->having_value == Item::COND_FALSE )
if ( ( !unsupported_feature && select_lex->having_value == Item::COND_FALSE )
|| ( select_lex->cond_count > 0
&& select_lex->cond_value == Item::COND_FALSE ) )
{
@ -473,11 +473,10 @@ create_columnstore_select_handler(THD* thd, SELECT_LEX* select_lex)
}
// Impossible HAVING or WHERE
// WIP replace with function call
// TODO replace with function call
if ( unsupported_feature
|| ( select_lex->having && select_lex->having_value == Item::COND_FALSE )
|| ( select_lex->cond_count > 0
&& select_lex->cond_value == Item::COND_FALSE ) )
|| select_lex->having_value == Item::COND_FALSE
|| select_lex->cond_value == Item::COND_FALSE )
{
unsupported_feature = true;
}