49
47
#define KEY_OPTIMIZE_EXISTS 1
50
48
#define KEY_OPTIMIZE_REF_OR_NULL 2
54
enum_nested_loop_state sub_select_cache(Join *join, JoinTable *join_tab, bool end_of_records);
55
enum_nested_loop_state sub_select(Join *join,JoinTable *join_tab, bool end_of_records);
56
enum_nested_loop_state end_send_group(Join *join, JoinTable *join_tab, bool end_of_records);
57
enum_nested_loop_state end_write_group(Join *join, JoinTable *join_tab, bool end_of_records);
52
enum_nested_loop_state sub_select_cache(JOIN *join, JoinTable *join_tab, bool end_of_records);
53
enum_nested_loop_state sub_select(JOIN *join,JoinTable *join_tab, bool end_of_records);
54
enum_nested_loop_state end_send_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
55
enum_nested_loop_state end_write_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
59
57
typedef struct st_rollup
88
79
COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {}
91
void TEST_join(Join *join);
82
void TEST_join(JOIN *join);
93
84
/* Extern functions in sql_select.cc */
94
85
bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag);
95
86
Table *create_tmp_table(Session *session,Tmp_Table_Param *param,List<Item> &fields,
96
Order *group, bool distinct, bool save_sum_fields,
87
order_st *group, bool distinct, bool save_sum_fields,
97
88
uint64_t select_options, ha_rows rows_limit,
98
89
const char* alias);
90
void free_tmp_table(Session *session, Table *entry);
99
91
void count_field_types(Select_Lex *select_lex, Tmp_Table_Param *param,
100
92
List<Item> &fields, bool reset_with_sum_func);
101
93
bool setup_copy_fields(Session *session, Tmp_Table_Param *param,
103
95
List<Item> &new_list1, List<Item> &new_list2,
104
96
uint32_t elements, List<Item> &fields);
105
97
void copy_fields(Tmp_Table_Param *param);
106
bool copy_funcs(Item **func_ptr, const Session *session);
98
void copy_funcs(Item **func_ptr);
107
99
Field* create_tmp_field_from_field(Session *session, Field* org_field,
108
100
const char *name, Table *table,
109
101
Item_field *item, uint32_t convert_blob_length);
110
102
bool test_if_ref(Item_field *left_item,Item *right_item);
111
COND *optimize_cond(Join *join, COND *conds, List<TableList> *join_list, Item::cond_result *cond_value);
103
COND *optimize_cond(JOIN *join, COND *conds, List<TableList> *join_list, Item::cond_result *cond_value);
112
104
COND *make_cond_for_table(COND *cond,table_map table, table_map used_table, bool exclude_expensive_cond);
113
105
COND* substitute_for_best_equal_field(COND *cond, COND_EQUAL *cond_equal, void *table_join_idx);
114
106
bool list_contains_unique_index(Table *table, bool (*find_func) (Field *, void *), void *data);
115
107
bool find_field_in_order_list (Field *field, void *data);
116
108
bool find_field_in_item_list (Field *field, void *data);
117
bool test_if_skip_sort_order(JoinTable *tab,Order *order,ha_rows select_limit, bool no_changes, const key_map *map);
118
Order *create_distinct_group(Session *session,
109
bool test_if_skip_sort_order(JoinTable *tab,order_st *order,ha_rows select_limit, bool no_changes, const key_map *map);
110
order_st *create_distinct_group(Session *session,
119
111
Item **ref_pointer_array,
112
order_st *order_list,
121
113
List<Item> &fields,
123
115
bool *all_order_by_fields_used);
128
120
List<Item> &res_all_fields,
129
121
uint32_t elements,
130
122
List<Item> &all_fields);
131
int do_select(Join *join, List<Item> *fields, Table *tmp_table);
123
int do_select(JOIN *join, List<Item> *fields, Table *tmp_table);
132
124
bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
133
int create_sort_index(Session *session, Join *join, Order *order, ha_rows filesort_limit, ha_rows select_limit, bool is_order_by);
125
int create_sort_index(Session *session, JOIN *join, order_st *order, ha_rows filesort_limit, ha_rows select_limit, bool is_order_by);
134
126
void save_index_subquery_explain_info(JoinTable *join_tab, Item* where);
135
127
Item *remove_additional_cond(Item* conds);
136
128
bool setup_sum_funcs(Session *session, Item_sum **func_ptr);
143
135
List<Item> &res_all_fields,
144
136
uint32_t elements,
145
137
List<Item> &all_fields);
146
bool change_group_ref(Session *session, Item_func *expr, Order *group_list, bool *changed);
147
bool check_interleaving_with_nj(JoinTable *next);
138
bool change_group_ref(Session *session, Item_func *expr, order_st *group_list, bool *changed);
139
bool check_interleaving_with_nj(JoinTable *last, JoinTable *next);
149
int join_read_const_table(JoinTable *tab, optimizer::Position *pos);
141
int join_read_const_table(JoinTable *tab, drizzled::optimizer::Position *pos);
150
142
int join_read_system(JoinTable *tab);
151
143
int join_read_const(JoinTable *tab);
152
144
int join_read_key(JoinTable *tab);
153
145
int join_read_always_key(JoinTable *tab);
154
146
int join_read_last_key(JoinTable *tab);
155
int join_no_more_records(ReadRecord *info);
156
int join_read_next(ReadRecord *info);
157
int join_read_next_different(ReadRecord *info);
147
int join_no_more_records(READ_RECORD *info);
148
int join_read_next(READ_RECORD *info);
149
int join_read_next_different(READ_RECORD *info);
158
150
int join_init_quick_read_record(JoinTable *tab);
159
151
int init_read_record_seq(JoinTable *tab);
160
152
int test_if_quick_select(JoinTable *tab);
161
153
int join_init_read_record(JoinTable *tab);
162
154
int join_read_first(JoinTable *tab);
163
int join_read_next_same(ReadRecord *info);
164
int join_read_next_same_diff(ReadRecord *info);
155
int join_read_next_same(READ_RECORD *info);
156
int join_read_next_same_diff(READ_RECORD *info);
165
157
int join_read_last(JoinTable *tab);
166
int join_read_prev_same(ReadRecord *info);
167
int join_read_prev(ReadRecord *info);
158
int join_read_prev_same(READ_RECORD *info);
159
int join_read_prev(READ_RECORD *info);
168
160
int join_read_always_key_or_null(JoinTable *tab);
169
int join_read_next_same_or_null(ReadRecord *info);
161
int join_read_next_same_or_null(READ_RECORD *info);
171
163
void calc_used_field_length(Session *, JoinTable *join_tab);
172
164
StoredKey *get_store_key(Session *session,
173
optimizer::KeyUse *keyuse,
165
drizzled::optimizer::KeyUse *keyuse,
174
166
table_map used_tables,
175
KeyPartInfo *key_part,
167
KEY_PART_INFO *key_part,
176
168
unsigned char *key_buff,
177
169
uint32_t maybe_null);
178
int join_tab_cmp(const void* ptr1, const void* ptr2);
179
int join_tab_cmp_straight(const void* ptr1, const void* ptr2);
170
extern "C" int join_tab_cmp(const void* ptr1, const void* ptr2);
171
extern "C" int join_tab_cmp_straight(const void* ptr1, const void* ptr2);
180
172
void push_index_cond(JoinTable *tab, uint32_t keyno, bool other_tbls_ok);
181
void add_not_null_conds(Join *join);
173
void add_not_null_conds(JOIN *join);
182
174
uint32_t max_part_bit(key_part_map bits);
183
175
COND *add_found_match_trig_cond(JoinTable *tab, COND *cond, JoinTable *root_tab);
184
Order *create_distinct_group(Session *session,
176
order_st *create_distinct_group(Session *session,
185
177
Item **ref_pointer_array,
187
179
List<Item> &fields,
188
180
List<Item> &all_fields,
189
181
bool *all_order_by_fields_used);
190
bool eq_ref_table(Join *join, Order *start_order, JoinTable *tab);
182
bool eq_ref_table(JOIN *join, order_st *start_order, JoinTable *tab);
183
int join_tab_cmp(const void* ptr1, const void* ptr2);
191
184
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having);
192
185
int remove_dup_with_hash_index(Session *session,
204
197
table_map normal_tables,
205
198
Select_Lex *select_lex,
206
std::vector<optimizer::SargableParam> &sargables);
207
ha_rows get_quick_record_count(Session *session, optimizer::SqlSelect *select, Table *table, const key_map *keys,ha_rows limit);
208
void optimize_keyuse(Join *join, DYNAMIC_ARRAY *keyuse_array);
209
void add_group_and_distinct_keys(Join *join, JoinTable *join_tab);
199
std::vector<drizzled::optimizer::SargableParam> &sargables);
200
ha_rows get_quick_record_count(Session *session, drizzled::optimizer::SqlSelect *select, Table *table, const key_map *keys,ha_rows limit);
201
void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
202
void add_group_and_distinct_keys(JOIN *join, JoinTable *join_tab);
210
203
void read_cached_record(JoinTable *tab);
211
204
bool mysql_select(Session *session, Item ***rref_pointer_array,
212
205
TableList *tables, uint32_t wild_num, List<Item> &list,
213
COND *conds, uint32_t og_num, Order *order, Order *group,
206
COND *conds, uint32_t og_num, order_st *order, order_st *group,
214
207
Item *having, uint64_t select_type,
215
208
select_result *result, Select_Lex_Unit *unit,
216
209
Select_Lex *select_lex);
217
210
// Create list for using with tempory table
218
211
void init_tmptable_sum_functions(Item_sum **func);
219
212
void update_tmptable_sum_func(Item_sum **func,Table *tmp_table);
220
bool only_eq_ref_tables(Join *join, Order *order, table_map tables);
221
bool create_ref_for_key(Join *join, JoinTable *j,
222
optimizer::KeyUse *org_keyuse,
213
bool only_eq_ref_tables(JOIN *join, order_st *order, table_map tables);
214
bool create_ref_for_key(JOIN *join, JoinTable *j,
215
drizzled::optimizer::KeyUse *org_keyuse,
223
216
table_map used_tables);
225
} /* namespace drizzled */
227
/** @TODO why is this in the middle of the file??? */
229
218
#include "drizzled/stored_key.h"
234
220
bool cp_buffer_from_ref(Session *session, table_reference_st *ref);
235
221
int safe_index_read(JoinTable *tab);
236
222
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);