1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
4
* Copyright (C) 2008-2009 Sun Microsystems
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
20
20
#ifndef DRIZZLED_SQL_SELECT_H
21
21
#define DRIZZLED_SQL_SELECT_H
23
#include <drizzled/cached_item.h>
24
#include <drizzled/field/varstring.h>
25
#include <drizzled/item/null.h>
23
#include "drizzled/cached_item.h"
24
#include "drizzled/session.h"
25
#include "drizzled/field/varstring.h"
26
#include "drizzled/item/null.h"
26
27
#include <drizzled/enum_nested_loop_state.h>
27
#include <drizzled/optimizer/position.h>
28
#include <drizzled/optimizer/sargable_param.h>
29
#include <drizzled/optimizer/key_use.h>
30
#include <drizzled/join_cache.h>
31
#include <drizzled/join_table.h>
32
#include <drizzled/records.h>
33
#include <drizzled/stored_key.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"
41
class Select_Lex_Unit;
42
39
class select_result;
43
class st_dynamic_array;
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);
59
typedef struct st_rollup
66
61
enum State { STATE_NONE, STATE_INITED, STATE_READY };
72
ref_pointer_arrays(NULL),
76
Rollup(State in_state,
77
Item_null_result **in_null_items,
78
Item ***in_ref_pointer_arrays,
79
List<Item> *in_fields)
82
null_items(in_null_items),
83
ref_pointer_arrays(in_ref_pointer_arrays),
87
State getState() const
92
void setState(State in_state)
97
Item_null_result **getNullItems() const
102
void setNullItems(Item_null_result **in_null_items)
104
null_items= in_null_items;
107
Item ***getRefPointerArrays() const
109
return ref_pointer_arrays;
112
void setRefPointerArrays(Item ***in_ref_pointer_arrays)
114
ref_pointer_arrays= in_ref_pointer_arrays;
117
List<Item> *getFields() const
122
void setFields(List<Item> *in_fields)
129
63
Item_null_result **null_items;
130
64
Item ***ref_pointer_arrays;
131
65
List<Item> *fields;
134
68
} /* namespace drizzled */
136
70
/** @TODO why is this in the middle of the file??? */
138
#include <drizzled/join.h>
72
#include "drizzled/join.h"
140
74
namespace drizzled
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;
88
COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {}
153
91
void TEST_join(Join *join);
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);
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,
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);
225
} /* namespace drizzled */
227
/** @TODO why is this in the middle of the file??? */
229
#include "drizzled/stored_key.h"
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);