1 /*
2    Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef NDBT_CALC_HPP
26 #define NDBT_CALC_HPP
27 
28 #include <NDBT_ResultRow.hpp>
29 
30 /* *************************************************************
31  * HugoCalculator
32  *
33  *  Comon class for the Hugo test suite, provides the functions
34  *  that is used for calculating values to load in to table and
35  *  also knows how to verify a row that's been read from db
36  *
37  * ************************************************************/
38 class HugoCalculator {
39 public:
40   HugoCalculator(const NdbDictionary::Table& tab);
41   Int32 calcValue(int record, int attrib, int updates) const;
42   const char* calcValue(int record, int attrib, int updates, char* buf,
43 			int len, Uint32* real_len) const;
44 
45   int verifyRowValues(NDBT_ResultRow* const  pRow) const;
46   int verifyRecAttr(int record, int updates, const NdbRecAttr* recAttr);
47   int verifyColValue(int record, int attrib, int updates,
48                      const char* valPtr, Uint32 valLen);
49   int getIdValue(NDBT_ResultRow* const pRow) const;
50   int getUpdatesValue(NDBT_ResultRow* const pRow) const;
getIdColNo() const51   int getIdColNo() const { return m_idCol;}
isIdCol(int colId)52   int isIdCol(int colId) { return m_idCol == colId; };
isUpdateCol(int colId)53   int isUpdateCol(int colId){ return m_updatesCol == colId; };
54 
getTable() const55   const NdbDictionary::Table& getTable() const { return m_tab;}
56 
57   int equalForRow(Uint8 *, const NdbRecord*, int rowid);
58   int setValues(Uint8*, const NdbRecord*, int rowid, int updateval);
59 private:
60   const NdbDictionary::Table& m_tab;
61   int m_idCol;
62   int m_updatesCol;
63 };
64 
65 
66 #endif
67 
68 
69 
70 
71