~drizzle-trunk/drizzle/development

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
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
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
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
575.4.7 by Monty Taylor
More header cleanup.
21
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
22
#include <drizzled/cached_item.h>
23
#include <drizzled/field/varstring.h>
24
#include <drizzled/item/null.h>
1089.1.8 by Brian Aker
Shuffled around a few structures.
25
#include <drizzled/enum_nested_loop_state.h>
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
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>
1089.1.8 by Brian Aker
Shuffled around a few structures.
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
2252.1.17 by Olaf van der Spek
Common fwd
36
namespace drizzled {
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.
37
1 by brian
clean slate
38
/**
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.
39
 * @file API and Classes to use when handling where clause
40
 */
1 by brian
clean slate
41
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.
42
/* PREV_BITS only used in sql_select.cc */
43
#define PREV_BITS(type,A)	((type) (((type) 1 << (A)) -1))
44
1 by brian
clean slate
45
/* Values in optimize */
46
#define KEY_OPTIMIZE_EXISTS		1
47
#define KEY_OPTIMIZE_REF_OR_NULL	2
48
1541.1.1 by Brian Aker
JOIN -> Join rename
49
enum_nested_loop_state sub_select_cache(Join *join, JoinTable *join_tab, bool end_of_records);
50
enum_nested_loop_state sub_select(Join *join,JoinTable *join_tab, bool end_of_records);
51
enum_nested_loop_state end_send_group(Join *join, JoinTable *join_tab, bool end_of_records);
52
enum_nested_loop_state end_write_group(Join *join, JoinTable *join_tab, bool end_of_records);
1 by brian
clean slate
53
2082.3.1 by vjsamuel1990 at gmail
Merge conversion of ROLLUP from struct to class.
54
class Rollup
1 by brian
clean slate
55
{
2082.3.1 by vjsamuel1990 at gmail
Merge conversion of ROLLUP from struct to class.
56
public:
1 by brian
clean slate
57
  enum State { STATE_NONE, STATE_INITED, STATE_READY };
2082.3.1 by vjsamuel1990 at gmail
Merge conversion of ROLLUP from struct to class.
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:
1 by brian
clean slate
119
  State state;
120
  Item_null_result **null_items;
121
  Item ***ref_pointer_arrays;
122
  List<Item> *fields;
2082.3.1 by vjsamuel1990 at gmail
Merge conversion of ROLLUP from struct to class.
123
};
1 by brian
clean slate
124
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
125
} /* namespace drizzled */
126
127
/** @TODO why is this in the middle of the file??? */
128
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
129
#include <drizzled/join.h>
1 by brian
clean slate
130
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
131
namespace drizzled
132
{
133
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
134
/*****************************************************************************
135
  Make som simple condition optimization:
136
  If there is a test 'field = const' change all refs to 'field' to 'const'
137
  Remove all dummy tests 'item = item', 'const op const'.
138
  Remove all 'item is NULL', when item can never be null!
139
  item->marker should be 0 for all items on entry
140
  Return in cond_value false if condition is impossible (1 = 2)
141
*****************************************************************************/
2047.1.1 by Andrew Hutchings
Refix using placement new for join code, vector for join cache buffer.
142
typedef std::pair<Item*, Item_func*> COND_CMP;
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
143
1541.1.1 by Brian Aker
JOIN -> Join rename
144
void TEST_join(Join *join);
1 by brian
clean slate
145
146
/* Extern functions in sql_select.cc */
147
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)
148
Table *create_tmp_table(Session *session,Tmp_Table_Param *param,List<Item> &fields,
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
149
			Order *group, bool distinct, bool save_sum_fields,
151 by Brian Aker
Ulonglong to uint64_t
150
			uint64_t select_options, ha_rows rows_limit,
1039.1.4 by Brian Aker
Modified alias to being const.
151
			const char* alias);
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
152
void count_field_types(Select_Lex *select_lex, Tmp_Table_Param *param,
1 by brian
clean slate
153
                       List<Item> &fields, bool reset_with_sum_func);
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
154
bool setup_copy_fields(Session *session, Tmp_Table_Param *param,
1 by brian
clean slate
155
		       Item **ref_pointer_array,
156
		       List<Item> &new_list1, List<Item> &new_list2,
482 by Brian Aker
Remove uint.
157
		       uint32_t elements, List<Item> &fields);
