MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UtilTransactions.hpp
1 /*
2  Copyright (C) 2003-2007 MySQL AB, 2009 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef UTIL_TRANSACTIONS_HPP
20 #define UTIL_TRANSACTIONS_HPP
21 
22 #include <NDBT.hpp>
23 
24 typedef int (ReadCallBackFn)(NDBT_ResultRow*);
25 
27 public:
29  const NdbDictionary::Index* idx = 0);
30  UtilTransactions(Ndb* ndb,
31  const char * tableName, const char * indexName = 0);
32 
33  int closeTransaction(Ndb*);
34 
35  int clearTable(Ndb*,
37  int records = 0,
38  int parallelism = 0);
39 
40  int clearTable(Ndb*,
41  int records = 0,
42  int parallelism = 0);
43 
44  // Delete all records from the table using a scan
45  int clearTable1(Ndb*,
46  int records = 0,
47  int parallelism = 0);
48  // Delete all records from the table using a scan
49  // Using batching
50  int clearTable2(Ndb*,
51  int records = 0,
52  int parallelism = 0);
53 
54  int clearTable3(Ndb*,
55  int records = 0,
56  int parallelism = 0);
57 
58  int selectCount(Ndb*,
59  int parallelism = 0,
60  int* count_rows = NULL,
62 
63  int scanReadRecords(Ndb*,
64  int parallelism,
66  int records,
67  int noAttribs,
68  int* attrib_list,
69  ReadCallBackFn* fn = NULL);
70  int verifyIndex(Ndb*,
71  const char* indexName,
72  int parallelism = 0,
73  bool transactional = false);
74 
75  int copyTableData(Ndb*,
76  const char* destName);
77 
85  int compare(Ndb*, const char * other_table, int flags);
86 
87 private:
88  static int takeOverAndDeleteRecord(Ndb*,
89  NdbOperation*);
90 
91  int addRowToDelete(Ndb* pNdb,
92  NdbConnection* pDelTrans,
93  NdbOperation* pOrgOp);
94 
95 
96  int addRowToInsert(Ndb* pNdb,
97  NdbConnection* pInsTrans,
98  NDBT_ResultRow & row,
99  const char* insertTabName);
100 
101 
102  int verifyUniqueIndex(Ndb*,
103  const NdbDictionary::Index *,
104  int parallelism = 0,
105  bool transactional = false);
106 
107  int scanAndCompareUniqueIndex(Ndb* pNdb,
108  const NdbDictionary::Index *,
109  int parallelism,
110  bool transactional);
111 
112  int readRowFromTableAndIndex(Ndb* pNdb,
113  NdbConnection* pTrans,
114  const NdbDictionary::Index *,
115  NDBT_ResultRow& row );
116 
117  int verifyOrderedIndex(Ndb*,
118  const NdbDictionary::Index *,
119  int parallelism = 0,
120  bool transactional = false);
121 
122 
123  int get_values(NdbOperation* op, NDBT_ResultRow& dst);
124  int equal(const NdbDictionary::Table*, NdbOperation*, const NDBT_ResultRow&);
125  int equal(const NdbDictionary::Index*, NdbOperation*, const NDBT_ResultRow&);
126 
127 protected:
128  int m_defaultClearMethod;
129  const NdbDictionary::Table& tab;
130  const NdbDictionary::Index* idx;
131  NdbConnection* pTrans;
132 
133  NdbOperation* getOperation(NdbConnection*,
135  NdbScanOperation* getScanOperation(NdbConnection*);
136 };
137 
138 #endif