24
* Defines the Join class
24
* Defines the JOIN class
27
27
#ifndef DRIZZLED_JOIN_H
28
28
#define DRIZZLED_JOIN_H
30
30
#include <drizzled/optimizer/position.h>
31
#include "drizzled/sql_select.h"
37
class Join :public memory::SqlAlloc
39
Join(const Join &rhs); /**< not implemented */
40
Join& operator=(const Join &rhs); /**< not implemented */
33
class JOIN :public Sql_alloc
35
JOIN(const JOIN &rhs); /**< not implemented */
36
JOIN& operator=(const JOIN &rhs); /**< not implemented */
43
39
* Contains a partial query execution plan which is extended during
44
40
* cost-based optimization.
46
optimizer::Position positions[MAX_TABLES+1];
42
drizzled::optimizer::Position positions[MAX_TABLES+1];
49
45
* Contains the optimal query execution plan after cost-based optimization
52
optimizer::Position best_positions[MAX_TABLES+1];
48
drizzled::optimizer::Position best_positions[MAX_TABLES+1];
55
51
JoinTable *join_tab;
104
100
simple_xxxxx is set if order_st/GROUP BY doesn't include any references
105
to other tables than the first non-constant table in the Join.
101
to other tables than the first non-constant table in the JOIN.
106
102
It's also set if order_st/GROUP BY is empty.
108
104
bool simple_order;
109
105
bool simple_group;
111
107
Is set only in case if we have a GROUP BY clause
112
and no ORDER BY after constant elimination of 'order'.
108
and no order_st BY after constant elimination of 'order'.
115
/** Is set if we have a GROUP BY and we have ORDER BY on a constant. */
111
/** Is set if we have a GROUP BY and we have order_st BY on a constant. */
116
112
bool skip_sort_order;
117
113
bool union_part; /**< this subselect is part of union */
118
114
bool optimized; /**< flag to avoid double optimization in EXPLAIN */
147
143
Select_Lex_Unit *unit;
148
144
/** select that processed */
149
145
Select_Lex *select_lex;
150
optimizer::SqlSelect *select; /**< created in optimization phase */
146
SQL_SELECT *select; /**< created in optimisation phase */
147
Array<Item_in_subselect> sj_subselects;
153
150
Bitmap of nested joins embedding the position at the end of the current
177
174
uint64_t select_options;
178
175
select_result *result;
179
176
Tmp_Table_Param tmp_table_param;
182
Join *tmp_join; /**< copy of this Join to be used with temporary tables */
179
JOIN *tmp_join; /**< copy of this JOIN to be used with temporary tables */
183
180
ROLLUP rollup; /**< Used with rollup */
184
181
DYNAMIC_ARRAY keyuse;
185
182
Item::cond_result cond_value;
195
192
List<Item> tmp_fields_list3;
199
Order *group_list; /**< hold parameters of mysql_select */
196
order_st *group_list; /**< hold parameters of mysql_select */
200
197
COND *conds; // ---"---
201
198
Item *conds_history; /**< store WHERE for explain */
202
199
TableList *tables_list; /**< hold 'tables' parameter of mysql_select */
219
216
allocations that occur in repetition at execution time will result in
220
217
excessive memory usage.
222
SortField *sortorder; // make_unireg_sortorder()
219
SORT_FIELD *sortorder; // make_unireg_sortorder()
223
220
Table **table_reexec; // make_simple_join()
224
221
JoinTable *join_tab_reexec; // make_simple_join()
225
222
/* end of allocation caching storage */
227
224
/** Constructors */
228
Join(Session *session_arg,
225
JOIN(Session *session_arg,
229
226
List<Item> &fields_arg,
230
227
uint64_t select_options_arg,
231
228
select_result *result_arg)
471
469
void copyPartialPlanIntoOptimalPlan(uint32_t size)
473
471
memcpy(best_positions, positions,
474
sizeof(optimizer::Position) * size);
472
sizeof(drizzled::optimizer::Position) * size);
477
void cache_const_exprs();
480
476
* @param[in] index the index of the position to retrieve
481
477
* @return a reference to the specified position in the optimal
484
optimizer::Position &getPosFromOptimalPlan(uint32_t index)
480
drizzled::optimizer::Position &getPosFromOptimalPlan(uint32_t index)
486
482
return best_positions[index];
500
496
* @param[in] index the index of the position to set
501
497
* @param[in] in_pos the value to set the position to
503
void setPosInPartialPlan(uint32_t index, optimizer::Position &in_pos)
499
void setPosInPartialPlan(uint32_t index, drizzled::optimizer::Position &in_pos)
505
501
positions[index]= in_pos;
519
515
* @return a pointer to the position in the partial query plan
521
optimizer::Position *getSpecificPosInPartialPlan(int32_t index)
517
drizzled::optimizer::Position *getSpecificPosInPartialPlan(int32_t index)
523
519
return positions + index;
528
enum_nested_loop_state evaluate_join_record(Join *join, JoinTable *join_tab, int error);
529
enum_nested_loop_state evaluate_null_complemented_join_record(Join *join, JoinTable *join_tab);
530
enum_nested_loop_state flush_cached_records(Join *join, JoinTable *join_tab, bool skip_last);
531
enum_nested_loop_state end_send(Join *join, JoinTable *join_tab, bool end_of_records);
532
enum_nested_loop_state end_write(Join *join, JoinTable *join_tab, bool end_of_records);
533
enum_nested_loop_state end_update(Join *join, JoinTable *join_tab, bool end_of_records);
534
enum_nested_loop_state end_unique_update(Join *join, JoinTable *join_tab, bool end_of_records);
536
} /* namespace drizzled */
524
enum_nested_loop_state evaluate_join_record(JOIN *join, JoinTable *join_tab, int error);
525
enum_nested_loop_state evaluate_null_complemented_join_record(JOIN *join, JoinTable *join_tab);
526
enum_nested_loop_state flush_cached_records(JOIN *join, JoinTable *join_tab, bool skip_last);
527
enum_nested_loop_state end_send(JOIN *join, JoinTable *join_tab, bool end_of_records);
528
enum_nested_loop_state end_write(JOIN *join, JoinTable *join_tab, bool end_of_records);
529
enum_nested_loop_state end_update(JOIN *join, JoinTable *join_tab, bool end_of_records);
530
enum_nested_loop_state end_unique_update(JOIN *join, JoinTable *join_tab, bool end_of_records);
538
532
#endif /* DRIZZLED_JOIN_H */