~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/key_use.h

  • Committer: Brian Aker
  • Date: 2009-09-27 19:20:46 UTC
  • mfrom: (1108.6.62 optimizer)
  • Revision ID: brian@gaz-20090927192046-prsq4ms1gj8q3aia
Merge Padraig

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
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
#ifndef DRIZZLED_OPTIMIZER_KEY_USE_H
 
21
#define DRIZZLED_OPTIMIZER_KEY_USE_H
 
22
 
 
23
#include <drizzled/server_includes.h>
 
24
 
 
25
namespace drizzled
 
26
{
 
27
namespace optimizer
 
28
{
 
29
 
 
30
class KeyUse 
 
31
{
 
32
public:
 
33
 
 
34
  KeyUse()
 
35
    :
 
36
      table(NULL),
 
37
      val(NULL),
 
38
      used_tables(0),
 
39
      key(0),
 
40
      keypart(0),
 
41
      optimize(0),
 
42
      keypart_map(0),
 
43
      ref_table_rows(0),
 
44
      null_rejecting(false),
 
45
      cond_guard(NULL)
 
46
  {}
 
47
 
 
48
  KeyUse(Table *in_table,
 
49
         Item *in_val,
 
50
         table_map in_used_tables,
 
51
         uint32_t in_key,
 
52
         uint32_t in_keypart,
 
53
         uint32_t in_optimize,
 
54
         key_part_map in_keypart_map,
 
55
         ha_rows in_ref_table_rows,
 
56
         bool in_null_rejecting,
 
57
         bool *in_cond_guard)
 
58
    :
 
59
      table(in_table),
 
60
      val(in_val),
 
61
      used_tables(in_used_tables),
 
62
      key(in_key),
 
63
      keypart(in_keypart),
 
64
      optimize(in_optimize),
 
65
      keypart_map(in_keypart_map),
 
66
      ref_table_rows(in_ref_table_rows),
 
67
      null_rejecting(in_null_rejecting),
 
68
      cond_guard(in_cond_guard)
 
69
  {}
 
70
 
 
71
  Table *getTable()
 
72
  {
 
73
    return table;
 
74
  }
 
75
 
 
76
  Item *getVal()
 
77
  {
 
78
    return val;
 
79
  }
 
80
 
 
81
  table_map getUsedTables()
 
82
  {
 
83
    return used_tables;
 
84
  }
 
85
 
 
86
  uint32_t getKey() const
 
87
  {
 
88
    return key;
 
89
  }
 
90
 
 
91
  uint32_t getKeypart() const
 
92
  {
 
93
    return keypart;
 
94
  }
 
95
 
 
96
  uint32_t getOptimizeFlags() const
 
97
  {
 
98
    return optimize;
 
99
  }
 
100
 
 
101
  key_part_map getKeypartMap()
 
102
  {
 
103
    return keypart_map;
 
104
  }
 
105
 
 
106
  ha_rows getTableRows() const
 
107
  {
 
108
    return ref_table_rows;
 
109
  }
 
110
 
 
111
  void setTableRows(ha_rows input)
 
112
  {
 
113
    ref_table_rows= input;
 
114
  }
 
115
 
 
116
  bool isNullRejected() const
 
117
  {
 
118
    return null_rejecting;
 
119
  }
 
120
 
 
121
  bool *getConditionalGuard()
 
122
  {
 
123
    return cond_guard;
 
124
  }
 
125
 
 
126
private:
 
127
 
 
128
  Table *table; /**< Pointer to the table this key belongs to */
 
129
 
 
130
  Item *val;    /**< or value if no field */
 
131
 
 
132
  table_map used_tables;
 
133
 
 
134
  uint32_t key;
 
135
 
 
136
  uint32_t keypart;
 
137
 
 
138
  uint32_t optimize; /**< 0, or KEY_OPTIMIZE_* */
 
139
 
 
140
  key_part_map keypart_map;
 
141
 
 
142
  ha_rows ref_table_rows;
 
143
 
 
144
  /**
 
145
   * If true, the comparison this value was created from will not be
 
146
   * satisfied if val has NULL 'value'.
 
147
   */
 
148
  bool null_rejecting;
 
149
 
 
150
  /**
 
151
   * !NULL - This KeyUse was created from an equality that was wrapped into
 
152
   *         an Item_func_trig_cond. This means the equality (and validity of
 
153
   *         this KeyUse element) can be turned on and off. The on/off state
 
154
   *         is indicted by the pointed value:
 
155
   *           *cond_guard == true <=> equality condition is on
 
156
   *           *cond_guard == false <=> equality condition is off
 
157
   *
 
158
   * NULL  - Otherwise (the source equality can't be turned off)
 
159
  */
 
160
  bool *cond_guard;
 
161
};
 
162
 
 
163
} /* end namespace optimizer */
 
164
 
 
165
} /* end namespace drizzled */
 
166
 
 
167
#endif /* DRIZZLED_OPTIMIZER_KEY_USE_H */