~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/include/kernel/signaldata/ScanFrag.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

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