mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / test / include / UtilTransactions.hpp
blob098b39c9e581c0151882c72b44c22b8e17f832e1
1 /* Copyright (c) 2003-2005, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef UTIL_TRANSACTIONS_HPP
17 #define UTIL_TRANSACTIONS_HPP
19 #include <NDBT.hpp>
21 typedef int (ReadCallBackFn)(NDBT_ResultRow*);
23 class UtilTransactions {
24 public:
25 UtilTransactions(const NdbDictionary::Table&,
26 const NdbDictionary::Index* idx = 0);
27 UtilTransactions(Ndb* ndb,
28 const char * tableName, const char * indexName = 0);
30 int closeTransaction(Ndb*);
32 int clearTable(Ndb*,
33 NdbScanOperation::ScanFlag,
34 int records = 0,
35 int parallelism = 0);
37 int clearTable(Ndb*,
38 int records = 0,
39 int parallelism = 0);
41 // Delete all records from the table using a scan
42 int clearTable1(Ndb*,
43 int records = 0,
44 int parallelism = 0);
45 // Delete all records from the table using a scan
46 // Using batching
47 int clearTable2(Ndb*,
48 int records = 0,
49 int parallelism = 0);
51 int clearTable3(Ndb*,
52 int records = 0,
53 int parallelism = 0);
55 int selectCount(Ndb*,
56 int parallelism = 0,
57 int* count_rows = NULL,
58 NdbOperation::LockMode lm = NdbOperation::LM_CommittedRead,
59 NdbConnection* pTrans = NULL);
60 int scanReadRecords(Ndb*,
61 int parallelism,
62 NdbOperation::LockMode lm,
63 int records,
64 int noAttribs,
65 int* attrib_list,
66 ReadCallBackFn* fn = NULL);
67 int verifyIndex(Ndb*,
68 const char* indexName,
69 int parallelism = 0,
70 bool transactional = false);
72 int copyTableData(Ndb*,
73 const char* destName);
75 /**
76 * Compare this table with other_table
78 * return 0 - on equality
79 * -1 - on error
80 * >0 - otherwise
82 int compare(Ndb*, const char * other_table, int flags);
84 private:
85 static int takeOverAndDeleteRecord(Ndb*,
86 NdbOperation*);
88 int addRowToDelete(Ndb* pNdb,
89 NdbConnection* pDelTrans,
90 NdbOperation* pOrgOp);
93 int addRowToInsert(Ndb* pNdb,
94 NdbConnection* pInsTrans,
95 NDBT_ResultRow & row,
96 const char* insertTabName);
99 int verifyUniqueIndex(Ndb*,
100 const NdbDictionary::Index *,
101 int parallelism = 0,
102 bool transactional = false);
104 int scanAndCompareUniqueIndex(Ndb* pNdb,
105 const NdbDictionary::Index *,
106 int parallelism,
107 bool transactional);
109 int readRowFromTableAndIndex(Ndb* pNdb,
110 NdbConnection* pTrans,
111 const NdbDictionary::Index *,
112 NDBT_ResultRow& row );
114 int verifyOrderedIndex(Ndb*,
115 const NdbDictionary::Index *,
116 int parallelism = 0,
117 bool transactional = false);
120 int get_values(NdbOperation* op, NDBT_ResultRow& dst);
121 int equal(const NdbDictionary::Table*, NdbOperation*, const NDBT_ResultRow&);
122 int equal(const NdbDictionary::Index*, NdbOperation*, const NDBT_ResultRow&);
124 protected:
125 int m_defaultClearMethod;
126 const NdbDictionary::Table& tab;
127 const NdbDictionary::Index* idx;
128 NdbConnection* pTrans;
130 NdbOperation* getOperation(NdbConnection*,
131 NdbOperation::OperationType);
132 NdbScanOperation* getScanOperation(NdbConnection*);
135 #endif