390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1055.2.21
by Jay Pipes
Documentation and indentation/style cleanups in sql_select, opt_range.h and join_tab.h. This patch doxygenates classes/structs and their member variables. |
4 |
* Copyright (C) 2008-2009 Sun Microsystems
|
390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
1
by brian
clean slate |
19 |
|
575.4.7
by Monty Taylor
More header cleanup. |
20 |
#ifndef DRIZZLED_SQL_SELECT_H
|
21 |
#define DRIZZLED_SQL_SELECT_H
|
|
22 |
||
1055.2.21
by Jay Pipes
Documentation and indentation/style cleanups in sql_select, opt_range.h and join_tab.h. This patch doxygenates classes/structs and their member variables. |
23 |
#include "drizzled/cached_item.h" |
24 |
#include "drizzled/session.h" |
|
25 |
#include "drizzled/field/varstring.h" |
|
26 |
#include "drizzled/item/null.h" |
|
1089.1.8
by Brian Aker
Shuffled around a few structures. |
27 |
#include <drizzled/enum_nested_loop_state.h> |
1108.6.56
by Padraig O'Sullivan
Extracted KeyUse into its own header file and placed it within the |
28 |
#include "drizzled/optimizer/position.h" |
29 |
#include "drizzled/optimizer/sargable_param.h" |
|
30 |
#include "drizzled/optimizer/key_use.h" |
|
1089.1.8
by Brian Aker
Shuffled around a few structures. |
31 |
#include "drizzled/join_cache.h" |
32 |
#include "drizzled/join_table.h" |
|
33 |
||
1108.6.33
by Padraig O'Sullivan
Use std::vector to hold an array of SargableParam objects instead of a |
34 |
#include <vector> |
35 |
||
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
36 |
|
37 |
class select_result; |
|
38 |
||
1
by brian
clean slate |
39 |
/**
|
1055.2.21
by Jay Pipes
Documentation and indentation/style cleanups in sql_select, opt_range.h and join_tab.h. This patch doxygenates classes/structs and their member variables. |
40 |
* @file API and Classes to use when handling where clause
|
41 |
*/
|
|
1
by brian
clean slate |
42 |
|
243.1.13
by Jay Pipes
More comments in mysql_priv.h to mark stuff TODO. Move sql_locale.h and object_creation_ctx.h up in the file since no more dependencies above them. |
43 |
/* PREV_BITS only used in sql_select.cc */
|
44 |
#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))
|
|
45 |
||
992.1.25
by Monty Taylor
Moved myisam to new plugin system. |
46 |
#include <plugin/myisam/myisam.h> |
520.8.4
by Monty Taylor
Removed global sql_array.h. |
47 |
#include <drizzled/sql_array.h> |
1
by brian
clean slate |
48 |
|
49 |
/* Values in optimize */
|
|
50 |
#define KEY_OPTIMIZE_EXISTS 1
|
|
51 |
#define KEY_OPTIMIZE_REF_OR_NULL 2
|
|
52 |
||
53 |
class JOIN; |
|
54 |
||
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
55 |
enum_nested_loop_state sub_select_cache(JOIN *join, JoinTable *join_tab, bool end_of_records); |
56 |
enum_nested_loop_state sub_select(JOIN *join,JoinTable *join_tab, bool end_of_records); |
|
57 |
enum_nested_loop_state end_send_group(JOIN *join, JoinTable *join_tab, bool end_of_records); |
|
58 |
enum_nested_loop_state end_write_group(JOIN *join, JoinTable *join_tab, bool end_of_records); |
|
1
by brian
clean slate |
59 |
|
60 |
typedef struct st_rollup |
|
61 |
{
|
|
62 |
enum State { STATE_NONE, STATE_INITED, STATE_READY }; |
|
63 |
State state; |
|
64 |
Item_null_result **null_items; |
|
65 |
Item ***ref_pointer_arrays; |
|
66 |
List<Item> *fields; |
|
67 |
} ROLLUP; |
|
68 |
||
1039.2.1
by Jay Pipes
First phase refactoring the JOIN class: |
69 |
#include "drizzled/join.h" |
1
by brian
clean slate |
70 |
|
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
71 |
/*****************************************************************************
|
72 |
Make som simple condition optimization:
|
|
73 |
If there is a test 'field = const' change all refs to 'field' to 'const'
|
|
74 |
Remove all dummy tests 'item = item', 'const op const'.
|
|
75 |
Remove all 'item is NULL', when item can never be null!
|
|
76 |
item->marker should be 0 for all items on entry
|
|
77 |
Return in cond_value false if condition is impossible (1 = 2)
|
|
78 |
*****************************************************************************/
|
|
1054.2.7
by Monty Taylor
Fixed Solaris build problem. Removde unused new/delete opeartors. |
79 |
struct COND_CMP { |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
80 |
Item *and_level; |
81 |
Item_func *cmp_func; |
|
82 |
COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {} |
|
83 |
};
|
|
84 |
||
1
by brian
clean slate |
85 |
void TEST_join(JOIN *join); |
86 |
||
87 |
/* Extern functions in sql_select.cc */
|
|
88 |
bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag); |
|
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
89 |
Table *create_tmp_table(Session *session,Tmp_Table_Param *param,List<Item> &fields, |
327.2.3
by Brian Aker
Refactoring of class Table |
90 |
order_st *group, bool distinct, bool save_sum_fields, |
151
by Brian Aker
Ulonglong to uint64_t |
91 |
uint64_t select_options, ha_rows rows_limit, |
1039.1.4
by Brian Aker
Modified alias to being const. |
92 |
const char* alias); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
93 |
void free_tmp_table(Session *session, Table *entry); |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
94 |
void count_field_types(Select_Lex *select_lex, Tmp_Table_Param *param, |
1
by brian
clean slate |
95 |
List<Item> &fields, bool reset_with_sum_func); |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
96 |
bool setup_copy_fields(Session *session, Tmp_Table_Param *param, |
1
by brian
clean slate |
97 |
Item **ref_pointer_array, |
98 |
List<Item> &new_list1, List<Item> &new_list2, |
|
482
by Brian Aker
Remove uint. |
99 |
uint32_t elements, List<Item> &fields); |
851
by Brian Aker
Class rewrite of Session (aka get all of the junk out) |
100 |
void copy_fields(Tmp_Table_Param *param); |
1
by brian
clean slate |
101 |
void copy_funcs(Item **func_ptr); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
102 |
Field* create_tmp_field_from_field(Session *session, Field* org_field, |
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
103 |
const char *name, Table *table, |
482
by Brian Aker
Remove uint. |
104 |
Item_field *item, uint32_t convert_blob_length); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
105 |
bool test_if_ref(Item_field *left_item,Item *right_item); |
106 |
COND *optimize_cond(JOIN *join, COND *conds, List<TableList> *join_list, Item::cond_result *cond_value); |
|
107 |
COND *make_cond_for_table(COND *cond,table_map table, table_map used_table, bool exclude_expensive_cond); |
|
108 |
COND* substitute_for_best_equal_field(COND *cond, COND_EQUAL *cond_equal, void *table_join_idx); |
|
109 |
bool list_contains_unique_index(Table *table, bool (*find_func) (Field *, void *), void *data); |
|
110 |
bool find_field_in_order_list (Field *field, void *data); |
|
111 |
bool find_field_in_item_list (Field *field, void *data); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
112 |
bool test_if_skip_sort_order(JoinTable *tab,order_st *order,ha_rows select_limit, bool no_changes, const key_map *map); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
113 |
order_st *create_distinct_group(Session *session, |
114 |
Item **ref_pointer_array, |
|
115 |
order_st *order_list, |
|
116 |
List<Item> &fields, |
|
117 |
List<Item> &, |
|
118 |
bool *all_order_by_fields_used); |
|
119 |
// Create list for using with tempory table
|
|
120 |
bool change_to_use_tmp_fields(Session *session, |
|
121 |
Item **ref_pointer_array, |
|
122 |
List<Item> &res_selected_fields, |
|
123 |
List<Item> &res_all_fields, |
|
124 |
uint32_t elements, |
|
125 |
List<Item> &all_fields); |
|
126 |
int do_select(JOIN *join, List<Item> *fields, Table *tmp_table); |
|
127 |
bool const_expression_in_where(COND *conds,Item *item, Item **comp_item); |
|
128 |
int create_sort_index(Session *session, JOIN *join, order_st *order, ha_rows filesort_limit, ha_rows select_limit, bool is_order_by); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
129 |
void save_index_subquery_explain_info(JoinTable *join_tab, Item* where); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
130 |
Item *remove_additional_cond(Item* conds); |
131 |
bool setup_sum_funcs(Session *session, Item_sum **func_ptr); |
|
132 |
bool init_sum_functions(Item_sum **func, Item_sum **end); |
|
133 |
bool update_sum_func(Item_sum **func); |
|
134 |
void copy_sum_funcs(Item_sum **func_ptr, Item_sum **end); |
|
135 |
bool change_refs_to_tmp_fields(Session *session, |
|
136 |
Item **ref_pointer_array, |
|
137 |
List<Item> &res_selected_fields, |
|
138 |
List<Item> &res_all_fields, |
|
139 |
uint32_t elements, |
|
140 |
List<Item> &all_fields); |
|
141 |
void select_describe(JOIN *join, bool need_tmp_table,bool need_order, bool distinct, const char *message= NULL); |
|
142 |
bool change_group_ref(Session *session, Item_func *expr, order_st *group_list, bool *changed); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
143 |
bool check_interleaving_with_nj(JoinTable *last, JoinTable *next); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
144 |
|
1108.6.29
by Padraig O'Sullivan
Added an optimizer namespace and sub-directory within drizzled. Moved the |
145 |
int join_read_const_table(JoinTable *tab, drizzled::optimizer::Position *pos); |
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
146 |
int join_read_system(JoinTable *tab); |
147 |
int join_read_const(JoinTable *tab); |
|
148 |
int join_read_key(JoinTable *tab); |
|
149 |
int join_read_always_key(JoinTable *tab); |
|
150 |
int join_read_last_key(JoinTable *tab); |
|
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
151 |
int join_no_more_records(READ_RECORD *info); |
152 |
int join_read_next(READ_RECORD *info); |
|
153 |
int join_read_next_different(READ_RECORD *info); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
154 |
int join_init_quick_read_record(JoinTable *tab); |
1090.1.1
by Brian Aker
Collection of patches/bug fixes from new-cleanup tree (none of the |
155 |
int init_read_record_seq(JoinTable *tab); |
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
156 |
int test_if_quick_select(JoinTable *tab); |
157 |
int join_init_read_record(JoinTable *tab); |
|
158 |
int join_read_first(JoinTable *tab); |
|
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
159 |
int join_read_next_same(READ_RECORD *info); |
160 |
int join_read_next_same_diff(READ_RECORD *info); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
161 |
int join_read_last(JoinTable *tab); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
162 |
int join_read_prev_same(READ_RECORD *info); |
163 |
int join_read_prev(READ_RECORD *info); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
164 |
int join_read_always_key_or_null(JoinTable *tab); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
165 |
int join_read_next_same_or_null(READ_RECORD *info); |
166 |
||
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
167 |
void calc_used_field_length(Session *, JoinTable *join_tab); |
1039.2.3
by Jay Pipes
Phase 3 of refactoring JOIN |
168 |
StoredKey *get_store_key(Session *session, |
1108.6.56
by Padraig O'Sullivan
Extracted KeyUse into its own header file and placed it within the |
169 |
drizzled::optimizer::KeyUse *keyuse, |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
170 |
table_map used_tables, |
171 |
KEY_PART_INFO *key_part, |
|
172 |
unsigned char *key_buff, |
|
173 |
uint32_t maybe_null); |
|
174 |
extern "C" int join_tab_cmp(const void* ptr1, const void* ptr2); |
|
175 |
extern "C" int join_tab_cmp_straight(const void* ptr1, const void* ptr2); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
176 |
void push_index_cond(JoinTable *tab, uint32_t keyno, bool other_tbls_ok); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
177 |
void add_not_null_conds(JOIN *join); |
178 |
uint32_t max_part_bit(key_part_map bits); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
179 |
COND *add_found_match_trig_cond(JoinTable *tab, COND *cond, JoinTable *root_tab); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
180 |
order_st *create_distinct_group(Session *session, |
181 |
Item **ref_pointer_array, |
|
182 |
order_st *order, |
|
183 |
List<Item> &fields, |
|
184 |
List<Item> &all_fields, |
|
185 |
bool *all_order_by_fields_used); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
186 |
bool eq_ref_table(JOIN *join, order_st *start_order, JoinTable *tab); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
187 |
int join_tab_cmp(const void* ptr1, const void* ptr2); |
188 |
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having); |
|
189 |
int remove_dup_with_hash_index(Session *session, |
|
190 |
Table *table, |
|
191 |
uint32_t field_count, |
|
192 |
Field **first_field, |
|
193 |
uint32_t key_length, |
|
194 |
Item *having); |
|
195 |
bool update_ref_and_keys(Session *session, |
|
196 |
DYNAMIC_ARRAY *keyuse, |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
197 |
JoinTable *join_tab, |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
198 |
uint32_t tables, |
199 |
COND *cond, |
|
200 |
COND_EQUAL *, |
|
201 |
table_map normal_tables, |
|
202 |
Select_Lex *select_lex, |
|
1108.6.39
by Padraig O'Sullivan
Placed the SargableParam class in the optimizer namespace and sub-directory. |
203 |
std::vector<drizzled::optimizer::SargableParam> &sargables); |
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
204 |
ha_rows get_quick_record_count(Session *session, SQL_SELECT *select, Table *table, const key_map *keys,ha_rows limit); |
205 |
void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array); |
|
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
206 |
void add_group_and_distinct_keys(JOIN *join, JoinTable *join_tab); |
207 |
void read_cached_record(JoinTable *tab); |
|
1039.2.2
by Jay Pipes
Phase 2 of JOIN refactoring. |
208 |
// Create list for using with tempory table
|
209 |
void init_tmptable_sum_functions(Item_sum **func); |
|
210 |
void update_tmptable_sum_func(Item_sum **func,Table *tmp_table); |
|
211 |
bool only_eq_ref_tables(JOIN *join, order_st *order, table_map tables); |
|
1108.6.56
by Padraig O'Sullivan
Extracted KeyUse into its own header file and placed it within the |
212 |
bool create_ref_for_key(JOIN *join, JoinTable *j, |
213 |
drizzled::optimizer::KeyUse *org_keyuse, |
|
214 |
table_map used_tables); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
215 |
|
1
by brian
clean slate |
216 |
/* functions from opt_sum.cc */
|
217 |
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order); |
|
327.2.4
by Brian Aker
Refactoring table.h |
218 |
int opt_sum_query(TableList *tables, List<Item> &all_fields,COND *conds); |
1
by brian
clean slate |
219 |
|
220 |
/* from sql_delete.cc, used by opt_range.cc */
|
|
221 |
extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b); |
|
222 |
||
1039.2.3
by Jay Pipes
Phase 3 of refactoring JOIN |
223 |
#include "drizzled/stored_key.h" |
1
by brian
clean slate |
224 |
|
1089.1.14
by Brian Aker
Fix TABLE_REF structure |
225 |
bool cp_buffer_from_ref(Session *session, table_reference_st *ref); |
1089.1.1
by Brian Aker
Remove of JOIN_TAB to JoinTable |
226 |
int safe_index_read(JoinTable *tab); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
227 |
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value); |
1101.1.16
by Monty Taylor
Reverted 1103 |
228 |
int test_if_item_cache_changed(List<Cached_item> &list); |
575.4.7
by Monty Taylor
More header cleanup. |
229 |
|
1054.1.7
by Brian Aker
Refactor TableList methods. |
230 |
void print_join(Session *session, String *str, |
231 |
List<TableList> *tables, enum_query_type); |
|
232 |
||
575.4.7
by Monty Taylor
More header cleanup. |
233 |
#endif /* DRIZZLED_SQL_SELECT_H */ |