~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008-2009 Sun Microsystems
 
4
 *  Copyright (C) 2008-2009 Sun Microsystems, Inc.
5
5
 *
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
21
21
#define DRIZZLED_SQL_SELECT_H
22
22
 
23
23
#include "drizzled/cached_item.h"
24
 
#include "drizzled/session.h"
25
24
#include "drizzled/field/varstring.h"
26
25
#include "drizzled/item/null.h"
27
26
#include <drizzled/enum_nested_loop_state.h>
30
29
#include "drizzled/optimizer/key_use.h"
31
30
#include "drizzled/join_cache.h"
32
31
#include "drizzled/join_table.h"
 
32
#include "drizzled/records.h"
 
33
#include "drizzled/stored_key.h"
33
34
 
34
35
#include <vector>
35
36
 
36
37
namespace drizzled
37
38
{
38
39
 
 
40
class Item_func;
 
41
class Select_Lex_Unit;
39
42
class select_result;
 
43
class st_dynamic_array;
40
44
 
41
45
/**
42
46
 * @file API and Classes to use when handling where clause
56
60
enum_nested_loop_state end_send_group(Join *join, JoinTable *join_tab, bool end_of_records);
57
61
enum_nested_loop_state end_write_group(Join *join, JoinTable *join_tab, bool end_of_records);
58
62
 
59
 
typedef struct st_rollup
 
63
class Rollup
60
64
{
 
65
public:
61
66
  enum State { STATE_NONE, STATE_INITED, STATE_READY };
 
67
 
 
68
  Rollup()
 
69
  :
 
70
  state(),
 
71
  null_items(NULL),
 
72
  ref_pointer_arrays(NULL),
 
73
  fields()
 
74
  {}
 
75
  
 
76
  Rollup(State in_state,
 
77
         Item_null_result **in_null_items,
 
78
         Item ***in_ref_pointer_arrays,
 
79
         List<Item> *in_fields)
 
80
  :
 
81
  state(in_state),
 
82
  null_items(in_null_items),
 
83
  ref_pointer_arrays(in_ref_pointer_arrays),
 
84
  fields(in_fields)
 
85
  {}
 
86
  
 
87
  State getState() const
 
88
  {
 
89
    return state;
 
90
  }
 
91
 
 
92
  void setState(State in_state)
 
93
  {
 
94
    state= in_state;
 
95
  }
 
96
 
 
97
  Item_null_result **getNullItems() const
 
98
  {
 
99
    return null_items;
 
100
  }
 
101
 
 
102
  void setNullItems(Item_null_result **in_null_items)
 
103
  {
 
104
    null_items= in_null_items;
 
105
  }
 
106
 
 
107
  Item ***getRefPointerArrays() const
 
108
  {
 
109
    return ref_pointer_arrays;
 
110
  }
 
111
 
 
112
  void setRefPointerArrays(Item ***in_ref_pointer_arrays)
 
113
  {
 
114
    ref_pointer_arrays= in_ref_pointer_arrays;
 
115
  }
 
116
 
 
117
  List<Item> *getFields() const
 
118
  {
 
119
    return fields;
 
120
  }
 
121
 
 
122
  void setFields(List<Item> *in_fields)
 
123
  {
 
124
    fields= in_fields;
 
125
  }
 
126
  
 
127
private:
62
128
  State state;
63
129
  Item_null_result **null_items;
64
130
  Item ***ref_pointer_arrays;
65
131
  List<Item> *fields;
66
 
} ROLLUP;
 
132
};
67
133
 
68
134
} /* namespace drizzled */
69
135
 
82
148
  item->marker should be 0 for all items on entry
83
149
  Return in cond_value false if condition is impossible (1 = 2)
84
150
*****************************************************************************/
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
 
};
 
151
typedef std::pair<Item*, Item_func*> COND_CMP;
90
152
 
91
153
void TEST_join(Join *join);
92
154
 
103
165
                       List<Item> &new_list1, List<Item> &new_list2,
104
166
                       uint32_t elements, List<Item> &fields);
105
167
void copy_fields(Tmp_Table_Param *param);
106
 
void copy_funcs(Item **func_ptr);
 
168
bool copy_funcs(Item **func_ptr, const Session *session);
107
169
Field* create_tmp_field_from_field(Session *session, Field* org_field,
108
170
                                   const char *name, Table *table,
109
171
                                   Item_field *item, uint32_t convert_blob_length);
145
207
                                                 List<Item> &all_fields);
146
208
bool change_group_ref(Session *session, Item_func *expr, Order *group_list, bool *changed);
147
209
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);
 
210
void update_const_equal_items(COND *cond, JoinTable *tab);
151
211
int join_read_const(JoinTable *tab);
152
212
int join_read_key(JoinTable *tab);
153
213
int join_read_always_key(JoinTable *tab);
181
241
void add_not_null_conds(Join *join);
182
242
uint32_t max_part_bit(key_part_map bits);
183
243
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
244
bool eq_ref_table(Join *join, Order *start_order, JoinTable *tab);
191
245
int remove_dup_with_compare(Session *session, Table *table, Field **first_field, uint32_t offset, Item *having);
192
246
int remove_dup_with_hash_index(Session *session, 
208
262
void optimize_keyuse(Join *join, DYNAMIC_ARRAY *keyuse_array);
209
263
void add_group_and_distinct_keys(Join *join, JoinTable *join_tab);
210
264
void read_cached_record(JoinTable *tab);
211
 
bool mysql_select(Session *session, Item ***rref_pointer_array,
 
265
bool select_query(Session *session, Item ***rref_pointer_array,
212
266
                  TableList *tables, uint32_t wild_num,  List<Item> &list,
213
267
                  COND *conds, uint32_t og_num, Order *order, Order *group,
214
268
                  Item *having, uint64_t select_type,
222
276
                        optimizer::KeyUse *org_keyuse, 
223
277
                        table_map used_tables);
224
278
 
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
279
bool cp_buffer_from_ref(Session *session, table_reference_st *ref);
235
280
int safe_index_read(JoinTable *tab);
236
281
COND *remove_eq_conds(Session *session, COND *cond, Item::cond_result *cond_value);