MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScanTab.hpp
1 /*
2  Copyright (C) 2003-2008 MySQL AB, 2009 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef SCAN_TAB_H
20 #define SCAN_TAB_H
21 
22 #include "SignalData.hpp"
23 
29 class ScanTabReq {
33  friend class Dbtc; // Reciver
34 
38  friend class NdbTransaction;
39  friend class NdbScanOperation;
40  friend class NdbIndexScanOperation;
41  friend class NdbQueryImpl;
42  friend class NdbScanFilterImpl;
43 
47  friend bool printSCANTABREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
48 
49 public:
53  STATIC_CONST( StaticLength = 11 );
54  STATIC_CONST( MaxTotalAttrInfo = 0xFFFF );
55 
59  STATIC_CONST( ReceiverIdSectionNum = 0 );
60  STATIC_CONST( AttrInfoSectionNum = 1 ); /* Long SCANTABREQ only */
61  STATIC_CONST( KeyInfoSectionNum = 2 ); /* Long SCANTABREQ only */
62 
63 private:
64 
65  // Type definitions
66 
70  UintR apiConnectPtr; // DATA 0
71  union {
72  UintR attrLenKeyLen; // DATA 1 : Short SCANTABREQ (Versions < 6.4.0)
73  UintR spare; // DATA 1 : Long SCANTABREQ
74  };
75  UintR requestInfo; // DATA 2
76  /*
77  Table ID. Note that for a range scan of a table using an ordered index,
78  tableID is the ID of the index, not of the underlying table.
79  */
80  UintR tableId; // DATA 3
81  UintR tableSchemaVersion; // DATA 4
82  UintR storedProcId; // DATA 5
83  UintR transId1; // DATA 6
84  UintR transId2; // DATA 7
85  UintR buddyConPtr; // DATA 8
86  UintR batch_byte_size; // DATA 9
87  UintR first_batch_size; // DATA 10
88 
92  Uint32 distributionKey;
93 
97  static Uint8 getParallelism(const UintR & requestInfo);
98  static Uint8 getLockMode(const UintR & requestInfo);
99  static Uint8 getHoldLockFlag(const UintR & requestInfo);
100  static Uint8 getReadCommittedFlag(const UintR & requestInfo);
101  static Uint8 getRangeScanFlag(const UintR & requestInfo);
102  static Uint8 getDescendingFlag(const UintR & requestInfo);
103  static Uint8 getTupScanFlag(const UintR & requestInfo);
104  static Uint8 getKeyinfoFlag(const UintR & requestInfo);
105  static Uint16 getScanBatch(const UintR & requestInfo);
106  static Uint8 getDistributionKeyFlag(const UintR & requestInfo);
107  static UintR getNoDiskFlag(const UintR & requestInfo);
108  static Uint32 getViaSPJFlag(const Uint32 & requestInfo);
109  static Uint32 getPassAllConfsFlag(const Uint32 & requestInfo);
110  static Uint32 get4WordConf(const Uint32&);
111 
115  static void clearRequestInfo(UintR & requestInfo);
116  static void setParallelism(UintR & requestInfo, Uint32 flag);
117  static void setLockMode(UintR & requestInfo, Uint32 flag);
118  static void setHoldLockFlag(UintR & requestInfo, Uint32 flag);
119  static void setReadCommittedFlag(UintR & requestInfo, Uint32 flag);
120  static void setRangeScanFlag(UintR & requestInfo, Uint32 flag);
121  static void setDescendingFlag(UintR & requestInfo, Uint32 flag);
122  static void setTupScanFlag(UintR & requestInfo, Uint32 flag);
123  static void setKeyinfoFlag(UintR & requestInfo, Uint32 flag);
124  static void setScanBatch(Uint32& requestInfo, Uint32 sz);
125  static void setDistributionKeyFlag(Uint32& requestInfo, Uint32 flag);
126  static void setNoDiskFlag(UintR & requestInfo, UintR val);
127  static void setViaSPJFlag(Uint32 & requestInfo, Uint32 val);
128  static void setPassAllConfsFlag(Uint32 & requestInfo, Uint32 val);
129  static void set4WordConf(Uint32 & requestInfo, Uint32 val);
130 };
131 
159 #define PARALLEL_SHIFT (0)
160 #define PARALLEL_MASK (255)
161 
162 #define LOCK_MODE_SHIFT (8)
163 #define LOCK_MODE_MASK (1)
164 
165 #define HOLD_LOCK_SHIFT (10)
166 #define HOLD_LOCK_MASK (1)
167 
168 #define KEYINFO_SHIFT (12)
169 #define KEYINFO_MASK (1)
170 
171 #define READ_COMMITTED_SHIFT (11)
172 #define READ_COMMITTED_MASK (1)
173 
174 #define RANGE_SCAN_SHIFT (15)
175 #define RANGE_SCAN_MASK (1)
176 
177 #define DESCENDING_SHIFT (14)
178 #define DESCENDING_MASK (1)
179 
180 #define TUP_SCAN_SHIFT (13)
181 #define TUP_SCAN_MASK (1)
182 
183 #define SCAN_BATCH_SHIFT (16)
184 #define SCAN_BATCH_MASK (1023)
185 
186 #define SCAN_DISTR_KEY_SHIFT (26)
187 #define SCAN_DISTR_KEY_MASK (1)
188 
189 #define SCAN_NODISK_SHIFT (9)
190 #define SCAN_NODISK_MASK (1)
191 
192 #define SCAN_SPJ_SHIFT (27)
193 #define SCAN_PASS_CONF_SHIFT (28)
194 #define SCAN_4WORD_CONF_SHIFT (29)
195 
196 inline
197 Uint8
198 ScanTabReq::getParallelism(const UintR & requestInfo){
199  return (Uint8)((requestInfo >> PARALLEL_SHIFT) & PARALLEL_MASK);
200 }
201 
202 inline
203 Uint8
204 ScanTabReq::getLockMode(const UintR & requestInfo){
205  return (Uint8)((requestInfo >> LOCK_MODE_SHIFT) & LOCK_MODE_MASK);
206 }
207 
208 inline
209 Uint8
210 ScanTabReq::getHoldLockFlag(const UintR & requestInfo){
211  return (Uint8)((requestInfo >> HOLD_LOCK_SHIFT) & HOLD_LOCK_MASK);
212 }
213 
214 inline
215 Uint8
216 ScanTabReq::getReadCommittedFlag(const UintR & requestInfo){
217  return (Uint8)((requestInfo >> READ_COMMITTED_SHIFT) & READ_COMMITTED_MASK);
218 }
219 
220 inline
221 Uint8
222 ScanTabReq::getRangeScanFlag(const UintR & requestInfo){
223  return (Uint8)((requestInfo >> RANGE_SCAN_SHIFT) & RANGE_SCAN_MASK);
224 }
225 
226 inline
227 Uint8
228 ScanTabReq::getDescendingFlag(const UintR & requestInfo){
229  return (Uint8)((requestInfo >> DESCENDING_SHIFT) & DESCENDING_MASK);
230 }
231 
232 inline
233 Uint8
234 ScanTabReq::getTupScanFlag(const UintR & requestInfo){
235  return (Uint8)((requestInfo >> TUP_SCAN_SHIFT) & TUP_SCAN_MASK);
236 }
237 
238 inline
239 Uint16
240 ScanTabReq::getScanBatch(const Uint32 & requestInfo){
241  return (Uint16)((requestInfo >> SCAN_BATCH_SHIFT) & SCAN_BATCH_MASK);
242 }
243 
244 inline
245 void
246 ScanTabReq::clearRequestInfo(UintR & requestInfo){
247  requestInfo = 0;
248 }
249 
250 inline
251 void
252 ScanTabReq::setParallelism(UintR & requestInfo, Uint32 type){
253  ASSERT_MAX(type, PARALLEL_MASK, "ScanTabReq::setParallelism");
254  requestInfo= (requestInfo & ~(PARALLEL_MASK << PARALLEL_SHIFT)) |
255  ((type & PARALLEL_MASK) << PARALLEL_SHIFT);
256 }
257 
258 inline
259 void
260 ScanTabReq::setLockMode(UintR & requestInfo, Uint32 mode){
261  ASSERT_MAX(mode, LOCK_MODE_MASK, "ScanTabReq::setLockMode");
262  requestInfo= (requestInfo & ~(LOCK_MODE_MASK << LOCK_MODE_SHIFT)) |
263  ((mode & LOCK_MODE_MASK) << LOCK_MODE_SHIFT);
264 }
265 
266 inline
267 void
268 ScanTabReq::setHoldLockFlag(UintR & requestInfo, Uint32 flag){
269  ASSERT_BOOL(flag, "ScanTabReq::setHoldLockFlag");
270  requestInfo= (requestInfo & ~(HOLD_LOCK_MASK << HOLD_LOCK_SHIFT)) |
271  ((flag & HOLD_LOCK_MASK) << HOLD_LOCK_SHIFT);
272 }
273 
274 inline
275 void
276 ScanTabReq::setReadCommittedFlag(UintR & requestInfo, Uint32 flag){
277  ASSERT_BOOL(flag, "ScanTabReq::setReadCommittedFlag");
278  requestInfo= (requestInfo & ~(READ_COMMITTED_MASK << READ_COMMITTED_SHIFT)) |
279  ((flag & READ_COMMITTED_MASK) << READ_COMMITTED_SHIFT);
280 }
281 
282 inline
283 void
284 ScanTabReq::setRangeScanFlag(UintR & requestInfo, Uint32 flag){
285  ASSERT_BOOL(flag, "ScanTabReq::setRangeScanFlag");
286  requestInfo= (requestInfo & ~(RANGE_SCAN_MASK << RANGE_SCAN_SHIFT)) |
287  ((flag & RANGE_SCAN_MASK) << RANGE_SCAN_SHIFT);
288 }
289 
290 inline
291 void
292 ScanTabReq::setDescendingFlag(UintR & requestInfo, Uint32 flag){
293  ASSERT_BOOL(flag, "ScanTabReq::setDescendingFlag");
294  requestInfo= (requestInfo & ~(DESCENDING_MASK << DESCENDING_SHIFT)) |
295  ((flag & DESCENDING_MASK) << DESCENDING_SHIFT);
296 }
297 
298 inline
299 void
300 ScanTabReq::setTupScanFlag(UintR & requestInfo, Uint32 flag){
301  ASSERT_BOOL(flag, "ScanTabReq::setTupScanFlag");
302  requestInfo= (requestInfo & ~(TUP_SCAN_MASK << TUP_SCAN_SHIFT)) |
303  ((flag & TUP_SCAN_MASK) << TUP_SCAN_SHIFT);
304 }
305 
306 inline
307 void
308 ScanTabReq::setScanBatch(Uint32 & requestInfo, Uint32 flag){
309  ASSERT_MAX(flag, SCAN_BATCH_MASK, "ScanTabReq::setScanBatch");
310  requestInfo= (requestInfo & ~(SCAN_BATCH_MASK << SCAN_BATCH_SHIFT)) |
311  ((flag & SCAN_BATCH_MASK) << SCAN_BATCH_SHIFT);
312 }
313 
314 inline
315 Uint8
316 ScanTabReq::getKeyinfoFlag(const UintR & requestInfo){
317  return (Uint8)((requestInfo >> KEYINFO_SHIFT) & KEYINFO_MASK);
318 }
319 
320 inline
321 void
322 ScanTabReq::setKeyinfoFlag(UintR & requestInfo, Uint32 flag){
323  ASSERT_BOOL(flag, "ScanTabReq::setKeyinfoFlag");
324  requestInfo= (requestInfo & ~(KEYINFO_MASK << KEYINFO_SHIFT)) |
325  ((flag & KEYINFO_MASK) << KEYINFO_SHIFT);
326 }
327 
328 inline
329 Uint8
330 ScanTabReq::getDistributionKeyFlag(const UintR & requestInfo){
331  return (Uint8)((requestInfo >> SCAN_DISTR_KEY_SHIFT) & SCAN_DISTR_KEY_MASK);
332 }
333 
334 inline
335 void
336 ScanTabReq::setDistributionKeyFlag(UintR & requestInfo, Uint32 flag){
337  ASSERT_BOOL(flag, "ScanTabReq::setKeyinfoFlag");
338  requestInfo= (requestInfo & ~(SCAN_DISTR_KEY_MASK << SCAN_DISTR_KEY_SHIFT)) |
339  ((flag & SCAN_DISTR_KEY_MASK) << SCAN_DISTR_KEY_SHIFT);
340 }
341 
342 inline
343 UintR
344 ScanTabReq::getNoDiskFlag(const UintR & requestInfo){
345  return (requestInfo >> SCAN_NODISK_SHIFT) & SCAN_NODISK_MASK;
346 }
347 
348 inline
349 void
350 ScanTabReq::setNoDiskFlag(UintR & requestInfo, Uint32 flag){
351  ASSERT_BOOL(flag, "TcKeyReq::setNoDiskFlag");
352  requestInfo= (requestInfo & ~(SCAN_NODISK_MASK << SCAN_NODISK_SHIFT)) |
353  ((flag & SCAN_NODISK_MASK) << SCAN_NODISK_SHIFT);
354 }
355 
356 inline
357 UintR
358 ScanTabReq::getViaSPJFlag(const UintR & requestInfo){
359  return (requestInfo >> SCAN_SPJ_SHIFT) & 1;
360 }
361 
362 inline
363 void
364 ScanTabReq::setViaSPJFlag(UintR & requestInfo, Uint32 flag){
365  ASSERT_BOOL(flag, "TcKeyReq::setViaSPJFlag");
366  requestInfo |= (flag << SCAN_SPJ_SHIFT);
367 }
368 
369 inline
370 UintR
371 ScanTabReq::getPassAllConfsFlag(const UintR & requestInfo){
372  return (requestInfo >> SCAN_PASS_CONF_SHIFT) & 1;
373 }
374 
375 inline
376 void
377 ScanTabReq::setPassAllConfsFlag(UintR & requestInfo, Uint32 flag){
378  ASSERT_BOOL(flag, "TcKeyReq::setPassAllConfs");
379  requestInfo |= (flag << SCAN_PASS_CONF_SHIFT);
380 }
381 
382 inline
383 UintR
384 ScanTabReq::get4WordConf(const UintR & requestInfo){
385  return (requestInfo >> SCAN_4WORD_CONF_SHIFT) & 1;
386 }
387 
388 inline
389 void
390 ScanTabReq::set4WordConf(UintR & requestInfo, Uint32 flag){
391  ASSERT_BOOL(flag, "TcKeyReq::setPassAllConfs");
392  requestInfo |= (flag << SCAN_4WORD_CONF_SHIFT);
393 }
394 
400 class ScanTabConf {
404  friend class NdbTransaction; // Reciver
405 
409  friend class Dbtc;
410 
414  friend bool printSCANTABCONF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
415 
416 public:
420  STATIC_CONST( SignalLength = 4 );
421  STATIC_CONST( EndOfData = (1 << 31) );
422 
423 private:
424 
425  // Type definitions
426 
430  UintR apiConnectPtr; // DATA 0
431  UintR requestInfo; // DATA 1
432  UintR transId1; // DATA 2
433  UintR transId2; // DATA 3
434 
435  struct OpData {
436  Uint32 apiPtrI;
437  /*
438  tcPtrI is the scan fragment record pointer, used in SCAN_NEXTREQ to
439  acknowledge the reception of the batch of rows from a fragment scan.
440  If RNIL, this means that this particular fragment is done scanning.
441  */
442  Uint32 tcPtrI;
443 
444  Uint32 rows;
445  Uint32 len;
446  };
447 
449  static Uint32 getLength(Uint32 opDataInfo) { return opDataInfo >> 10; };
450  static Uint32 getRows(Uint32 opDataInfo) { return opDataInfo & 1023;}
451 };
452 
464 #define OPERATIONS_SHIFT (0)
465 #define OPERATIONS_MASK (0xFF)
466 
467 #define STATUS_SHIFT (8)
468 #define STATUS_MASK (0xFF)
469 
470 
476 class ScanTabRef {
480  friend class NdbTransaction; // Reciver
481 
485  friend class Dbtc;
486 
490  friend bool printSCANTABREF(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
491 
492 public:
496  STATIC_CONST( SignalLength = 5 );
497 
498 private:
499 
500  // Type definitions
501 
505  UintR apiConnectPtr; // DATA 0
506  UintR transId1; // DATA 1
507  UintR transId2; // DATA 2
508  UintR errorCode; // DATA 3
509  UintR closeNeeded; // DATA 4
510 
511 };
512 
513 /*
514  SENDER: API
515  RECIVER: Dbtc
516 
517  This signal is sent by API to acknowledge the reception of batches of rows
518  from one or more fragment scans, and to request the fetching of the next
519  batches of rows.
520 
521  Any locks held by the transaction on rows in the previously fetched batches
522  are released (unless explicitly transfered to this or another transaction in
523  a TCKEYREQ signal with TakeOverScanFlag set).
524 
525  The fragment scan batches to acknowledge are identified by the tcPtrI words
526  in the list of struct OpData received in ScanTabConf (scan fragment record
527  pointer).
528 
529  The list of scan fragment record pointers is sent as an array of words,
530  inline in the signal if <= 21 words, else as the first section in a long
531  signal.
532  */
533 class ScanNextReq {
537  friend class Dbtc; // Reciver
538 
542  friend class NdbOperation;
543  friend class NdbQueryImpl;
544 
548  friend bool printSCANNEXTREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);
549 
550 public:
554  STATIC_CONST( SignalLength = 4 );
555 
559  STATIC_CONST( ReceiverIdsSectionNum = 0);
560 
561 private:
562 
563  // Type definitions
564 
568  UintR apiConnectPtr; // DATA 0
569  UintR stopScan; // DATA 1
570  UintR transId1; // DATA 2
571  UintR transId2; // DATA 3
572 
573  // stopScan = 1, stop this scan
574 
575  /*
576  After this data comes the list of scan fragment record pointers for the
577  fragment scans to acknowledge, if they fit within the 25 words available
578  in the signal (else they are sent in the first long signal section).
579  */
580 };
581 
582 #endif