~vadim-tk/percona-server/percona-galera-5.1.57

« back to all changes in this revision

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

  • Committer: root
  • Date: 2011-07-10 16:09:24 UTC
  • Revision ID: root@r815.office.percona.com-20110710160924-fyffqsbaclgu6vui
Initial port

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 NDBT_DATA_SET_TRANSACTION_HPP
 
17
#define NDBT_DATA_SET_TRANSACTION_HPP
 
18
 
 
19
#include "NDBT_Table.hpp"
 
20
#include <NdbApi.hpp>
 
21
 
 
22
class NDBT_DataSet;
 
23
 
 
24
/**
 
25
 * This class contains a bunch a methods
 
26
 * that operates on NDB together with a NDBT_DataSet
 
27
 * using <b>one</b> transaction
 
28
 */
 
29
class NDBT_DataSetTransaction {
 
30
public:
 
31
  /**
 
32
   * Store the data into ndb
 
33
   */
 
34
  static void insert(Ndb * theNdbObject,
 
35
                     const NDBT_DataSet *,
 
36
                     bool rollback = false);
 
37
  
 
38
  /**
 
39
   * Read data (using pk) from ndb
 
40
   */
 
41
  static void readByPk(Ndb * theNdbObject,
 
42
                       NDBT_DataSet *,
 
43
                       bool rollback = false);
 
44
  
 
45
  /**
 
46
   * Update data using pk
 
47
   *
 
48
   */
 
49
  static void updateByPk(Ndb * theNdbObject,
 
50
                         const NDBT_DataSet *,
 
51
                         bool rollback = false);
 
52
 
 
53
  /**
 
54
   * Delete 
 
55
   */
 
56
  static void deleteByPk(Ndb * theNdbObject,
 
57
                         const NDBT_DataSet *,
 
58
                         bool rollback = false);
 
59
};
 
60
 
 
61
class NDBT_DataSetAsyncTransaction {
 
62
public:
 
63
  enum OperationType {
 
64
    OT_Insert,
 
65
    OT_ReadByPk,
 
66
    OT_UpdateByPk,
 
67
    OT_DeleteByPk
 
68
  };
 
69
 
 
70
  /**
 
71
   * A callback for the NDBT_DataSetAsyncTransaction 
 
72
   * interface.
 
73
   *
 
74
   * The callback method returns:
 
75
   * - the operation performed
 
76
   * - the data set
 
77
   * - if the transaction was commited or aborted
 
78
   */
 
79
  typedef (* NDBT_DataSetAsyncTransactionCallback)(OperationType,
 
80
                                                   const NDBT_DataSet *,
 
81
                                                   bool commit,
 
82
                                                   void * anyObject);
 
83
  /**
 
84
   * Store the data into ndb
 
85
   */
 
86
  static void insert(Ndb * theNdbObject,
 
87
                     const NDBT_DataSet *,
 
88
                     bool rollback = false,
 
89
                     NDBT_DataSetAsyncTransactionCallback fun,
 
90
                     void * anyObject);
 
91
  
 
92
  /**
 
93
   * Read data (using pk) from ndb
 
94
   */
 
95
  static void readByPk(Ndb * theNdbObject,
 
96
                       NDBT_DataSet *,
 
97
                       bool rollback = false,
 
98
                       NDBT_DataSetAsyncTransactionCallback fun,
 
99
                       void * anyObject);
 
100
 
 
101
  
 
102
  /**
 
103
   * Update data using pk
 
104
   *
 
105
   */
 
106
  static void updateByPk(Ndb * theNdbObject,
 
107
                         const NDBT_DataSet *,
 
108
                         bool rollback = false,
 
109
                         NDBT_DataSetAsyncTransactionCallback fun,
 
110
                         void * anyObject);
 
111
 
 
112
 
 
113
  /**
 
114
   * Delete 
 
115
   */
 
116
  static void deleteByPk(Ndb * theNdbObject,
 
117
                         const NDBT_DataSet *,
 
118
                         bool rollback = false,
 
119
                         NDBT_DataSetAsyncTransactionCallback fun,
 
120
                         void * anyObject);
 
121
  
 
122
};
 
123
 
 
124
class NDBT_DataSetBulkOperation {
 
125
public:
 
126
  /**
 
127
   * Store the data into ndb
 
128
   */
 
129
  static void insert(Ndb * theNdbObject,
 
130
                     const NDBT_DataSet *,
 
131
                     int parallellTransactions = 1,
 
132
                     int operationsPerTransaction = 10);
 
133
  
 
134
  /**
 
135
   * Read data (using pk) from ndb
 
136
   */
 
137
  static void readByPk(Ndb * theNdbObject,
 
138
                       NDBT_DataSet *,
 
139
                       int parallellTransactions = 1,
 
140
                       int operationsPerTransaction = 10);
 
141
  
 
142
  /**
 
143
   * Update data using pk
 
144
   *
 
145
   */
 
146
  static void updateByPk(Ndb * theNdbObject,
 
147
                         const NDBT_DataSet *,
 
148
                         int parallellTransactions = 1,
 
149
                         int operationsPerTransaction = 10);
 
150
 
 
151
  /**
 
152
   * Delete 
 
153
   */
 
154
  static void deleteByPk(Ndb * theNdbObject,
 
155
                         const NDBT_DataSet *,
 
156
                         int parallellTransactions = 1,
 
157
                         int operationsPerTransaction = 10);
 
158
};
 
159
 
 
160
 
 
161
#endif