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

MCOL-1052 Use existed getSelectPlan as a basis for group_by_handler plan generation.

This commit is contained in:
Roman Nozdrin
2018-03-30 19:07:33 +03:00
parent fa4067b6f0
commit a47f16054d
5 changed files with 2522 additions and 45 deletions

View File

@ -20,6 +20,9 @@ SET ( libcalmysql_SRCS
ha_pseudocolumn.cpp) ha_pseudocolumn.cpp)
add_definitions(-DMYSQL_DYNAMIC_PLUGIN) add_definitions(-DMYSQL_DYNAMIC_PLUGIN)
add_definitions(-DDEBUG_WALK_COND)
add_definitions(-DINFINIDB_DEBUG)
#add_definitions(-DOUTER_JOIN_DEBUG)
set_source_files_properties(ha_calpont.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti -fno-implicit-templates") set_source_files_properties(ha_calpont.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti -fno-implicit-templates")

View File

@ -254,16 +254,29 @@ class ha_calpont_group_by_handler: public group_by_handler
// ha_calpont_group_by_handler(THD *thd_arg, List<Item> *fields_arg, // ha_calpont_group_by_handler(THD *thd_arg, List<Item> *fields_arg,
// TABLE_LIST *table_list_arg, Query *query) // 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), fields(query->select), : group_by_handler(thd_arg, calpont_hton),
table_list(query->from), query(query) {} select(query->select),
~ha_calpont_group_by_handler() {} table_list(query->from),
distinct(query->distinct),
where(query->where),
group_by(query->group_by),
order_by(query->order_by),
having(query->having),
query(query)
{ }
~ha_calpont_group_by_handler() { }
int init_scan(); int init_scan();
int next_row(); int next_row();
int end_scan(); int end_scan();
List<Item> *fields; List<Item> *select;
TABLE_LIST *table_list; TABLE_LIST *table_list;
bool first_row; bool distinct;
Query *query; Item *where;
ORDER *group_by;
ORDER *order_by;
Item *having;
bool first_row; // useless by now
Query *query; // useless by now
}; };
#endif //HA_CALPONT_H__ #endif //HA_CALPONT_H__

File diff suppressed because it is too large Load Diff

View File

@ -5532,6 +5532,7 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
sm::tableid_t tableid = 0; sm::tableid_t tableid = 0;
cal_table_info ti; cal_table_info ti;
cal_group_info gi;
sm::cpsm_conhdl_t* hndl; sm::cpsm_conhdl_t* hndl;
SCSEP csep; SCSEP csep;
@ -5602,10 +5603,19 @@ int ha_calpont_impl_group_by_init(ha_calpont_group_by_handler* group_hand, TABLE
ti.csep->traceFlags(ci->traceFlags); ti.csep->traceFlags(ci->traceFlags);
ti.msTablePtr = group_hand->table_list->table; ti.msTablePtr = group_hand->table_list->table;
ti.groupByFields = group_hand->fields; //ti.groupByTables = group_hand->table_list;
//ti.groupByFields = group_hand->fields;
gi.groupByTables = group_hand->table_list;
gi.groupByFields = group_hand->select;
gi.groupByWhere = group_hand->where;
gi.groupByGroup = group_hand->group_by;
gi.groupByOrder = group_hand->order_by;
gi.groupByHaving = group_hand->having;
gi.groupByDistinct = group_hand->distinct;
// send plan whenever group_init is called // send plan whenever group_init is called
cp_get_group_plan(thd, ti.csep, ti); cp_get_group_plan(thd, ti.csep, ti, gi);
} }
IDEBUG( cerr << tableName << " send plan:" << endl ); IDEBUG( cerr << tableName << " send plan:" << endl );

View File

@ -178,8 +178,7 @@ struct cal_table_info
msTablePtr(0), msTablePtr(0),
conn_hndl(0), conn_hndl(0),
condInfo(0), condInfo(0),
moreRows(false), moreRows(false)
groupByFields(0)
{ } { }
~cal_table_info() {} ~cal_table_info() {}
sm::cpsm_tplh_t* tpl_ctx; sm::cpsm_tplh_t* tpl_ctx;
@ -190,7 +189,27 @@ struct cal_table_info
gp_walk_info* condInfo; gp_walk_info* condInfo;
execplan::SCSEP csep; execplan::SCSEP csep;
bool moreRows; //are there more rows to consume (b/c of limit) bool moreRows; //are there more rows to consume (b/c of limit)
List<Item> *groupByFields; // MCOL-1052 For CSEP generation };
struct cal_group_info
{
cal_group_info() : groupByFields(0),
groupByTables(0),
groupByWhere(0),
groupByGroup(0),
groupByOrder(0),
groupByHaving(0),
groupByDistinct(false)
{ }
~cal_group_info() { }
List<Item>* groupByFields; // MCOL-1052 SELECT
TABLE_LIST* groupByTables; // MCOL-1052 FROM
Item* groupByWhere; // MCOL-1052 WHERE
ORDER* groupByGroup; // MCOL-1052 GROUP BY
ORDER* groupByOrder; // MCOL-1052 ORDER BY
Item* groupByHaving; // MCOL-1052 HAVING
bool groupByDistinct; //MCOL-1052 DISTINCT
}; };
typedef std::tr1::unordered_map<TABLE*, cal_table_info> CalTableMap; typedef std::tr1::unordered_map<TABLE*, cal_table_info> CalTableMap;
@ -299,8 +318,9 @@ const std::string infinidb_err_msg = "\nThe query includes syntax that is not su
int cp_get_plan(THD* thd, execplan::SCSEP& csep); int cp_get_plan(THD* thd, execplan::SCSEP& csep);
int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti); int cp_get_table_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti);
int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti); int cp_get_group_plan(THD* thd, execplan::SCSEP& csep, cal_impl_if::cal_table_info& ti,cal_impl_if::cal_group_info& gi);
int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false); int getSelectPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep, bool isUnion = false);
int getGroupPlan(gp_walk_info& gwi, SELECT_LEX& select_lex, execplan::SCSEP& csep,cal_group_info& gi, bool isUnion = false);
void setError(THD* thd, uint32_t errcode, const std::string errmsg, gp_walk_info* gwi); void setError(THD* thd, uint32_t errcode, const std::string errmsg, gp_walk_info* gwi);
void setError(THD* thd, uint32_t errcode, const std::string errmsg); void setError(THD* thd, uint32_t errcode, const std::string errmsg);
void gp_walk(const Item* item, void* arg); void gp_walk(const Item* item, void* arg);