1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00
This commit is contained in:
David Hall
2018-05-17 16:06:01 -05:00
2 changed files with 72 additions and 100 deletions

View File

@@ -508,8 +508,8 @@ void debug_walk(const Item* item, void* arg)
{ {
item_name = isp->get_arg(0)->name; item_name = isp->get_arg(0)->name;
} }
else if (!item_name && isp->get_arg_count() else if (!item_name && isp->get_arg_count()
&& isp->get_arg(0)->type() == Item::INT_ITEM) && isp->get_arg(0)->type() == Item::INT_ITEM)
{ {
item_name = (char*)"INT||*"; item_name = (char*)"INT||*";
} }
@@ -707,19 +707,17 @@ void debug_walk(const Item* item, void* arg)
else if (ref->real_item()->type() == Item::FIELD_ITEM) else if (ref->real_item()->type() == Item::FIELD_ITEM)
{ {
Item_field* ifp = (Item_field*)ref->real_item(); Item_field* ifp = (Item_field*)ref->real_item();
// MCOL-1052 The field referenced presumable came from // MCOL-1052 The field referenced presumable came from
// extended SELECT list. // extended SELECT list.
if ( !ifp->field_name ) if ( !ifp->field_name )
{ {
cerr << "REF extra FIELD_ITEM: " << ifp->name << endl; cerr << "REF extra FIELD_ITEM: " << ifp->name << endl;
} }
else else
{ {
cerr << "REF FIELD_ITEM: " << ifp->db_name << '.' << bestTableName(ifp) << '.' << cerr << "REF FIELD_ITEM: " << ifp->db_name << '.' << bestTableName(ifp) << '.' <<
ifp->field_name << endl; ifp->field_name << endl;
} }
break; break;
} }
else if (ref->real_item()->type() == Item::FUNC_ITEM) else if (ref->real_item()->type() == Item::FUNC_ITEM)
@@ -921,13 +919,12 @@ void debug_walk(const Item* item, void* arg)
cerr << "Window Function Item " << ifp->window_func()->func_name() << endl; cerr << "Window Function Item " << ifp->window_func()->func_name() << endl;
break; break;
} }
case Item::NULL_ITEM: case Item::NULL_ITEM:
{ {
cerr << "NULL item" << endl; cerr << "NULL item" << endl;
break; break;
} }
default: default:
{ {
cerr << "UNKNOWN_ITEM type " << item->type() << endl; cerr << "UNKNOWN_ITEM type " << item->type() << endl;
@@ -1009,8 +1006,8 @@ uint32_t buildOuterJoin(gp_walk_info& gwi, SELECT_LEX& select_lex)
// View is already processed in view::transform // View is already processed in view::transform
// @bug5319. view is sometimes treated as derived table and // @bug5319. view is sometimes treated as derived table and
// fromSub::transform does not build outer join filters. // fromSub::transform does not build outer join filters.
if (!table_ptr->derived && table_ptr->view) //if (!table_ptr->derived && table_ptr->view)
continue; // continue;
CalpontSystemCatalog:: TableAliasName tan = make_aliasview( CalpontSystemCatalog:: TableAliasName tan = make_aliasview(
(table_ptr->db ? table_ptr->db : ""), (table_ptr->db ? table_ptr->db : ""),
@@ -5129,9 +5126,8 @@ void gp_walk(const Item* item, void* arg)
gwip->clauseType = SELECT; gwip->clauseType = SELECT;
if (col->type() != Item::COND_ITEM) if (col->type() != Item::COND_ITEM)
{ {
rc = buildReturnedColumn(col, *gwip, gwip->fatalParseError); rc = buildReturnedColumn(col, *gwip, gwip->fatalParseError);
if ( col->type() == Item::FIELD_ITEM ) if ( col->type() == Item::FIELD_ITEM )
gwip->fatalParseError = false; gwip->fatalParseError = false;
} }
@@ -5210,25 +5206,20 @@ void gp_walk(const Item* item, void* arg)
{ {
Item_field* ifip = static_cast<Item_field*>(col); Item_field* ifip = static_cast<Item_field*>(col);
std::vector<Item*>::iterator iter = gwip->havingAggColsItems.begin(); std::vector<Item*>::iterator iter = gwip->havingAggColsItems.begin();
Item_func_or_sum* isfp = NULL; Item_func_or_sum *isfp = NULL;
for( ;iter != gwip->havingAggColsItems.end(); iter++ )
for ( ; iter != gwip->havingAggColsItems.end(); iter++ )
{ {
Item* temp_isfp = *iter; Item *temp_isfp = *iter;
isfp = reinterpret_cast<Item_func_or_sum*>(temp_isfp); isfp = reinterpret_cast<Item_func_or_sum*>(temp_isfp);
if ( isfp->type() == Item::SUM_FUNC_ITEM && if ( isfp->type() == Item::SUM_FUNC_ITEM &&
isfp->result_field == ifip->field ) isfp->result_field == ifip->field )
{ {
ReturnedColumn* rc = buildAggregateColumn(isfp, *gwip); ReturnedColumn* rc = buildAggregateColumn(isfp, *gwip);
if (rc) if (rc)
gwip->rcWorkStack.push(rc); gwip->rcWorkStack.push(rc);
break; break;
} }
} }
break; break;
} }
else else
@@ -8090,9 +8081,9 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
/*@brief buildConstColFromFilter- change SimpleColumn into ConstColumn*/ /*@brief buildConstColFromFilter- change SimpleColumn into ConstColumn*/
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
* Server could optimize out fields from GROUP BY list, when certain * Server could optimize out fields from GROUP BY list, when certain
* filter predicate is used, e.g. * filter predicate is used, e.g.
* field = 'AIR', field IN ('AIR'). This utility function tries to * field = 'AIR', field IN ('AIR'). This utility function tries to
* replace such fields with ConstantColumns using cond_pushed filters. * replace such fields with ConstantColumns using cond_pushed filters.
* PARAMETERS: * PARAMETERS:
* originalSC SimpleColumn* removed field * originalSC SimpleColumn* removed field
@@ -8102,8 +8093,8 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
* ConstantColumn* if originalSC equals with cond_pushed columns. * ConstantColumn* if originalSC equals with cond_pushed columns.
* NULL otherwise * NULL otherwise
***********************************************************/ ***********************************************************/
ConstantColumn* buildConstColFromFilter(SimpleColumn* originalSC, ConstantColumn* buildConstColFromFilter(SimpleColumn* originalSC,
gp_walk_info& gwi, cal_group_info& gi) gp_walk_info& gwi, cal_group_info& gi)
{ {
execplan::SimpleColumn* simpleCol; execplan::SimpleColumn* simpleCol;
execplan::ConstantColumn* constCol; execplan::ConstantColumn* constCol;
@@ -8111,24 +8102,18 @@ ConstantColumn* buildConstColFromFilter(SimpleColumn* originalSC,
execplan::SimpleFilter* simpFilter; execplan::SimpleFilter* simpFilter;
execplan::ConstantColumn* result = NULL; execplan::ConstantColumn* result = NULL;
std::vector<ParseTree*>::iterator ptIt = gi.pushedPts.begin(); std::vector<ParseTree*>::iterator ptIt = gi.pushedPts.begin();
for(; ptIt != gi.pushedPts.end(); ptIt++)
for (; ptIt != gi.pushedPts.end(); ptIt++)
{ {
simpFilter = dynamic_cast<execplan::SimpleFilter*>((*ptIt)->data()); simpFilter = dynamic_cast<execplan::SimpleFilter*>((*ptIt)->data());
if (simpFilter == NULL) if (simpFilter == NULL)
continue; continue;
simpleCol = dynamic_cast<execplan::SimpleColumn*>(simpFilter->lhs()); simpleCol = dynamic_cast<execplan::SimpleColumn*>(simpFilter->lhs());
constCol = dynamic_cast<execplan::ConstantColumn*>(simpFilter->rhs()); constCol = dynamic_cast<execplan::ConstantColumn*>(simpFilter->rhs());
if(simpleCol == NULL || constCol == NULL)
if (simpleCol == NULL || constCol == NULL)
continue; continue;
op = simpFilter->op(); op = simpFilter->op();
if ( originalSC->sameColumn(dynamic_cast<execplan::ReturnedColumn*>(simpleCol))
if ( originalSC->sameColumn(dynamic_cast<execplan::ReturnedColumn*>(simpleCol)) && op.get()->op() == OP_EQ && constCol)
&& op.get()->op() == OP_EQ && constCol)
{ {
#ifdef DEBUG_WALK_COND #ifdef DEBUG_WALK_COND
cerr << "buildConstColFromFilter() replaced " << endl; cerr << "buildConstColFromFilter() replaced " << endl;
@@ -8139,7 +8124,6 @@ ConstantColumn* buildConstColFromFilter(SimpleColumn* originalSC,
result = constCol; result = constCol;
} }
} }
return result; return result;
} }
@@ -8160,10 +8144,10 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.internalDecimalScale = (gwi.thd->variables.infinidb_use_decimal_scale ? gwi.thd->variables.infinidb_decimal_scale : -1); gwi.internalDecimalScale = (gwi.thd->variables.infinidb_use_decimal_scale ? gwi.thd->variables.infinidb_decimal_scale : -1);
gwi.subSelectType = csep->subType(); gwi.subSelectType = csep->subType();
JOIN* join = select_lex.join; JOIN* join = select_lex.join;
Item_cond* icp = 0; Item_cond* icp = 0;
if ( gi.groupByWhere ) if ( gi.groupByWhere )
icp = reinterpret_cast<Item_cond*>(gi.groupByWhere); icp = reinterpret_cast<Item_cond*>(gi.groupByWhere);
@@ -8328,12 +8312,12 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.clauseType = WHERE; gwi.clauseType = WHERE;
if (icp) if (icp)
{ {
// MCOL-1052 The condition could be useless. // MCOL-1052 The condition could be useless.
// MariaDB bug 624 - without the fix_fields call, delete with join may error with "No query step". // MariaDB bug 624 - without the fix_fields call, delete with join may error with "No query step".
//#if MYSQL_VERSION_ID < 50172 //#if MYSQL_VERSION_ID < 50172
//@bug 3039. fix fields for constants //@bug 3039. fix fields for constants
if (!icp->fixed) if (!icp->fixed)
{ {
@@ -8371,7 +8355,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
{ {
gwi.rcWorkStack.push(new ConstantColumn((int64_t)0, ConstantColumn::NUM)); gwi.rcWorkStack.push(new ConstantColumn((int64_t)0, ConstantColumn::NUM));
} }
uint32_t failed = buildOuterJoin(gwi, select_lex); uint32_t failed = buildOuterJoin(gwi, select_lex);
if (failed) return failed; if (failed) return failed;
@@ -8433,7 +8417,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
#ifdef DEBUG_WALK_COND #ifdef DEBUG_WALK_COND
{ {
cerr << "------------------- SELECT --------------------" << endl; cerr << "------------------- SELECT --------------------" << endl;
List_iterator_fast<Item> it(*gi.groupByFields); List_iterator_fast<Item> it(*gi.groupByFields);
Item* item; Item* item;
while ((item = it++)) while ((item = it++))
@@ -8531,10 +8515,10 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
escapeBackTick(itemAlias.empty() ? ifp->name : itemAlias.c_str()) + "`"); escapeBackTick(itemAlias.empty() ? ifp->name : itemAlias.c_str()) + "`");
else else
gwi.selectCols.push_back("`" + escapeBackTick((itemAlias.empty() ? ifp->name : itemAlias.c_str())) + "`"); gwi.selectCols.push_back("`" + escapeBackTick((itemAlias.empty() ? ifp->name : itemAlias.c_str())) + "`");
// MCOL-1052 Replace SimpleColumn with ConstantColumn, // MCOL-1052 Replace SimpleColumn with ConstantColumn,
// since it must have a single value only. // since it must have a single value only.
if (constCol) if(constCol)
{ {
gwi.returnedCols.push_back(spcc); gwi.returnedCols.push_back(spcc);
gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(ifp->field_name), spcc)); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(ifp->field_name), spcc));
@@ -8544,7 +8528,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.returnedCols.push_back(spsc); gwi.returnedCols.push_back(spsc);
gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(ifp->field_name), spsc)); gwi.columnMap.insert(CalpontSelectExecutionPlan::ColumnMap::value_type(string(ifp->field_name), spsc));
} }
TABLE_LIST* tmp = 0; TABLE_LIST* tmp = 0;
if (ifp->cached_table) if (ifp->cached_table)
@@ -8581,12 +8564,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.returnedCols.push_back(spac); gwi.returnedCols.push_back(spac);
// This item will be used in HAVING later. // This item will be used in HAVING later.
Item_func_or_sum* isfp = reinterpret_cast<Item_func_or_sum*>(item); Item_func_or_sum* isfp = reinterpret_cast<Item_func_or_sum*>(item);
if ( ! isfp->name_length ) if ( ! isfp->name_length )
{ {
gwi.havingAggColsItems.push_back(item); gwi.havingAggColsItems.push_back(item);
} }
gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`'); gwi.selectCols.push_back('`' + escapeBackTick(spac->alias().c_str()) + '`');
String str(256); String str(256);
item->print(&str, QT_INFINIDB_NO_QUOTE); item->print(&str, QT_INFINIDB_NO_QUOTE);
@@ -8653,7 +8635,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
continue; continue;
} }
if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) || if ( ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE ) ||
((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) || ((gwi.thd->lex)->sql_command == SQLCOM_DELETE ) ||
((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) || ((gwi.thd->lex)->sql_command == SQLCOM_UPDATE_MULTI ) ||
@@ -8771,7 +8753,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
return -1; return -1;
} }
} }
//@Bug 3021. Bypass postprocess for update and delete. //@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 )) //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 ))
//{} //{}
@@ -9044,7 +9026,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.fatalParseError = false; gwi.fatalParseError = false;
gwi.parseErrorText = ""; gwi.parseErrorText = "";
if (gi.groupByHaving != 0) if (gi.groupByHaving != 0)
{ {
Item_cond* having = reinterpret_cast<Item_cond*>(gi.groupByHaving); Item_cond* having = reinterpret_cast<Item_cond*>(gi.groupByHaving);
#ifdef DEBUG_WALK_COND #ifdef DEBUG_WALK_COND
@@ -9468,7 +9450,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// for subquery, order+limit by will be supported in infinidb. build order by columns // for subquery, order+limit by will be supported in infinidb. build order by columns
// @todo union order by and limit support // @todo union order by and limit support
//if (gwi.hasWindowFunc || gwi.subSelectType != CalpontSelectExecutionPlan::MAIN_SELECT) //if (gwi.hasWindowFunc || gwi.subSelectType != CalpontSelectExecutionPlan::MAIN_SELECT)
for (; ordercol; ordercol = ordercol->next) for (; ordercol; ordercol = ordercol->next)
{ {
ReturnedColumn* rc = NULL; ReturnedColumn* rc = NULL;
@@ -9499,44 +9481,38 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
if ( rc && ord_item->type() == Item::FIELD_ITEM ) if ( rc && ord_item->type() == Item::FIELD_ITEM )
{ {
execplan::CalpontSelectExecutionPlan::ReturnedColumnList::iterator iter = gwi.groupByCols.begin(); execplan::CalpontSelectExecutionPlan::ReturnedColumnList::iterator iter = gwi.groupByCols.begin();
for( ; iter != gwi.groupByCols.end(); iter++ )
for ( ; iter != gwi.groupByCols.end(); iter++ )
{ {
if ( rc->sameColumn((*iter).get()) ) if( rc->sameColumn((*iter).get()) )
break; break;
} }
// MCOL-1052 Find and remove the optimized field // MCOL-1052 Find and remove the optimized field
// from ORDER using cond_pushed filters. // from ORDER using cond_pushed filters.
if (buildConstColFromFilter( if(buildConstColFromFilter(
dynamic_cast<SimpleColumn*>(rc), gwi, gi)) dynamic_cast<SimpleColumn*>(rc),gwi, gi))
{ {
break; break;
} }
// MCOL-1052 GROUP BY items list doesn't contain // MCOL-1052 GROUP BY items list doesn't contain
// this ORDER BY item. // this ORDER BY item.
if ( iter == gwi.groupByCols.end() ) if ( iter == gwi.groupByCols.end() )
{ {
Item_ident* iip = reinterpret_cast<Item_ident*>(ord_item); Item_ident *iip = reinterpret_cast<Item_ident*>(ord_item);
std::ostringstream ostream; std::ostringstream ostream;
ostream << "'"; ostream << "'";
if (iip->db_name) if (iip->db_name)
ostream << iip->db_name << '.'; ostream << iip->db_name << '.';
else else
ostream << "unknown db" << '.'; ostream << "unknown db" << '.';
if (iip->table_name) if (iip->table_name)
ostream << iip->table_name << '.'; ostream << iip->table_name << '.';
else else
ostream << "unknown table" << '.'; ostream << "unknown table" << '.';
if (iip->field_name) if (iip->field_name)
ostream << iip->field_name; ostream << iip->field_name;
else else
ostream << "unknown field"; ostream << "unknown field";
ostream << "'"; ostream << "'";
Message::Args args; Message::Args args;
args.add(ostream.str()); args.add(ostream.str());
@@ -9559,15 +9535,14 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
item_ptr = *(((Item_ref*)item_ptr)->ref); item_ptr = *(((Item_ref*)item_ptr)->ref);
rc = buildReturnedColumn(item_ptr, gwi, gwi.fatalParseError); rc = buildReturnedColumn(item_ptr, gwi, gwi.fatalParseError);
} }
// This ORDER BY item must be an agg function - // This ORDER BY item must be an agg function -
// the ordercol->item_ptr and exteded SELECT list // the ordercol->item_ptr and exteded SELECT list
// must contain the corresponding item. // must contain the corresponding item.
if (!rc) if (!rc)
{ {
Item* item_ptr = ordercol->item_ptr; Item* item_ptr = ordercol->item_ptr;
if (item_ptr) if (item_ptr)
rc = buildReturnedColumn(item_ptr, gwi, gwi.fatalParseError); rc = buildReturnedColumn(item_ptr, gwi, gwi.fatalParseError);
} }
@@ -9588,8 +9563,8 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
gwi.orderByCols.push_back(SRCP(rc)); gwi.orderByCols.push_back(SRCP(rc));
} }
// make sure columnmap, returnedcols and count(*) arg_list are not empty // make sure columnmap, returnedcols and count(*) arg_list are not empty
TableMap::iterator tb_iter = gwi.tableMap.begin(); TableMap::iterator tb_iter = gwi.tableMap.begin();
@@ -9814,7 +9789,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
} }
else else
ordercol = 0; ordercol = 0;
ord_cols = ""; ord_cols = "";
for (; ordercol; ordercol = ordercol->next) for (; ordercol; ordercol = ordercol->next)

View File

@@ -427,7 +427,7 @@ int vbin2hex(const uint8_t* p, const unsigned l, char* o)
return 0; return 0;
} }
int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool handler_flag = false) int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool handler_flag=false)
{ {
int rc = HA_ERR_END_OF_FILE; int rc = HA_ERR_END_OF_FILE;
int num_attr = ti.msTablePtr->s->fields; int num_attr = ti.msTablePtr->s->fields;
@@ -469,7 +469,6 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
{ {
Field** f; Field** f;
f = ti.msTablePtr->field; f = ti.msTablePtr->field;
//set all fields to null in null col bitmap //set all fields to null in null col bitmap
if (!handler_flag) if (!handler_flag)
memset(buf, -1, ti.msTablePtr->s->null_bytes); memset(buf, -1, ti.msTablePtr->s->null_bytes);
@@ -477,7 +476,6 @@ int fetchNextRow(uchar* buf, cal_table_info& ti, cal_connection_info* ci, bool h
{ {
memset(ti.msTablePtr->null_flags, -1, ti.msTablePtr->s->null_bytes); memset(ti.msTablePtr->null_flags, -1, ti.msTablePtr->s->null_bytes);
} }
std::vector<CalpontSystemCatalog::ColType>& colTypes = ti.tpl_scan_ctx->ctp; std::vector<CalpontSystemCatalog::ColType>& colTypes = ti.tpl_scan_ctx->ctp;
int64_t intColVal = 0; int64_t intColVal = 0;
uint64_t uintColVal = 0; uint64_t uintColVal = 0;
@@ -5079,7 +5077,7 @@ int ha_calpont_impl_rnd_pos(uchar* buf, uchar* pos)
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
/*@brief ha_calpont_impl_group_by_init - Get data for MariaDB group_by /*@brief ha_calpont_impl_group_by_init - Get data for MariaDB group_by
pushdown handler */ pushdown handler */
/*********************************************************** /***********************************************************
* DESCRIPTION: * DESCRIPTION:
@@ -5137,8 +5135,8 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, 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; thd->infinidb_vtable.vtable_state = THD::INFINIDB_ERROR;
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
uint32_t sessionID = tid2sid(thd->thread_id); uint32_t sessionID = tid2sid(thd->thread_id);
boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID); boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(sessionID);
csc->identity(CalpontSystemCatalog::FE); csc->identity(CalpontSystemCatalog::FE);
@@ -5150,9 +5148,9 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
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_DISABLE_VTABLE && if (thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE &&
!thd->infinidb_vtable.isNewQuery) !thd->infinidb_vtable.isNewQuery)
return 0; return 0;
@@ -5188,7 +5186,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
sm::cpsm_conhdl_t* hndl; sm::cpsm_conhdl_t* hndl;
SCSEP csep; SCSEP csep;
bool localQuery = (thd->variables.infinidb_local_query > 0 ? true : false); bool localQuery = (thd->variables.infinidb_local_query > 0 ? true : false);
{ {
ci->stats.reset(); // reset query stats ci->stats.reset(); // reset query stats
@@ -5218,7 +5216,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
sm::sm_cleanup(ci->cal_conn_hndl); sm::sm_cleanup(ci->cal_conn_hndl);
ci->cal_conn_hndl = 0; ci->cal_conn_hndl = 0;
} }
sm::sm_init(sessionID, &ci->cal_conn_hndl, localQuery); sm::sm_init(sessionID, &ci->cal_conn_hndl, localQuery);
idbassert(ci->cal_conn_hndl != 0); idbassert(ci->cal_conn_hndl != 0);
ci->cal_conn_hndl->csc = csc; ci->cal_conn_hndl->csc = csc;
@@ -5261,7 +5259,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
csep->schemaName(group_hand->table_list->db); csep->schemaName(group_hand->table_list->db);
csep->traceFlags(ci->traceFlags); csep->traceFlags(ci->traceFlags);
// MCOL-1052 Send Items lists down to the optimizer. // MCOL-1052 Send Items lists down to the optimizer.
gi.groupByTables = group_hand->table_list; gi.groupByTables = group_hand->table_list;
gi.groupByFields = group_hand->select; gi.groupByFields = group_hand->select;
@@ -5270,7 +5268,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
gi.groupByOrder = group_hand->order_by; gi.groupByOrder = group_hand->order_by;
gi.groupByHaving = group_hand->having; gi.groupByHaving = group_hand->having;
gi.groupByDistinct = group_hand->distinct; gi.groupByDistinct = group_hand->distinct;
// MCOL-1052 Send pushed conditions here, since server could omit GROUP BY // MCOL-1052 Send pushed conditions here, since server could omit GROUP BY
// items in case of = or IN functions used on GROUP BY columns. // items in case of = or IN functions used on GROUP BY columns.
{ {
@@ -5278,16 +5276,15 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
execplan::CalpontSelectExecutionPlan::ColumnMap::iterator colMapIter; execplan::CalpontSelectExecutionPlan::ColumnMap::iterator colMapIter;
execplan::CalpontSelectExecutionPlan::ColumnMap::iterator condColMapIter; execplan::CalpontSelectExecutionPlan::ColumnMap::iterator condColMapIter;
execplan::ParseTree* ptIt; execplan::ParseTree* ptIt;
for (TABLE_LIST* tl = gi.groupByTables; tl; tl = tl->next_local) for(TABLE_LIST* tl = gi.groupByTables; tl; tl=tl->next_local)
{ {
mapiter = ci->tableMap.find(tl->table); mapiter = ci->tableMap.find(tl->table);
if(mapiter != ci->tableMap.end() && mapiter->second.condInfo != NULL
if (mapiter != ci->tableMap.end() && mapiter->second.condInfo != NULL && mapiter->second.condInfo->condPush)
&& mapiter->second.condInfo->condPush)
{ {
while (!mapiter->second.condInfo->ptWorkStack.empty()) while(!mapiter->second.condInfo->ptWorkStack.empty())
{ {
ptIt = mapiter->second.condInfo->ptWorkStack.top(); ptIt=mapiter->second.condInfo->ptWorkStack.top();
mapiter->second.condInfo->ptWorkStack.pop(); mapiter->second.condInfo->ptWorkStack.pop();
gi.pushedPts.push_back(ptIt); gi.pushedPts.push_back(ptIt);
} }
@@ -5321,14 +5318,14 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str()); push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 9999, msg.c_str());
} }
#ifdef PLAN_HEX_FILE #ifdef PLAN_HEX_FILE
// plan serialization // plan serialization
ifstream ifs("/tmp/li1-plan.hex"); ifstream ifs("/tmp/li1-plan.hex");
ByteStream bs1; ByteStream bs1;
ifs >> bs1; ifs >> bs1;
ifs.close(); ifs.close();
csep->unserialize(bs1); csep->unserialize(bs1);
#endif #endif
if (ci->traceFlags & 1) if (ci->traceFlags & 1)
{ {
@@ -5343,7 +5340,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
IDEBUG( cout << "-------------- EXECUTION PLAN END --------------\n" << endl ); IDEBUG( cout << "-------------- EXECUTION PLAN END --------------\n" << endl );
} }
}// end of execution plan generation }// end of execution plan generation
{ {
ByteStream msg; ByteStream msg;
ByteStream emsgBs; ByteStream emsgBs;
@@ -5574,10 +5571,10 @@ internal_error:
ci->cal_conn_hndl = 0; ci->cal_conn_hndl = 0;
} }
return ER_INTERNAL_ERROR; return ER_INTERNAL_ERROR;
} }
/*@brief ha_calpont_impl_group_by_next - Return result set for MariaDB group_by /*@brief ha_calpont_impl_group_by_next - Return result set for MariaDB group_by
pushdown handler pushdown handler
*/ */
/*********************************************************** /***********************************************************
@@ -5593,7 +5590,7 @@ internal_error:
***********************************************************/ ***********************************************************/
int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE* table) int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE* table)
{ {
THD* thd = current_thd; THD* thd = current_thd;
/* 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 && (
@@ -5702,7 +5699,7 @@ int ha_calpont_impl_group_by_next(ha_calpont_group_by_handler* group_hand, TABLE
emsg = errorcodes.errorString(rc); emsg = errorcodes.errorString(rc);
} }
setError(thd, ER_INTERNAL_ERROR, emsg); setError(thd, ER_INTERNAL_ERROR, emsg);
ci->stats.fErrorNo = rc; ci->stats.fErrorNo = rc;
CalpontSystemCatalog::removeCalpontSystemCatalog(tid2sid(thd->thread_id)); CalpontSystemCatalog::removeCalpontSystemCatalog(tid2sid(thd->thread_id));
rc = ER_INTERNAL_ERROR; rc = ER_INTERNAL_ERROR;
@@ -5811,7 +5808,7 @@ int ha_calpont_impl_group_by_end(ha_calpont_group_by_handler* group_hand, TABLE*
cal_table_info ti = ci->tableMap[table]; cal_table_info ti = ci->tableMap[table];
sm::cpsm_conhdl_t* hndl; sm::cpsm_conhdl_t* hndl;
hndl = ci->cal_conn_hndl; hndl = ci->cal_conn_hndl;
if (ti.tpl_ctx) if (ti.tpl_ctx)
{ {