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

MCOL-1052 WIP Process UNION subqueries separetely.

This commit is contained in:
Roman Nozdrin
2018-04-02 15:03:59 +03:00
parent d562caecba
commit 78aeedb162
5 changed files with 32 additions and 47 deletions

View File

@ -1148,7 +1148,7 @@ static MYSQL_SYSVAR_ULONG(
* Details are in server/sql/group_by_handler.h
* PARAMETERS:
* thd - THD pointer.
* query - Query structure, that describes the pushdown query.
* query - Query structure, that describes the pushdowned query.
* RETURN:
* group_by_handler if success
* NULL in other case
@ -1157,13 +1157,13 @@ static group_by_handler *
create_calpont_group_by_handler(THD *thd, Query *query)
{
ha_calpont_group_by_handler *handler = NULL;
Item *item;
List_iterator_fast<Item> it(*query->select);
if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE )
{
handler = new ha_calpont_group_by_handler(thd, query);
}
// Notify the server, that CS handles GROUP BY, ORDER BY and HAVING clauses.
query->group_by = NULL;
query->order_by = NULL;
query->having = NULL;
return handler;
}
@ -1172,7 +1172,7 @@ int 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_vtable.vtable_state = THD::INFINIDB_CREATE_VTABLE;
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()
{
// if (!first_row)
// return(HA_ERR_END_OF_FILE);
DBUG_ENTER("ha_calpont_group_by_handler::next_row");
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);
}

View File

@ -251,8 +251,6 @@ public:
class ha_calpont_group_by_handler: public group_by_handler
{
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)
: group_by_handler(thd_arg, calpont_hton),
select(query->select),
@ -261,8 +259,7 @@ class ha_calpont_group_by_handler: public group_by_handler
where(query->where),
group_by(query->group_by),
order_by(query->order_by),
having(query->having),
query(query)
having(query->having)
{ }
~ha_calpont_group_by_handler() { }
int init_scan();
@ -275,8 +272,6 @@ class ha_calpont_group_by_handler: public group_by_handler
ORDER *group_by;
ORDER *order_by;
Item *having;
bool first_row; // useless by now
Query *query; // useless by now
};
#endif //HA_CALPONT_H__

View File

@ -8259,7 +8259,7 @@ 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);
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)
{
@ -8324,9 +8324,11 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
bool unionSel = false;
// MCOL-1052
/*
if (!isUnion && select_lex.master_unit()->is_union())
{
gwi.thd->infinidb_vtable.isUnion = true;
// gwi.thd->infinidb_vtable.isUnion = true;
CalpontSelectExecutionPlan::SelectList unionVec;
SELECT_LEX* select_cursor = select_lex.master_unit()->first_select();
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;
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;
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)
distUnionNum = unionVec.size();
/*#ifdef DEBUG_WALK_COND
*//*#ifdef DEBUG_WALK_COND
IDEBUG( cerr << ">>>> UNION DEBUG" << endl );
JOIN* join = sl->join;
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 << "<<<<UNION DEBUG" << endl );
#endif*/
}
/* }
csep->unionVec(unionVec);
csep->distinctUnionNum(distUnionNum);
@ -8387,7 +8389,7 @@ int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, SCSEP& csep, cal_gro
if (unionVec.empty())
gwi.thd->infinidb_vtable.impossibleWhereOnUnion = true;
}
*/
gwi.clauseType = WHERE;
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();
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)
continue;

View File

@ -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)
{
//first_row= true;
string tableName = group_hand->table_list->table->s->table_name.str;
IDEBUG( cout << "group_by_init for table " <<
group_hand->table_list->table->s->table_name.str << endl );
IDEBUG( cout << "group_by_init for table " << tableName << endl );
THD* thd = current_thd;
//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;
// by pass the extra union trips. return 0
//if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE)
// return 0;
if (thd->infinidb_vtable.isUnion && thd->infinidb_vtable.vtable_state == THD::INFINIDB_CREATE_VTABLE)
return 0;
// @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.