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

@@ -707,7 +707,6 @@ 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 )
@@ -719,7 +718,6 @@ void debug_walk(const Item* item, void* arg)
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)
@@ -927,7 +925,6 @@ void debug_walk(const Item* item, void* arg)
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 : ""),
@@ -5131,7 +5128,6 @@ void gp_walk(const Item* item, void* arg)
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
@@ -8103,7 +8094,7 @@ int cp_get_group_plan(THD* thd, SCSEP& csep, cal_impl_if::cal_group_info& gi)
* 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,22 +8102,16 @@ 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)
{ {
@@ -8139,7 +8124,6 @@ ConstantColumn* buildConstColFromFilter(SimpleColumn* originalSC,
result = constCol; result = constCol;
} }
} }
return result; return result;
} }
@@ -8534,7 +8518,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
// 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,7 +8564,6 @@ 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);
@@ -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());
@@ -9567,7 +9543,6 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
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);
} }

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;
@@ -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)
{ {