Drizzled Public API Documentation

key_field.h
1 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2009 Sun Microsystems, Inc.
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  */
19 
20 #pragma once
21 
22 #include <drizzled/sql_select.h>
23 #include <vector>
24 
25 namespace drizzled {
26 namespace optimizer {
27 
31 class KeyField
32 {
33 public:
34 
35  KeyField()
36  :
37  field(NULL),
38  val(NULL),
39  level(0),
40  optimize(0),
41  eq_func(false),
42  null_rejecting(false),
43  cond_guard(NULL)
44  {}
45 
46  KeyField(Field *in_field,
47  Item *in_val,
48  uint32_t in_level,
49  uint32_t in_optimize,
50  bool in_eq_func,
51  bool in_null_rejecting,
52  bool *in_cond_guard)
53  :
54  field(in_field),
55  val(in_val),
56  level(in_level),
57  optimize(in_optimize),
58  eq_func(in_eq_func),
59  null_rejecting(in_null_rejecting),
60  cond_guard(in_cond_guard)
61  {}
62 
63  Field *getField()
64  {
65  return field;
66  }
67 
68  void setField(Field *in_field)
69  {
70  field= in_field;
71  }
72 
73  Item *getValue()
74  {
75  return val;
76  }
77 
78  void setValue(Item *in_val)
79  {
80  val= in_val;
81  }
82 
83  uint32_t getLevel() const
84  {
85  return level;
86  }
87 
88  void setLevel(uint32_t in_level)
89  {
90  level= in_level;
91  }
92 
93  uint32_t getOptimizeFlags() const
94  {
95  return optimize;
96  }
97 
98  void setOptimizeFlags(uint32_t in_opt)
99  {
100  optimize= in_opt;
101  }
102 
103  bool isEqualityCondition() const
104  {
105  return eq_func;
106  }
107 
108  void setEqualityConditionUsed(bool in_val)
109  {
110  eq_func= in_val;
111  }
112 
113  bool rejectNullValues() const
114  {
115  return null_rejecting;
116  }
117 
118  void setRejectNullValues(bool in_val)
119  {
120  null_rejecting= in_val;
121  }
122 
123  bool *getConditionalGuard()
124  {
125  return cond_guard;
126  }
127 
128  void setConditionalGuard(bool *in_cond_guard)
129  {
130  cond_guard= in_cond_guard;
131  }
132 
133 private:
134 
135  Field *field;
137  uint32_t level;
138  uint32_t optimize;
139  bool eq_func;
145  bool *cond_guard;
147 };
148 
149 void add_key_fields(Join *join,
150  KeyField **key_fields,
151  uint32_t *and_level,
152  COND *cond,
153  table_map usable_tables,
154  std::vector<SargableParam> &sargables);
155 
156 void add_key_part(DYNAMIC_ARRAY *keyuse_array, KeyField *key_field);
157 
192 void add_key_fields_for_nj(Join *join,
193  TableList *nested_join_table,
194  KeyField **end,
195  uint32_t *and_level,
196  std::vector<SargableParam> &sargables);
197 
221 KeyField *merge_key_fields(KeyField *start,
222  KeyField *new_fields,
223  KeyField *end,
224  uint32_t and_level);
225 
245 void add_key_field(KeyField **key_fields,
246  uint32_t and_level,
247  Item_func *cond,
248  Field *field,
249  bool eq_func,
250  Item **value,
251  uint32_t num_values,
252  table_map usable_tables,
253  std::vector<SargableParam> &sargables);
254 
276 void add_key_equal_fields(KeyField **key_fields,
277  uint32_t and_level,
278  Item_func *cond,
279  Item_field *field_item,
280  bool eq_func,
281  Item **val,
282  uint32_t num_values,
283  table_map usable_tables,
284  std::vector<SargableParam> &sargables);
285 
286 } /* end namespace optimizer */
287 
288 } /* end namespace drizzled */
289