149
149
class SJ_TMP_TABLE;
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);
151
typedef enum_nested_loop_state (*Next_select_func)(JOIN *, JoinTable *, bool);
152
typedef int (*Read_record_func)(JoinTable *tab);
153
153
Next_select_func setup_end_select_func(JOIN *join);
155
#include "drizzled/join_tab.h"
155
#include "drizzled/join_table.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);
157
enum_nested_loop_state sub_select_cache(JOIN *join, JoinTable *join_tab, bool end_of_records);
158
enum_nested_loop_state sub_select(JOIN *join,JoinTable *join_tab, bool end_of_records);
159
enum_nested_loop_state end_send_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
160
enum_nested_loop_state end_write_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
163
163
* Information about a position of table within a join order. Used in join
282
282
bool list_contains_unique_index(Table *table, bool (*find_func) (Field *, void *), void *data);
283
283
bool find_field_in_order_list (Field *field, void *data);
284
284
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);
285
bool test_if_skip_sort_order(JoinTable *tab,order_st *order,ha_rows select_limit, bool no_changes, const key_map *map);
286
286
order_st *create_distinct_group(Session *session,
287
287
Item **ref_pointer_array,
288
288
order_st *order_list,
299
299
int do_select(JOIN *join, List<Item> *fields, Table *tmp_table);
300
300
bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
301
301
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);
302
void advance_sj_state(const table_map remaining_tables, const JoinTable *tab);
303
void restore_prev_sj_state(const table_map remaining_tables, const JoinTable *tab);
304
void save_index_subquery_explain_info(JoinTable *join_tab, Item* where);
305
305
Item *remove_additional_cond(Item* conds);
306
306
bool setup_sum_funcs(Session *session, Item_sum **func_ptr);
307
307
bool init_sum_functions(Item_sum **func, Item_sum **end);
317
317
int subq_sj_candidate_cmp(Item_in_subselect* const *el1, Item_in_subselect* const *el2);
318
318
bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred);
319
319
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);
320
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);
322
int join_read_const_table(JoinTable *tab, POSITION *pos);
323
int join_read_system(JoinTable *tab);
324
int join_read_const(JoinTable *tab);
325
int join_read_key(JoinTable *tab);
326
int join_read_always_key(JoinTable *tab);
327
int join_read_last_key(JoinTable *tab);
328
328
int join_no_more_records(READ_RECORD *info);
329
329
int join_read_next(READ_RECORD *info);
330
330
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);
331
int join_init_quick_read_record(JoinTable *tab);
332
int test_if_quick_select(JoinTable *tab);
333
int join_init_read_record(JoinTable *tab);
334
int join_read_first(JoinTable *tab);
335
335
int join_read_next_same(READ_RECORD *info);
336
336
int join_read_next_same_diff(READ_RECORD *info);
337
int join_read_last(JOIN_TAB *tab);
337
int join_read_last(JoinTable *tab);
338
338
int join_read_prev_same(READ_RECORD *info);
339
339
int join_read_prev(READ_RECORD *info);
340
int join_read_always_key_or_null(JOIN_TAB *tab);
340
int join_read_always_key_or_null(JoinTable *tab);
341
341
int join_read_next_same_or_null(READ_RECORD *info);
343
void calc_used_field_length(Session *, JOIN_TAB *join_tab);
343
void calc_used_field_length(Session *, JoinTable *join_tab);
344
344
StoredKey *get_store_key(Session *session,
346
346
table_map used_tables,
349
349
uint32_t maybe_null);
350
350
extern "C" int join_tab_cmp(const void* ptr1, const void* ptr2);
351
351
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);
352
void push_index_cond(JoinTable *tab, uint32_t keyno, bool other_tbls_ok);
353
353
void add_not_null_conds(JOIN *join);
354
354
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);
355
COND *add_found_match_trig_cond(JoinTable *tab, COND *cond, JoinTable *root_tab);
356
356
order_st *create_distinct_group(Session *session,
357
357
Item **ref_pointer_array,
359
359
List<Item> &fields,
360
360
List<Item> &all_fields,
361
361
bool *all_order_by_fields_used);
362
bool eq_ref_table(JOIN *join, order_st *start_order, JOIN_TAB *tab);
362
bool eq_ref_table(JOIN *join, order_st *start_order, JoinTable *tab);
363
363
uint64_t get_bound_sj_equalities(TableList *sj_nest, table_map remaining_tables);
364
364
int join_tab_cmp(const void* ptr1, const void* ptr2);
365
365
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having);
380
380
SARGABLE_PARAM **sargables);
381
381
ha_rows get_quick_record_count(Session *session, SQL_SELECT *select, Table *table, const key_map *keys,ha_rows limit);
382
382
void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
383
void add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab);
383
void add_group_and_distinct_keys(JOIN *join, JoinTable *join_tab);
384
384
int do_sj_reset(SJ_TMP_TABLE *sj_tbl);
385
void read_cached_record(JOIN_TAB *tab);
385
void read_cached_record(JoinTable *tab);
386
386
// Create list for using with tempory table
387
387
void init_tmptable_sum_functions(Item_sum **func);
388
388
void update_tmptable_sum_func(Item_sum **func,Table *tmp_table);
389
389
bool find_eq_ref_candidate(Table *table, table_map sj_inner_tables);
390
390
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);
391
bool create_ref_for_key(JOIN *join, JoinTable *j, KEYUSE *org_keyuse, table_map used_tables);
393
393
/* functions from opt_sum.cc */
394
394
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);
402
402
bool cp_buffer_from_ref(Session *session, TABLE_REF *ref);
403
403
bool error_if_full_join(JOIN *join);
404
int safe_index_read(JOIN_TAB *tab);
404
int safe_index_read(JoinTable *tab);
405
405
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);
406
406
int test_if_item_cache_changed(List<Cached_item> &list);