1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef NDB_SCAN_FILTER_HPP
17
#define NDB_SCAN_FILTER_HPP
19
#include <ndb_types.h>
20
#include <ndbapi_limits.h>
23
* @class NdbScanFilter
24
* @brief A simple way to specify filters for scan operations
26
* @note This filter interface is under development and may change in
34
* @param op The NdbOperation that the filter belongs to (is applied to).
35
* @param abort_on_too_large abort transaction on filter too large
37
* @param max_size Maximum size of generated filter in words
39
NdbScanFilter(class NdbOperation * op,
40
bool abort_on_too_large = true,
41
Uint32 max_size = NDB_MAX_SCANFILTER_SIZE_IN_WORDS);
48
AND = 1, ///< (x1 AND x2 AND x3)
49
OR = 2, ///< (x1 OR x2 OR X3)
50
NAND = 3, ///< NOT (x1 AND x2 AND x3)
51
NOR = 4 ///< NOT (x1 OR x2 OR x3)
56
COND_LE = 0, ///< lower bound
57
COND_LT = 1, ///< lower bound, strict
58
COND_GE = 2, ///< upper bound
59
COND_GT = 3, ///< upper bound, strict
60
COND_EQ = 4, ///< equality
61
COND_NE = 5, ///< not equal
62
COND_LIKE = 6, ///< like
63
COND_NOT_LIKE = 7 ///< not like
73
* �return 0 if successful, -1 otherwize
75
int begin(Group group = AND);
79
* �return 0 if successful, -1 otherwize
83
/** @} *********************************************************************/
86
* <i>Explanation missing</i>
91
* <i>Explanation missing</i>
96
* Compare column <b>ColId</b> with <b>val</b>
98
int cmp(BinaryCondition cond, int ColId, const void *val, Uint32 len = 0);
101
* @name Integer Comparators
104
/** Compare column value with integer for equal
105
* �return 0 if successful, -1 otherwize
107
int eq(int ColId, Uint32 value) { return cmp(COND_EQ, ColId, &value, 4);}
109
/** Compare column value with integer for not equal.
110
* �return 0 if successful, -1 otherwize
112
int ne(int ColId, Uint32 value) { return cmp(COND_NE, ColId, &value, 4);}
113
/** Compare column value with integer for less than.
114
* �return 0 if successful, -1 otherwize
116
int lt(int ColId, Uint32 value) { return cmp(COND_LT, ColId, &value, 4);}
117
/** Compare column value with integer for less than or equal.
118
* �return 0 if successful, -1 otherwize
120
int le(int ColId, Uint32 value) { return cmp(COND_LE, ColId, &value, 4);}
121
/** Compare column value with integer for greater than.
122
* �return 0 if successful, -1 otherwize
124
int gt(int ColId, Uint32 value) { return cmp(COND_GT, ColId, &value, 4);}
125
/** Compare column value with integer for greater than or equal.
126
* �return 0 if successful, -1 otherwize
128
int ge(int ColId, Uint32 value) { return cmp(COND_GE, ColId, &value, 4);}
130
/** Compare column value with integer for equal. 64-bit.
131
* �return 0 if successful, -1 otherwize
133
int eq(int ColId, Uint64 value) { return cmp(COND_EQ, ColId, &value, 8);}
134
/** Compare column value with integer for not equal. 64-bit.
135
* �return 0 if successful, -1 otherwize
137
int ne(int ColId, Uint64 value) { return cmp(COND_NE, ColId, &value, 8);}
138
/** Compare column value with integer for less than. 64-bit.
139
* �return 0 if successful, -1 otherwize
141
int lt(int ColId, Uint64 value) { return cmp(COND_LT, ColId, &value, 8);}
142
/** Compare column value with integer for less than or equal. 64-bit.
143
* �return 0 if successful, -1 otherwize
145
int le(int ColId, Uint64 value) { return cmp(COND_LE, ColId, &value, 8);}
146
/** Compare column value with integer for greater than. 64-bit.
147
* �return 0 if successful, -1 otherwize
149
int gt(int ColId, Uint64 value) { return cmp(COND_GT, ColId, &value, 8);}
150
/** Compare column value with integer for greater than or equal. 64-bit.
151
* �return 0 if successful, -1 otherwize
153
int ge(int ColId, Uint64 value) { return cmp(COND_GE, ColId, &value, 8);}
154
/** @} *********************************************************************/
156
/** Check if column value is NULL */
157
int isnull(int ColId);
158
/** Check if column value is non-NULL */
159
int isnotnull(int ColId);
161
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
163
* Like comparison operator.
164
* �return 0 if successful, -1 otherwize
166
int like(int ColId, const char * val, Uint32 len, bool nopad=false);
168
* Notlike comparison operator.
169
* �return 0 if successful, -1 otherwize
171
int notlike(int ColId, const char * val, Uint32 len, bool nopad=false);
172
/** @} *********************************************************************/
176
FilterTooLarge = 4294
180
* Get filter level error.
182
* Most errors are set only on operation level, and they abort the
183
* transaction. The error FilterTooLarge is set on filter level and
184
* by default it propagates to operation level and also aborts the
187
* If option abort_on_too_large is set to false, then FilterTooLarge
188
* does not propagate. One can then either ignore this error (in
189
* which case no filtering is done) or try to define a new filter
192
const class NdbError & getNdbError() const;
193
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
194
NdbOperation * getNdbOperation();
197
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
198
friend class NdbScanFilterImpl;
200
class NdbScanFilterImpl & m_impl;
201
NdbScanFilter& operator=(const NdbScanFilter&); ///< Defined not implemented