1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
|
/* Copyright (c) 2003-2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef SCAN_FRAG_HPP
#define SCAN_FRAG_HPP
#include "SignalData.hpp"
#include "ndb_limits.h"
class ScanFragReq {
/**
* Sender(s)
*/
friend class Dbtc;
friend class Backup;
friend class Suma;
/**
* Reciver(s)
*/
friend class Dblqh;
public:
STATIC_CONST( SignalLength = 12 );
friend bool printSCAN_FRAGREQ(FILE *, const Uint32*, Uint32, Uint16);
public:
Uint32 senderData;
Uint32 resultRef; // Where to send the result
Uint32 savePointId;
Uint32 requestInfo;
Uint32 tableId;
Uint32 fragmentNoKeyLen;
Uint32 schemaVersion;
Uint32 transId1;
Uint32 transId2;
Uint32 clientOpPtr;
Uint32 batch_size_rows;
Uint32 batch_size_bytes;
static Uint32 getLockMode(const Uint32 & requestInfo);
static Uint32 getHoldLockFlag(const Uint32 & requestInfo);
static Uint32 getKeyinfoFlag(const Uint32 & requestInfo);
static Uint32 getReadCommittedFlag(const Uint32 & requestInfo);
static Uint32 getRangeScanFlag(const Uint32 & requestInfo);
static Uint32 getDescendingFlag(const Uint32 & requestInfo);
static Uint32 getTupScanFlag(const Uint32 & requestInfo);
static Uint32 getAttrLen(const Uint32 & requestInfo);
static Uint32 getScanPrio(const Uint32 & requestInfo);
static Uint32 getNoDiskFlag(const Uint32 & requestInfo);
static Uint32 getLcpScanFlag(const Uint32 & requestInfo);
static void setLockMode(Uint32 & requestInfo, Uint32 lockMode);
static void setHoldLockFlag(Uint32 & requestInfo, Uint32 holdLock);
static void setKeyinfoFlag(Uint32 & requestInfo, Uint32 keyinfo);
static void setReadCommittedFlag(Uint32 & requestInfo, Uint32 readCommitted);
static void setRangeScanFlag(Uint32 & requestInfo, Uint32 rangeScan);
static void setDescendingFlag(Uint32 & requestInfo, Uint32 descending);
static void setTupScanFlag(Uint32 & requestInfo, Uint32 tupScan);
static void setAttrLen(Uint32 & requestInfo, Uint32 attrLen);
static void setScanPrio(Uint32& requestInfo, Uint32 prio);
static void setNoDiskFlag(Uint32& requestInfo, Uint32 val);
static void setLcpScanFlag(Uint32 & requestInfo, Uint32 val);
};
class KeyInfo20 {
/**
* Sender(s)
*/
friend class Dblqh;
/**
* Reciver(s)
*/
friend class Backup;
friend class NdbOperation;
friend class NdbScanReceiver;
public:
STATIC_CONST( HeaderLength = 5);
STATIC_CONST( DataLength = 20 );
static Uint32 setScanInfo(Uint32 noOfOps, Uint32 scanNo);
static Uint32 getScanNo(Uint32 scanInfo);
static Uint32 getScanOp(Uint32 scanInfo);
public:
Uint32 clientOpPtr;
Uint32 keyLen;
Uint32 scanInfo_Node;
Uint32 transId1;
Uint32 transId2;
Uint32 keyData[DataLength];
};
class ScanFragConf {
/**
* Sender(s)
*/
friend class Dblqh;
/**
* Reciver(s)
*/
friend class Dbtc;
friend class Backup;
friend class Suma;
public:
STATIC_CONST( SignalLength = 6 );
public:
Uint32 senderData;
Uint32 completedOps;
Uint32 fragmentCompleted;
Uint32 transId1;
Uint32 transId2;
Uint32 total_len;
};
class ScanFragRef {
/**
* Sender(s)
*/
friend class Dblqh;
/**
* Reciver(s)
*/
friend class Dbtc;
friend class Backup;
friend class Suma;
public:
STATIC_CONST( SignalLength = 4 );
public:
enum ErrorCode {
ZNO_FREE_TC_CONREC_ERROR = 484,
ZTOO_FEW_CONCURRENT_OPERATIONS = 485,
ZTOO_MANY_CONCURRENT_OPERATIONS = 486,
ZSCAN_NO_FRAGMENT_ERROR = 487,
ZTOO_MANY_ACTIVE_SCAN_ERROR = 488,
ZNO_FREE_SCANREC_ERROR = 489,
ZWRONG_BATCH_SIZE = 1230,
ZSTANDBY_SCAN_ERROR = 1209,
ZSCAN_BOOK_ACC_OP_ERROR = 1219,
ZUNKNOWN_TRANS_ERROR = 1227
};
Uint32 senderData;
Uint32 transId1;
Uint32 transId2;
Uint32 errorCode;
};
/**
* This is part of Scan Fragment protocol
*
* Not to be confused with ScanNextReq in Scan Table protocol
*/
class ScanFragNextReq {
/**
* Sender(s)
*/
friend class Dbtc;
friend class Backup;
friend class Suma;
/**
* Reciver(s)
*/
friend class Dblqh;
friend bool printSCANFRAGNEXTREQ(FILE * output, const Uint32 * theData,
Uint32 len, Uint16 receiverBlockNo);
public:
STATIC_CONST( SignalLength = 6 );
public:
Uint32 senderData;
Uint32 closeFlag;
Uint32 transId1;
Uint32 transId2;
Uint32 batch_size_rows;
Uint32 batch_size_bytes;
};
/**
* Request Info
*
* a = Length of attrinfo - 16 Bits (16-31)
* c = LCP scan - 1 Bit 3
* d = No disk - 1 Bit 4
* l = Lock Mode - 1 Bit 5
* h = Hold lock - 1 Bit 7
* k = Keyinfo - 1 Bit 8
* r = read committed - 1 Bit 9
* x = range scan - 1 Bit 6
* z = descending - 1 Bit 10
* t = tup scan - 1 Bit 11 (implies x=z=0)
* p = Scan prio - 4 Bits (12-15) -> max 15
*
* 1111111111222222222233
* 01234567890123456789012345678901
* dlxhkrztppppaaaaaaaaaaaaaaaa
*/
#define SF_LOCK_MODE_SHIFT (5)
#define SF_LOCK_MODE_MASK (1)
#define SF_NO_DISK_SHIFT (4)
#define SF_HOLD_LOCK_SHIFT (7)
#define SF_KEYINFO_SHIFT (8)
#define SF_READ_COMMITTED_SHIFT (9)
#define SF_RANGE_SCAN_SHIFT (6)
#define SF_DESCENDING_SHIFT (10)
#define SF_TUP_SCAN_SHIFT (11)
#define SF_LCP_SCAN_SHIFT (3)
#define SF_ATTR_LEN_SHIFT (16)
#define SF_ATTR_LEN_MASK (65535)
#define SF_PRIO_SHIFT 12
#define SF_PRIO_MASK 15
inline
Uint32
ScanFragReq::getLockMode(const Uint32 & requestInfo){
return (requestInfo >> SF_LOCK_MODE_SHIFT) & SF_LOCK_MODE_MASK;
}
inline
Uint32
ScanFragReq::getHoldLockFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_HOLD_LOCK_SHIFT) & 1;
}
inline
Uint32
ScanFragReq::getKeyinfoFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_KEYINFO_SHIFT) & 1;
}
inline
Uint32
ScanFragReq::getRangeScanFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_RANGE_SCAN_SHIFT) & 1;
}
inline
Uint32
ScanFragReq::getDescendingFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_DESCENDING_SHIFT) & 1;
}
inline
Uint32
ScanFragReq::getTupScanFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_TUP_SCAN_SHIFT) & 1;
}
inline
Uint32
ScanFragReq::getReadCommittedFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_READ_COMMITTED_SHIFT) & 1;
}
inline
Uint32
ScanFragReq::getAttrLen(const Uint32 & requestInfo){
return (requestInfo >> SF_ATTR_LEN_SHIFT) & SF_ATTR_LEN_MASK;
}
inline
Uint32
ScanFragReq::getScanPrio(const Uint32 & requestInfo){
return (requestInfo >> SF_PRIO_SHIFT) & SF_PRIO_MASK;
}
inline
void
ScanFragReq::setScanPrio(UintR & requestInfo, UintR val){
ASSERT_MAX(val, SF_PRIO_MASK, "ScanFragReq::setScanPrio");
requestInfo |= (val << SF_PRIO_SHIFT);
}
inline
void
ScanFragReq::setLockMode(UintR & requestInfo, UintR val){
ASSERT_MAX(val, SF_LOCK_MODE_MASK, "ScanFragReq::setLockMode");
requestInfo |= (val << SF_LOCK_MODE_SHIFT);
}
inline
void
ScanFragReq::setHoldLockFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setHoldLockFlag");
requestInfo |= (val << SF_HOLD_LOCK_SHIFT);
}
inline
void
ScanFragReq::setKeyinfoFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setKeyinfoFlag");
requestInfo |= (val << SF_KEYINFO_SHIFT);
}
inline
void
ScanFragReq::setReadCommittedFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setReadCommittedFlag");
requestInfo |= (val << SF_READ_COMMITTED_SHIFT);
}
inline
void
ScanFragReq::setRangeScanFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setRangeScanFlag");
requestInfo |= (val << SF_RANGE_SCAN_SHIFT);
}
inline
void
ScanFragReq::setDescendingFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setDescendingFlag");
requestInfo |= (val << SF_DESCENDING_SHIFT);
}
inline
void
ScanFragReq::setTupScanFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setTupScanFlag");
requestInfo |= (val << SF_TUP_SCAN_SHIFT);
}
inline
void
ScanFragReq::setAttrLen(UintR & requestInfo, UintR val){
ASSERT_MAX(val, SF_ATTR_LEN_MASK, "ScanFragReq::setAttrLen");
requestInfo |= (val << SF_ATTR_LEN_SHIFT);
}
inline
Uint32
ScanFragReq::getNoDiskFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_NO_DISK_SHIFT) & 1;
}
inline
void
ScanFragReq::setNoDiskFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setNoDiskFlag");
requestInfo |= (val << SF_NO_DISK_SHIFT);
}
inline
Uint32
ScanFragReq::getLcpScanFlag(const Uint32 & requestInfo){
return (requestInfo >> SF_LCP_SCAN_SHIFT) & 1;
}
inline
void
ScanFragReq::setLcpScanFlag(UintR & requestInfo, UintR val){
ASSERT_BOOL(val, "ScanFragReq::setLcpScanFlag");
requestInfo |= (val << SF_LCP_SCAN_SHIFT);
}
inline
Uint32
KeyInfo20::setScanInfo(Uint32 opNo, Uint32 scanNo){
ASSERT_MAX(opNo, 1023, "KeyInfo20::setScanInfo");
ASSERT_MAX(scanNo, 255, "KeyInfo20::setScanInfo");
return (opNo << 8) + scanNo;
}
inline
Uint32
KeyInfo20::getScanNo(Uint32 scanInfo){
return scanInfo & 0xFF;
}
inline
Uint32
KeyInfo20::getScanOp(Uint32 scanInfo){
return (scanInfo >> 8) & 0x3FF;
}
#endif
|