MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TcKeyReq.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef TC_KEY_REQ_H
19 #define TC_KEY_REQ_H
20 
21 #include "SignalData.hpp"
22 #include <transporter/TransporterDefinitions.hpp>
23 
46 class TcKeyReq {
50  friend class Dbtc; // Receiver
51 
55  friend class Ndbcntr;
56  friend class NdbQueryImpl;
57  friend class NdbOperation;
58  friend class NdbIndexOperation;
59  friend class NdbScanOperation;
60  friend class NdbBlob;
61  friend class DbUtil;
62  friend class Trix;
63 
67  friend bool printTCKEYREQ(FILE *, const Uint32 *, Uint32, Uint16);
68  friend bool printTCINDXREQ(FILE *, const Uint32 *, Uint32, Uint16);
69 
70 public:
74  STATIC_CONST( StaticLength = 8 );
75  STATIC_CONST( SignalLength = 25 );
76  STATIC_CONST( MaxKeyInfo = 8 );
77  STATIC_CONST( MaxAttrInfo = 5 );
78  STATIC_CONST( MaxTotalAttrInfo = ((MAX_SEND_MESSAGE_BYTESIZE / 4) -
79  SignalLength ));
80 
84  STATIC_CONST( KeyInfoSectionNum = 0 );
85  STATIC_CONST( AttrInfoSectionNum = 1 );
86 
87  STATIC_CONST( UnlockKeyLen = 2 );
88 
89 private:
90 
91  enum AbortOption {
92  CommitIfFailFree = 0, AbortOnError = 0,
93  CommitAsMuchAsPossible = 2, IgnoreError = 2
94  };
95 
96  typedef AbortOption CommitType;
97 
102  // ----------------------------------------------------------------------
103  // Unconditional part = must be present in signal. First 8 words
104  // ----------------------------------------------------------------------
105  Uint32 apiConnectPtr; // DATA 0
106  union {
107  Uint32 senderData;
108  UintR apiOperationPtr; // DATA 1
109  };
125  UintR attrLen; // DATA 2 (also stores API Version)
126  UintR tableId; // DATA 3
127  UintR requestInfo; // DATA 4 Various transaction flags
128  UintR tableSchemaVersion; // DATA 5
129  UintR transId1; // DATA 6
130  UintR transId2; // DATA 7
131 
132  // ----------------------------------------------------------------------
133  // Conditional part = can be present in signal.
134  // These four words will be sent only if their indicator is set.
135  // ----------------------------------------------------------------------
136  UintR scanInfo; // DATA 8 Various flags for scans, see below
137  UintR distrGroupHashValue; // DATA 9
138  UintR distributionKeySize; // DATA 10
139  UintR storedProcId; // DATA 11
140 
141  // ----------------------------------------------------------------------
142  // Variable sized KEY and ATTRINFO part.
143  // These will be placed to pack the signal in an appropriate manner.
144  // ----------------------------------------------------------------------
145  UintR keyInfo[MaxKeyInfo]; // DATA 12 - 19
146  UintR attrInfo[MaxAttrInfo]; // DATA 20 - 24
147 
152  static Uint16 getAPIVersion(const UintR & attrLen);
153  static Uint16 getAttrinfoLen(const UintR & attrLen);
154  static void setAPIVersion(UintR & attrLen, Uint16 apiVersion);
155  static void setAttrinfoLen(UintR & attrLen, Uint16 aiLen);
156 
157 
161  static Uint8 getCommitFlag(const UintR & requestInfo);
162  static Uint8 getAbortOption(const UintR & requestInfo);
163  static Uint8 getStartFlag(const UintR & requestInfo);
164  static Uint8 getSimpleFlag(const UintR & requestInfo);
165  static Uint8 getDirtyFlag(const UintR & requestInfo);
166  static Uint8 getInterpretedFlag(const UintR & requestInfo);
167  static Uint8 getDistributionKeyFlag(const UintR & requestInfo);
168  static Uint8 getViaSPJFlag(const UintR & requestInfo);
169  static Uint8 getScanIndFlag(const UintR & requestInfo);
170  static Uint8 getOperationType(const UintR & requestInfo);
171  static Uint8 getExecuteFlag(const UintR & requestInfo);
172 
173  static Uint16 getKeyLength(const UintR & requestInfo);
174  static Uint8 getAIInTcKeyReq(const UintR & requestInfo);
175  static UintR getNoDiskFlag(const UintR & requestInfo);
176 
177  static UintR getCoordinatedTransactionFlag(const UintR & requestInfo);
178 
182  static Uint8 getTakeOverScanFlag(const UintR & scanInfo);
183  static Uint16 getTakeOverScanFragment(const UintR & scanInfo);
184  static Uint32 getTakeOverScanInfo(const UintR & scanInfo);
185 
186 
190  static void clearRequestInfo(UintR & requestInfo);
191  static void setAbortOption(UintR & requestInfo, Uint32 type);
192  static void setCommitFlag(UintR & requestInfo, Uint32 flag);
193  static void setStartFlag(UintR & requestInfo, Uint32 flag);
194  static void setSimpleFlag(UintR & requestInfo, Uint32 flag);
195  static void setDirtyFlag(UintR & requestInfo, Uint32 flag);
196  static void setInterpretedFlag(UintR & requestInfo, Uint32 flag);
197  static void setDistributionKeyFlag(UintR & requestInfo, Uint32 flag);
198  static void setViaSPJFlag(UintR & requestInfo, Uint32 flag);
199  static void setScanIndFlag(UintR & requestInfo, Uint32 flag);
200  static void setExecuteFlag(UintR & requestInfo, Uint32 flag);
201  static void setOperationType(UintR & requestInfo, Uint32 type);
202 
203  static void setKeyLength(UintR & requestInfo, Uint32 len);
204  static void setAIInTcKeyReq(UintR & requestInfo, Uint32 len);
205  static void setNoDiskFlag(UintR & requestInfo, UintR val);
206 
207  static void setReorgFlag(UintR & requestInfo, UintR val);
208  static UintR getReorgFlag(const UintR & requestInfo);
209  static void setCoordinatedTransactionFlag(UintR & requestInfo, UintR val);
210  static void setQueueOnRedoProblemFlag(UintR & requestInfo, UintR val);
211  static UintR getQueueOnRedoProblemFlag(const UintR & requestInfo);
212 
216  static UintR getDeferredConstraints(const UintR & requestInfo);
217  static void setDeferredConstraints(UintR & requestInfo, UintR val);
218 
222  static void setTakeOverScanFlag(UintR & scanInfo, Uint8 flag);
223  static void setTakeOverScanFragment(UintR & scanInfo, Uint16 fragment);
224  static void setTakeOverScanInfo(UintR & scanInfo, Uint32 aScanInfo);
225 };
226 
258 #define TCKEY_NODISK_SHIFT (1)
259 #define COMMIT_SHIFT (4)
260 #define START_SHIFT (11)
261 #define SIMPLE_SHIFT (8)
262 #define DIRTY_SHIFT (0)
263 #define EXECUTE_SHIFT (10)
264 #define INTERPRETED_SHIFT (15)
265 #define DISTR_KEY_SHIFT (2)
266 #define VIA_SPJ_SHIFT (3)
267 #define SCAN_SHIFT (14)
268 
269 #define OPERATION_SHIFT (5)
270 #define OPERATION_MASK (7)
271 
272 #define AINFO_SHIFT (16)
273 #define AINFO_MASK (7)
274 
275 #define KEY_LEN_SHIFT (20)
276 #define KEY_LEN_MASK (4095)
277 
278 #define COMMIT_TYPE_SHIFT (12)
279 #define COMMIT_TYPE_MASK (3)
280 
281 #define TC_REORG_SHIFT (19)
282 #define QUEUE_ON_REDO_SHIFT (9)
283 
284 #define TC_COORDINATED_SHIFT (16)
285 #define TC_DEFERRED_CONSTAINTS_SHIFT (17)
286 
308 #define TAKE_OVER_SHIFT (0)
309 
310 #define TAKE_OVER_FRAG_SHIFT (20)
311 #define TAKE_OVER_FRAG_MASK (4095)
312 
313 #define SCAN_INFO_SHIFT (1)
314 #define SCAN_INFO_MASK (0x3ffff)
315 
328 #define API_VER_NO_SHIFT (16)
329 #define API_VER_NO_MASK (65535)
330 
331 #define ATTRLEN_SHIFT (0)
332 #define ATTRLEN_MASK (65535)
333 
334 inline
335 Uint8
336 TcKeyReq::getCommitFlag(const UintR & requestInfo){
337  return (Uint8)((requestInfo >> COMMIT_SHIFT) & 1);
338 }
339 
340 inline
341 Uint8
342 TcKeyReq::getAbortOption(const UintR & requestInfo){
343  return (Uint8)((requestInfo >> COMMIT_TYPE_SHIFT) & COMMIT_TYPE_MASK);
344 }
345 
346 inline
347 Uint8
348 TcKeyReq::getStartFlag(const UintR & requestInfo){
349  return (Uint8)((requestInfo >> START_SHIFT) & 1);
350 }
351 
352 inline
353 Uint8
354 TcKeyReq::getSimpleFlag(const UintR & requestInfo){
355  return (Uint8)((requestInfo >> SIMPLE_SHIFT) & 1);
356 }
357 
358 inline
359 Uint8
360 TcKeyReq::getExecuteFlag(const UintR & requestInfo){
361  return (Uint8)((requestInfo >> EXECUTE_SHIFT) & 1);
362 }
363 
364 inline
365 Uint8
366 TcKeyReq::getDirtyFlag(const UintR & requestInfo){
367  return (Uint8)((requestInfo >> DIRTY_SHIFT) & 1);
368 }
369 
370 inline
371 Uint8
372 TcKeyReq::getInterpretedFlag(const UintR & requestInfo){
373  return (Uint8)((requestInfo >> INTERPRETED_SHIFT) & 1);
374 }
375 
376 inline
377 Uint8
378 TcKeyReq::getDistributionKeyFlag(const UintR & requestInfo){
379  return (Uint8)((requestInfo >> DISTR_KEY_SHIFT) & 1);
380 }
381 
382 inline
383 UintR
384 TcKeyReq::getCoordinatedTransactionFlag(const UintR & requestInfo){
385  return (UintR)((requestInfo >> TC_COORDINATED_SHIFT) & 1);
386 }
387 
388 inline
389 Uint8
390 TcKeyReq::getViaSPJFlag(const UintR & requestInfo){
391  return (Uint8)((requestInfo >> VIA_SPJ_SHIFT) & 1);
392 }
393 
394 inline
395 Uint8
396 TcKeyReq::getScanIndFlag(const UintR & requestInfo){
397  return (Uint8)((requestInfo >> SCAN_SHIFT) & 1);
398 }
399 
400 inline
401 Uint8
402 TcKeyReq::getOperationType(const UintR & requestInfo){
403  return (Uint8)((requestInfo >> OPERATION_SHIFT) & OPERATION_MASK);
404 }
405 
406 inline
407 Uint16
408 TcKeyReq::getKeyLength(const UintR & requestInfo){
409  return (Uint16)((requestInfo >> KEY_LEN_SHIFT) & KEY_LEN_MASK);
410 }
411 
412 inline
413 Uint8
414 TcKeyReq::getAIInTcKeyReq(const UintR & requestInfo){
415  return (Uint8)((requestInfo >> AINFO_SHIFT) & AINFO_MASK);
416 }
417 
418 inline
419 void
420 TcKeyReq::clearRequestInfo(UintR & requestInfo){
421  requestInfo = 0;
422 }
423 
424 inline
425 void
426 TcKeyReq::setAbortOption(UintR & requestInfo, Uint32 type){
427  ASSERT_MAX(type, COMMIT_TYPE_MASK, "TcKeyReq::setAbortOption");
428  requestInfo &= ~(COMMIT_TYPE_MASK << COMMIT_TYPE_SHIFT);
429  requestInfo |= (type << COMMIT_TYPE_SHIFT);
430 }
431 
432 inline
433 void
434 TcKeyReq::setCommitFlag(UintR & requestInfo, Uint32 flag){
435  ASSERT_BOOL(flag, "TcKeyReq::setCommitFlag");
436  requestInfo &= ~(1 << COMMIT_SHIFT);
437  requestInfo |= (flag << COMMIT_SHIFT);
438 }
439 
440 inline
441 void
442 TcKeyReq::setStartFlag(UintR & requestInfo, Uint32 flag){
443  ASSERT_BOOL(flag, "TcKeyReq::setStartFlag");
444  requestInfo &= ~(1 << START_SHIFT);
445  requestInfo |= (flag << START_SHIFT);
446 }
447 
448 inline
449 void
450 TcKeyReq::setSimpleFlag(UintR & requestInfo, Uint32 flag){
451  ASSERT_BOOL(flag, "TcKeyReq::setSimpleFlag");
452  requestInfo &= ~(1 << SIMPLE_SHIFT);
453  requestInfo |= (flag << SIMPLE_SHIFT);
454 }
455 
456 inline
457 void
458 TcKeyReq::setDirtyFlag(UintR & requestInfo, Uint32 flag){
459  ASSERT_BOOL(flag, "TcKeyReq::setDirstFlag");
460  requestInfo &= ~(1 << DIRTY_SHIFT);
461  requestInfo |= (flag << DIRTY_SHIFT);
462 }
463 
464 inline
465 void
466 TcKeyReq::setExecuteFlag(UintR & requestInfo, Uint32 flag){
467  ASSERT_BOOL(flag, "TcKeyReq::setExecuteFlag");
468  requestInfo &= ~(1 << EXECUTE_SHIFT);
469  requestInfo |= (flag << EXECUTE_SHIFT);
470 }
471 
472 inline
473 void
474 TcKeyReq::setInterpretedFlag(UintR & requestInfo, Uint32 flag){
475  ASSERT_BOOL(flag, "TcKeyReq::setInterpretedFlag");
476  requestInfo &= ~(1 << INTERPRETED_SHIFT);
477  requestInfo |= (flag << INTERPRETED_SHIFT);
478 }
479 
480 inline
481 void
482 TcKeyReq::setDistributionKeyFlag(UintR & requestInfo, Uint32 flag){
483  ASSERT_BOOL(flag, "TcKeyReq::setDistributionKeyFlag");
484  requestInfo &= ~(1 << DISTR_KEY_SHIFT);
485  requestInfo |= (flag << DISTR_KEY_SHIFT);
486 }
487 
488 inline
489 void
490 TcKeyReq::setCoordinatedTransactionFlag(UintR & requestInfo, UintR flag){
491  ASSERT_BOOL(flag, "TcKeyReq::setCoordinatedTransactionFlag");
492  requestInfo &= ~(1 << TC_COORDINATED_SHIFT);
493  requestInfo |= (flag << TC_COORDINATED_SHIFT);
494 }
495 
496 inline
497 void
498 TcKeyReq::setViaSPJFlag(UintR & requestInfo, Uint32 flag){
499  ASSERT_BOOL(flag, "TcKeyReq::setViaSPJFlag");
500  requestInfo &= ~(1 << VIA_SPJ_SHIFT);
501  requestInfo |= (flag << VIA_SPJ_SHIFT);
502 }
503 
504 inline
505 void
506 TcKeyReq::setScanIndFlag(UintR & requestInfo, Uint32 flag){
507  ASSERT_BOOL(flag, "TcKeyReq::setScanIndFlag");
508  requestInfo &= ~(1 << SCAN_SHIFT);
509  requestInfo |= (flag << SCAN_SHIFT);
510 }
511 
512 inline
513 void
514 TcKeyReq::setOperationType(UintR & requestInfo, Uint32 type){
515  ASSERT_MAX(type, OPERATION_MASK, "TcKeyReq::setOperationType");
516  requestInfo &= ~(OPERATION_MASK << OPERATION_SHIFT);
517  requestInfo |= (type << OPERATION_SHIFT);
518 }
519 
520 inline
521 void
522 TcKeyReq::setKeyLength(UintR & requestInfo, Uint32 len){
523  ASSERT_MAX(len, KEY_LEN_MASK, "TcKeyReq::setKeyLength");
524  requestInfo &= ~(KEY_LEN_MASK << KEY_LEN_SHIFT);
525  requestInfo |= (len << KEY_LEN_SHIFT);
526 }
527 
528 inline
529 void
530 TcKeyReq::setAIInTcKeyReq(UintR & requestInfo, Uint32 len){
531  ASSERT_MAX(len, AINFO_MASK, "TcKeyReq::setAIInTcKeyReq");
532  requestInfo &= ~(AINFO_MASK << AINFO_SHIFT);
533  requestInfo |= (len << AINFO_SHIFT);
534 }
535 
536 inline
537 Uint8
538 TcKeyReq::getTakeOverScanFlag(const UintR & scanInfo){
539  return (Uint8)((scanInfo >> TAKE_OVER_SHIFT) & 1);
540 }
541 
542 inline
543 Uint16
544 TcKeyReq::getTakeOverScanFragment(const UintR & scanInfo){
545  return (Uint16)((scanInfo >> TAKE_OVER_FRAG_SHIFT) & TAKE_OVER_FRAG_MASK);
546 }
547 
548 inline
549 Uint32
550 TcKeyReq::getTakeOverScanInfo(const UintR & scanInfo){
551  return (Uint32)((scanInfo >> SCAN_INFO_SHIFT) & SCAN_INFO_MASK);
552 }
553 
554 
555 inline
556 void
557 TcKeyReq::setTakeOverScanFlag(UintR & scanInfo, Uint8 flag){
558  ASSERT_BOOL(flag, "TcKeyReq::setTakeOverScanFlag");
559  scanInfo |= (flag << TAKE_OVER_SHIFT);
560 }
561 
562 inline
563 void
564 TcKeyReq::setTakeOverScanFragment(UintR & scanInfo, Uint16 node){
565 // ASSERT_MAX(node, TAKE_OVER_NODE_MASK, "TcKeyReq::setTakeOverScanNode");
566  scanInfo |= (node << TAKE_OVER_FRAG_SHIFT);
567 }
568 
569 inline
570 void
571 TcKeyReq::setTakeOverScanInfo(UintR & scanInfo, Uint32 aScanInfo){
572 // ASSERT_MAX(aScanInfo, SCAN_INFO_MASK, "TcKeyReq::setTakeOverScanInfo");
573  scanInfo |= (aScanInfo << SCAN_INFO_SHIFT);
574 }
575 
576 
577 inline
578 Uint16
579 TcKeyReq::getAPIVersion(const UintR & anAttrLen){
580  return (Uint16)((anAttrLen >> API_VER_NO_SHIFT) & API_VER_NO_MASK);
581 }
582 
583 inline
584 void
585 TcKeyReq::setAPIVersion(UintR & anAttrLen, Uint16 apiVersion){
586 // ASSERT_MAX(apiVersion, API_VER_NO_MASK, "TcKeyReq::setAPIVersion");
587  anAttrLen |= (apiVersion << API_VER_NO_SHIFT);
588 }
589 
590 inline
591 Uint16
592 TcKeyReq::getAttrinfoLen(const UintR & anAttrLen){
593  return (Uint16)((anAttrLen) & ATTRLEN_MASK);
594 }
595 
596 inline
597 void
598 TcKeyReq::setAttrinfoLen(UintR & anAttrLen, Uint16 aiLen){
599 // ASSERT_MAX(aiLen, ATTRLEN_MASK, "TcKeyReq::setAttrinfoLen");
600  anAttrLen |= aiLen;
601 }
602 
603 inline
604 UintR
605 TcKeyReq::getNoDiskFlag(const UintR & requestInfo){
606  return (requestInfo >> TCKEY_NODISK_SHIFT) & 1;
607 }
608 
609 inline
610 void
611 TcKeyReq::setNoDiskFlag(UintR & requestInfo, Uint32 flag){
612  ASSERT_BOOL(flag, "TcKeyReq::setNoDiskFlag");
613  requestInfo &= ~(1 << TCKEY_NODISK_SHIFT);
614  requestInfo |= (flag << TCKEY_NODISK_SHIFT);
615 }
616 
617 inline
618 UintR
619 TcKeyReq::getReorgFlag(const UintR & requestInfo){
620  return (requestInfo >> TC_REORG_SHIFT) & 1;
621 }
622 
623 inline
624 void
625 TcKeyReq::setReorgFlag(UintR & requestInfo, Uint32 flag){
626  ASSERT_BOOL(flag, "TcKeyReq::setReorgFlag");
627  requestInfo |= (flag << TC_REORG_SHIFT);
628 }
629 
630 inline
631 UintR
632 TcKeyReq::getQueueOnRedoProblemFlag(const UintR & requestInfo){
633  return (requestInfo >> QUEUE_ON_REDO_SHIFT) & 1;
634 }
635 
636 inline
637 void
638 TcKeyReq::setQueueOnRedoProblemFlag(UintR & requestInfo, Uint32 flag){
639  ASSERT_BOOL(flag, "TcKeyReq::setNoDiskFlag");
640  requestInfo |= (flag << QUEUE_ON_REDO_SHIFT);
641 }
642 
643 inline
644 void
645 TcKeyReq::setDeferredConstraints(UintR & requestInfo, UintR val){
646  ASSERT_BOOL(val, "TcKeyReq::setDeferredConstraints");
647  requestInfo |= (val << TC_DEFERRED_CONSTAINTS_SHIFT);
648 }
649 
650 inline
651 UintR
652 TcKeyReq::getDeferredConstraints(const UintR & requestInfo){
653  return (requestInfo >> TC_DEFERRED_CONSTAINTS_SHIFT) & 1;
654 }
655 
656 
657 #endif