17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_SQL_SELECT_H
21
#define DRIZZLED_SQL_SELECT_H
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>
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
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);
59
typedef struct st_rollup
61
57
enum State { STATE_NONE, STATE_INITED, STATE_READY };
63
ref_pointer_arrays(NULL),
67
Rollup(State in_state,
68
Item_null_result **in_null_items,
69
Item ***in_ref_pointer_arrays,
70
List<Item> *in_fields)
73
null_items(in_null_items),
74
ref_pointer_arrays(in_ref_pointer_arrays),
78
State getState() const
83
void setState(State in_state)
88
Item_null_result **getNullItems() const
93
void setNullItems(Item_null_result **in_null_items)
95
null_items= in_null_items;
98
Item ***getRefPointerArrays() const
100
return ref_pointer_arrays;
103
void setRefPointerArrays(Item ***in_ref_pointer_arrays)
105
ref_pointer_arrays= in_ref_pointer_arrays;
108
List<Item> *getFields() const
113
void setFields(List<Item> *in_fields)
63
120
Item_null_result **null_items;
64
121
Item ***ref_pointer_arrays;
65
122
List<Item> *fields;
68
125
} /* namespace drizzled */
70
127
/** @TODO why is this in the middle of the file??? */
72
#include "drizzled/join.h"
129
#include <drizzled/join.h>
74
131
namespace drizzled
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
*****************************************************************************/
88
COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {}
142
typedef std::pair<Item*, Item_func*> COND_CMP;
91
144
void TEST_join(Join *join);
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);
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,
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,
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);
225
} /* namespace drizzled */
227
/** @TODO why is this in the middle of the file??? */
229
#include "drizzled/stored_key.h"
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);
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);
242
277
} /* namespace drizzled */
244
#endif /* DRIZZLED_SQL_SELECT_H */