~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 *
 *  Copyright (C) 2009 Sun Microsystems, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef DRIZZLED_OPTIMIZER_KEY_USE_H
#define DRIZZLED_OPTIMIZER_KEY_USE_H

namespace drizzled
{
namespace optimizer
{

class KeyUse 
{
public:

  KeyUse()
    :
      table(NULL),
      val(NULL),
      used_tables(0),
      key(0),
      keypart(0),
      optimize(0),
      keypart_map(0),
      ref_table_rows(0),
      null_rejecting(false),
      cond_guard(NULL)
  {}

  KeyUse(Table *in_table,
         Item *in_val,
         table_map in_used_tables,
         uint32_t in_key,
         uint32_t in_keypart,
         uint32_t in_optimize,
         key_part_map in_keypart_map,
         ha_rows in_ref_table_rows,
         bool in_null_rejecting,
         bool *in_cond_guard)
    :
      table(in_table),
      val(in_val),
      used_tables(in_used_tables),
      key(in_key),
      keypart(in_keypart),
      optimize(in_optimize),
      keypart_map(in_keypart_map),
      ref_table_rows(in_ref_table_rows),
      null_rejecting(in_null_rejecting),
      cond_guard(in_cond_guard)
  {}

  Table *getTable()
  {
    return table;
  }

  Item *getVal()
  {
    return val;
  }

  table_map getUsedTables()
  {
    return used_tables;
  }

  uint32_t getKey() const
  {
    return key;
  }

  uint32_t getKeypart() const
  {
    return keypart;
  }

  uint32_t getOptimizeFlags() const
  {
    return optimize;
  }

  key_part_map getKeypartMap()
  {
    return keypart_map;
  }

  ha_rows getTableRows() const
  {
    return ref_table_rows;
  }

  void setTableRows(ha_rows input)
  {
    ref_table_rows= input;
  }

  bool isNullRejected() const
  {
    return null_rejecting;
  }

  bool *getConditionalGuard()
  {
    return cond_guard;
  }

private:

  Table *table; /**< Pointer to the table this key belongs to */

  Item *val;	/**< or value if no field */

  table_map used_tables;

  uint32_t key;

  uint32_t keypart;

  uint32_t optimize; /**< 0, or KEY_OPTIMIZE_* */

  key_part_map keypart_map;

  ha_rows ref_table_rows;

  /**
   * If true, the comparison this value was created from will not be
   * satisfied if val has NULL 'value'.
   */
  bool null_rejecting;

  /**
   * !NULL - This KeyUse was created from an equality that was wrapped into
   *         an Item_func_trig_cond. This means the equality (and validity of
   *         this KeyUse element) can be turned on and off. The on/off state
   *         is indicted by the pointed value:
   *           *cond_guard == true <=> equality condition is on
   *           *cond_guard == false <=> equality condition is off
   *
   * NULL  - Otherwise (the source equality can't be turned off)
  */
  bool *cond_guard;
};

} /* end namespace optimizer */

} /* end namespace drizzled */

#endif /* DRIZZLED_OPTIMIZER_KEY_USE_H */