~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/test/include/UtilTransactions.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
 
15
 
 
16
#ifndef UTIL_TRANSACTIONS_HPP
 
17
#define UTIL_TRANSACTIONS_HPP
 
18
 
 
19
#include <NDBT.hpp>
 
20
 
 
21
typedef int (ReadCallBackFn)(NDBT_ResultRow*);
 
22
 
 
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);
 
29
  
 
30
  int closeTransaction(Ndb*);
 
31
  
 
32
  int clearTable(Ndb*, 
 
33
                 NdbScanOperation::ScanFlag,
 
34
                 int records = 0,
 
35
                 int parallelism = 0);
 
36
 
 
37
  int clearTable(Ndb*, 
 
38
                 int records = 0,
 
39
                 int parallelism = 0);
 
40
  
 
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);
 
50
  
 
51
  int clearTable3(Ndb*, 
 
52
                  int records = 0,
 
53
                  int parallelism = 0);
 
54
  
 
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);
 
71
 
 
72
  int copyTableData(Ndb*,
 
73
                const char* destName);
 
74
                
 
75
  /**
 
76
   * Compare this table with other_table
 
77
   *
 
78
   * return 0 - on equality
 
79
   *       -1 - on error
 
80
   *      >0 - otherwise
 
81
   */
 
82
  int compare(Ndb*, const char * other_table, int flags);
 
83
  
 
84
private:
 
85
  static int takeOverAndDeleteRecord(Ndb*, 
 
86
                                     NdbOperation*);
 
87
 
 
88
  int addRowToDelete(Ndb* pNdb, 
 
89
                     NdbConnection* pDelTrans,
 
90
                     NdbOperation* pOrgOp);
 
91
 
 
92
  
 
93
  int addRowToInsert(Ndb* pNdb, 
 
94
                     NdbConnection* pInsTrans,
 
95
                     NDBT_ResultRow & row,
 
96
                     const char* insertTabName);
 
97
 
 
98
 
 
99
  int verifyUniqueIndex(Ndb*,
 
100
                        const NdbDictionary::Index *,
 
101
                        int parallelism = 0,
 
102
                        bool transactional = false);
 
103
 
 
104
  int scanAndCompareUniqueIndex(Ndb* pNdb,
 
105
                                const NdbDictionary::Index *,
 
106
                                int parallelism,
 
107
                                bool transactional);
 
108
  
 
109
  int readRowFromTableAndIndex(Ndb* pNdb,
 
110
                               NdbConnection* pTrans,
 
111
                               const NdbDictionary::Index *,
 
112
                               NDBT_ResultRow& row );
 
113
 
 
114
  int verifyOrderedIndex(Ndb*,
 
115
                         const NdbDictionary::Index *,
 
116
                         int parallelism = 0,
 
117
                         bool transactional = false);
 
118
  
 
119
 
 
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&);
 
123
 
 
124
protected:
 
125
  int m_defaultClearMethod;
 
126
  const NdbDictionary::Table& tab;
 
127
  const NdbDictionary::Index* idx;
 
128
  NdbConnection* pTrans;
 
129
  
 
130
  NdbOperation* getOperation(NdbConnection*, 
 
131
                             NdbOperation::OperationType);
 
132
  NdbScanOperation* getScanOperation(NdbConnection*);
 
133
};
 
134
 
 
135
#endif