1 /*
2    Copyright (c) 2003, 2021, Oracle and/or its affiliates.
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 LQH_KEY_H
26 #define LQH_KEY_H
27 
28 #include "SignalData.hpp"
29 #include <trigger_definitions.h>
30 
31 #define JAM_FILE_ID 27
32 
33 
34 class LqhKeyReq {
35   /**
36    * Reciver(s)
37    */
38   friend class Dblqh;         // Reciver
39 
40   /**
41    * Sender(s)
42    */
43   friend class Dbspj;
44   friend class Dbtc;
45   friend class Restore;
46 
47   /**
48    * For printing
49    */
50   friend bool printLQHKEYREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
51 
52 public:
53   STATIC_CONST( FixedSignalLength = 11 );
54   STATIC_CONST( MaxKeyInfo = 4 );
55   STATIC_CONST( MaxAttrInfo = 5);
56 
57   /* Long LQHKEYREQ definitions */
58   STATIC_CONST( KeyInfoSectionNum = 0 );
59   STATIC_CONST( AttrInfoSectionNum = 1 );
60 
61   STATIC_CONST( UnlockKeyLen = 2 );
62 
63 private:
64 
65   /**
66    * DATA VARIABLES
67    */
68 //-------------------------------------------------------------
69 // Unconditional part. First 10 words
70 //-------------------------------------------------------------
71   UintR clientConnectPtr;	// DATA 0
72   UintR attrLen;	        // DATA 1
73   UintR hashValue;		// DATA 2
74   UintR requestInfo;   		// DATA 3
75   UintR tcBlockref;		// DATA 4
76   UintR tableSchemaVersion;	// DATA 5
77   UintR fragmentData;		// DATA 6
78   UintR transId1;		// DATA 7
79   UintR transId2;		// DATA 8
80   UintR savePointId;            // DATA 9
81   union {
82     /**
83      * When sent from  TC -> LQH this variable contains scanInfo
84      * When send from LQH -> LQH this variable contains numFiredTriggers
85      */
86     UintR numFiredTriggers;	// DATA 10
87     Uint32 scanInfo;            // DATA 10
88   };
89 
90 //-------------------------------------------------------------
91 // Variable sized key part. Those will be placed to
92 // pack the signal in an appropriate manner.
93 //-------------------------------------------------------------
94   UintR variableData[10];           // DATA 11 - 21
95 
96   static UintR getAttrLen(const UintR & scanInfoAttrLen);
97   static UintR getScanTakeOverFlag(const UintR & scanInfoAttrLen);
98   static UintR getStoredProcFlag(const UintR & scanData);
99   static UintR getDistributionKey(const UintR & scanData);
100   static UintR getReorgFlag(const UintR& scanData);
101   static void setReorgFlag(UintR& scanData, Uint32 val);
102 
103   static UintR getTableId(const UintR & tableSchemaVersion);
104   static UintR getSchemaVersion(const UintR & tableSchemaVersion);
105 
106   static UintR getFragmentId(const UintR & fragmentData);
107   static UintR getNextReplicaNodeId(const UintR & fragmentData);
108 
109   static Uint8 getLockType(const UintR & requestInfo);
110   static Uint8 getDirtyFlag(const UintR & requestInfo);
111   static Uint8 getInterpretedFlag(const UintR & requestInfo);
112   static Uint8 getSimpleFlag(const UintR & requestInfo);
113   static Uint8 getOperation(const UintR & requestInfo);
114   static Uint8 getSeqNoReplica(const UintR & requestInfo);
115   static Uint8 getLastReplicaNo(const UintR & requestInfo);
116   static Uint8 getAIInLqhKeyReq(const UintR & requestInfo);
117   static UintR getKeyLen(const UintR & requestInfo);
118   static UintR getSameClientAndTcFlag(const UintR & requestInfo);
119   static UintR getReturnedReadLenAIFlag(const UintR & requestInfo);
120   static UintR getApplicationAddressFlag(const UintR & requestInfo);
121   static UintR getMarkerFlag(const UintR & requestInfo);
122   static UintR getNoDiskFlag(const UintR & requestInfo);
123 
124   /**
125    * Setters
126    */
127 
128   static void setAttrLen(UintR & scanInfoAttrLen, UintR val);
129   static void setScanTakeOverFlag(UintR & scanInfoAttrLen, UintR val);
130   static void setStoredProcFlag(UintR & scanData, UintR val);
131   static void setDistributionKey(UintR & scanData, UintR val);
132 
133   static void setTableId(UintR & tableSchemaVersion, UintR val);
134   static void setSchemaVersion(UintR & tableSchemaVersion, UintR val);
135 
136   static void setFragmentId(UintR & fragmentData, UintR val);
137   static void setNextReplicaNodeId(UintR & fragmentData, UintR val);
138 
139   static void setLockType(UintR & requestInfo, UintR val);
140   static void setDirtyFlag(UintR & requestInfo, UintR val);
141   static void setInterpretedFlag(UintR & requestInfo, UintR val);
142   static void setSimpleFlag(UintR & requestInfo, UintR val);
143   static void setOperation(UintR & requestInfo, UintR val);
144   static void setSeqNoReplica(UintR & requestInfo, UintR val);
145   static void setLastReplicaNo(UintR & requestInfo, UintR val);
146   static void setAIInLqhKeyReq(UintR & requestInfo, UintR val);
147   static void clearAIInLqhKeyReq(UintR & requestInfo);
148   static void setKeyLen(UintR & requestInfo, UintR val);
149   static void setSameClientAndTcFlag(UintR & requestInfo, UintR val);
150   static void setReturnedReadLenAIFlag(UintR & requestInfo, UintR val);
151   static void setApplicationAddressFlag(UintR & requestInfo, UintR val);
152   static void setMarkerFlag(UintR & requestInfo, UintR val);
153   static void setNoDiskFlag(UintR & requestInfo, UintR val);
154 
155   static UintR getRowidFlag(const UintR & requestInfo);
156   static void setRowidFlag(UintR & requestInfo, UintR val);
157 
158   /**
159    * When doing DIRTY WRITES
160    */
161   static UintR getGCIFlag(const UintR & requestInfo);
162   static void setGCIFlag(UintR & requestInfo, UintR val);
163 
164   static UintR getNrCopyFlag(const UintR & requestInfo);
165   static void setNrCopyFlag(UintR & requestInfo, UintR val);
166 
167   static UintR getQueueOnRedoProblemFlag(const UintR & requestInfo);
168   static void setQueueOnRedoProblemFlag(UintR & requestInfo, UintR val);
169 
170   /**
171    * Do normal protocol (LQHKEYCONF/REF) even if doing dirty read
172    */
173   static UintR getNormalProtocolFlag(const UintR & requestInfo);
174   static void setNormalProtocolFlag(UintR & requestInfo, UintR val);
175 
176   /**
177    * Include corr factor
178    */
179   static UintR getCorrFactorFlag(const UintR & requestInfo);
180   static void setCorrFactorFlag(UintR & requestInfo, UintR val);
181 
182   /**
183    * Include deferred constraints
184    */
185   static UintR getDeferredConstraints(const UintR & requestInfo);
186   static void setDeferredConstraints(UintR & requestInfo, UintR val);
187 
188   /**
189    * Include disable foreign keys
190    */
191   static UintR getDisableFkConstraints(const UintR & requestInfo);
192   static void setDisableFkConstraints(UintR & requestInfo, UintR val);
193 };
194 
195 /**
196  * Request Info
197  *
198  * k = Key len                - (Short LQHKEYREQ only)
199  *                              10 Bits (0-9) max 1023
200  * l = Last Replica No        - 2  Bits -> Max 3 (10-11)
201 
202  IF version < NDBD_ROWID_VERSION
203    * t = Lock type            - 3  Bits -> Max 7 (12-14)
204  * p = Application Addr. Ind  - 1  Bit (15)
205  * d = Dirty indicator        - 1  Bit (16)
206  * i = Interpreted indicator  - 1  Bit (17)
207  * s = Simple indicator       - 1  Bit (18)
208  * o = Operation              - 3  Bits (19-21)
209  * r = Sequence replica       - 2  Bits (22-23)
210  * a = Attr Info in LQHKEYREQ - (Short LQHKEYREQ only)
211                                 3  Bits (24-26)
212  * c = Same client and tc     - 1  Bit (27)
213  * u = Read Len Return Ind    - 1  Bit (28)
214  * m = Commit ack marker      - 1  Bit (29)
215  * x = No disk usage          - 1  Bit (30)
216  * z = Use rowid for insert   - 1  Bit (31)
217  * g = gci flag               - 1  Bit (12)
218  * n = NR copy                - 1  Bit (13)
219  * q = Queue on redo problem  - 1  Bit (14)
220  * A = CorrFactor flag        - 1  Bit (24)
221  * P = Do normal protocol even if dirty-read - 1 Bit (25)
222  * D = Deferred constraints   - 1  Bit (26)
223  * F = Disable FK constraints - 1  Bit (0)
224 
225  * Short LQHKEYREQ :
226  *             1111111111222222222233
227  *   01234567890123456789012345678901
228  *   kkkkkkkkkklltttpdisooorraaacumxz
229  *   kkkkkkkkkkllgn pdisooorraaacumxz
230  *
231  * Long LQHKEYREQ :
232  *             1111111111222222222233
233  *   01234567890123456789012345678901
234  *   F         llgnqpdisooorrAPDcumxz
235  *
236  */
237 
238 #define RI_KEYLEN_SHIFT      (0)
239 #define RI_KEYLEN_MASK       (1023)
240 #define RI_LAST_REPL_SHIFT   (10)
241 #define RI_LAST_REPL_MASK    (3)
242 #define RI_LOCK_TYPE_SHIFT   (12)
243 #define RI_LOCK_TYPE_MASK    (7)
244 #define RI_APPL_ADDR_SHIFT   (15)
245 #define RI_DIRTY_SHIFT       (16)
246 #define RI_INTERPRETED_SHIFT (17)
247 #define RI_SIMPLE_SHIFT      (18)
248 #define RI_OPERATION_SHIFT   (19)
249 #define RI_OPERATION_MASK    (7)
250 #define RI_SEQ_REPLICA_SHIFT (22)
251 #define RI_SEQ_REPLICA_MASK  (3)
252 #define RI_AI_IN_THIS_SHIFT  (24)
253 #define RI_AI_IN_THIS_MASK   (7)
254 #define RI_SAME_CLIENT_SHIFT (27)
255 #define RI_RETURN_AI_SHIFT   (28)
256 #define RI_MARKER_SHIFT      (29)
257 #define RI_NODISK_SHIFT      (30)
258 #define RI_ROWID_SHIFT       (31)
259 #define RI_GCI_SHIFT         (12)
260 #define RI_NR_COPY_SHIFT     (13)
261 #define RI_QUEUE_REDO_SHIFT  (14)
262 #define RI_CORR_FACTOR_VALUE (24)
263 #define RI_NORMAL_DIRTY      (25)
264 #define RI_DEFERRED_CONSTAINTS (26)
265 #define RI_DISABLE_FK        (0)
266 
267 /**
268  * Scan Info
269  *
270  * a = Attr Len                 - (Short LQHKEYREQ only)
271  *                                 16 Bits -> max 65535 (0-15)
272  * p = Stored Procedure Ind     -  1 Bit (16)
273  * d = Distribution key         -  8 Bit  -> max 255 (17-24)
274  * t = Scan take over indicator -  1 Bit (25)
275  * m = Reorg value              -  2 Bit (26-27)
276  *
277  *           1111111111222222222233
278  * 01234567890123456789012345678901
279  * aaaaaaaaaaaaaaaapddddddddtmm       (Short LQHKEYREQ)
280  *                 pddddddddtmm       (Long LQHKEYREQ)
281  */
282 
283 #define SI_ATTR_LEN_MASK     (65535)
284 #define SI_ATTR_LEN_SHIFT    (0)
285 #define SI_STORED_PROC_SHIFT (16)
286 #define SI_DISTR_KEY_MASK    (255)
287 #define SI_DISTR_KEY_SHIFT   (17)
288 #define SI_SCAN_TO_SHIFT     (25)
289 #define SI_REORG_SHIFT (26)
290 #define SI_REORG_MASK  (3)
291 
292 inline
293 UintR
getAttrLen(const UintR & scanData)294 LqhKeyReq::getAttrLen(const UintR & scanData)
295 {
296   return (scanData >> SI_ATTR_LEN_SHIFT) & SI_ATTR_LEN_MASK;
297 }
298 
299 inline
300 Uint32
getScanTakeOverFlag(const UintR & scanData)301 LqhKeyReq::getScanTakeOverFlag(const UintR & scanData)
302 {
303   return (scanData >> SI_SCAN_TO_SHIFT) & 1;
304 }
305 
306 inline
307 UintR
getStoredProcFlag(const UintR & scanData)308 LqhKeyReq::getStoredProcFlag(const UintR & scanData){
309   return (scanData >> SI_STORED_PROC_SHIFT) & 1;
310 }
311 
312 inline
313 UintR
getDistributionKey(const UintR & scanData)314 LqhKeyReq::getDistributionKey(const UintR & scanData){
315   return (scanData >> SI_DISTR_KEY_SHIFT) & SI_DISTR_KEY_MASK;
316 }
317 
318 inline
getTableId(const UintR & tableSchemaVersion)319 UintR LqhKeyReq::getTableId(const UintR & tableSchemaVersion)
320 {
321  return tableSchemaVersion & 0xFFFF;
322 }
323 
324 inline
getSchemaVersion(const UintR & tableSchemaVersion)325 UintR LqhKeyReq::getSchemaVersion(const UintR & tableSchemaVersion)
326 {
327   return tableSchemaVersion >> 16;
328 }
329 
330 inline
getFragmentId(const UintR & fragmentData)331 UintR LqhKeyReq::getFragmentId(const UintR & fragmentData)
332 {
333   return fragmentData & 0xFFFF;
334 }
335 
336 inline
getNextReplicaNodeId(const UintR & fragmentData)337 UintR LqhKeyReq::getNextReplicaNodeId(const UintR & fragmentData)
338 {
339  return fragmentData >> 16;
340 }
341 
342 inline
getLastReplicaNo(const UintR & requestInfo)343 Uint8 LqhKeyReq::getLastReplicaNo(const UintR & requestInfo)
344 {
345  return (requestInfo >> RI_LAST_REPL_SHIFT) & RI_LAST_REPL_MASK;
346 }
347 
348 inline
getLockType(const UintR & requestInfo)349 Uint8 LqhKeyReq::getLockType(const UintR & requestInfo)
350 {
351   return (requestInfo >> RI_LOCK_TYPE_SHIFT) & RI_LOCK_TYPE_MASK;
352 }
353 
354 inline
getDirtyFlag(const UintR & requestInfo)355 Uint8 LqhKeyReq::getDirtyFlag(const UintR & requestInfo)
356 {
357   return (requestInfo >> RI_DIRTY_SHIFT) & 1;
358 }
359 
360 inline
getInterpretedFlag(const UintR & requestInfo)361 Uint8 LqhKeyReq::getInterpretedFlag(const UintR & requestInfo)
362 {
363   return (requestInfo >> RI_INTERPRETED_SHIFT) & 1;
364 }
365 
366 inline
getSimpleFlag(const UintR & requestInfo)367 Uint8 LqhKeyReq::getSimpleFlag(const UintR & requestInfo)
368 {
369   return (requestInfo >> RI_SIMPLE_SHIFT) & 1;
370 }
371 
372 inline
getOperation(const UintR & requestInfo)373 Uint8 LqhKeyReq::getOperation(const UintR & requestInfo)
374 {
375   return (requestInfo >> RI_OPERATION_SHIFT) & RI_OPERATION_MASK;
376 }
377 
378 inline
getSeqNoReplica(const UintR & requestInfo)379 Uint8 LqhKeyReq::getSeqNoReplica(const UintR & requestInfo)
380 {
381   return (requestInfo >> RI_SEQ_REPLICA_SHIFT) & RI_SEQ_REPLICA_MASK;
382 }
383 
384 
385 inline
getAIInLqhKeyReq(const UintR & requestInfo)386 Uint8 LqhKeyReq::getAIInLqhKeyReq(const UintR & requestInfo)
387 {
388   return (requestInfo >> RI_AI_IN_THIS_SHIFT) & RI_AI_IN_THIS_MASK;
389 }
390 
391 inline
getKeyLen(const UintR & requestInfo)392 UintR LqhKeyReq::getKeyLen(const UintR & requestInfo)
393 {
394   return (requestInfo >> RI_KEYLEN_SHIFT) & RI_KEYLEN_MASK;
395 }
396 
397 inline
398 UintR
getSameClientAndTcFlag(const UintR & requestInfo)399 LqhKeyReq::getSameClientAndTcFlag(const UintR & requestInfo)
400 {
401   return (requestInfo >> RI_SAME_CLIENT_SHIFT) & 1;
402 }
403 
404 inline
getReturnedReadLenAIFlag(const UintR & requestInfo)405 UintR LqhKeyReq::getReturnedReadLenAIFlag(const UintR & requestInfo)
406 {
407   return (requestInfo >> RI_RETURN_AI_SHIFT) & 1;
408 }
409 
410 inline
411 UintR
getApplicationAddressFlag(const UintR & requestInfo)412 LqhKeyReq::getApplicationAddressFlag(const UintR & requestInfo){
413   return (requestInfo >> RI_APPL_ADDR_SHIFT) & 1;
414 }
415 
416 inline
417 void
setAttrLen(UintR & scanInfoAttrLen,UintR val)418 LqhKeyReq::setAttrLen(UintR & scanInfoAttrLen, UintR val){
419   ASSERT_MAX(val, SI_ATTR_LEN_MASK, "LqhKeyReq::setAttrLen");
420   scanInfoAttrLen |= (val << SI_ATTR_LEN_SHIFT);
421 }
422 
423 
424 inline
425 void
setScanTakeOverFlag(UintR & scanInfoAttrLen,UintR val)426 LqhKeyReq::setScanTakeOverFlag(UintR & scanInfoAttrLen, UintR val){
427   ASSERT_BOOL(val, "LqhKeyReq::setScanTakeOverFlag");
428   scanInfoAttrLen |= (val << SI_SCAN_TO_SHIFT);
429 }
430 
431 inline
432 void
setStoredProcFlag(UintR & scanData,UintR val)433 LqhKeyReq::setStoredProcFlag(UintR & scanData, UintR val){
434   ASSERT_BOOL(val, "LqhKeyReq::setStoredProcFlag");
435   scanData |= (val << SI_STORED_PROC_SHIFT);
436 }
437 
438 inline
439 void
setDistributionKey(UintR & scanData,UintR val)440 LqhKeyReq::setDistributionKey(UintR & scanData, UintR val){
441   ASSERT_MAX(val, SI_DISTR_KEY_MASK, "LqhKeyReq::setDistributionKey");
442   scanData |= (val << SI_DISTR_KEY_SHIFT);
443 }
444 
445 inline
446 Uint32
getReorgFlag(const UintR & scanData)447 LqhKeyReq::getReorgFlag(const UintR & scanData){
448   return (scanData >> SI_REORG_SHIFT) & SI_REORG_MASK;
449 }
450 
451 inline
452 void
setReorgFlag(UintR & scanData,UintR val)453 LqhKeyReq::setReorgFlag(UintR & scanData, UintR val){
454   ASSERT_MAX(val, SI_REORG_MASK, "LqhKeyReq::setMovingFlag");
455   scanData |= (val << SI_REORG_SHIFT);
456 }
457 
458 #if 0
459 inline
460 void
461 
462 LqhKeyReq::setTableId(UintR & tableSchemaVersion, UintR val){
463 
464 }
465 inline
466 void
467 LqhKeyReq::setSchemaVersion(UintR & tableSchemaVersion, UintR val);
468 
469 inline
470 void
471 LqhKeyReq::setFragmentId(UintR & fragmentData, UintR val);
472 
473 inline
474 void
475 LqhKeyReq::setNextReplicaNodeId(UintR & fragmentData, UintR val);
476 #endif
477 
478 inline
479 void
setLockType(UintR & requestInfo,UintR val)480 LqhKeyReq::setLockType(UintR & requestInfo, UintR val){
481   ASSERT_MAX(val, RI_LOCK_TYPE_MASK, "LqhKeyReq::setLockType");
482   requestInfo |= (val << RI_LOCK_TYPE_SHIFT);
483 }
484 
485 inline
486 void
setDirtyFlag(UintR & requestInfo,UintR val)487 LqhKeyReq::setDirtyFlag(UintR & requestInfo, UintR val){
488   ASSERT_BOOL(val, "LqhKeyReq::setDirtyFlag");
489   requestInfo |= (val << RI_DIRTY_SHIFT);
490 }
491 
492 inline
493 void
setInterpretedFlag(UintR & requestInfo,UintR val)494 LqhKeyReq::setInterpretedFlag(UintR & requestInfo, UintR val){
495   ASSERT_BOOL(val, "LqhKeyReq::setInterpretedFlag");
496   requestInfo |= (val << RI_INTERPRETED_SHIFT);
497 }
498 
499 inline
500 void
setSimpleFlag(UintR & requestInfo,UintR val)501 LqhKeyReq::setSimpleFlag(UintR & requestInfo, UintR val){
502   ASSERT_BOOL(val, "LqhKeyReq::setSimpleFlag");
503   requestInfo |= (val << RI_SIMPLE_SHIFT);
504 }
505 
506 inline
507 void
setOperation(UintR & requestInfo,UintR val)508 LqhKeyReq::setOperation(UintR & requestInfo, UintR val){
509   ASSERT_MAX(val, RI_OPERATION_MASK, "LqhKeyReq::setOperation");
510   requestInfo |= (val << RI_OPERATION_SHIFT);
511 }
512 
513 inline
514 void
setSeqNoReplica(UintR & requestInfo,UintR val)515 LqhKeyReq::setSeqNoReplica(UintR & requestInfo, UintR val){
516   ASSERT_MAX(val, RI_SEQ_REPLICA_MASK, "LqhKeyReq::setSeqNoReplica");
517   requestInfo |= (val << RI_SEQ_REPLICA_SHIFT);
518 }
519 
520 inline
521 void
setLastReplicaNo(UintR & requestInfo,UintR val)522 LqhKeyReq::setLastReplicaNo(UintR & requestInfo, UintR val){
523   ASSERT_MAX(val, RI_LAST_REPL_MASK, "LqhKeyReq::setLastReplicaNo");
524   requestInfo |= (val << RI_LAST_REPL_SHIFT);
525 }
526 
527 inline
528 void
setAIInLqhKeyReq(UintR & requestInfo,UintR val)529 LqhKeyReq::setAIInLqhKeyReq(UintR & requestInfo, UintR val){
530   ASSERT_MAX(val, RI_AI_IN_THIS_MASK, "LqhKeyReq::setAIInLqhKeyReq");
531   requestInfo |= (val << RI_AI_IN_THIS_SHIFT);
532 }
533 
534 inline
535 void
clearAIInLqhKeyReq(UintR & requestInfo)536 LqhKeyReq::clearAIInLqhKeyReq(UintR & requestInfo){
537   requestInfo &= ~((Uint32)RI_AI_IN_THIS_MASK << RI_AI_IN_THIS_SHIFT);
538 }
539 
540 inline
541 void
setKeyLen(UintR & requestInfo,UintR val)542 LqhKeyReq::setKeyLen(UintR & requestInfo, UintR val){
543   ASSERT_MAX(val, RI_KEYLEN_MASK, "LqhKeyReq::setKeyLen");
544   requestInfo |= (val << RI_KEYLEN_SHIFT);
545 }
546 
547 inline
548 void
setSameClientAndTcFlag(UintR & requestInfo,UintR val)549 LqhKeyReq::setSameClientAndTcFlag(UintR & requestInfo, UintR val){
550   ASSERT_BOOL(val, "LqhKeyReq::setSameClientAndTcFlag");
551   requestInfo |= (val << RI_SAME_CLIENT_SHIFT);
552 }
553 
554 inline
555 void
setReturnedReadLenAIFlag(UintR & requestInfo,UintR val)556 LqhKeyReq::setReturnedReadLenAIFlag(UintR & requestInfo, UintR val){
557   ASSERT_BOOL(val, "LqhKeyReq::setReturnedReadLenAIFlag");
558   requestInfo |= (val << RI_RETURN_AI_SHIFT);
559 }
560 
561 inline
562 void
setApplicationAddressFlag(UintR & requestInfo,UintR val)563 LqhKeyReq::setApplicationAddressFlag(UintR & requestInfo, UintR val){
564   ASSERT_BOOL(val, "LqhKeyReq::setApplicationAddressFlag");
565   requestInfo |= (val << RI_APPL_ADDR_SHIFT);
566 }
567 
568 /**** */
569 
570 inline
571 void
setMarkerFlag(UintR & requestInfo,UintR val)572 LqhKeyReq::setMarkerFlag(UintR & requestInfo, UintR val){
573   ASSERT_BOOL(val, "LqhKeyReq::setMarkerFlag");
574   requestInfo |= (val << RI_MARKER_SHIFT);
575 }
576 
577 inline
578 UintR
getMarkerFlag(const UintR & requestInfo)579 LqhKeyReq::getMarkerFlag(const UintR & requestInfo){
580   return (requestInfo >> RI_MARKER_SHIFT) & 1;
581 }
582 
583 inline
584 void
setNoDiskFlag(UintR & requestInfo,UintR val)585 LqhKeyReq::setNoDiskFlag(UintR & requestInfo, UintR val){
586   ASSERT_BOOL(val, "LqhKeyReq::setNoDiskFlag");
587   requestInfo |= (val << RI_NODISK_SHIFT);
588 }
589 
590 inline
591 UintR
getNoDiskFlag(const UintR & requestInfo)592 LqhKeyReq::getNoDiskFlag(const UintR & requestInfo){
593   return (requestInfo >> RI_NODISK_SHIFT) & 1;
594 }
595 
596 inline
597 void
setRowidFlag(UintR & requestInfo,UintR val)598 LqhKeyReq::setRowidFlag(UintR & requestInfo, UintR val){
599   ASSERT_BOOL(val, "LqhKeyReq::setRowidFlag");
600   requestInfo |= (val << RI_ROWID_SHIFT);
601 }
602 
603 inline
604 UintR
getRowidFlag(const UintR & requestInfo)605 LqhKeyReq::getRowidFlag(const UintR & requestInfo){
606   return (requestInfo >> RI_ROWID_SHIFT) & 1;
607 }
608 
609 inline
610 void
setGCIFlag(UintR & requestInfo,UintR val)611 LqhKeyReq::setGCIFlag(UintR & requestInfo, UintR val){
612   ASSERT_BOOL(val, "LqhKeyReq::setGciFlag");
613   requestInfo |= (val << RI_GCI_SHIFT);
614 }
615 
616 inline
617 UintR
getGCIFlag(const UintR & requestInfo)618 LqhKeyReq::getGCIFlag(const UintR & requestInfo){
619   return (requestInfo >> RI_GCI_SHIFT) & 1;
620 }
621 
622 inline
623 void
setNrCopyFlag(UintR & requestInfo,UintR val)624 LqhKeyReq::setNrCopyFlag(UintR & requestInfo, UintR val){
625   ASSERT_BOOL(val, "LqhKeyReq::setNrCopyFlag");
626   requestInfo |= (val << RI_NR_COPY_SHIFT);
627 }
628 
629 inline
630 UintR
getNrCopyFlag(const UintR & requestInfo)631 LqhKeyReq::getNrCopyFlag(const UintR & requestInfo){
632   return (requestInfo >> RI_NR_COPY_SHIFT) & 1;
633 }
634 
635 inline
636 void
setNormalProtocolFlag(UintR & requestInfo,UintR val)637 LqhKeyReq::setNormalProtocolFlag(UintR & requestInfo, UintR val){
638   ASSERT_BOOL(val, "LqhKeyReq::setNrCopyFlag");
639   requestInfo |= (val << RI_NORMAL_DIRTY);
640 }
641 
642 inline
643 UintR
getNormalProtocolFlag(const UintR & requestInfo)644 LqhKeyReq::getNormalProtocolFlag(const UintR & requestInfo){
645   return (requestInfo >> RI_NORMAL_DIRTY) & 1;
646 }
647 
648 inline
649 void
setCorrFactorFlag(UintR & requestInfo,UintR val)650 LqhKeyReq::setCorrFactorFlag(UintR & requestInfo, UintR val){
651   ASSERT_BOOL(val, "LqhKeyReq::setCorrFactorFlag");
652   requestInfo |= (val << RI_CORR_FACTOR_VALUE);
653 }
654 
655 inline
656 UintR
getCorrFactorFlag(const UintR & requestInfo)657 LqhKeyReq::getCorrFactorFlag(const UintR & requestInfo){
658   return (requestInfo >> RI_CORR_FACTOR_VALUE) & 1;
659 }
660 
661 inline
662 void
setDeferredConstraints(UintR & requestInfo,UintR val)663 LqhKeyReq::setDeferredConstraints(UintR & requestInfo, UintR val){
664   ASSERT_BOOL(val, "LqhKeyReq::setDeferredConstraints");
665   requestInfo |= (val << RI_DEFERRED_CONSTAINTS);
666 }
667 
668 inline
669 UintR
getDeferredConstraints(const UintR & requestInfo)670 LqhKeyReq::getDeferredConstraints(const UintR & requestInfo){
671   return (requestInfo >> RI_DEFERRED_CONSTAINTS) & 1;
672 }
673 
674 inline
675 void
setDisableFkConstraints(UintR & requestInfo,UintR val)676 LqhKeyReq::setDisableFkConstraints(UintR & requestInfo, UintR val){
677   ASSERT_BOOL(val, "LqhKeyReq::setDisableFkConstraints");
678   requestInfo |= (val << RI_DISABLE_FK);
679 }
680 
681 inline
682 UintR
getDisableFkConstraints(const UintR & requestInfo)683 LqhKeyReq::getDisableFkConstraints(const UintR & requestInfo){
684   return (requestInfo >> RI_DISABLE_FK) & 1;
685 }
686 
687 inline
688 Uint32
table_version_major_lqhkeyreq(Uint32 x)689 table_version_major_lqhkeyreq(Uint32 x)
690 {
691   // LQHKEYREQ only contains 16-bit schema version...
692   return x & 0xFFFF;
693 }
694 
695 
696 inline
697 void
setQueueOnRedoProblemFlag(UintR & requestInfo,UintR val)698 LqhKeyReq::setQueueOnRedoProblemFlag(UintR & requestInfo, UintR val){
699   ASSERT_BOOL(val, "LqhKeyReq::setQueueOnRedoProblem");
700   requestInfo |= (val << RI_QUEUE_REDO_SHIFT);
701 }
702 
703 inline
704 UintR
getQueueOnRedoProblemFlag(const UintR & requestInfo)705 LqhKeyReq::getQueueOnRedoProblemFlag(const UintR & requestInfo){
706   return (requestInfo >> RI_QUEUE_REDO_SHIFT) & 1;
707 }
708 
709 class LqhKeyConf {
710   /**
711    * Reciver(s)
712    */
713   friend class Dbtc;
714   friend class Restore;
715   friend class Dbspj;
716 
717   /**
718    * Sender(s)
719    */
720   friend class Dblqh;
721 
722   // Sent in a packed signal
723   friend class PackedSignal;
724   /**
725    * For printing
726    */
727   friend bool printPACKED_SIGNAL(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
728   friend bool printLQHKEYCONF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
729 
730 public:
731   STATIC_CONST( SignalLength = 7 );
732 
733 private:
734 
735   /**
736    * DATA VARIABLES
737    */
738   Uint32 connectPtr;
739   Uint32 opPtr;
740   Uint32 userRef;
741   union {
742     /**
743      * For read operations this variable contains the number of bytes read
744      * For unlock operations this variable contains the unlocked op's TC REF
745      */
746     Uint32 readLen;
747     Uint32 unlockTcRef;
748   };
749   Uint32 transId1;
750   Uint32 transId2;
751   Uint32 numFiredTriggers; // bit 31 defered trigger
752 
getFiredCount(Uint32 v)753   static Uint32 getFiredCount(Uint32 v) {
754     return NoOfFiredTriggers::getFiredCount(v);
755   }
getDeferredUKBit(Uint32 v)756   static Uint32 getDeferredUKBit(Uint32 v) {
757     return NoOfFiredTriggers::getDeferredUKBit(v);
758   }
setDeferredUKBit(Uint32 & v)759   static void setDeferredUKBit(Uint32 & v) {
760     NoOfFiredTriggers::setDeferredUKBit(v);
761   }
getDeferredFKBit(Uint32 v)762   static Uint32 getDeferredFKBit(Uint32 v) {
763     return NoOfFiredTriggers::getDeferredFKBit(v);
764   }
setDeferredFKBit(Uint32 & v)765   static void setDeferredFKBit(Uint32 & v) {
766     NoOfFiredTriggers::setDeferredFKBit(v);
767   }
768 };
769 
770 class LqhKeyRef {
771   /**
772    * Reciver(s)
773    */
774   friend class Dbtc;
775   friend class Dbspj;
776   friend class Restore;
777 
778   /**
779    * Sender(s)
780    */
781   friend class Dblqh;
782 
783   /**
784    * For printing
785    */
786   friend bool printLQHKEYREF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
787 
788 public:
789   STATIC_CONST( SignalLength = 5 );
790 
791 private:
792 
793   /**
794    * DATA VARIABLES
795    */
796   Uint32 userRef;
797   Uint32 connectPtr;
798   Uint32 errorCode;
799   Uint32 transId1;
800   Uint32 transId2;
801 };
802 
803 
804 #undef JAM_FILE_ID
805 
806 #endif
807