~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.h

  • Committer: Brian Aker
  • Date: 2010-12-19 06:20:54 UTC
  • mfrom: (2005.1.1 bug673105)
  • Revision ID: brian@tangent.org-20101219062054-1kt0l3dxs4z2z8md
Merge Dave.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
207
145
                                                 List<Item> &all_fields);
208
146
bool change_group_ref(Session *session, Item_func *expr, Order *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);
 
184
Order *create_distinct_group(Session *session,
 
185
                                Item **ref_pointer_array,
 
186
                                Order *order,
 
187
                                List<Item> &fields,
 
188
                                List<Item> &all_fields,
 
189
                                bool *all_order_by_fields_used);
244
190
bool eq_ref_table(Join *join, Order *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, 
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
213
                  COND *conds, uint32_t og_num, Order *order, Order *group,
268
214
                  Item *having, uint64_t select_type,
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);