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 */
19 #include "SignalData.hpp"
20 #include "ndb_limits.h"
35 STATIC_CONST( SignalLength
= 12 );
37 friend bool printSCAN_FRAGREQ(FILE *, const Uint32
*, Uint32
, Uint16
);
41 Uint32 resultRef
; // Where to send the result
45 Uint32 fragmentNoKeyLen
;
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
);
88 friend class NdbOperation
;
89 friend class NdbScanReceiver
;
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
);
102 Uint32 scanInfo_Node
;
105 Uint32 keyData
[DataLength
];
121 STATIC_CONST( SignalLength
= 6 );
126 Uint32 fragmentCompleted
;
145 STATIC_CONST( SignalLength
= 4 );
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
167 * This is part of Scan Fragment protocol
169 * Not to be confused with ScanNextReq in Scan Table protocol
171 class ScanFragNextReq
{
184 friend bool printSCANFRAGNEXTREQ(FILE * output
, const Uint32
* theData
,
185 Uint32 len
, Uint16 receiverBlockNo
);
187 STATIC_CONST( SignalLength
= 6 );
194 Uint32 batch_size_rows
;
195 Uint32 batch_size_bytes
;
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
237 ScanFragReq::getLockMode(const Uint32
& requestInfo
){
238 return (requestInfo
>> SF_LOCK_MODE_SHIFT
) & SF_LOCK_MODE_MASK
;
243 ScanFragReq::getHoldLockFlag(const Uint32
& requestInfo
){
244 return (requestInfo
>> SF_HOLD_LOCK_SHIFT
) & 1;
249 ScanFragReq::getKeyinfoFlag(const Uint32
& requestInfo
){
250 return (requestInfo
>> SF_KEYINFO_SHIFT
) & 1;
255 ScanFragReq::getRangeScanFlag(const Uint32
& requestInfo
){
256 return (requestInfo
>> SF_RANGE_SCAN_SHIFT
) & 1;
261 ScanFragReq::getDescendingFlag(const Uint32
& requestInfo
){
262 return (requestInfo
>> SF_DESCENDING_SHIFT
) & 1;
267 ScanFragReq::getTupScanFlag(const Uint32
& requestInfo
){
268 return (requestInfo
>> SF_TUP_SCAN_SHIFT
) & 1;
273 ScanFragReq::getReadCommittedFlag(const Uint32
& requestInfo
){
274 return (requestInfo
>> SF_READ_COMMITTED_SHIFT
) & 1;
279 ScanFragReq::getAttrLen(const Uint32
& requestInfo
){
280 return (requestInfo
>> SF_ATTR_LEN_SHIFT
) & SF_ATTR_LEN_MASK
;
285 ScanFragReq::getScanPrio(const Uint32
& requestInfo
){
286 return (requestInfo
>> SF_PRIO_SHIFT
) & SF_PRIO_MASK
;
291 ScanFragReq::setScanPrio(UintR
& requestInfo
, UintR val
){
292 ASSERT_MAX(val
, SF_PRIO_MASK
, "ScanFragReq::setScanPrio");
293 requestInfo
|= (val
<< SF_PRIO_SHIFT
);
298 ScanFragReq::setLockMode(UintR
& requestInfo
, UintR val
){
299 ASSERT_MAX(val
, SF_LOCK_MODE_MASK
, "ScanFragReq::setLockMode");
300 requestInfo
|= (val
<< SF_LOCK_MODE_SHIFT
);
305 ScanFragReq::setHoldLockFlag(UintR
& requestInfo
, UintR val
){
306 ASSERT_BOOL(val
, "ScanFragReq::setHoldLockFlag");
307 requestInfo
|= (val
<< SF_HOLD_LOCK_SHIFT
);
312 ScanFragReq::setKeyinfoFlag(UintR
& requestInfo
, UintR val
){
313 ASSERT_BOOL(val
, "ScanFragReq::setKeyinfoFlag");
314 requestInfo
|= (val
<< SF_KEYINFO_SHIFT
);
319 ScanFragReq::setReadCommittedFlag(UintR
& requestInfo
, UintR val
){
320 ASSERT_BOOL(val
, "ScanFragReq::setReadCommittedFlag");
321 requestInfo
|= (val
<< SF_READ_COMMITTED_SHIFT
);
326 ScanFragReq::setRangeScanFlag(UintR
& requestInfo
, UintR val
){
327 ASSERT_BOOL(val
, "ScanFragReq::setRangeScanFlag");
328 requestInfo
|= (val
<< SF_RANGE_SCAN_SHIFT
);
333 ScanFragReq::setDescendingFlag(UintR
& requestInfo
, UintR val
){
334 ASSERT_BOOL(val
, "ScanFragReq::setDescendingFlag");
335 requestInfo
|= (val
<< SF_DESCENDING_SHIFT
);
340 ScanFragReq::setTupScanFlag(UintR
& requestInfo
, UintR val
){
341 ASSERT_BOOL(val
, "ScanFragReq::setTupScanFlag");
342 requestInfo
|= (val
<< SF_TUP_SCAN_SHIFT
);
347 ScanFragReq::setAttrLen(UintR
& requestInfo
, UintR val
){
348 ASSERT_MAX(val
, SF_ATTR_LEN_MASK
, "ScanFragReq::setAttrLen");
349 requestInfo
|= (val
<< SF_ATTR_LEN_SHIFT
);
354 ScanFragReq::getNoDiskFlag(const Uint32
& requestInfo
){
355 return (requestInfo
>> SF_NO_DISK_SHIFT
) & 1;
360 ScanFragReq::setNoDiskFlag(UintR
& requestInfo
, UintR val
){
361 ASSERT_BOOL(val
, "ScanFragReq::setNoDiskFlag");
362 requestInfo
|= (val
<< SF_NO_DISK_SHIFT
);
367 ScanFragReq::getLcpScanFlag(const Uint32
& requestInfo
){
368 return (requestInfo
>> SF_LCP_SCAN_SHIFT
) & 1;
373 ScanFragReq::setLcpScanFlag(UintR
& requestInfo
, UintR val
){
374 ASSERT_BOOL(val
, "ScanFragReq::setLcpScanFlag");
375 requestInfo
|= (val
<< SF_LCP_SCAN_SHIFT
);
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
;
388 KeyInfo20::getScanNo(Uint32 scanInfo
){
389 return scanInfo
& 0xFF;
394 KeyInfo20::getScanOp(Uint32 scanInfo
){
395 return (scanInfo
>> 8) & 0x3FF;