diff --git a/dbcon/mysql/ha_calpont.cpp b/dbcon/mysql/ha_calpont.cpp index ae0850109..a780a72e0 100644 --- a/dbcon/mysql/ha_calpont.cpp +++ b/dbcon/mysql/ha_calpont.cpp @@ -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 it(*query->select); - - if ( thd->infinidb_vtable.vtable_state == THD::INFINIDB_DISABLE_VTABLE ) - { - handler = new ha_calpont_group_by_handler(thd, query); - } + + 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); } diff --git a/dbcon/mysql/ha_calpont.h b/dbcon/mysql/ha_calpont.h index f15078fad..0e475e615 100644 --- a/dbcon/mysql/ha_calpont.h +++ b/dbcon/mysql/ha_calpont.h @@ -250,20 +250,17 @@ public: class ha_calpont_group_by_handler: public group_by_handler { - public: -// ha_calpont_group_by_handler(THD *thd_arg, List *fields_arg, -// TABLE_LIST *table_list_arg, Query *query) + public: ha_calpont_group_by_handler(THD *thd_arg, Query *query) - : group_by_handler(thd_arg, calpont_hton), - select(query->select), - 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) - { } + : group_by_handler(thd_arg, calpont_hton), + select(query->select), + table_list(query->from), + distinct(query->distinct), + where(query->where), + group_by(query->group_by), + order_by(query->order_by), + having(query->having) + { } ~ha_calpont_group_by_handler() { } int init_scan(); int next_row(); @@ -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__ diff --git a/dbcon/mysql/ha_calpont_execplan.cpp b/dbcon/mysql/ha_calpont_execplan.cpp index 6a8b1ac95..7ed3c0e69 100644 --- a/dbcon/mysql/ha_calpont_execplan.cpp +++ b/dbcon/mysql/ha_calpont_execplan.cpp @@ -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 << "<<<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 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; diff --git a/dbcon/mysql/ha_calpont_impl.cpp b/dbcon/mysql/ha_calpont_impl.cpp index d279d995e..09e125421 100644 --- a/dbcon/mysql/ha_calpont_impl.cpp +++ b/dbcon/mysql/ha_calpont_impl.cpp @@ -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. diff --git a/dbcon/mysql/sm.cpp b/dbcon/mysql/sm.cpp index 569fee6a5..fe1a23e76 100644 --- a/dbcon/mysql/sm.cpp +++ b/dbcon/mysql/sm.cpp @@ -145,7 +145,7 @@ status_t tpl_scan_fetch_getband(cpsm_conhdl_t* hndl, sp_cpsm_tplsch_t& ntplsch, if (ntplsch->bs.length() != 0) { ntplsch->deserializeTable(ntplsch->bs); - + if (ntplsch->rowGroup && ntplsch->rowGroup->getRGData() == NULL) { ntplsch->bs.restart();