Skip to content

Commit c93ac0a

Browse files
committed
cleanups and simplifications
1 parent 7ca8b4b commit c93ac0a

File tree

5 files changed

+21
-40
lines changed

5 files changed

+21
-40
lines changed

sql/group_by_handler.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int Pushdown_query::execute(JOIN *join)
7070
}
7171

7272
/* Check if we can accept the row */
73-
if (!handler->having || handler->having->val_bool())
73+
if (!having || having->val_bool())
7474
{
7575
if (store_data_in_temp_table)
7676
{

sql/group_by_handler.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,13 @@ class group_by_handler
3434
{
3535
public:
3636
THD *thd;
37-
List<Item> *fields;
38-
TABLE_LIST *table_list;
39-
ORDER *group_by, *order_by;
40-
Item *where, *having;
4137
handlerton *ht;
4238

4339
/* Temporary table where all results should be stored in record[0] */
4440
TABLE *table;
4541

46-
group_by_handler(THD *thd_arg, List<Item> *fields_arg,
47-
TABLE_LIST *table_list_arg, ORDER *group_by_arg,
48-
ORDER *order_by_arg, Item *where_arg, Item *having_arg,
49-
handlerton *ht_arg)
50-
: thd(thd_arg), fields(fields_arg), table_list(table_list_arg),
51-
group_by(group_by_arg), order_by(order_by_arg), where(where_arg),
52-
having(having_arg), ht(ht_arg), table(0) {}
42+
group_by_handler(THD *thd_arg, handlerton *ht_arg)
43+
: thd(thd_arg), ht(ht_arg), table(0) {}
5344
virtual ~group_by_handler() {}
5445

5546
/*
@@ -65,15 +56,17 @@ class group_by_handler
6556
This is becasue we can't revert back the old having and order_by elements.
6657
*/
6758

68-
virtual bool init(TABLE *temporary_table, Item *having_arg,
69-
ORDER *order_by_arg)
59+
virtual bool init(Item *having_arg, ORDER *order_by_arg)
7060
{
71-
table= temporary_table;
72-
having= having_arg;
73-
order_by= order_by_arg;
7461
return 0;
7562
}
7663

64+
bool ha_init(TABLE *temporary_table, Item *having_arg, ORDER *order_by_arg)
65+
{
66+
table= temporary_table;
67+
return init(having_arg, order_by_arg);
68+
}
69+
7770
/*
7871
Bits of things the storage engine can do for this query.
7972
Should be initialized on object creation.

sql/sql_select.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,13 +1960,13 @@ JOIN::optimize_inner()
19601960
DBUG_RETURN(1);
19611961

19621962
/* Give storage engine access to temporary table */
1963-
if ((err= gbh->init(exec_tmp_table1,
1964-
having, order)))
1963+
if ((err= gbh->ha_init(exec_tmp_table1, having, order)))
19651964
{
19661965
gbh->print_error(err, MYF(0));
19671966
DBUG_RETURN(1);
19681967
}
19691968
pushdown_query->store_data_in_temp_table= need_tmp;
1969+
pushdown_query->having= having;
19701970
/*
19711971
If no ORDER BY clause was specified explicitly, we should sort things
19721972
according to the group_by
@@ -2080,7 +2080,7 @@ int JOIN::init_execution()
20802080
thd->lex->set_limit_rows_examined();
20812081

20822082
/* Create a tmp table if distinct or if the sort is too complicated */
2083-
if (need_tmp && !pushdown_query)
2083+
if (need_tmp && !exec_tmp_table1)
20842084
{
20852085
DBUG_PRINT("info",("Creating tmp table"));
20862086
THD_STAGE_INFO(thd, stage_copying_to_tmp_table);

sql/sql_select.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,10 +1971,11 @@ class Pushdown_query: public Sql_alloc
19711971
SELECT_LEX *select_lex;
19721972
bool store_data_in_temp_table;
19731973
group_by_handler *handler;
1974+
Item *having;
19741975

19751976
Pushdown_query(SELECT_LEX *select_lex_arg, group_by_handler *handler_arg)
19761977
: select_lex(select_lex_arg), store_data_in_temp_table(0),
1977-
handler(handler_arg) {}
1978+
handler(handler_arg), having(0) {}
19781979

19791980
~Pushdown_query() { delete handler; }
19801981

storage/sequence/sequence.cc

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,16 @@ static int dummy_ret_int() { return 0; }
359359

360360
class ha_seq_group_by_handler: public group_by_handler
361361
{
362+
List<Item> *fields;
363+
TABLE_LIST *table_list;
362364
bool first_row;
363365

364366
public:
365367
ha_seq_group_by_handler(THD *thd_arg, List<Item> *fields_arg,
366-
TABLE_LIST *table_list_arg, ORDER *group_by_arg,
367-
ORDER *order_by_arg, Item *where_arg,
368-
Item *having_arg)
369-
:group_by_handler(thd_arg, fields_arg, table_list_arg, group_by_arg,
370-
order_by_arg, where_arg, having_arg, sequence_hton) {}
368+
TABLE_LIST *table_list_arg)
369+
: group_by_handler(thd_arg, sequence_hton), fields(fields_arg),
370+
table_list(table_list_arg) {}
371371
~ha_seq_group_by_handler() {}
372-
bool init(TABLE *temporary_table, Item *having_arg,
373-
ORDER *order_by_arg);
374372
int init_scan() { first_row= 1 ; return 0; }
375373
int next_row();
376374
int end_scan() { return 0; }
@@ -427,21 +425,10 @@ create_group_by_handler(THD *thd, List<Item> *fields, TABLE_LIST *table_list,
427425
}
428426

429427
/* Create handler and return it */
430-
handler= new ha_seq_group_by_handler(thd, fields, table_list, group_by,
431-
order_by, where, having);
428+
handler= new ha_seq_group_by_handler(thd, fields, table_list);
432429
return handler;
433430
}
434431

435-
bool ha_seq_group_by_handler::init(TABLE *temporary_table, Item *having_arg,
436-
ORDER *order_by_arg)
437-
{
438-
/*
439-
Here we could add checks if the temporary table was created correctly
440-
*/
441-
return group_by_handler::init(temporary_table, having_arg, order_by_arg);
442-
}
443-
444-
445432
int ha_seq_group_by_handler::next_row()
446433
{
447434
List_iterator_fast<Item> it(*fields);

0 commit comments

Comments
 (0)