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 SCAN_FILTER_HPP
17
#define SCAN_FILTER_HPP
23
* Create a scan filter for table tab
24
* colNo - column to filter on
25
* val - val to use when selecting valu to filter on
28
ScanFilter(const NDBT_Table& tab,
32
ScanFilter(int records = 1000){};
33
virtual int filterOp(NdbOperation*) = 0;
34
virtual int verifyRecord(NDBT_ResultRow&) = 0;
37
// const NDBT_Table& tab;
40
class LessThanFilter : public ScanFilter {
42
LessThanFilter(int records){ compare_value = records / 100; };
45
int filterOp(NdbOperation* pOp);
46
int verifyRecord(NDBT_ResultRow&);
49
class EqualFilter : public ScanFilter {
50
static const Uint32 compare_value = 100;
51
int filterOp(NdbOperation* pOp);
52
int verifyRecord(NDBT_ResultRow&);
55
class NoFilter : public ScanFilter {
56
int filterOp(NdbOperation* pOp);
57
int verifyRecord(NDBT_ResultRow&);
61
int LessThanFilter::filterOp(NdbOperation* pOp){
63
if (pOp->load_const_u32(1, compare_value) != 0)
66
if (pOp->read_attr("KOL2", 2) != 0)
69
if (pOp->branch_lt(1, 2, 0) != 0)
72
if (pOp->interpret_exit_nok() != 0)
75
if (pOp->def_label(0) != 0)
78
if (pOp->interpret_exit_ok() != 0)
84
int LessThanFilter::verifyRecord(NDBT_ResultRow& row){
85
NdbRecAttr* rec = row.attributeStore(1);
86
if (rec->u_32_value() < compare_value)
91
int EqualFilter::filterOp(NdbOperation* pOp){
93
if (pOp->load_const_u32(1, compare_value) != 0)
96
if (pOp->read_attr("KOL2", 2) != 0)
99
if (pOp->branch_eq(1, 2, 0) != 0)
102
if (pOp->interpret_exit_nok() != 0)
105
if (pOp->def_label(0) != 0)
108
if (pOp->interpret_exit_ok() != 0)
114
int EqualFilter::verifyRecord(NDBT_ResultRow& row){
115
NdbRecAttr* rec = row.attributeStore(1);
116
if (rec->u_32_value() == compare_value)
121
int NoFilter::filterOp(NdbOperation* pOp){
125
int NoFilter::verifyRecord(NDBT_ResultRow& row){
126
// Check if this record should be in the result set or not