diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-10-02 14:38:06 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-10-05 17:14:15 +0200 |
commit | c93ac0a1c68ed73cc4a59a475a8d576122557001 (patch) | |
tree | 9e2e8007b6a861cfc11006a396256f79d25b81e1 | |
parent | 7ca8b4bbfa3fc1ac12bbfc20530426fa534b9142 (diff) | |
download | mariadb-git-c93ac0a1c68ed73cc4a59a475a8d576122557001.tar.gz |
cleanups and simplifications
-rw-r--r-- | sql/group_by_handler.cc | 2 | ||||
-rw-r--r-- | sql/group_by_handler.h | 25 | ||||
-rw-r--r-- | sql/sql_select.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.h | 3 | ||||
-rw-r--r-- | storage/sequence/sequence.cc | 25 |
5 files changed, 21 insertions, 40 deletions
diff --git a/sql/group_by_handler.cc b/sql/group_by_handler.cc index ce73b1c3512..e3420b8d48d 100644 --- a/sql/group_by_handler.cc +++ b/sql/group_by_handler.cc @@ -70,7 +70,7 @@ int Pushdown_query::execute(JOIN *join) } /* Check if we can accept the row */ - if (!handler->having || handler->having->val_bool()) + if (!having || having->val_bool()) { if (store_data_in_temp_table) { diff --git a/sql/group_by_handler.h b/sql/group_by_handler.h index 207e90e73c9..534acc27ee2 100644 --- a/sql/group_by_handler.h +++ b/sql/group_by_handler.h @@ -34,22 +34,13 @@ class group_by_handler { public: THD *thd; - List<Item> *fields; - TABLE_LIST *table_list; - ORDER *group_by, *order_by; - Item *where, *having; handlerton *ht; /* Temporary table where all results should be stored in record[0] */ TABLE *table; - group_by_handler(THD *thd_arg, List<Item> *fields_arg, - TABLE_LIST *table_list_arg, ORDER *group_by_arg, - ORDER *order_by_arg, Item *where_arg, Item *having_arg, - handlerton *ht_arg) - : thd(thd_arg), fields(fields_arg), table_list(table_list_arg), - group_by(group_by_arg), order_by(order_by_arg), where(where_arg), - having(having_arg), ht(ht_arg), table(0) {} + group_by_handler(THD *thd_arg, handlerton *ht_arg) + : thd(thd_arg), ht(ht_arg), table(0) {} virtual ~group_by_handler() {} /* @@ -65,15 +56,17 @@ public: This is becasue we can't revert back the old having and order_by elements. */ - virtual bool init(TABLE *temporary_table, Item *having_arg, - ORDER *order_by_arg) + virtual bool init(Item *having_arg, ORDER *order_by_arg) { - table= temporary_table; - having= having_arg; - order_by= order_by_arg; return 0; } + bool ha_init(TABLE *temporary_table, Item *having_arg, ORDER *order_by_arg) + { + table= temporary_table; + return init(having_arg, order_by_arg); + } + /* Bits of things the storage engine can do for this query. Should be initialized on object creation. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 5307b4b8f52..12735ce3435 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1960,13 +1960,13 @@ JOIN::optimize_inner() DBUG_RETURN(1); /* Give storage engine access to temporary table */ - if ((err= gbh->init(exec_tmp_table1, - having, order))) + if ((err= gbh->ha_init(exec_tmp_table1, having, order))) { gbh->print_error(err, MYF(0)); DBUG_RETURN(1); } pushdown_query->store_data_in_temp_table= need_tmp; + pushdown_query->having= having; /* If no ORDER BY clause was specified explicitly, we should sort things according to the group_by @@ -2080,7 +2080,7 @@ int JOIN::init_execution() thd->lex->set_limit_rows_examined(); /* Create a tmp table if distinct or if the sort is too complicated */ - if (need_tmp && !pushdown_query) + if (need_tmp && !exec_tmp_table1) { DBUG_PRINT("info",("Creating tmp table")); THD_STAGE_INFO(thd, stage_copying_to_tmp_table); diff --git a/sql/sql_select.h b/sql/sql_select.h index 79894742caa..1e853d73a32 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -1971,10 +1971,11 @@ public: SELECT_LEX *select_lex; bool store_data_in_temp_table; group_by_handler *handler; + Item *having; Pushdown_query(SELECT_LEX *select_lex_arg, group_by_handler *handler_arg) : select_lex(select_lex_arg), store_data_in_temp_table(0), - handler(handler_arg) {} + handler(handler_arg), having(0) {} ~Pushdown_query() { delete handler; } diff --git a/storage/sequence/sequence.cc b/storage/sequence/sequence.cc index 46dcd2f3296..d0d46495acf 100644 --- a/storage/sequence/sequence.cc +++ b/storage/sequence/sequence.cc @@ -359,18 +359,16 @@ static int dummy_ret_int() { return 0; } class ha_seq_group_by_handler: public group_by_handler { + List<Item> *fields; + TABLE_LIST *table_list; bool first_row; public: ha_seq_group_by_handler(THD *thd_arg, List<Item> *fields_arg, - TABLE_LIST *table_list_arg, ORDER *group_by_arg, - ORDER *order_by_arg, Item *where_arg, - Item *having_arg) - :group_by_handler(thd_arg, fields_arg, table_list_arg, group_by_arg, - order_by_arg, where_arg, having_arg, sequence_hton) {} + TABLE_LIST *table_list_arg) + : group_by_handler(thd_arg, sequence_hton), fields(fields_arg), + table_list(table_list_arg) {} ~ha_seq_group_by_handler() {} - bool init(TABLE *temporary_table, Item *having_arg, - ORDER *order_by_arg); int init_scan() { first_row= 1 ; return 0; } int next_row(); int end_scan() { return 0; } @@ -427,21 +425,10 @@ create_group_by_handler(THD *thd, List<Item> *fields, TABLE_LIST *table_list, } /* Create handler and return it */ - handler= new ha_seq_group_by_handler(thd, fields, table_list, group_by, - order_by, where, having); + handler= new ha_seq_group_by_handler(thd, fields, table_list); return handler; } -bool ha_seq_group_by_handler::init(TABLE *temporary_table, Item *having_arg, - ORDER *order_by_arg) -{ - /* - Here we could add checks if the temporary table was created correctly - */ - return group_by_handler::init(temporary_table, having_arg, order_by_arg); -} - - int ha_seq_group_by_handler::next_row() { List_iterator_fast<Item> it(*fields); |