74
79
uint32_t sj_pred_no;
79
typedef struct st_table_ref
82
uint32_t key_parts; /**< num of key parts */
83
uint32_t key_length; /**< length of key_buff */
84
int32_t key; /**< key no (index) */
85
unsigned char *key_buff; /**< value to look for with key */
86
unsigned char *key_buff2; /**< key_buff+key_length */
87
StoredKey **key_copy; /**< No idea what this does... */
88
Item **items; /**< val()'s for each keypart */
90
Array of pointers to trigger variables. Some/all of the pointers may be
91
NULL. The ref access can be used iff
93
for each used key part i, (!cond_guards[i] || *cond_guards[i])
95
This array is used by subquery code. The subquery code may inject
96
triggered conditions, i.e. conditions that can be 'switched off'. A ref
97
access created from such condition is not valid when at least one of the
98
underlying conditions is switched off (see subquery code for more details)
102
(null_rejecting & (1<<i)) means the condition is '=' and no matching
103
rows will be produced if items[i] IS NULL (see add_not_null_conds())
105
key_part_map null_rejecting;
106
table_map depend_map; /**< Table depends on these tables. */
107
/** null byte position in the key_buf. Used for REF_OR_NULL optimization */
108
unsigned char *null_ref_key;
110
true <=> disable the "cache" as doing lookup with the same key value may
111
produce different results (because of Index Condition Pushdown)
118
#include "drizzled/join_cache.h"
120
/** The states in which a nested loop join can be in */
121
enum enum_nested_loop_state
123
NESTED_LOOP_KILLED= -2,
124
NESTED_LOOP_ERROR= -1,
126
NESTED_LOOP_NO_MORE_ROWS= 1,
127
NESTED_LOOP_QUERY_LIMIT= 3,
128
NESTED_LOOP_CURSOR_LIMIT= 4
131
/** Description of a join type */
151
typedef enum_nested_loop_state (*Next_select_func)(JOIN *, struct st_join_table *, bool);
152
typedef int (*Read_record_func)(struct st_join_table *tab);
153
Next_select_func setup_end_select_func(JOIN *join);
155
#include "drizzled/join_tab.h"
157
enum_nested_loop_state sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
158
enum_nested_loop_state sub_select(JOIN *join,JOIN_TAB *join_tab, bool end_of_records);
159
enum_nested_loop_state end_send_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
160
enum_nested_loop_state end_write_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
87
enum_nested_loop_state sub_select_cache(JOIN *join, JoinTable *join_tab, bool end_of_records);
88
enum_nested_loop_state sub_select(JOIN *join,JoinTable *join_tab, bool end_of_records);
89
enum_nested_loop_state end_send_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
90
enum_nested_loop_state end_write_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
163
93
* Information about a position of table within a join order. Used in join
282
212
bool list_contains_unique_index(Table *table, bool (*find_func) (Field *, void *), void *data);
283
213
bool find_field_in_order_list (Field *field, void *data);
284
214
bool find_field_in_item_list (Field *field, void *data);
285
bool test_if_skip_sort_order(JOIN_TAB *tab,order_st *order,ha_rows select_limit, bool no_changes, const key_map *map);
215
bool test_if_skip_sort_order(JoinTable *tab,order_st *order,ha_rows select_limit, bool no_changes, const key_map *map);
286
216
order_st *create_distinct_group(Session *session,
287
217
Item **ref_pointer_array,
288
218
order_st *order_list,
299
229
int do_select(JOIN *join, List<Item> *fields, Table *tmp_table);
300
230
bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
301
231
int create_sort_index(Session *session, JOIN *join, order_st *order, ha_rows filesort_limit, ha_rows select_limit, bool is_order_by);
302
void advance_sj_state(const table_map remaining_tables, const JOIN_TAB *tab);
303
void restore_prev_sj_state(const table_map remaining_tables, const JOIN_TAB *tab);
304
void save_index_subquery_explain_info(JOIN_TAB *join_tab, Item* where);
232
void advance_sj_state(const table_map remaining_tables, const JoinTable *tab);
233
void restore_prev_sj_state(const table_map remaining_tables, const JoinTable *tab);
234
void save_index_subquery_explain_info(JoinTable *join_tab, Item* where);
305
235
Item *remove_additional_cond(Item* conds);
306
236
bool setup_sum_funcs(Session *session, Item_sum **func_ptr);
307
237
bool init_sum_functions(Item_sum **func, Item_sum **end);
317
247
int subq_sj_candidate_cmp(Item_in_subselect* const *el1, Item_in_subselect* const *el2);
318
248
bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred);
319
249
bool change_group_ref(Session *session, Item_func *expr, order_st *group_list, bool *changed);
320
bool check_interleaving_with_nj(JOIN_TAB *last, JOIN_TAB *next);
250
bool check_interleaving_with_nj(JoinTable *last, JoinTable *next);
322
int join_read_const_table(JOIN_TAB *tab, POSITION *pos);
323
int join_read_system(JOIN_TAB *tab);
324
int join_read_const(JOIN_TAB *tab);
325
int join_read_key(JOIN_TAB *tab);
326
int join_read_always_key(JOIN_TAB *tab);
327
int join_read_last_key(JOIN_TAB *tab);
252
int join_read_const_table(JoinTable *tab, POSITION *pos);
253
int join_read_system(JoinTable *tab);
254
int join_read_const(JoinTable *tab);
255
int join_read_key(JoinTable *tab);
256
int join_read_always_key(JoinTable *tab);
257
int join_read_last_key(JoinTable *tab);
328
258
int join_no_more_records(READ_RECORD *info);
329
259
int join_read_next(READ_RECORD *info);
330
260
int join_read_next_different(READ_RECORD *info);
331
int join_init_quick_read_record(JOIN_TAB *tab);
332
int test_if_quick_select(JOIN_TAB *tab);
333
int join_init_read_record(JOIN_TAB *tab);
334
int join_read_first(JOIN_TAB *tab);
261
int join_init_quick_read_record(JoinTable *tab);
262
int init_read_record_seq(JoinTable *tab);
263
int test_if_quick_select(JoinTable *tab);
264
int join_init_read_record(JoinTable *tab);
265
int join_read_first(JoinTable *tab);
335
266
int join_read_next_same(READ_RECORD *info);
336
267
int join_read_next_same_diff(READ_RECORD *info);
337
int join_read_last(JOIN_TAB *tab);
268
int join_read_last(JoinTable *tab);
338
269
int join_read_prev_same(READ_RECORD *info);
339
270
int join_read_prev(READ_RECORD *info);
340
int join_read_always_key_or_null(JOIN_TAB *tab);
271
int join_read_always_key_or_null(JoinTable *tab);
341
272
int join_read_next_same_or_null(READ_RECORD *info);
343
void calc_used_field_length(Session *, JOIN_TAB *join_tab);
274
void calc_used_field_length(Session *, JoinTable *join_tab);
344
275
StoredKey *get_store_key(Session *session,
346
277
table_map used_tables,
347
278
KEY_PART_INFO *key_part,
348
279
unsigned char *key_buff,
349
280
uint32_t maybe_null);
350
281
extern "C" int join_tab_cmp(const void* ptr1, const void* ptr2);
351
282
extern "C" int join_tab_cmp_straight(const void* ptr1, const void* ptr2);
352
void push_index_cond(JOIN_TAB *tab, uint32_t keyno, bool other_tbls_ok);
283
void push_index_cond(JoinTable *tab, uint32_t keyno, bool other_tbls_ok);
353
284
void add_not_null_conds(JOIN *join);
354
285
uint32_t max_part_bit(key_part_map bits);
355
COND *add_found_match_trig_cond(JOIN_TAB *tab, COND *cond, JOIN_TAB *root_tab);
286
COND *add_found_match_trig_cond(JoinTable *tab, COND *cond, JoinTable *root_tab);
356
287
order_st *create_distinct_group(Session *session,
357
288
Item **ref_pointer_array,
359
290
List<Item> &fields,
360
291
List<Item> &all_fields,
361
292
bool *all_order_by_fields_used);
362
bool eq_ref_table(JOIN *join, order_st *start_order, JOIN_TAB *tab);
293
bool eq_ref_table(JOIN *join, order_st *start_order, JoinTable *tab);
363
294
uint64_t get_bound_sj_equalities(TableList *sj_nest, table_map remaining_tables);
364
295
int join_tab_cmp(const void* ptr1, const void* ptr2);
365
296
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having);
380
311
SARGABLE_PARAM **sargables);
381
312
ha_rows get_quick_record_count(Session *session, SQL_SELECT *select, Table *table, const key_map *keys,ha_rows limit);
382
313
void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
383
void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
384
int do_sj_reset(SJ_TMP_TABLE *sj_tbl);
385
void read_cached_record(JOIN_TAB *tab);
314
void add_group_and_distinct_keys(JOIN *join, JoinTable *join_tab);
315
int do_sj_reset(SemiJoinTable *sj_tbl);
316
void read_cached_record(JoinTable *tab);
386
317
// Create list for using with tempory table
387
318
void init_tmptable_sum_functions(Item_sum **func);
388
319
void update_tmptable_sum_func(Item_sum **func,Table *tmp_table);
389
320
bool find_eq_ref_candidate(Table *table, table_map sj_inner_tables);
390
321
bool only_eq_ref_tables(JOIN *join, order_st *order, table_map tables);
391
bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, table_map used_tables);
322
bool create_ref_for_key(JOIN *join, JoinTable *j, KeyUse *org_keyuse, table_map used_tables);
393
324
/* functions from opt_sum.cc */
394
325
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);