418
418
Table *tmp_table;
419
419
/// used to store 2 possible tmp table of SELECT
420
420
Table *exec_tmp_table1, *exec_tmp_table2;
422
422
Item_sum **sum_funcs, ***sum_funcs_end;
423
423
/** second copy of sumfuncs (for queries with 2 temporary tables */
424
424
Item_sum **sum_funcs2, ***sum_funcs_end2;
516
516
JOIN_TAB *join_tab_reexec; // make_simple_join()
517
517
/* end of allocation caching storage */
519
JOIN(Session *thd_arg, List<Item> &fields_arg, uint64_t select_options_arg,
519
JOIN(Session *session_arg, List<Item> &fields_arg, uint64_t select_options_arg,
520
520
select_result *result_arg)
521
:fields_list(fields_arg), sj_subselects(thd_arg->mem_root, 4)
521
:fields_list(fields_arg), sj_subselects(session_arg->mem_root, 4)
523
init(thd_arg, fields_arg, select_options_arg, result_arg);
523
init(session_arg, fields_arg, select_options_arg, result_arg);
526
void init(Session *thd_arg, List<Item> &fields_arg, uint64_t select_options_arg,
526
void init(Session *session_arg, List<Item> &fields_arg, uint64_t select_options_arg,
527
527
select_result *result_arg)
529
529
join_tab= join_tab_save= 0;
546
546
join_tab_reexec= 0;
547
session= session_arg;
548
548
sum_funcs= sum_funcs2= 0;
549
549
having= tmp_having= having_history= 0;
550
550
select_options= select_options_arg;
551
551
result= result_arg;
552
lock= session_arg->lock;
553
553
select_lex= 0; //for safety
555
555
select_distinct= test(select_options & SELECT_DISTINCT);
633
633
bool change_result(select_result *result);
634
634
bool is_top_level_join() const
636
return (unit == &thd->lex->unit && (unit->fake_select_lex == 0 ||
636
return (unit == &session->lex->unit && (unit->fake_select_lex == 0 ||
637
637
select_lex == unit->fake_select_lex));
649
649
/* Extern functions in sql_select.cc */
650
650
bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag);
651
Table *create_tmp_table(Session *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
651
Table *create_tmp_table(Session *session,TMP_TABLE_PARAM *param,List<Item> &fields,
652
652
order_st *group, bool distinct, bool save_sum_fields,
653
653
uint64_t select_options, ha_rows rows_limit,
655
void free_tmp_table(Session *thd, Table *entry);
655
void free_tmp_table(Session *session, Table *entry);
656
656
void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
657
657
List<Item> &fields, bool reset_with_sum_func);
658
bool setup_copy_fields(Session *thd, TMP_TABLE_PARAM *param,
658
bool setup_copy_fields(Session *session, TMP_TABLE_PARAM *param,
659
659
Item **ref_pointer_array,
660
660
List<Item> &new_list1, List<Item> &new_list2,
661
661
uint32_t elements, List<Item> &fields);
662
662
void copy_fields(TMP_TABLE_PARAM *param);
663
663
void copy_funcs(Item **func_ptr);
664
Field* create_tmp_field_from_field(Session *thd, Field* org_field,
664
Field* create_tmp_field_from_field(Session *session, Field* org_field,
665
665
const char *name, Table *table,
666
666
Item_field *item, uint32_t convert_blob_length);
680
680
bool null_key; /* true <=> the value of the key has a null part */
681
681
enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
682
store_key(Session *thd, Field *field_arg, unsigned char *ptr, unsigned char *null, uint32_t length)
682
store_key(Session *session, Field *field_arg, unsigned char *ptr, unsigned char *null, uint32_t length)
683
683
:null_key(0), null_ptr(null), err(0)
685
685
if (field_arg->type() == DRIZZLE_TYPE_BLOB)
694
694
to_field->init(field_arg->table);
697
to_field=field_arg->new_key_field(thd->mem_root, field_arg->table,
697
to_field=field_arg->new_key_field(session->mem_root, field_arg->table,
700
700
virtual ~store_key() {} /** Not actually needed */
709
709
enum store_key_result copy()
711
711
enum store_key_result result;
712
Session *thd= to_field->table->in_use;
713
enum_check_fields saved_count_cuted_fields= thd->count_cuted_fields;
712
Session *session= to_field->table->in_use;
713
enum_check_fields saved_count_cuted_fields= session->count_cuted_fields;
715
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
715
session->count_cuted_fields= CHECK_FIELD_IGNORE;
717
717
result= copy_inner();
719
thd->count_cuted_fields= saved_count_cuted_fields;
719
session->count_cuted_fields= saved_count_cuted_fields;
735
735
Copy_field copy_field;
736
736
const char *field_name;
738
store_key_field(Session *thd, Field *to_field_arg, unsigned char *ptr,
738
store_key_field(Session *session, Field *to_field_arg, unsigned char *ptr,
739
739
unsigned char *null_ptr_arg,
740
740
uint32_t length, Field *from_field, const char *name_arg)
741
:store_key(thd, to_field_arg,ptr,
741
:store_key(session, to_field_arg,ptr,
742
742
null_ptr_arg ? null_ptr_arg : from_field->maybe_null() ? &err
743
743
: (unsigned char*) 0, length), field_name(name_arg)
767
store_key_item(Session *thd, Field *to_field_arg, unsigned char *ptr,
767
store_key_item(Session *session, Field *to_field_arg, unsigned char *ptr,
768
768
unsigned char *null_ptr_arg, uint32_t length, Item *item_arg)
769
:store_key(thd, to_field_arg, ptr,
769
:store_key(session, to_field_arg, ptr,
770
770
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
771
771
&err : (unsigned char*) 0, length), item(item_arg)
789
store_key_const_item(Session *thd, Field *to_field_arg, unsigned char *ptr,
789
store_key_const_item(Session *session, Field *to_field_arg, unsigned char *ptr,
790
790
unsigned char *null_ptr_arg, uint32_t length,
792
:store_key_item(thd, to_field_arg,ptr,
792
:store_key_item(session, to_field_arg,ptr,
793
793
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
794
794
&err : (unsigned char*) 0, length, item_arg), inited(0)
817
bool cp_buffer_from_ref(Session *thd, TABLE_REF *ref);
817
bool cp_buffer_from_ref(Session *session, TABLE_REF *ref);
818
818
bool error_if_full_join(JOIN *join);
819
819
int safe_index_read(JOIN_TAB *tab);
820
COND *remove_eq_conds(Session *thd, COND *cond, Item::cond_result *cond_value);
820
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);
821
821
int test_if_item_cache_changed(List<Cached_item> &list);