~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.h

  • Committer: Brian Aker
  • Date: 2010-10-28 17:12:01 UTC
  • mfrom: (1887.1.3 merge)
  • Revision ID: brian@tangent.org-20101028171201-baj6l1bnntn1s4ad
Merge in POTFILES changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
21
21
#define DRIZZLED_SQL_SELECT_H
22
22
 
23
23
#include "drizzled/cached_item.h"
 
24
#include "drizzled/session.h"
24
25
#include "drizzled/field/varstring.h"
25
26
#include "drizzled/item/null.h"
26
27
#include <drizzled/enum_nested_loop_state.h>
29
30
#include "drizzled/optimizer/key_use.h"
30
31
#include "drizzled/join_cache.h"
31
32
#include "drizzled/join_table.h"
32
 
#include "drizzled/records.h"
33
 
#include "drizzled/stored_key.h"
34
33
 
35
34
#include <vector>
36
35
 
37
36
namespace drizzled
38
37
{
39
38
 
40
 
class Item_func;
41
 
class Select_Lex_Unit;
42
39
class select_result;
43
 
class st_dynamic_array;
44
40
 
45
41
/**
46
42
 * @file API and Classes to use when handling where clause
60
56
enum_nested_loop_state end_send_group(Join *join, JoinTable *join_tab, bool end_of_records);
61
57
enum_nested_loop_state end_write_group(Join *join, JoinTable *join_tab, bool end_of_records);
62
58
 
63
 
class Rollup
 
59
typedef struct st_rollup
64
60
{
65
 
public:
66
61
  enum State { STATE_NONE, STATE_INITED, STATE_READY };
67
 
 
68
 
  Rollup()
69
 
  :
70
 
  state(),
71
 
  null_items(NULL),
72
 
  ref_pointer_arrays(NULL),
73
 
  fields()
74
 
  {}
75
 
  
76
 
  Rollup(State in_state,
77
 
         Item_null_result **in_null_items,
78
 
         Item ***in_ref_pointer_arrays,
79
 
         List<Item> *in_fields)
80
 
  :
81
 
  state(in_state),
82
 
  null_items(in_null_items),
83
 
  ref_pointer_arrays(in_ref_pointer_arrays),
84
 
  fields(in_fields)
85
 
  {}
86
 
  
87
 
  State getState() const
88
 
  {
89
 
    return state;
90
 
  }
91
 
 
92
 
  void setState(State in_state)
93
 
  {
94
 
    state= in_state;
95
 
  }
96
 
 
97
 
  Item_null_result **getNullItems() const
98
 
  {
99
 
    return null_items;
100
 
  }
101
 
 
102
 
  void setNullItems(Item_null_result **in_null_items)
103
 
  {
104
 
    null_items= in_null_items;
105
 
  }
106
 
 
107
 
  Item ***getRefPointerArrays() const
108
 
  {
109
 
    return ref_pointer_arrays;
110
 
  }
111
 
 
112
 
  void setRefPointerArrays(Item ***in_ref_pointer_arrays)
113
 
  {
114
 
    ref_pointer_arrays= in_ref_pointer_arrays;
115
 
  }
116
 
 
117
 
  List<Item> *getFields() const
118
 
  {
119
 
    return fields;
120
 
  }
121
 
 
122
 
  void setFields(List<Item> *in_fields)
123
 
  {
124
 
    fields= in_fields;
125
 
  }
126
 
  
127
 
private:
128
62
  State state;
129
63
  Item_null_result **null_items;
130
64
  Item ***ref_pointer_arrays;
131
65
  List<Item> *fields;
132
 
};
 
66
} ROLLUP;
133
67
 
134
68
} /* namespace drizzled */
135
69
 
148
82
  item->marker should be 0 for all items on entry
149
83
  Return in cond_value false if condition is impossible (1 = 2)
150
84
*****************************************************************************/
151
 
typedef std::pair<Item*, Item_func*> COND_CMP;
 
85
struct COND_CMP {
 
86
  Item *and_level;
 
87
  Item_func *cmp_func;
 
88
  COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {}
 
89
};
152
90
 
153
91
void TEST_join(Join *join);
154
92
 
155
93
/* Extern functions in sql_select.cc */
156
94
bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag);
157
95
Table *create_tmp_table(Session *session,Tmp_Table_Param *param,List<Item> &fields,
158
 
                        Order *group, bool distinct, bool save_sum_fields,
 
96
                        order_st *group, bool distinct, bool save_sum_fields,
159
97
                        uint64_t select_options, ha_rows rows_limit,
160
98
                        const char* alias);
161
99
void count_field_types(Select_Lex *select_lex, Tmp_Table_Param *param,
165
103
                       List<Item> &new_list1, List<Item> &new_list2,
166
104
                       uint32_t elements, List<Item> &fields);
167
105
void copy_fields(Tmp_Table_Param *param);
168
 
bool copy_funcs(Item **func_ptr, const Session *session);
 