851 by Brian Aker
Class rewrite of Session (aka get all of the junk out)
158
void copy_fields(Tmp_Table_Param *param);
1819.9.80 by Georgi Kodinov, Stewart Smith
Merge Revision revid:georgi.kodinov@oracle.com-20100813080739-27p9rgxvo26a6psh from MySQL InnoDB
159
bool copy_funcs(Item **func_ptr, const Session *session);
520.1.22 by Brian Aker
Second pass of thd cleanup
160
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
161
                                   const char *name, Table *table,
482 by Brian Aker
Remove uint.
162
                                   Item_field *item, uint32_t convert_blob_length);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
163
bool test_if_ref(Item_field *left_item,Item *right_item);
1541.1.1 by Brian Aker
JOIN -> Join rename
164
COND *optimize_cond(Join *join, COND *conds, List<TableList> *join_list, Item::cond_result *cond_value);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
165
COND *make_cond_for_table(COND *cond,table_map table, table_map used_table, bool exclude_expensive_cond);
166
COND* substitute_for_best_equal_field(COND *cond, COND_EQUAL *cond_equal, void *table_join_idx);
167
bool list_contains_unique_index(Table *table, bool (*find_func) (Field *, void *), void *data);
168
bool find_field_in_order_list (Field *field, void *data);
169
bool find_field_in_item_list (Field *field, void *data);
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
170
bool test_if_skip_sort_order(JoinTable *tab,Order *order,ha_rows select_limit, bool no_changes, const key_map *map);
171
Order *create_distinct_group(Session *session,
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
172
                                Item **ref_pointer_array,
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
173
                                Order *order_list,
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
174
                                List<Item> &fields,
175
                                List<Item> &,
176
                                bool *all_order_by_fields_used);
177
// Create list for using with tempory table
178
bool change_to_use_tmp_fields(Session *session,
179
                              Item **ref_pointer_array,
180
			                        List<Item> &res_selected_fields,
181
			                        List<Item> &res_all_fields,
182
			                        uint32_t elements,
183
                              List<Item> &all_fields);
1541.1.1 by Brian Aker
JOIN -> Join rename
184
int do_select(Join *join, List<Item> *fields, Table *tmp_table);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
185
bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
186
int create_sort_index(Session *session, Join *join, Order *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
187
void save_index_subquery_explain_info(JoinTable *join_tab, Item* where);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
188
Item *remove_additional_cond(Item* conds);
189
bool setup_sum_funcs(Session *session, Item_sum **func_ptr);
190
bool init_sum_functions(Item_sum **func, Item_sum **end);
191
bool update_sum_func(Item_sum **func);
192
void copy_sum_funcs(Item_sum **func_ptr, Item_sum **end);
193
bool change_refs_to_tmp_fields(Session *session,
194
                               Item **ref_pointer_array,
195
                               List<Item> &res_selected_fields,
196
                               List<Item> &res_all_fields,
197
                               uint32_t elements,
198
			                         List<Item> &all_fields);
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
199
bool change_group_ref(Session *session, Item_func *expr, Order *group_list, bool *changed);
1637.5.9 by Prafulla Tekawade
Fix for Bug 592444
200
bool check_interleaving_with_nj(JoinTable *next);
2141.3.1 by vjsamuel1990 at gmail
Merge encapsulate join_read_const_table() into JoinTable.
201
void update_const_equal_items(COND *cond, JoinTable *tab);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
202
int join_read_const(JoinTable *tab);
203
int join_read_key(JoinTable *tab);
204
int join_read_always_key(JoinTable *tab);
205
int join_read_last_key(JoinTable *tab);
1538 by Brian Aker
Code shuffle on ReadRecord
206
int join_no_more_records(ReadRecord *info);
207
int join_read_next(ReadRecord *info);
208
int join_read_next_different(ReadRecord *info);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
209
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
210
int init_read_record_seq(JoinTable *tab);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
211
int test_if_quick_select(JoinTable *tab);
212
int join_init_read_record(JoinTable *tab);
213
int join_read_first(JoinTable *tab);
1538 by Brian Aker
Code shuffle on ReadRecord
214
int join_read_next_same(ReadRecord *info);
215
int join_read_next_same_diff(ReadRecord *info);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
216
int join_read_last(JoinTable *tab);
1538 by Brian Aker
Code shuffle on ReadRecord
217
int join_read_prev_same(ReadRecord *info);
218
int join_read_prev(ReadRecord *info);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
219
int join_read_always_key_or_null(JoinTable *tab);
1538 by Brian Aker
Code shuffle on ReadRecord
220
int join_read_next_same_or_null(ReadRecord *info);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
221
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
222
void calc_used_field_length(Session *, JoinTable *join_tab);
1039.2.3 by Jay Pipes
Phase 3 of refactoring JOIN
223
StoredKey *get_store_key(Session *session, 
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
224
                         optimizer::KeyUse *keyuse,
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
225
                         table_map used_tables,
1534 by Brian Aker
Remove of KeyPartInfo
226
                         KeyPartInfo *key_part,
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
227
                         unsigned char *key_buff,
228
                         uint32_t maybe_null);
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
229
int join_tab_cmp(const void* ptr1, const void* ptr2);
230
int join_tab_cmp_straight(const void* ptr1, const void* ptr2);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
231
void push_index_cond(JoinTable *tab, uint32_t keyno, bool other_tbls_ok);
1541.1.1 by Brian Aker
JOIN -> Join rename
232
void add_not_null_conds(Join *join);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
233
uint32_t max_part_bit(key_part_map bits);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
234
COND *add_found_match_trig_cond(JoinTable *tab, COND *cond, JoinTable *root_tab);
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
235
bool eq_ref_table(Join *join, Order *start_order, JoinTable *tab);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
236
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having);
237
int remove_dup_with_hash_index(Session *session, 
238
                               Table *table,
239
                               uint32_t field_count,
240
                               Field **first_field,
241
                               uint32_t key_length,
242
                               Item *having);
