~drizzle-trunk/drizzle/development

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