2
Copyright (C) 2003-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
3
All rights reserved. Use is subject to license terms.
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.
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.
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
19
#ifndef HUGO_OPERATIONS_HPP
20
#define HUGO_OPERATIONS_HPP
23
#include <HugoCalculator.hpp>
24
#include <UtilTransactions.hpp>
27
class HugoOperations : public UtilTransactions {
29
HugoOperations(const NdbDictionary::Table&,
30
const NdbDictionary::Index* idx = 0);
33
int startTransaction(Ndb*, const NdbDictionary::Table *table= 0,
34
const char *keyData= 0, Uint32 keyLen= 0);
35
int setTransaction(NdbTransaction*,bool not_null_ok= false);
36
int closeTransaction(Ndb*);
37
NdbTransaction* getTransaction();
40
void setTransactionId(Uint64);
42
int pkInsertRecord(Ndb*,
45
int updatesValue = 0);
47
int pkWriteRecord(Ndb*,
50
int updatesValue = 0);
52
int pkWritePartialRecord(Ndb*,
56
int pkReadRecord(Ndb*,
59
NdbOperation::LockMode lm = NdbOperation::LM_Read,
60
NdbOperation::LockMode * lmused = 0);
62
int pkReadRandRecord(Ndb*,
65
NdbOperation::LockMode lm = NdbOperation::LM_Read,
66
NdbOperation::LockMode * lmused = 0);
68
int pkReadRecordLockHandle(Ndb*,
69
Vector<const NdbLockHandle*>& lockHandles,
72
NdbOperation::LockMode lm = NdbOperation::LM_Read,
73
NdbOperation::LockMode * lmused = 0);
75
int pkUnlockRecord(Ndb*,
76
Vector<const NdbLockHandle*>& lockHandles,
78
int numRecords = ~(0),
79
NdbOperation::AbortOption ao = NdbOperation::AbortOnError);
81
int pkUpdateRecord(Ndb*,
84
int updatesValue = 0);
86
int pkDeleteRecord(Ndb*,
90
int pkRefreshRecord(Ndb*,
93
int anyValueInfo = 0); /* 0 - none, 1+ Val | record */
95
int execute_Commit(Ndb*,
96
AbortOption ao = AbortOnError);
97
int execute_NoCommit(Ndb*,
98
AbortOption ao = AbortOnError);
99
int execute_Rollback(Ndb*);
101
int saveCopyOfRecord(int numRecords = 1);
102
int compareRecordToCopy(int numRecords = 1);
104
BaseString getRecordStr(int recordNum);
105
int getRecordGci(int recordNum);
107
int setValueForAttr(NdbOperation*,
112
int equalForAttr(NdbOperation*,
116
int equalForRow(NdbOperation*, int rowid);
118
bool getPartIdForRow(const NdbOperation* pOp, int rowid, Uint32& partId);
120
int setValues(NdbOperation*, int rowId, int updateId);
122
int verifyUpdatesValue(int updatesValue, int _numRows = 0);
124
int indexReadRecords(Ndb*, const char * idxName, int recordNo,
125
bool exclusive = false,
128
int indexUpdateRecord(Ndb*,
129
const char * idxName,
132
int updatesValue = 0);
134
int scanReadRecords(Ndb*, NdbScanOperation::LockMode =
135
NdbScanOperation::LM_CommittedRead,
138
NdbIndexScanOperation* pIndexScanOp;
140
NDBT_ResultRow& get_row(Uint32 idx) { return *rows[idx];}
142
int execute_async(Ndb*, NdbTransaction::ExecType, NdbOperation::AbortOption = NdbOperation::AbortOnError);
143
int execute_async_prepare(Ndb*, NdbTransaction::ExecType, NdbOperation::AbortOption = NdbOperation::AbortOnError);
145
int wait_async(Ndb*, int timeout = -1);
147
int releaseLockHandles(Ndb*,
148
Vector<const NdbLockHandle*>& lockHandles,
150
int numRecords = ~(0));
152
const NdbError& getNdbError() const;
153
void setQuiet() { m_quiet = true; }
155
typedef Uint32 (*AnyValueCallback)(Ndb*, NdbTransaction*, int rowid, int updVal);
157
void setAnyValueCallback(AnyValueCallback);
160
void allocRows(int rows);
163
Vector<NDBT_ResultRow*> rows;
164
Vector<NdbIndexScanOperation*> indexScans;
167
Vector<BaseString> savedRecords;
169
struct RsPair { NdbScanOperation* m_result_set; int records; };
170
Vector<RsPair> m_result_sets;
171
Vector<RsPair> m_executed_result_sets;
175
friend void HugoOperations_async_callback(int, NdbTransaction*, void*);
176
void callback(int res, NdbTransaction*);
177
Uint32 getAnyValueForRowUpd(int row, int update);
180
void setNdbError(const NdbError& error);
183
AnyValueCallback avCallback;