~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.h

  • Committer: Olaf van der Spek
  • Date: 2011-10-24 21:23:54 UTC
  • mto: This revision was merged to the branch mainline in revision 2449.
  • Revision ID: olafvdspek@gmail.com-20111024212354-j32gbc2sbsw0985q
Use str_ref

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_SQL_SELECT_H
21
 
#define DRIZZLED_SQL_SELECT_H
 
20
#pragma once
22
21
 
23
 
#include "drizzled/cached_item.h"
24
 
#include "drizzled/session.h"
25
 
#include "drizzled/field/varstring.h"
26
 
#include "drizzled/item/null.h"
 
22
#include <drizzled/cached_item.h>
 
23
#include <drizzled/field/varstring.h>
 
24
#include <drizzled/item/null.h>
27
25
#include <drizzled/enum_nested_loop_state.h>
28
 
#include "drizzled/optimizer/position.h"
29
 
#include "drizzled/optimizer/sargable_param.h"
30
 
#include "drizzled/optimizer/key_use.h"
31
 
#include "drizzled/join_cache.h"
32
 
#include "drizzled/join_table.h"
 
26
#include <drizzled/optimizer/position.h>
 
27
#include <drizzled/optimizer/sargable_param.h>
 
28
#include <drizzled/optimizer/key_use.h>
 
29
#include <drizzled/join_cache.h>
 
30
#include <drizzled/join_table.h>
 
31
#include <drizzled/records.h>
 
32
#include <drizzled/stored_key.h>
33
33
 
34
34
#include <vector>
35
35
 
36
 
namespace drizzled
37
 
