You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
MCOL-1052 WIP Process UNION subqueries separetely.
This commit is contained in:
@ -1148,7 +1148,7 @@ static MYSQL_SYSVAR_ULONG(
|
|||||||
* Details are in server/sql/group_by_handler.h
|
* Details are in server/sql/group_by_handler.h
|
||||||
* PARAMETERS:
|
* PARAMETERS:
|
||||||
* thd - THD pointer.
|
* thd - THD pointer.
|
||||||
* query - Query structure, that describes the pushdown query.
|
* query - Query structure, that describes the pushdowned query.
|
||||||
* RETURN:
|
* RETURN:
|
||||||
* group_by_handler if success
|
* group_by_handler if success
|
||||||
* NULL in other case
|
* NULL in other case
|
||||||
@ -1157,13 +1157,13 @@ static group_by_handler *
|
|||||||
create_calpont_group_by_handler(THD *thd, Query *query)
|
create_calpont_group_by_handler(THD *thd, Query *query)
|
||||||
{
|
{
|
||||||
ha_calpont_group_by_handler *handler = NULL;
|
ha_calpont_group_by_handler *handler = NULL;
|
||||||
Item *item;
|
|
||||||
List_iterator_fast<Item> it(*query->select);
|
handler = new ha_calpont_group_by_handler(thd, query);
|
||||||
|
|
||||||
if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE )
|
// Notify the server, that CS handles GROUP BY, ORDER BY and HAVING clauses.
|
||||||
{
|
query->group_by = NULL;
|
||||||
handler = new ha_calpont_group_by_handler(thd, query);
|
query->order_by = NULL;
|
||||||
}
|
query->having = NULL;
|
||||||
|
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
@ -1172,7 +1172,7 @@ int ha_calpont_group_by_handler::init_scan()
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("ha_calpont_group_by_handler::init_scan");
|
DBUG_ENTER("ha_calpont_group_by_handler::init_scan");
|
||||||
|
|
||||||
// MCOL-1052
|
// Save vtable_state to restore the after we inited.
|
||||||
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state;
|
THD::infinidb_state oldState = thd->infinidb_vtable.vtable_state;
|
||||||
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE;
|
thd->infinidb_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE;
|
||||||
int rc = ha_calpont_impl_group_by_init(this, table);
|
int rc = ha_calpont_impl_group_by_init(this, table);
|
||||||
@ -1183,19 +1183,9 @@ int ha_calpont_group_by_handler::init_scan()
|
|||||||
|
|
||||||
int ha_calpont_group_by_handler::next_row()
|
int ha_calpont_group_by_handler::next_row()
|
||||||
{
|
{
|
||||||
// if (!first_row)
|
|
||||||
// return(HA_ERR_END_OF_FILE);
|
|
||||||
DBUG_ENTER("ha_calpont_group_by_handler::next_row");
|
DBUG_ENTER("ha_calpont_group_by_handler::next_row");
|
||||||
int rc = ha_calpont_impl_group_by_next(this, table);
|
int rc = ha_calpont_impl_group_by_next(this, table);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// first_row= 0;
|
|
||||||
//Field *field = *(table->field);
|
|
||||||
//field->store(5LL, 1);
|
|
||||||
//field->set_notnull();
|
|
||||||
//return(0);
|
|
||||||
|
|
||||||
DBUG_RETURN(rc);
|
DBUG_RETURN(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,20 +250,17 @@ public:
|
|||||||
|
|
||||||
class ha_calpont_group_by_handler: public group_by_handler
|
class ha_calpont_group_by_handler: public group_by_handler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ha_calpont_group_by_handler(THD *thd_arg, List<Item> *fields_arg,
|
|
||||||
// TABLE_LIST *table_list_arg, Query *query)
|
|
||||||
ha_calpont_group_by_handler(THD *thd_arg, Query *query)
|
ha_calpont_group_by_handler(THD *thd_arg, Query *query)
|
||||||
: group_by_handler(thd_arg, calpont_hton),
|
: group_by_handler(thd_arg, calpont_hton),
|
||||||
select(query->select),
|
select(query->select),
|
||||||
table_list(query->from),
|
table_list(query->from),
|
||||||
distinct(query->distinct),
|
distinct(query->distinct),
|
||||||
where(query->where),
|
where(query->where),
|
||||||
group_by(query->group_by),
|
group_by(query->group_by),
|
||||||
order_by(query->order_by),
|
order_by(query->order_by),
|
||||||
having(query->having),
|
having(query->having)
|
||||||
query(query)
|
{ }
|
||||||
{ }
|
|
||||||
~ha_calpont_group_by_handler() { }
|
~ha_calpont_group_by_handler() { }
|
||||||
int init_scan();
|
int init_scan();
|
||||||
int next_row();
|
int next_row();
|
||||||
@ -275,8 +272,6 @@ class ha_calpont_group_by_handler: public group_by_handler
|
|||||||
ORDER *group_by;
|
ORDER *group_by;
|
||||||
ORDER *order_by;
|
ORDER *order_by;
|
||||||
Item *having;
|
Item *having;
|
||||||
bool first_row; // useless by now
|
|
||||||
Query *query; // useless by now
|
|
||||||
};
|
};
|
||||||
#endif //HA_CALPONT_H__
|
#endif //HA_CALPONT_H__
|
||||||
|
|
||||||
|
@ -8259,7 +8259,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
|
// gwi.thd->infinidb_vtable.isUnion = true; //by-pass the 2nd pass of rnd_init
|
||||||
}
|
}
|
||||||
else if (table_ptr->view)
|
else if (table_ptr->view)
|
||||||
{
|
{
|
||||||
@ -8324,9 +8324,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
|
|||||||
|
|
||||||
bool unionSel = false;
|
bool unionSel = false;
|
||||||
|
|
||||||
|
// MCOL-1052
|
||||||
|
/*
|
||||||
if (!isUnion && select_lex.master_unit()->is_union())
|
if (!isUnion && select_lex.master_unit()->is_union())
|
||||||
{
|
{
|
||||||
gwi.thd->infinidb_vtable.isUnion = true;
|
// gwi.thd->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;
|
||||||
@ -8359,7 +8361,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
|
|||||||
union_gwi.thd = gwi.thd;
|
union_gwi.thd = gwi.thd;
|
||||||
uint32_t err = 0;
|
uint32_t err = 0;
|
||||||
|
|
||||||
if ((err = getSelectPlan(union_gwi, *sl, plan, unionSel)) != 0)
|
if ((err = getGroupPlan(union_gwi, *sl, plan, gi, unionSel)) != 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
unionVec.push_back(SCEP(plan));
|
unionVec.push_back(SCEP(plan));
|
||||||
@ -8368,7 +8370,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
|
|||||||
if (sl == select_lex.master_unit()->union_distinct)
|
if (sl == select_lex.master_unit()->union_distinct)
|
||||||
distUnionNum = unionVec.size();
|
distUnionNum = unionVec.size();
|
||||||
|
|
||||||
/*#ifdef DEBUG_WALK_COND
|
*//*#ifdef DEBUG_WALK_COND
|
||||||
IDEBUG( cerr << ">>>> UNION DEBUG" << endl );
|
IDEBUG( cerr << ">>>> UNION DEBUG" << endl );
|
||||||
JOIN* join = sl->join;
|
JOIN* join = sl->join;
|
||||||
Item_cond* icp = 0;
|
Item_cond* icp = 0;
|
||||||
@ -8379,7 +8381,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
|
|||||||
IDEBUG ( cerr << *plan << endl );
|
IDEBUG ( cerr << *plan << endl );
|
||||||
IDEBUG ( cerr << "<<<<UNION DEBUG" << endl );
|
IDEBUG ( cerr << "<<<<UNION DEBUG" << endl );
|
||||||
#endif*/
|
#endif*/
|
||||||
}
|
/* }
|
||||||
|
|
||||||
csep->unionVec(unionVec);
|
csep->unionVec(unionVec);
|
||||||
csep->distinctUnionNum(distUnionNum);
|
csep->distinctUnionNum(distUnionNum);
|
||||||
@ -8387,7 +8389,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
|
|||||||
if (unionVec.empty())
|
if (unionVec.empty())
|
||||||
gwi.thd->infinidb_vtable.impossibleWhereOnUnion = true;
|
gwi.thd->infinidb_vtable.impossibleWhereOnUnion = true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
gwi.clauseType = WHERE;
|
gwi.clauseType = WHERE;
|
||||||
|
|
||||||
if (icp)
|
if (icp)
|
||||||
@ -10040,7 +10042,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
|
|||||||
//TABLE_LIST* table_ptr = select_lex.get_table_list();
|
//TABLE_LIST* table_ptr = select_lex.get_table_list();
|
||||||
set<string> aliasSet; // to avoid duplicate table alias
|
set<string> aliasSet; // to avoid duplicate table alias
|
||||||
|
|
||||||
for (; table_ptr; table_ptr = table_ptr->next_global)
|
for (; table_ptr; table_ptr = table_ptr->next_local)
|
||||||
{
|
{
|
||||||
if (string(table_ptr->table_name).find("$vtable") != string::npos)
|
if (string(table_ptr->table_name).find("$vtable") != string::npos)
|
||||||
continue;
|
continue;
|
||||||
|
@ -5939,10 +5939,8 @@ int ha_calpont_impl_rnd_pos(uchar* buf, uchar* pos)
|
|||||||
***********************************************************/
|
***********************************************************/
|
||||||
int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE* table)
|
int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE* table)
|
||||||
{
|
{
|
||||||
//first_row= true;
|
|
||||||
string tableName = group_hand->table_list->table->s->table_name.str;
|
string tableName = group_hand->table_list->table->s->table_name.str;
|
||||||
IDEBUG( cout << "group_by_init for table " <<
|
IDEBUG( cout << "group_by_init for table " << tableName << endl );
|
||||||
group_hand->table_list->table->s->table_name.str << endl );
|
|
||||||
THD* thd = current_thd;
|
THD* thd = current_thd;
|
||||||
|
|
||||||
//check whether the system is ready to process statement.
|
//check whether the system is ready to process statement.
|
||||||
@ -5993,8 +5991,8 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
|
|||||||
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 (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::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.
|
||||||
|
@ -145,7 +145,7 @@ status_t tpl_scan_fetch_getband(cpsm_conhdl_t* hndl, sp_cpsm_tplsch_t& ntplsch,
|
|||||||
if (ntplsch->bs.length() != 0)
|
if (ntplsch->bs.length() != 0)
|
||||||
{
|
{
|
||||||
ntplsch->deserializeTable(ntplsch->bs);
|
ntplsch->deserializeTable(ntplsch->bs);
|
||||||
|
|
||||||
if (ntplsch->rowGroup && ntplsch->rowGroup->getRGData() == NULL)
|
if (ntplsch->rowGroup && ntplsch->rowGroup->getRGData() == NULL)
|
||||||
{
|
{
|
||||||
ntplsch->bs.restart();
|
ntplsch->bs.restart();
|
||||||
|
Reference in New Issue
Block a user