~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.h

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
  classes to use when handling where clause
25
25
*/
26
26
 
 
27
#ifdef USE_PRAGMA_INTERFACE
 
28
#pragma interface                       /* gcc class implementation */
 
29
#endif
27
30
 
28
31
/* PREV_BITS only used in sql_select.cc */
29
32
#define PREV_BITS(type,A)       ((type) (((type) 1 << (A)) -1))
418
421
  Table    *tmp_table;
419
422
  /// used to store 2 possible tmp table of SELECT
420
423
  Table    *exec_tmp_table1, *exec_tmp_table2;
421
 
  Session          *session;
 
424
  THD      *thd;
422
425
  Item_sum  **sum_funcs, ***sum_funcs_end;
423
426
  /** second copy of sumfuncs (for queries with 2 temporary tables */
424
427
  Item_sum  **sum_funcs2, ***sum_funcs_end2;
516
519
  JOIN_TAB *join_tab_reexec;                    // make_simple_join()
517
520
  /* end of allocation caching storage */
518
521
 
519
 
  JOIN(Session *session_arg, List<Item> &fields_arg, uint64_t select_options_arg,
 
522
  JOIN(THD *thd_arg, List<Item> &fields_arg, uint64_t select_options_arg,
520
523
       select_result *result_arg)
521
 
    :fields_list(fields_arg), sj_subselects(session_arg->mem_root, 4)
 
524
    :fields_list(fields_arg), sj_subselects(thd_arg->mem_root, 4)
522
525
  {
523
 
    init(session_arg, fields_arg, select_options_arg, result_arg);
 
526
    init(thd_arg, fields_arg, select_options_arg, result_arg);
524
527
  }
525
528
 
526
 
  void init(Session *session_arg, List<Item> &fields_arg, uint64_t select_options_arg,
 
529
  void init(THD *thd_arg, List<Item> &fields_arg, uint64_t select_options_arg,
527
530
       select_result *result_arg)
528
531
  {
529
532
    join_tab= join_tab_save= 0;
544
547
    sortorder= 0;
545
548
    table_reexec= 0;
546
549
    join_tab_reexec= 0;
547
 
    session= session_arg;
 
550
    thd= thd_arg;
548
551
    sum_funcs= sum_funcs2= 0;
549
552
    having= tmp_having= having_history= 0;
550
553
    select_options= select_options_arg;
551
554
    result= result_arg;
552
 
    lock= session_arg->lock;
 
555
    lock= thd_arg->lock;
553
556
    select_lex= 0; //for safety
554
557
    tmp_join= 0;
555
558
    select_distinct= test(select_options & SELECT_DISTINCT);
633
636
  bool change_result(select_result *result);
634
637
  bool is_top_level_join() const
635
638
  {
636
 
    return (unit == &session->lex->unit && (unit->fake_select_lex == 0 ||
 
639
    return (unit == &thd->lex->unit && (unit->fake_select_lex == 0 ||
637
640
                                        select_lex == unit->fake_select_lex));
638
641
  }
639
642
};
648
651
 
649
652
/* Extern functions in sql_select.cc */
650
653
bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag);
651
 
Table *create_tmp_table(Session *session,TMP_TABLE_PARAM *param,List<Item> &fields,
 
654
Table *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
652
655
                        order_st *group, bool distinct, bool save_sum_fields,
653
656
                        uint64_t select_options, ha_rows rows_limit,
654
657
                        char* alias);
655
 
void free_tmp_table(Session *session, Table *entry);
 
658
void free_tmp_table(THD *thd, Table *entry);
656
659
void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param, 
657
660
                       List<Item> &fields, bool reset_with_sum_func);
658
 
bool setup_copy_fields(Session *session, TMP_TABLE_PARAM *param,
 
661
bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
659
662
                       Item **ref_pointer_array,
660
663
                       List<Item> &new_list1, List<Item> &new_list2,
661
664
                       uint32_t elements, List<Item> &fields);
662
665
void copy_fields(TMP_TABLE_PARAM *param);
663
666
void copy_funcs(Item **func_ptr);
664
 
Field* create_tmp_field_from_field(Session *session, Field* org_field,
 
667
Field* create_tmp_field_from_field(THD *thd, Field* org_field,
665
668
                                   const char *name, Table *table,
666
669
                                   Item_field *item, uint32_t convert_blob_length);
667
670
                                                                      
679
682
public:
680
683
  bool null_key; /* true <=> the value of the key has a null part */
681
684
  enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
682
 
  store_key(Session *session, Field *field_arg, unsigned char *ptr, unsigned char *null, uint32_t length)
 
685
  store_key(THD *thd, Field *field_arg, unsigned char *ptr, unsigned char *null, uint32_t length)
683
686
    :null_key(0), null_ptr(null), err(0)
684
687
  {
685
688
    if (field_arg->type() == DRIZZLE_TYPE_BLOB)
694
697
      to_field->init(field_arg->table);
695
698
    }
696
699
    else
697
 
      to_field=field_arg->new_key_field(session->mem_root, field_arg->table,
 
700
      to_field=field_arg->new_key_field(thd->mem_root, field_arg->table,
698
701
                                        ptr, null, 1);
699
702
  }
700
703
  virtual ~store_key() {}                       /** Not actually needed */
709
712
  enum store_key_result copy()
710
713
  {
711
714
    enum store_key_result result;
712
 
    Session *session= to_field->table->in_use;
713
 
    enum_check_fields saved_count_cuted_fields= session->count_cuted_fields;
 
715
    THD *thd= to_field->table->in_use;
 
716
    enum_check_fields saved_count_cuted_fields= thd->count_cuted_fields;
714
717
 
715
 
    session->count_cuted_fields= CHECK_FIELD_IGNORE;
 
718
    thd->count_cuted_fields= CHECK_FIELD_IGNORE;
716
719
 
717
720
    result= copy_inner();
718
721
 
719
 
    session->count_cuted_fields= saved_count_cuted_fields;
 
722
    thd->count_cuted_fields= saved_count_cuted_fields;
720
723
 
721
724
    return result;
722
725
  }
735
738
  Copy_field copy_field;
736
739
  const char *field_name;
737
740
 public:
738
 
  store_key_field(Session *session, Field *to_field_arg, unsigned char *ptr,
 
741
  store_key_field(THD *thd, Field *to_field_arg, unsigned char *ptr,
739
742
                  unsigned char *null_ptr_arg,
740
743
                  uint32_t length, Field *from_field, const char *name_arg)
741
 
    :store_key(session, to_field_arg,ptr,
 
744
    :store_key(thd, to_field_arg,ptr,
742
745
               null_ptr_arg ? null_ptr_arg : from_field->maybe_null() ? &err
743
746
               : (unsigned char*) 0, length), field_name(name_arg)
744
747
  {
764
767
 protected:
765
768
  Item *item;
766
769
public:
767
 
  store_key_item(Session *session, Field *to_field_arg, unsigned char *ptr,
 
770
  store_key_item(THD *thd, Field *to_field_arg, unsigned char *ptr,
768
771
                 unsigned char *null_ptr_arg, uint32_t length, Item *item_arg)
769
 
    :store_key(session, to_field_arg, ptr,
 
772
    :store_key(thd, to_field_arg, ptr,
770
773
               null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
771
774
               &err : (unsigned char*) 0, length), item(item_arg)
772
775
  {}
786
789
{
787
790
  bool inited;
788
791
public:
789
 
  store_key_const_item(Session *session, Field *to_field_arg, unsigned char *ptr,
 
792
  store_key_const_item(THD *thd, Field *to_field_arg, unsigned char *ptr,
790
793
                       unsigned char *null_ptr_arg, uint32_t length,
791
794
                       Item *item_arg)
792
 
    :store_key_item(session, to_field_arg,ptr,
 
795
    :store_key_item(thd, to_field_arg,ptr,
793
796
                    null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
794
797
                    &err : (unsigned char*) 0, length, item_arg), inited(0)
795
798
  {
814
817
  }
815
818
};
816
819
 
817
 
bool cp_buffer_from_ref(Session *session, TABLE_REF *ref);
 
820
bool cp_buffer_from_ref(THD *thd, TABLE_REF *ref);
818
821
bool error_if_full_join(JOIN *join);
819
822
int safe_index_read(JOIN_TAB *tab);
820
 
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);
 
823
COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
821
824
int test_if_item_cache_changed(List<Cached_item> &list);