2318.4.9 by Olaf van der Spek
Refactor
243
void update_ref_and_keys(Session *session,
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
244
                         DYNAMIC_ARRAY *keyuse,
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
245
                         JoinTable *join_tab,
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
246
                         uint32_t tables,
247
                         COND *cond, 
248
                         COND_EQUAL *,
249
                         table_map normal_tables,
250
                         Select_Lex *select_lex,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
251
                         std::vector<optimizer::SargableParam> &sargables);
252
ha_rows get_quick_record_count(Session *session, optimizer::SqlSelect *select, Table *table, const key_map *keys,ha_rows limit);
1541.1.1 by Brian Aker
JOIN -> Join rename
253
void optimize_keyuse(Join *join, DYNAMIC_ARRAY *keyuse_array);
254
void add_group_and_distinct_keys(Join *join, JoinTable *join_tab);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
255
void read_cached_record(JoinTable *tab);
2026.2.1 by Monty Taylor
Renamed things prefixed mysql_ or mysqld_
256
bool select_query(Session *session, Item ***rref_pointer_array,
1241.7.6 by Padraig O'Sullivan
Added some dtrace probes for tracing the optimizer.
257
                  TableList *tables, uint32_t wild_num,  List<Item> &list,
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
258
                  COND *conds, uint32_t og_num, Order *order, Order *group,
1241.7.6 by Padraig O'Sullivan
Added some dtrace probes for tracing the optimizer.
259
                  Item *having, uint64_t select_type,
260
                  select_result *result, Select_Lex_Unit *unit,
261
                  Select_Lex *select_lex);
1039.2.2 by Jay Pipes
Phase 2 of JOIN refactoring.
262
// Create list for using with tempory table
263
void init_tmptable_sum_functions(Item_sum **func);
264
void update_tmptable_sum_func(Item_sum **func,Table *tmp_table);
1892.3.3 by tdavies
struct order_st changed and renamed to c++ class named:Order
265
bool only_eq_ref_tables(Join *join, Order *order, table_map tables);
1541.1.1 by Brian Aker
JOIN -> Join rename
266
bool create_ref_for_key(Join *join, JoinTable *j, 
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
267
                        optimizer::KeyUse *org_keyuse, 
1108.6.56 by Padraig O'Sullivan
Extracted KeyUse into its own header file and placed it within the
268
                        table_map used_tables);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
269
1089.1.14 by Brian Aker
Fix TABLE_REF structure
270
bool cp_buffer_from_ref(Session *session, table_reference_st *ref);
1089.1.1 by Brian Aker
Remove of JOIN_TAB to JoinTable
271
int safe_index_read(JoinTable *tab);
520.1.22 by Brian Aker
Second pass of thd cleanup
272
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);
1101.1.16 by Monty Taylor
Reverted 1103
273
int test_if_item_cache_changed(List<Cached_item> &list);
575.4.7 by Monty Taylor
More header cleanup.
274
2215.2.1 by Stewart Smith
remove enum_query_type which was effectively unused. It was set to one value once, compared to it once (i.e. always true) and passed around everywhere doing nothing.
275
void print_join(Session *session, String *str, List<TableList> *tables);
1054.1.7 by Brian Aker
Refactor TableList methods.
276
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
277
} /* namespace drizzled */
278