mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / include / kernel / signaldata / ScanFrag.hpp
blob244828751d8f1b255743f867f330a6eacc989556
1 /* Copyright (c) 2003-2006 MySQL AB
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #ifndef SCAN_FRAG_HPP
17 #define SCAN_FRAG_HPP
19 #include "SignalData.hpp"
20 #include "ndb_limits.h"
22 class ScanFragReq {
23 /**
24 * Sender(s)
26 friend class Dbtc;
27 friend class Backup;
28 friend class Suma;
30 /**
31 * Reciver(s)
33 friend class Dblqh;
34 public:
35 STATIC_CONST( SignalLength = 12 );
37 friend bool printSCAN_FRAGREQ(FILE *, const Uint32*, Uint32, Uint16);
39 public:
40 Uint32 senderData;
41 Uint32 resultRef; // Where to send the result
42 Uint32 savePointId;
43 Uint32 requestInfo;
44 Uint32 tableId;
45 Uint32 fragmentNoKeyLen;
46 Uint32 schemaVersion;
47 Uint32 transId1;
48 Uint32 transId2;
49 Uint32 clientOpPtr;
50 Uint32 batch_size_rows;
51 Uint32 batch_size_bytes;
53 static Uint32 getLockMode(const Uint32 & requestInfo);
54 static Uint32 getHoldLockFlag(const Uint32 & requestInfo);
55 static Uint32 getKeyinfoFlag(const Uint32 & requestInfo);
56 static Uint32 getReadCommittedFlag(const Uint32 & requestInfo);
57 static Uint32 getRangeScanFlag(const Uint32 & requestInfo);
58 static Uint32 getDescendingFlag(const Uint32 & requestInfo);
59 static Uint32 getTupScanFlag(const Uint32 & requestInfo);
60 static Uint32 getAttrLen(const Uint32 & requestInfo);
61 static Uint32 getScanPrio(const Uint32 & requestInfo);
62 static Uint32 getNoDiskFlag(const Uint32 & requestInfo);
63 static Uint32 getLcpScanFlag(const Uint32 & requestInfo);
65 static void setLockMode(Uint32 & requestInfo, Uint32 lockMode);
66 static void setHoldLockFlag(Uint32 & requestInfo, Uint32 holdLock);
67 static void setKeyinfoFlag(Uint32 & requestInfo, Uint32 keyinfo);
68 static void setReadCommittedFlag(Uint32 & requestInfo, Uint32 readCommitted);
69 static void setRangeScanFlag(Uint32 & requestInfo, Uint32 rangeScan);
70 static void setDescendingFlag(Uint32 & requestInfo, Uint32 descending);
71 static void setTupScanFlag(Uint32 & requestInfo, Uint32 tupScan);
72 static void setAttrLen(Uint32 & requestInfo, Uint32 attrLen);
73 static void setScanPrio(Uint32& requestInfo, Uint32 prio);
74 static void setNoDiskFlag(Uint32& requestInfo, Uint32 val);
75 static void setLcpScanFlag(Uint32 & requestInfo, Uint32 val);
78 class KeyInfo20 {
79 /**
80 * Sender(s)
82 friend class Dblqh;
84 /**
85 * Reciver(s)
87 friend class Backup;
88 friend class NdbOperation;
89 friend class NdbScanReceiver;
90 public:
91 STATIC_CONST( HeaderLength = 5);
92 STATIC_CONST( DataLength = 20 );
95 static Uint32 setScanInfo(Uint32 noOfOps, Uint32 scanNo);
96 static Uint32 getScanNo(Uint32 scanInfo);
97 static Uint32 getScanOp(Uint32 scanInfo);
99 public:
100 Uint32 clientOpPtr;
101 Uint32 keyLen;
102 Uint32 scanInfo_Node;
103 Uint32 transId1;
104 Uint32 transId2;
105 Uint32 keyData[DataLength];
108 class ScanFragConf {
110 * Sender(s)
112 friend class Dblqh;
115 * Reciver(s)
117 friend class Dbtc;
118 friend class Backup;
119 friend class Suma;
120 public:
121 STATIC_CONST( SignalLength = 6 );
123 public:
124 Uint32 senderData;
125 Uint32 completedOps;
126 Uint32 fragmentCompleted;
127 Uint32 transId1;
128 Uint32 transId2;
129 Uint32 total_len;
132 class ScanFragRef {
134 * Sender(s)
136 friend class Dblqh;
139 * Reciver(s)
141 friend class Dbtc;
142 friend class Backup;
143 friend class Suma;
144 public:
145 STATIC_CONST( SignalLength = 4 );
146 public:
147 enum ErrorCode {
148 ZNO_FREE_TC_CONREC_ERROR = 484,
149 ZTOO_FEW_CONCURRENT_OPERATIONS = 485,
150 ZTOO_MANY_CONCURRENT_OPERATIONS = 486,
151 ZSCAN_NO_FRAGMENT_ERROR = 487,
152 ZTOO_MANY_ACTIVE_SCAN_ERROR = 488,
153 ZNO_FREE_SCANREC_ERROR = 489,
154 ZWRONG_BATCH_SIZE = 1230,
155 ZSTANDBY_SCAN_ERROR = 1209,
156 ZSCAN_BOOK_ACC_OP_ERROR = 1219,
157 ZUNKNOWN_TRANS_ERROR = 1227
160 Uint32 senderData;
161 Uint32 transId1;
162 Uint32 transId2;
163 Uint32 errorCode;
167 * This is part of Scan Fragment protocol
169 * Not to be confused with ScanNextReq in Scan Table protocol
171 class ScanFragNextReq {
173 * Sender(s)
175 friend class Dbtc;
176 friend class Backup;
177 friend class Suma;
180 * Reciver(s)
182 friend class Dblqh;
184 friend bool printSCANFRAGNEXTREQ(FILE * output, const Uint32 * theData,
185 Uint32 len, Uint16 receiverBlockNo);
186 public:
187 STATIC_CONST( SignalLength = 6 );
189 public:
190 Uint32 senderData;
191 Uint32 closeFlag;
192 Uint32 transId1;
193 Uint32 transId2;
194 Uint32 batch_size_rows;
195 Uint32 batch_size_bytes;
199 * Request Info
201 * a = Length of attrinfo - 16 Bits (16-31)
202 * c = LCP scan - 1 Bit 3
203 * d = No disk - 1 Bit 4
204 * l = Lock Mode - 1 Bit 5
205 * h = Hold lock - 1 Bit 7
206 * k = Keyinfo - 1 Bit 8
207 * r = read committed - 1 Bit 9
208 * x = range scan - 1 Bit 6
209 * z = descending - 1 Bit 10
210 * t = tup scan - 1 Bit 11 (implies x=z=0)
211 * p = Scan prio - 4 Bits (12-15) -> max 15
213 * 1111111111222222222233
214 * 01234567890123456789012345678901
215 * dlxhkrztppppaaaaaaaaaaaaaaaa
217 #define SF_LOCK_MODE_SHIFT (5)
218 #define SF_LOCK_MODE_MASK (1)
220 #define SF_NO_DISK_SHIFT (4)
221 #define SF_HOLD_LOCK_SHIFT (7)
222 #define SF_KEYINFO_SHIFT (8)
223 #define SF_READ_COMMITTED_SHIFT (9)
224 #define SF_RANGE_SCAN_SHIFT (6)
225 #define SF_DESCENDING_SHIFT (10)
226 #define SF_TUP_SCAN_SHIFT (11)
227 #define SF_LCP_SCAN_SHIFT (3)
229 #define SF_ATTR_LEN_SHIFT (16)
230 #define SF_ATTR_LEN_MASK (65535)
232 #define SF_PRIO_SHIFT 12
233 #define SF_PRIO_MASK 15
235 inline
236 Uint32
237 ScanFragReq::getLockMode(const Uint32 & requestInfo){
238 return (requestInfo >> SF_LOCK_MODE_SHIFT) & SF_LOCK_MODE_MASK;
241 inline
242 Uint32
243 ScanFragReq::getHoldLockFlag(const Uint32 & requestInfo){
244 return (requestInfo >> SF_HOLD_LOCK_SHIFT) & 1;
247 inline
248 Uint32
249 ScanFragReq::getKeyinfoFlag(const Uint32 & requestInfo){
250 return (requestInfo >> SF_KEYINFO_SHIFT) & 1;
253 inline
254 Uint32
255 ScanFragReq::getRangeScanFlag(const Uint32 & requestInfo){
256 return (requestInfo >> SF_RANGE_SCAN_SHIFT) & 1;
259 inline
260 Uint32
261 ScanFragReq::getDescendingFlag(const Uint32 & requestInfo){
262 return (requestInfo >> SF_DESCENDING_SHIFT) & 1;
265 inline
266 Uint32
267 ScanFragReq::getTupScanFlag(const Uint32 & requestInfo){
268 return (requestInfo >> SF_TUP_SCAN_SHIFT) & 1;
271 inline
272 Uint32
273 ScanFragReq::getReadCommittedFlag(const Uint32 & requestInfo){
274 return (requestInfo >> SF_READ_COMMITTED_SHIFT) & 1;
277 inline
278 Uint32
279 ScanFragReq::getAttrLen(const Uint32 & requestInfo){
280 return (requestInfo >> SF_ATTR_LEN_SHIFT) & SF_ATTR_LEN_MASK;
283 inline
284 Uint32
285 ScanFragReq::getScanPrio(const Uint32 & requestInfo){
286 return (requestInfo >> SF_PRIO_SHIFT) & SF_PRIO_MASK;
289 inline
290 void
291 ScanFragReq::setScanPrio(UintR & requestInfo, UintR val){
292 ASSERT_MAX(val, SF_PRIO_MASK, "ScanFragReq::setScanPrio");
293 requestInfo |= (val << SF_PRIO_SHIFT);
296 inline
297 void
298 ScanFragReq::setLockMode(UintR & requestInfo, UintR val){
299 ASSERT_MAX(val, SF_LOCK_MODE_MASK, "ScanFragReq::setLockMode");
300 requestInfo |= (val << SF_LOCK_MODE_SHIFT);
303 inline
304 void
305 ScanFragReq::setHoldLockFlag(UintR & requestInfo, UintR val){
306 ASSERT_BOOL(val, "ScanFragReq::setHoldLockFlag");
307 requestInfo |= (val << SF_HOLD_LOCK_SHIFT);
310 inline
311 void
312 ScanFragReq::setKeyinfoFlag(UintR & requestInfo, UintR val){
313 ASSERT_BOOL(val, "ScanFragReq::setKeyinfoFlag");
314 requestInfo |= (val << SF_KEYINFO_SHIFT);
317 inline
318 void
319 ScanFragReq::setReadCommittedFlag(UintR & requestInfo, UintR val){
320 ASSERT_BOOL(val, "ScanFragReq::setReadCommittedFlag");
321 requestInfo |= (val << SF_READ_COMMITTED_SHIFT);
324 inline
325 void
326 ScanFragReq::setRangeScanFlag(UintR & requestInfo, UintR val){
327 ASSERT_BOOL(val, "ScanFragReq::setRangeScanFlag");
328 requestInfo |= (val << SF_RANGE_SCAN_SHIFT);
331 inline
332 void
333 ScanFragReq::setDescendingFlag(UintR & requestInfo, UintR val){
334 ASSERT_BOOL(val, "ScanFragReq::setDescendingFlag");
335 requestInfo |= (val << SF_DESCENDING_SHIFT);
338 inline
339 void
340 ScanFragReq::setTupScanFlag(UintR & requestInfo, UintR val){
341 ASSERT_BOOL(val, "ScanFragReq::setTupScanFlag");
342 requestInfo |= (val << SF_TUP_SCAN_SHIFT);
345 inline
346 void
347 ScanFragReq::setAttrLen(UintR & requestInfo, UintR val){
348 ASSERT_MAX(val, SF_ATTR_LEN_MASK, "ScanFragReq::setAttrLen");
349 requestInfo |= (val << SF_ATTR_LEN_SHIFT);
352 inline
353 Uint32
354 ScanFragReq::getNoDiskFlag(const Uint32 & requestInfo){
355 return (requestInfo >> SF_NO_DISK_SHIFT) & 1;
358 inline
359 void
360 ScanFragReq::setNoDiskFlag(UintR & requestInfo, UintR val){
361 ASSERT_BOOL(val, "ScanFragReq::setNoDiskFlag");
362 requestInfo |= (val << SF_NO_DISK_SHIFT);
365 inline
366 Uint32
367 ScanFragReq::getLcpScanFlag(const Uint32 & requestInfo){
368 return (requestInfo >> SF_LCP_SCAN_SHIFT) & 1;
371 inline
372 void
373 ScanFragReq::setLcpScanFlag(UintR & requestInfo, UintR val){
374 ASSERT_BOOL(val, "ScanFragReq::setLcpScanFlag");
375 requestInfo |= (val << SF_LCP_SCAN_SHIFT);
378 inline
379 Uint32
380 KeyInfo20::setScanInfo(Uint32 opNo, Uint32 scanNo){
381 ASSERT_MAX(opNo, 1023, "KeyInfo20::setScanInfo");
382 ASSERT_MAX(scanNo, 255, "KeyInfo20::setScanInfo");
383 return (opNo << 8) + scanNo;
386 inline
387 Uint32
388 KeyInfo20::getScanNo(Uint32 scanInfo){
389 return scanInfo & 0xFF;
392 inline
393 Uint32
394 KeyInfo20::getScanOp(Uint32 scanInfo){
395 return (scanInfo >> 8) & 0x3FF;
398 #endif