MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HugoOperations.hpp
1 /*
2  Copyright (C) 2003-2008 MySQL AB, 2008-2010 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 HUGO_OPERATIONS_HPP
20 #define HUGO_OPERATIONS_HPP
21 
22 #include <NDBT.hpp>
23 #include <HugoCalculator.hpp>
24 #include <UtilTransactions.hpp>
25 #include <Vector.hpp>
26 
28 public:
30  const NdbDictionary::Index* idx = 0);
31 
32  ~HugoOperations();
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();
38  void refresh();
39 
40  void setTransactionId(Uint64);
41 
42  int pkInsertRecord(Ndb*,
43  int recordNo,
44  int numRecords = 1,
45  int updatesValue = 0);
46 
47  int pkWriteRecord(Ndb*,
48  int recordNo,
49  int numRecords = 1,
50  int updatesValue = 0);
51 
52  int pkWritePartialRecord(Ndb*,
53  int recordNo,
54  int numRecords = 1);
55 
56  int pkReadRecord(Ndb*,
57  int record,
58  int numRecords = 1,
60  NdbOperation::LockMode * lmused = 0);
61 
62  int pkReadRandRecord(Ndb*,
63  int records,
64  int numRecords = 1,
66  NdbOperation::LockMode * lmused = 0);
67 
68  int pkReadRecordLockHandle(Ndb*,
69  Vector<const NdbLockHandle*>& lockHandles,
70  int record,
71  int numRecords = 1,
73  NdbOperation::LockMode * lmused = 0);
74 
75  int pkUnlockRecord(Ndb*,
76  Vector<const NdbLockHandle*>& lockHandles,
77  int offset = 0,
78  int numRecords = ~(0),
80 
81  int pkUpdateRecord(Ndb*,
82  int recordNo,
83  int numRecords = 1,
84  int updatesValue = 0);
85 
86  int pkDeleteRecord(Ndb*,
87  int recordNo,
88  int numRecords = 1);
89 
90  int pkRefreshRecord(Ndb*,
91  int recordNo,
92  int numRecords = 1,
93  int anyValueInfo = 0); /* 0 - none, 1+ Val | record */
94 
95  int execute_Commit(Ndb*,
96  AbortOption ao = AbortOnError);
97  int execute_NoCommit(Ndb*,
98  AbortOption ao = AbortOnError);
99  int execute_Rollback(Ndb*);
100 
101  int saveCopyOfRecord(int numRecords = 1);
102  int compareRecordToCopy(int numRecords = 1);
103 
104  BaseString getRecordStr(int recordNum);
105  int getRecordGci(int recordNum);
106 
107  int setValueForAttr(NdbOperation*,
108  int attrId,
109  int rowId,
110  int updateId);
111 
112  int equalForAttr(NdbOperation*,
113  int attrId,
114  int rowId);
115 
116  int equalForRow(NdbOperation*, int rowid);
117 
118  bool getPartIdForRow(const NdbOperation* pOp, int rowid, Uint32& partId);
119 
120  int setValues(NdbOperation*, int rowId, int updateId);
121 
122  int verifyUpdatesValue(int updatesValue, int _numRows = 0);
123 
124  int indexReadRecords(Ndb*, const char * idxName, int recordNo,
125  bool exclusive = false,
126  int records = 1);
127 
128  int indexUpdateRecord(Ndb*,
129  const char * idxName,
130  int recordNo,
131  int numRecords = 1,
132  int updatesValue = 0);
133 
134  int scanReadRecords(Ndb*, NdbScanOperation::LockMode =
136  int numRecords = 1);
137 
138  NdbIndexScanOperation* pIndexScanOp;
139 
140  NDBT_ResultRow& get_row(Uint32 idx) { return *rows[idx];}
141 
144 
145  int wait_async(Ndb*, int timeout = -1);
146 
147  int releaseLockHandles(Ndb*,
148  Vector<const NdbLockHandle*>& lockHandles,
149  int offset = 0,
150  int numRecords = ~(0));
151 
152  const NdbError& getNdbError() const;
153  void setQuiet() { m_quiet = true; }
154 
155  typedef Uint32 (*AnyValueCallback)(Ndb*, NdbTransaction*, int rowid, int updVal);
156 
157  void setAnyValueCallback(AnyValueCallback);
158 
159 protected:
160  void allocRows(int rows);
161  void deallocRows();
162 
165  HugoCalculator calc;
166 
167  Vector<BaseString> savedRecords;
168 
169  struct RsPair { NdbScanOperation* m_result_set; int records; };
170  Vector<RsPair> m_result_sets;
171  Vector<RsPair> m_executed_result_sets;
172 
173  int m_async_reply;
174  int m_async_return;
175  friend void HugoOperations_async_callback(int, NdbTransaction*, void*);
176  void callback(int res, NdbTransaction*);
177  Uint32 getAnyValueForRowUpd(int row, int update);
178 
179 
180  void setNdbError(const NdbError& error);
181  NdbError m_error;
182  bool m_quiet;
183  AnyValueCallback avCallback;
184 };
185 
186 #endif