{
38
 
 
39
 
class select_result;
 
36
namespace drizzled {
40
37
 
41
38
/**
42
39
 * @file API and Classes to use when handling where clause
49
46
#define KEY_OPTIMIZE_EXISTS             1
50
47
#define KEY_OPTIMIZE_REF_OR_NULL        2
51
48
 
52
 
class Join;
53
 
 
54
49
enum_nested_loop_state sub_select_cache(Join *join, JoinTable *join_tab, bool end_of_records);
55
50
enum_nested_loop_state sub_select(Join *join,JoinTable *join_tab, bool end_of_records);
56
51
enum_nested_loop_state end_send_group(Join *join, JoinTable *join_tab, bool end_of_records);
57
52
enum_nested_loop_state end_write_group(Join *join, JoinTable *join_tab, bool end_of_records);
58
53
 
59
 
typedef struct st_rollup
 
54
class Rollup
60
55
{
 
56
public:
61
57
  enum State { STATE_NONE, STATE_INITED, STATE_READY };
 
58
 
 
59
  Rollup()
 
60
  :
 
61
  state(),
 
62
  null_items(NULL),
 
63
  ref_pointer_arrays(NULL),
 
64
  fields()
 
65
  {}
 
66
  
 
67
  Rollup(State in_state,
 
68
         Item_null_result **in_null_items,
 
69
         Item ***in_ref_pointer_arrays,
 
70
         List<Item> *in_fields)
 
71
  :
 
72
  state(in_state),
 
73
  null_items(in_null_items),
 
74
  ref_pointer_arrays(in_ref_pointer_arrays),
 
75
  fields(in_fields)
 
76
  {}
 
77
  
 
78
  State getState() const
 
79
  {
 
80
    return state;
 
81
  }
 
82
 
 
83
  void setState(State in_state)
 
84
  {
 
85
    state= in_state;
 
86
  }
 
87
 
 
88
  Item_null_result **getNullItems() const
 
89
  {
 
90
    return null_items;
 
91
  }
 
92
 
 
93
  void setNullItems(Item_null_result **in_null_items)
 
94
  {
 
95
    null_items= in_null_items;
 
96
  }
 
97
 
 
98
  Item ***getRefPointerArrays() const
 
99
  {
 
100
    return ref_pointer_arrays;
 
101
  }
 
102
 
 
103
  void setRefPointerArrays(Item ***in_ref_pointer_arrays)
 
104
  {
 
105
    ref_pointer_arrays= in_ref_pointer_arrays;
 
106
  }
 
107
 
 
108
  List<Item> *getFields() const
 
109
  {
 
110
    return fields;
 
111
  }
 
112
 
 
113
  void setFields(List<Item> *in_fields)
 
114
  {
 
115
    fields= in_fields;
 
116
  }
 
117
  
 
118
private:
62
119
  State state;
63
120
  Item_null_result **null_items;
64
121
  Item ***ref_pointer_arrays;
65
122
  List<Item> *fields;
66
 
} ROLLUP;
 
123
};
67
124
 
68
125
} /* namespace drizzled */
69
126
 
70
127
/** @TODO why is this in the middle of the file??? */
71
128
 
72
 
#include "drizzled/join.h"
 
129
#include <drizzled/join.h>
73
130
 
74
131
namespace drizzled
75
132
{
82
139
  item->marker should be 0 for all items on entry
83
140
  Return in cond_value false if condition is impossible (1 = 2)
84
141
*****************************************************************************/
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
 
};
 
142
typedef std::pair<Item*, Item_func*> COND_CMP;
90
143
 
91
144
void TEST_join(Join *join);
92
145
 
145
198
                                                 List<Item> &all_fields);
146
199
bool change_group_ref(Session *session, Item_func *expr, Order *group_list, bool *changed);
147
200
bool check_interleaving_with_nj(JoinTable *next);
148
 
 
149
 
int join_read_const_table(JoinTable *tab, optimizer::Position *pos);
150
 
int join_read_system(JoinTable *tab);
 
201
void update_const_equal_items(COND *cond, JoinTable *tab);
151
202
int join_read_const(JoinTable *tab);
152
203
int join_read_key(JoinTable *tab);
153
204
int join_read_always_key(JoinTable *tab);
181
232
void add_not_null_conds(Join *join);
182
233
uint32_t max_part_bit(key_part_map bits);
183
234
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);
190
235
bool eq_ref_table(Join *join, Order *start_order, JoinTable *tab);
191
236
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having);
192
237
int remove_dup_with_hash_index(Session *session, 
195
240
                               Field **first_field,
196
241
                               uint32_t key_length,
197
242
                               Item *having);
198
 
bool update_ref_and_keys(Session *session,
 
243
void update_ref_and_keys(Session *session,
199
244
                         DYNAMIC_ARRAY *keyuse,
200
245
                         JoinTable *join_tab,
201
246
                         uint32_t tables,
208
253
void optimize_keyuse(Join *join, DYNAMIC_ARRAY *keyuse_array);
209
254
void add_group_and_distinct_keys(Join *join, JoinTable *join_tab);
210
255
void read_cached_record(JoinTable *tab);
211
 
bool mysql_select(Session *session, Item ***rref_pointer_array,
 
256
bool select_query(Session *session, Item ***rref_pointer_array,
212
257
                  TableList *tables, uint32_t wild_num,  List<Item> &list,
213
258
                  COND *conds, uint32_t og_num, Order *order, Order *group,
214
259
                  Item *having, uint64_t select_type,
222
267
                        optimizer::KeyUse *org_keyuse, 
223
268
                        table_map used_tables);
224
269
 
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
 
 
234
270
bool cp_buffer_from_ref(Session *session, table_reference_st *ref);
235
271
int safe_index_read(JoinTable *tab);
236
272
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);
237
273
int test_if_item_cache_changed(List<Cached_item> &list);
238
274
 
239
 
void print_join(Session *session, String *str,
240
 
                List<TableList> *tables, enum_query_type);
 
275
void print_join(Session *session, String *str, List<TableList> *tables);
241
276
 
242
277
} /* namespace drizzled */
243
278
 
244
 
#endif /* DRIZZLED_SQL_SELECT_H */