106
void copy_funcs(Item **func_ptr);
169
107
Field* create_tmp_field_from_field(Session *session, Field* org_field,
170
108
                                   const char *name, Table *table,
171
109
                                   Item_field *item, uint32_t convert_blob_length);
176
114
bool list_contains_unique_index(Table *table, bool (*find_func) (Field *, void *), void *data);
177
115
bool find_field_in_order_list (Field *field, void *data);
178
116
bool find_field_in_item_list (Field *field, void *data);
179
 
bool test_if_skip_sort_order(JoinTable *tab,Order *order,ha_rows select_limit, bool no_changes, const key_map *map);
180
 
Order *create_distinct_group(Session *session,
 
117
bool test_if_skip_sort_order(JoinTable *tab,order_st *order,ha_rows select_limit, bool no_changes, const key_map *map);
 
118
order_st *create_distinct_group(Session *session,
181
119
                                Item **ref_pointer_array,
182
 
                                Order *order_list,
 
120
                                order_st *order_list,
183
121
                                List<Item> &fields,
184
122
                                List<Item> &,
185
123
                                bool *all_order_by_fields_used);
192
130
                              List<Item> &all_fields);
193
131
int do_select(Join *join, List<Item> *fields, Table *tmp_table);
194
132
bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
195
 
int create_sort_index(Session *session, Join *join, Order *order, ha_rows filesort_limit, ha_rows select_limit, bool is_order_by);
 
133
int create_sort_index(Session *session, Join *join, order_st *order, ha_rows filesort_limit, ha_rows select_limit, bool is_order_by);
196
134
void save_index_subquery_explain_info(JoinTable *join_tab, Item* where);
197
135
Item *remove_additional_cond(Item* conds);
198
136
bool setup_sum_funcs(Session *session, Item_sum **func_ptr);
205
143
                               List<Item> &res_all_fields,
206
144
                               uint32_t elements,
207
145
                                                 List<Item> &all_fields);
208
 
bool change_group_ref(Session *session, Item_func *expr, Order *group_list, bool *changed);
 
146
bool change_group_ref(Session *session, Item_func *expr, order_st *group_list, bool *changed);
209
147
bool check_interleaving_with_nj(JoinTable *next);
210
 
void update_const_equal_items(COND *cond, JoinTable *tab);
 
148
 
 
149
int join_read_const_table(JoinTable *tab, optimizer::Position *pos);
 
150
int join_read_system(JoinTable *tab);
211
151
int join_read_const(JoinTable *tab);
212
152
int join_read_key(JoinTable *tab);
213
153
int join_read_always_key(JoinTable *tab);
241
181
void add_not_null_conds(Join *join);
242
182
uint32_t max_part_bit(key_part_map bits);
243
183
COND *add_found_match_trig_cond(JoinTable *tab, COND *cond, JoinTable *root_tab);
244
 
bool eq_ref_table(Join *join, Order *start_order, JoinTable *tab);
 
184
order_st *create_distinct_group(Session *session,
 
185
                                Item **ref_pointer_array,
 
186
                                order_st *order,
 
187
                                List<Item> &fields,
 
188
                                List<Item> &all_fields,
 
189
                                bool *all_order_by_fields_used);
 
190
bool eq_ref_table(Join *join, order_st *start_order, JoinTable *tab);
245
191
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having);
246
192
int remove_dup_with_hash_index(Session *session, 
247
193
                               Table *table,
262
208
void optimize_keyuse(Join *join, DYNAMIC_ARRAY *keyuse_array);
263
209
void add_group_and_distinct_keys(Join *join, JoinTable *join_tab);
264
210
void read_cached_record(JoinTable *tab);
265
 
bool select_query(Session *session, Item ***rref_pointer_array,
 
211
bool mysql_select(Session *session, Item ***rref_pointer_array,
266
212
                  TableList *tables, uint32_t wild_num,  List<Item> &list,
267
 
                  COND *conds, uint32_t og_num, Order *order, Order *group,
 
213
                  COND *conds, uint32_t og_num, order_st *order, order_st *group,
268
214
                  Item *having, uint64_t select_type,
269
215
                  select_result *result, Select_Lex_Unit *unit,
270
216
                  Select_Lex *select_lex);
271
217
// Create list for using with tempory table
272
218
void init_tmptable_sum_functions(Item_sum **func);
273
219
void update_tmptable_sum_func(Item_sum **func,Table *tmp_table);
274
 
bool only_eq_ref_tables(Join *join, Order *order, table_map tables);
 
220
bool only_eq_ref_tables(Join *join, order_st *order, table_map tables);
275
221
bool create_ref_for_key(Join *join, JoinTable *j, 
276
222
                        optimizer::KeyUse *org_keyuse, 
277
223
                        table_map used_tables);
278
224
 
 
225
} /* namespace drizzled */
 
226
 
 
227
/** @TODO why is this in the middle of the file??? */
 
228
 
 
229
#include "drizzled/stored_key.h"
 
230
 
 
231
namespace drizzled
 
232
{
 
233
 
279
234
bool cp_buffer_from_ref(Session *session, table_reference_st *ref);
280
235
int safe_index_read(JoinTable *tab);
281
236
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);