1 /*
2    Copyright (c) 2003, 2019, 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, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef TC_KEY_REQ_H
26 #define TC_KEY_REQ_H
27 
28 #include "SignalData.hpp"
29 #include <transporter/TransporterDefinitions.hpp>
30 
31 #define JAM_FILE_ID 127
32 
33 
34 /**
35  * @class TcKeyReq
36  * @brief Contains KeyInfo and AttrInfo and is commonly followed by more signals
37  *
38  * - SENDER:    API, NDBCNTR
39  * - RECEIVER:  TC
40  *
41  * Short TCKEYREQ
42  * Prior to NDB 6.4.0, TCKEYREQ was always sent as a short signal train with
43  * up to 8 words of KeyInfo and 5 words of AttrInfo in the TCKEYREQ signal, and
44  * all other Key and AttrInfo sent in separate signal trains.  This format is
45  * supported for non NdbRecord operations, backwards compatibility, and for
46  * internal TCKEYREQ signals received from non-API clients.
47  *
48  * Long TCKEYREQ
49  * From NDB 6.4.0, for NdbRecord operations the API nodes send long TCKEYREQ
50  * signals with all KeyInfo and AttrInfo in long sections sent with the
51  * TCKEYREQ signal.  As each section has a section length, and no Key/AttrInfo
52  * is sent in the TCKEYREQ signal itself, the KeyLength, AttrInfoLen and
53  * AIInTcKeyReq fields of the header are no longer required, and their bits
54  * can be reused in future.
55  */
56 class TcKeyReq {
57   /**
58    * Receiver(s)
59    */
60   friend class Dbtc;         // Receiver
61 
62   /**
63    * Sender(s)
64    */
65   friend class Ndbcntr;
66   friend class NdbQueryImpl;
67   friend class NdbOperation;
68   friend class NdbIndexOperation;
69   friend class NdbScanOperation;
70   friend class NdbBlob;
71   friend class DbUtil;
72   friend class Trix;
73 
74   /**
75    * For printing
76    */
77   friend bool printTCKEYREQ(FILE *, const Uint32 *, Uint32, Uint16);
78   friend bool printTCINDXREQ(FILE *, const Uint32 *, Uint32, Uint16);
79 
80 public:
81   /**
82    * Length of signal
83    */
84   STATIC_CONST( StaticLength = 8 );
85   STATIC_CONST( SignalLength = 25 );
86   STATIC_CONST( MaxKeyInfo = 8 );
87   STATIC_CONST( MaxAttrInfo = 5 );
88   STATIC_CONST( MaxTotalAttrInfo = ((MAX_SEND_MESSAGE_BYTESIZE / 4) -
89                                     SignalLength ));
90 
91   /**
92    * Long signal variant of TCKEYREQ
93    */
94   STATIC_CONST( KeyInfoSectionNum = 0 );
95   STATIC_CONST( AttrInfoSectionNum = 1 );
96 
97   STATIC_CONST( UnlockKeyLen = 2 );
98 
99 private:
100 
101   enum AbortOption {
102     CommitIfFailFree = 0, AbortOnError = 0,
103     CommitAsMuchAsPossible = 2, IgnoreError = 2
104   };
105 
106   typedef AbortOption CommitType;
107 
108   /**
109    * DATA VARIABLES
110    */
111 
112   // ----------------------------------------------------------------------
113   //  Unconditional part = must be present in signal.  First 8 words
114   // ----------------------------------------------------------------------
115   Uint32 apiConnectPtr;        // DATA 0
116   union {
117     Uint32 senderData;
118     UintR apiOperationPtr;      // DATA 1
119   };
120   /**
121    * Short TCKEYREQ only :
122    *   ATTRIBUTE INFO (attrinfo) LENGTH
123    *   This is the total length of all attribute info that is sent from
124    *   the application as part of this operation.
125    *   It includes all attribute info sent in possible attrinfo
126    *   signals as well as the attribute info sent in TCKEYREQ.
127    *
128    * Long TCKEYREQ
129    *   ATTRIBUTE INFO (attrinfo) LENGTH is unused in signal.
130    *   Get AttrInfoLength from length of section 1, if present.
131    *
132    */
133   UintR attrLen;              // DATA 2
134   UintR tableId;              // DATA 3
135   UintR requestInfo;          // DATA 4   Various transaction flags
136   UintR tableSchemaVersion;   // DATA 5
137   UintR transId1;             // DATA 6
138   UintR transId2;             // DATA 7
139 
140   // ----------------------------------------------------------------------
141   //  Conditional part = can be present in signal.
142   //  These four words will be sent only if their indicator is set.
143   // ----------------------------------------------------------------------
144   UintR scanInfo;             // DATA 8   Various flags for scans, see below
145   UintR distrGroupHashValue;  // DATA 9
146   UintR distributionKeySize;  // DATA 10
147   UintR storedProcId;         // DATA 11
148 
149   // ----------------------------------------------------------------------
150   //  Variable sized KEY and ATTRINFO part.
151   //  These will be placed to pack the signal in an appropriate manner.
152   // ----------------------------------------------------------------------
153   UintR keyInfo[MaxKeyInfo];           // DATA 12 - 19
154   UintR attrInfo[MaxAttrInfo];          // DATA 20 - 24
155 
156   /**
157    * Get:ers for attrLen
158    */
159 
160   static Uint16  getAttrinfoLen(const UintR & attrLen);
161   static void setAttrinfoLen(UintR & attrLen, Uint16 aiLen);
162 
163 
164   /**
165    * Get:ers for requestInfo
166    */
167   static Uint8 getCommitFlag(const UintR & requestInfo);
168   static Uint8 getAbortOption(const UintR & requestInfo);
169   static Uint8 getStartFlag(const UintR & requestInfo);
170   static Uint8 getSimpleFlag(const UintR & requestInfo);
171   static Uint8 getDirtyFlag(const UintR & requestInfo);
172   static Uint8 getInterpretedFlag(const UintR & requestInfo);
173   static Uint8 getDistributionKeyFlag(const UintR & requestInfo);
174   static Uint8 getViaSPJFlag(const UintR & requestInfo);
175   static Uint8 getScanIndFlag(const UintR & requestInfo);
176   static Uint8 getOperationType(const UintR & requestInfo);
177   static Uint8 getExecuteFlag(const UintR & requestInfo);
178   static Uint8 getReadCommittedBaseFlag(const UintR & TrequestInfo);
179 
180   static Uint16 getKeyLength(const UintR & requestInfo);
181   static Uint8  getAIInTcKeyReq(const UintR & requestInfo);
182   static UintR  getNoDiskFlag(const UintR & requestInfo);
183 
184   static UintR getCoordinatedTransactionFlag(const UintR & requestInfo);
185 
186   /**
187    * Get:ers for scanInfo
188    */
189   static Uint8  getTakeOverScanFlag(const UintR & scanInfo);
190   static Uint16 getTakeOverScanFragment(const UintR & scanInfo);
191   static Uint32 getTakeOverScanInfo(const UintR & scanInfo);
192 
193 
194   /**
195    * Set:ers for requestInfo
196    */
197   static void clearRequestInfo(UintR & requestInfo);
198   static void setAbortOption(UintR & requestInfo, Uint32 type);
199   static void setCommitFlag(UintR & requestInfo, Uint32 flag);
200   static void setStartFlag(UintR & requestInfo, Uint32 flag);
201   static void setSimpleFlag(UintR & requestInfo, Uint32 flag);
202   static void setDirtyFlag(UintR & requestInfo, Uint32 flag);
203   static void setInterpretedFlag(UintR & requestInfo, Uint32 flag);
204   static void setDistributionKeyFlag(UintR & requestInfo, Uint32 flag);
205   static void setViaSPJFlag(UintR & requestInfo, Uint32 flag);
206   static void setScanIndFlag(UintR & requestInfo, Uint32 flag);
207   static void setExecuteFlag(UintR & requestInfo, Uint32 flag);
208   static void setOperationType(UintR & requestInfo, Uint32 type);
209   static void setReadCommittedBaseFlag(UintR & requestInfo, Uint32 flag);
210 
211   static void setKeyLength(UintR & requestInfo, Uint32 len);
212   static void setAIInTcKeyReq(UintR & requestInfo, Uint32 len);
213   static void setNoDiskFlag(UintR & requestInfo, UintR val);
214 
215   static void setReorgFlag(UintR & requestInfo, UintR val);
216   static UintR getReorgFlag(const UintR & requestInfo);
217   static void setCoordinatedTransactionFlag(UintR & requestInfo, UintR val);
218   static void setQueueOnRedoProblemFlag(UintR & requestInfo, UintR val);
219   static UintR getQueueOnRedoProblemFlag(const UintR & requestInfo);
220 
221   /**
222    * Check constraints deferred
223    */
224   static UintR getDeferredConstraints(const UintR & requestInfo);
225   static void setDeferredConstraints(UintR & requestInfo, UintR val);
226 
227   /**
228    * Foreign key constraints disabled
229    */
230   static UintR getDisableFkConstraints(const UintR & requestInfo);
231   static void setDisableFkConstraints(UintR & requestInfo, UintR val);
232 
233   /**
234    * Set:ers for scanInfo
235    */
236   static void setTakeOverScanFlag(UintR & scanInfo, Uint8 flag);
237   static void setTakeOverScanFragment(UintR & scanInfo, Uint16 fragment);
238   static void setTakeOverScanInfo(UintR & scanInfo, Uint32 aScanInfo);
239 
240   /**
241    * Nowait option
242    */
243   static void setNoWaitFlag(UintR & requestInfo, UintR val);
244   static UintR getNoWaitFlag(const UintR & requestInfo);
245 };
246 
247 /**
248  * Request Info
249  *
250  a = Attr Info in TCKEYREQ - 3  Bits -> Max 7 (Bit 16-18)
251      (Short TCKEYREQ only, for long req a == 0)
252  b = Distribution Key Ind  - 1  Bit 2
253  v = Via SPJ               - 1  Bit 3
254  c = Commit Indicator      - 1  Bit 4
255  d = Dirty Indicator       - 1  Bit 0
256  e = Scan Indicator        - 1  Bit 14
257  i = Interpreted Indicator - 1  Bit 15
258  k = Key length            - 12 Bits -> Max 4095 (Bit 20 - 31)
259      (Short TCKEYREQ only, for long req use length of
260       section 0)
261  o = Operation Type        - 3  Bits -> Max 7 (Bit 5-7)
262  l = Execute               - 1  Bit 10
263  p = Simple Indicator      - 1  Bit 8
264  s = Start Indicator       - 1  Bit 11
265  y = Commit Type           - 2  Bit 12-13
266  n = No disk flag          - 1  Bit 1
267  r = reorg flag            - 1  Bit 19
268  x = Coordinated Tx flag   - 1  Bit 16
269  q = Queue on redo problem - 1  Bit 9
270  D = deferred constraint   - 1  Bit 17
271  f = Disable FK constraint - 1  Bit 18
272 
273  * Read committed base is using a bit that is only available
274  * in Long TCKEYREQ signals. So this feature is only available
275  * when using Long TCKEYREQ signals. Short TCKEYREQ are only
276  * used for backwards compatability against old nodes not
277  * supporting Read Committed base flag anyways and in special
278  * test cases that also don't use Read Committed base.
279 
280  R = Read Committed base   - 1  Bit 20
281  w = NoWait read           - 1  Bit 21
282 
283            1111111111222222222233
284  01234567890123456789012345678901
285  dnb cooop lsyyeiaaarkkkkkkkkkkkk  (Short TCKEYREQ)
286  dnbvcooopqlsyyeixDfrRw            (Long TCKEYREQ)
287 */
288 
289 #define TCKEY_NODISK_SHIFT (1)
290 #define COMMIT_SHIFT       (4)
291 #define START_SHIFT        (11)
292 #define SIMPLE_SHIFT       (8)
293 #define DIRTY_SHIFT        (0)
294 #define EXECUTE_SHIFT      (10)
295 #define INTERPRETED_SHIFT  (15)
296 #define DISTR_KEY_SHIFT    (2)
297 #define VIA_SPJ_SHIFT      (3)
298 #define SCAN_SHIFT         (14)
299 
300 #define OPERATION_SHIFT   (5)
301 #define OPERATION_MASK    (7)
302 
303 #define AINFO_SHIFT       (16)
304 #define AINFO_MASK        (7)
305 
306 #define KEY_LEN_SHIFT     (20)
307 #define KEY_LEN_MASK      (4095)
308 
309 #define COMMIT_TYPE_SHIFT  (12)
310 #define COMMIT_TYPE_MASK   (3)
311 
312 #define TC_REORG_SHIFT     (19)
313 #define QUEUE_ON_REDO_SHIFT (9)
314 
315 #define TC_COORDINATED_SHIFT (16)
316 #define TC_DEFERRED_CONSTAINTS_SHIFT (17)
317 
318 #define TC_DISABLE_FK_SHIFT (18)
319 #define TC_READ_COMMITTED_BASE_SHIFT (20)
320 #define TC_NOWAIT_SHIFT (21)
321 
322 /**
323  * Scan Info
324  *
325  * Scan Info is used to identify the row and lock to take over from a scan.
326  *
327  * If "Scan take over indicator" is set, this operation will take over a lock
328  * currently held on a row being scanned.
329  * Scan locks not taken over in this way (by same or other transaction) are
330  * released when fetching the next batch of rows (SCAN_NEXTREQ signal).
331  * The value for "take over node" and "scan info" are obtained from the
332  * KEYINFO20 signal sent to NDB API by LQH if requested in SCAN_TABREQ.
333  *
334  t = Scan take over indicator -  1 Bit
335  n = Take over node           - 12 Bits -> max 4095
336  p = Scan Info                - 18 Bits -> max 0x3ffff
337 
338            1111111111222222222233
339  01234567890123456789012345678901
340  tpppppppppppppppppp nnnnnnnnnnnn
341 */
342 
343 #define TAKE_OVER_SHIFT      (0)
344 
345 #define TAKE_OVER_FRAG_SHIFT (20)
346 #define TAKE_OVER_FRAG_MASK  (4095)
347 
348 #define SCAN_INFO_SHIFT      (1)
349 #define SCAN_INFO_MASK       (0x3ffff)
350 
351 /**
352  * Attr Len
353  *
354  n = Attrinfo length(words)   - 16 Bits -> max 65535 (Short TCKEYREQ only)
355  a = removed was API version no  - 16 Bits -> max 65535
356  API version no is more than 16 bits, was not used in kernel
357  (removed in 7.3.3, 7.2.14, 7.1.29, 7.0.40, 6.3.53)
358 
359            1111111111222222222233
360  01234567890123456789012345678901
361  aaaaaaaaaaaaaaaannnnnnnnnnnnnnnn   (Short TCKEYREQ)
362  aaaaaaaaaaaaaaaa                   (Long TCKEYREQ)
363 */
364 
365 #define ATTRLEN_SHIFT        (0)
366 #define ATTRLEN_MASK         (65535)
367 
368 inline
369 Uint8
getCommitFlag(const UintR & requestInfo)370 TcKeyReq::getCommitFlag(const UintR & requestInfo){
371   return (Uint8)((requestInfo >> COMMIT_SHIFT) & 1);
372 }
373 
374 inline
375 Uint8
getAbortOption(const UintR & requestInfo)376 TcKeyReq::getAbortOption(const UintR & requestInfo){
377   return (Uint8)((requestInfo >> COMMIT_TYPE_SHIFT) & COMMIT_TYPE_MASK);
378 }
379 
380 inline
381 Uint8
getStartFlag(const UintR & requestInfo)382 TcKeyReq::getStartFlag(const UintR & requestInfo){
383   return (Uint8)((requestInfo >> START_SHIFT) & 1);
384 }
385 
386 inline
387 Uint8
getSimpleFlag(const UintR & requestInfo)388 TcKeyReq::getSimpleFlag(const UintR & requestInfo){
389   return (Uint8)((requestInfo >> SIMPLE_SHIFT) & 1);
390 }
391 
392 inline
393 Uint8
getExecuteFlag(const UintR & requestInfo)394 TcKeyReq::getExecuteFlag(const UintR & requestInfo){
395   return (Uint8)((requestInfo >> EXECUTE_SHIFT) & 1);
396 }
397 
398 inline
399 Uint8
getReadCommittedBaseFlag(const UintR & requestInfo)400 TcKeyReq::getReadCommittedBaseFlag(const UintR & requestInfo){
401   return (Uint8)((requestInfo >> TC_READ_COMMITTED_BASE_SHIFT) & 1);
402 }
403 
404 inline
405 Uint8
getDirtyFlag(const UintR & requestInfo)406 TcKeyReq::getDirtyFlag(const UintR & requestInfo){
407   return (Uint8)((requestInfo >> DIRTY_SHIFT) & 1);
408 }
409 
410 inline
411 Uint8
getInterpretedFlag(const UintR & requestInfo)412 TcKeyReq::getInterpretedFlag(const UintR & requestInfo){
413   return (Uint8)((requestInfo >> INTERPRETED_SHIFT) & 1);
414 }
415 
416 inline
417 Uint8
getDistributionKeyFlag(const UintR & requestInfo)418 TcKeyReq::getDistributionKeyFlag(const UintR & requestInfo){
419   return (Uint8)((requestInfo >> DISTR_KEY_SHIFT) & 1);
420 }
421 
422 inline
423 UintR
getCoordinatedTransactionFlag(const UintR & requestInfo)424 TcKeyReq::getCoordinatedTransactionFlag(const UintR & requestInfo){
425   return (UintR)((requestInfo >> TC_COORDINATED_SHIFT) & 1);
426 }
427 
428 inline
429 Uint8
getViaSPJFlag(const UintR & requestInfo)430 TcKeyReq::getViaSPJFlag(const UintR & requestInfo){
431   return (Uint8)((requestInfo >> VIA_SPJ_SHIFT) & 1);
432 }
433 
434 inline
435 Uint8
getScanIndFlag(const UintR & requestInfo)436 TcKeyReq::getScanIndFlag(const UintR & requestInfo){
437   return (Uint8)((requestInfo >> SCAN_SHIFT) & 1);
438 }
439 
440 inline
441 Uint8
getOperationType(const UintR & requestInfo)442 TcKeyReq::getOperationType(const UintR & requestInfo){
443   return (Uint8)((requestInfo >> OPERATION_SHIFT) & OPERATION_MASK);
444 }
445 
446 inline
447 Uint16
getKeyLength(const UintR & requestInfo)448 TcKeyReq::getKeyLength(const UintR & requestInfo){
449   return (Uint16)((requestInfo >> KEY_LEN_SHIFT) & KEY_LEN_MASK);
450 }
451 
452 inline
453 Uint8
getAIInTcKeyReq(const UintR & requestInfo)454 TcKeyReq::getAIInTcKeyReq(const UintR & requestInfo){
455   return (Uint8)((requestInfo >> AINFO_SHIFT) & AINFO_MASK);
456 }
457 
458 inline
459 void
clearRequestInfo(UintR & requestInfo)460 TcKeyReq::clearRequestInfo(UintR & requestInfo){
461   requestInfo = 0;
462 }
463 
464 inline
465 void
setAbortOption(UintR & requestInfo,Uint32 type)466 TcKeyReq::setAbortOption(UintR & requestInfo, Uint32 type){
467   ASSERT_MAX(type, COMMIT_TYPE_MASK, "TcKeyReq::setAbortOption");
468   requestInfo &= ~(COMMIT_TYPE_MASK << COMMIT_TYPE_SHIFT);
469   requestInfo |= (type << COMMIT_TYPE_SHIFT);
470 }
471 
472 inline
473 void
setCommitFlag(UintR & requestInfo,Uint32 flag)474 TcKeyReq::setCommitFlag(UintR & requestInfo, Uint32 flag){
475   ASSERT_BOOL(flag, "TcKeyReq::setCommitFlag");
476   requestInfo &= ~(1 << COMMIT_SHIFT);
477   requestInfo |= (flag << COMMIT_SHIFT);
478 }
479 
480 inline
481 void
setStartFlag(UintR & requestInfo,Uint32 flag)482 TcKeyReq::setStartFlag(UintR & requestInfo, Uint32 flag){
483   ASSERT_BOOL(flag, "TcKeyReq::setStartFlag");
484   requestInfo &= ~(1 << START_SHIFT);
485   requestInfo |= (flag << START_SHIFT);
486 }
487 
488 inline
489 void
setSimpleFlag(UintR & requestInfo,Uint32 flag)490 TcKeyReq::setSimpleFlag(UintR & requestInfo, Uint32 flag){
491   ASSERT_BOOL(flag, "TcKeyReq::setSimpleFlag");
492   requestInfo &= ~(1 << SIMPLE_SHIFT);
493   requestInfo |= (flag << SIMPLE_SHIFT);
494 }
495 
496 inline
497 void
setDirtyFlag(UintR & requestInfo,Uint32 flag)498 TcKeyReq::setDirtyFlag(UintR & requestInfo, Uint32 flag){
499   ASSERT_BOOL(flag, "TcKeyReq::setDirstFlag");
500   requestInfo &= ~(1 << DIRTY_SHIFT);
501   requestInfo |= (flag << DIRTY_SHIFT);
502 }
503 
504 inline
505 void
setExecuteFlag(UintR & requestInfo,Uint32 flag)506 TcKeyReq::setExecuteFlag(UintR & requestInfo, Uint32 flag){
507   ASSERT_BOOL(flag, "TcKeyReq::setExecuteFlag");
508   requestInfo &= ~(1 << EXECUTE_SHIFT);
509   requestInfo |= (flag << EXECUTE_SHIFT);
510 }
511 
512 inline
513 void
setReadCommittedBaseFlag(UintR & requestInfo,Uint32 flag)514 TcKeyReq::setReadCommittedBaseFlag(UintR & requestInfo, Uint32 flag){
515   ASSERT_BOOL(flag, "TcKeyReq::setReadCommittedBaseFlag");
516   requestInfo &= ~(1 << TC_READ_COMMITTED_BASE_SHIFT);
517   requestInfo |= (flag << TC_READ_COMMITTED_BASE_SHIFT);
518 }
519 
520 inline
521 void
setInterpretedFlag(UintR & requestInfo,Uint32 flag)522 TcKeyReq::setInterpretedFlag(UintR & requestInfo, Uint32 flag){
523   ASSERT_BOOL(flag, "TcKeyReq::setInterpretedFlag");
524   requestInfo &= ~(1 << INTERPRETED_SHIFT);
525   requestInfo |= (flag << INTERPRETED_SHIFT);
526 }
527 
528 inline
529 void
setDistributionKeyFlag(UintR & requestInfo,Uint32 flag)530 TcKeyReq::setDistributionKeyFlag(UintR & requestInfo, Uint32 flag){
531   ASSERT_BOOL(flag, "TcKeyReq::setDistributionKeyFlag");
532   requestInfo &= ~(1 << DISTR_KEY_SHIFT);
533   requestInfo |= (flag << DISTR_KEY_SHIFT);
534 }
535 
536 inline
537 void
setCoordinatedTransactionFlag(UintR & requestInfo,UintR flag)538 TcKeyReq::setCoordinatedTransactionFlag(UintR & requestInfo, UintR flag){
539   ASSERT_BOOL(flag, "TcKeyReq::setCoordinatedTransactionFlag");
540   requestInfo &= ~(1 << TC_COORDINATED_SHIFT);
541   requestInfo |= (flag << TC_COORDINATED_SHIFT);
542 }
543 
544 inline
545 void
setViaSPJFlag(UintR & requestInfo,Uint32 flag)546 TcKeyReq::setViaSPJFlag(UintR & requestInfo, Uint32 flag){
547   ASSERT_BOOL(flag, "TcKeyReq::setViaSPJFlag");
548   requestInfo &= ~(1 << VIA_SPJ_SHIFT);
549   requestInfo |= (flag << VIA_SPJ_SHIFT);
550 }
551 
552 inline
553 void
setScanIndFlag(UintR & requestInfo,Uint32 flag)554 TcKeyReq::setScanIndFlag(UintR & requestInfo, Uint32 flag){
555   ASSERT_BOOL(flag, "TcKeyReq::setScanIndFlag");
556   requestInfo &= ~(1 << SCAN_SHIFT);
557   requestInfo |= (flag << SCAN_SHIFT);
558 }
559 
560 inline
561 void
setOperationType(UintR & requestInfo,Uint32 type)562 TcKeyReq::setOperationType(UintR & requestInfo, Uint32 type){
563   ASSERT_MAX(type, OPERATION_MASK, "TcKeyReq::setOperationType");
564   requestInfo &= ~(OPERATION_MASK << OPERATION_SHIFT);
565   requestInfo |= (type << OPERATION_SHIFT);
566 }
567 
568 inline
569 void
setKeyLength(UintR & requestInfo,Uint32 len)570 TcKeyReq::setKeyLength(UintR & requestInfo, Uint32 len){
571   ASSERT_MAX(len, KEY_LEN_MASK, "TcKeyReq::setKeyLength");
572   requestInfo &= ~(KEY_LEN_MASK << KEY_LEN_SHIFT);
573   requestInfo |= (len << KEY_LEN_SHIFT);
574 }
575 
576 inline
577 void
setAIInTcKeyReq(UintR & requestInfo,Uint32 len)578 TcKeyReq::setAIInTcKeyReq(UintR & requestInfo, Uint32 len){
579   ASSERT_MAX(len, AINFO_MASK, "TcKeyReq::setAIInTcKeyReq");
580   requestInfo &= ~(AINFO_MASK << AINFO_SHIFT);
581   requestInfo |= (len << AINFO_SHIFT);
582 }
583 
584 inline
585 Uint8
getTakeOverScanFlag(const UintR & scanInfo)586 TcKeyReq::getTakeOverScanFlag(const UintR & scanInfo){
587   return (Uint8)((scanInfo >> TAKE_OVER_SHIFT) & 1);
588 }
589 
590 inline
591 Uint16
getTakeOverScanFragment(const UintR & scanInfo)592 TcKeyReq::getTakeOverScanFragment(const UintR & scanInfo){
593   return (Uint16)((scanInfo >> TAKE_OVER_FRAG_SHIFT) & TAKE_OVER_FRAG_MASK);
594 }
595 
596 inline
597 Uint32
getTakeOverScanInfo(const UintR & scanInfo)598 TcKeyReq::getTakeOverScanInfo(const UintR & scanInfo){
599   return (Uint32)((scanInfo >> SCAN_INFO_SHIFT) & SCAN_INFO_MASK);
600 }
601 
602 
603 inline
604 void
setTakeOverScanFlag(UintR & scanInfo,Uint8 flag)605 TcKeyReq::setTakeOverScanFlag(UintR & scanInfo, Uint8 flag){
606   ASSERT_BOOL(flag, "TcKeyReq::setTakeOverScanFlag");
607   scanInfo |= (flag << TAKE_OVER_SHIFT);
608 }
609 
610 inline
611 void
setTakeOverScanFragment(UintR & scanInfo,Uint16 node)612 TcKeyReq::setTakeOverScanFragment(UintR & scanInfo, Uint16 node){
613 //  ASSERT_MAX(node, TAKE_OVER_NODE_MASK, "TcKeyReq::setTakeOverScanNode");
614   scanInfo |= (node << TAKE_OVER_FRAG_SHIFT);
615 }
616 
617 inline
618 void
setTakeOverScanInfo(UintR & scanInfo,Uint32 aScanInfo)619 TcKeyReq::setTakeOverScanInfo(UintR & scanInfo, Uint32 aScanInfo){
620 //  ASSERT_MAX(aScanInfo, SCAN_INFO_MASK, "TcKeyReq::setTakeOverScanInfo");
621   scanInfo |= (aScanInfo << SCAN_INFO_SHIFT);
622 }
623 
624 
625 inline
626 Uint16
getAttrinfoLen(const UintR & anAttrLen)627 TcKeyReq::getAttrinfoLen(const UintR & anAttrLen){
628   return (Uint16)((anAttrLen) & ATTRLEN_MASK);
629 }
630 
631 inline
632 void
setAttrinfoLen(UintR & anAttrLen,Uint16 aiLen)633 TcKeyReq::setAttrinfoLen(UintR & anAttrLen, Uint16 aiLen){
634 //  ASSERT_MAX(aiLen, ATTRLEN_MASK, "TcKeyReq::setAttrinfoLen");
635   anAttrLen |= aiLen;
636 }
637 
638 inline
639 UintR
getNoDiskFlag(const UintR & requestInfo)640 TcKeyReq::getNoDiskFlag(const UintR & requestInfo){
641   return (requestInfo >> TCKEY_NODISK_SHIFT) & 1;
642 }
643 
644 inline
645 void
setNoDiskFlag(UintR & requestInfo,Uint32 flag)646 TcKeyReq::setNoDiskFlag(UintR & requestInfo, Uint32 flag){
647   ASSERT_BOOL(flag, "TcKeyReq::setNoDiskFlag");
648   requestInfo &= ~(1 << TCKEY_NODISK_SHIFT);
649   requestInfo |= (flag << TCKEY_NODISK_SHIFT);
650 }
651 
652 inline
653 UintR
getReorgFlag(const UintR & requestInfo)654 TcKeyReq::getReorgFlag(const UintR & requestInfo){
655   return (requestInfo >> TC_REORG_SHIFT) & 1;
656 }
657 
658 inline
659 void
setReorgFlag(UintR & requestInfo,Uint32 flag)660 TcKeyReq::setReorgFlag(UintR & requestInfo, Uint32 flag){
661   ASSERT_BOOL(flag, "TcKeyReq::setReorgFlag");
662   requestInfo |= (flag << TC_REORG_SHIFT);
663 }
664 
665 inline
666 UintR
getQueueOnRedoProblemFlag(const UintR & requestInfo)667 TcKeyReq::getQueueOnRedoProblemFlag(const UintR & requestInfo){
668   return (requestInfo >> QUEUE_ON_REDO_SHIFT) & 1;
669 }
670 
671 inline
672 void
setQueueOnRedoProblemFlag(UintR & requestInfo,Uint32 flag)673 TcKeyReq::setQueueOnRedoProblemFlag(UintR & requestInfo, Uint32 flag){
674   ASSERT_BOOL(flag, "TcKeyReq::setNoDiskFlag");
675   requestInfo |= (flag << QUEUE_ON_REDO_SHIFT);
676 }
677 
678 inline
679 void
setDeferredConstraints(UintR & requestInfo,UintR val)680 TcKeyReq::setDeferredConstraints(UintR & requestInfo, UintR val){
681   ASSERT_BOOL(val, "TcKeyReq::setDeferredConstraints");
682   requestInfo |= (val << TC_DEFERRED_CONSTAINTS_SHIFT);
683 }
684 
685 inline
686 UintR
getDeferredConstraints(const UintR & requestInfo)687 TcKeyReq::getDeferredConstraints(const UintR & requestInfo){
688   return (requestInfo >> TC_DEFERRED_CONSTAINTS_SHIFT) & 1;
689 }
690 
691 inline
692 void
setDisableFkConstraints(UintR & requestInfo,UintR val)693 TcKeyReq::setDisableFkConstraints(UintR & requestInfo, UintR val){
694   ASSERT_BOOL(val, "TcKeyReq::setDisableFkConstraints");
695   requestInfo |= (val << TC_DISABLE_FK_SHIFT);
696 }
697 
698 inline
699 UintR
getDisableFkConstraints(const UintR & requestInfo)700 TcKeyReq::getDisableFkConstraints(const UintR & requestInfo){
701   return (requestInfo >> TC_DISABLE_FK_SHIFT) & 1;
702 }
703 
704 inline
705 void
setNoWaitFlag(UintR & requestInfo,UintR val)706 TcKeyReq::setNoWaitFlag(UintR & requestInfo, UintR val){
707   ASSERT_BOOL(val, "TcKeyReq::setNoWaitFlag");
708   requestInfo |= (val << TC_NOWAIT_SHIFT);
709 }
710 
711 inline
712 UintR
getNoWaitFlag(const UintR & requestInfo)713 TcKeyReq::getNoWaitFlag(const UintR & requestInfo){
714   return (requestInfo >> TC_NOWAIT_SHIFT) & 1;
715 }
716 
717 #undef JAM_FILE_ID
718 
719 #endif
720