1
/* Copyright (C) 2003 MySQL AB
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.
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.
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 */
19
#include "SignalData.hpp"
23
* @brief Contains KeyInfo and AttrInfo and is commonly followed by more signals
25
* - SENDER: API, NDBCNTR
32
friend class Dbtc; // Receiver
38
friend class NdbOperation;
39
friend class NdbIndexOperation;
40
friend class NdbScanOperation;
47
friend bool printTCKEYREQ(FILE *, const Uint32 *, Uint32, Uint16);
48
friend bool printTCINDXREQ(FILE *, const Uint32 *, Uint32, Uint16);
54
STATIC_CONST( StaticLength = 8 );
55
STATIC_CONST( SignalLength = 25 );
56
STATIC_CONST( MaxKeyInfo = 8 );
57
STATIC_CONST( MaxAttrInfo = 5 );
58
STATIC_CONST( MaxTotalAttrInfo = 0xFFFF );
63
CommitIfFailFree = 0, AbortOnError = 0,
64
CommitAsMuchAsPossible = 2, IgnoreError = 2
67
typedef AbortOption CommitType;
73
// ----------------------------------------------------------------------
74
// Unconditional part = must be present in signal. First 8 words
75
// ----------------------------------------------------------------------
76
Uint32 apiConnectPtr; // DATA 0
79
UintR apiOperationPtr; // DATA 1
82
* ATTRIBUTE INFO (attrinfo) LENGTH
83
* This is the total length of all attribute info that is sent from
84
* the application as part of this operation.
85
* It includes all attribute info sent in possible attrinfo
86
* signals as well as the attribute info sent in TCKEYREQ.
88
UintR attrLen; // DATA 2 (also stores API Version)
89
UintR tableId; // DATA 3
90
UintR requestInfo; // DATA 4 Various transaction flags
91
UintR tableSchemaVersion; // DATA 5
92
UintR transId1; // DATA 6
93
UintR transId2; // DATA 7
95
// ----------------------------------------------------------------------
96
// Conditional part = can be present in signal.
97
// These four words will be sent only if their indicator is set.
98
// ----------------------------------------------------------------------
99
UintR scanInfo; // DATA 8 Various flags for scans
100
UintR distrGroupHashValue; // DATA 9
101
UintR distributionKeySize; // DATA 10
102
UintR storedProcId; // DATA 11
104
// ----------------------------------------------------------------------
105
// Variable sized KEY and ATTRINFO part.
106
// These will be placed to pack the signal in an appropriate manner.
107
// ----------------------------------------------------------------------
108
UintR keyInfo[MaxKeyInfo]; // DATA 12 - 19
109
UintR attrInfo[MaxAttrInfo]; // DATA 20 - 24
112
* Get:ers for attrLen
115
static Uint16 getAPIVersion(const UintR & attrLen);
116
static Uint16 getAttrinfoLen(const UintR & attrLen);
117
static void setAPIVersion(UintR & attrLen, Uint16 apiVersion);
118
static void setAttrinfoLen(UintR & attrLen, Uint16 aiLen);
122
* Get:ers for requestInfo
124
static Uint8 getCommitFlag(const UintR & requestInfo);
125
static Uint8 getAbortOption(const UintR & requestInfo);
126
static Uint8 getStartFlag(const UintR & requestInfo);
127
static Uint8 getSimpleFlag(const UintR & requestInfo);
128
static Uint8 getDirtyFlag(const UintR & requestInfo);
129
static Uint8 getInterpretedFlag(const UintR & requestInfo);
130
static Uint8 getDistributionKeyFlag(const UintR & requestInfo);
131
static Uint8 getScanIndFlag(const UintR & requestInfo);
132
static Uint8 getOperationType(const UintR & requestInfo);
133
static Uint8 getExecuteFlag(const UintR & requestInfo);
135
static Uint16 getKeyLength(const UintR & requestInfo);
136
static Uint8 getAIInTcKeyReq(const UintR & requestInfo);
137
static Uint8 getExecutingTrigger(const UintR & requestInfo);
138
static UintR getNoDiskFlag(const UintR & requestInfo);
141
* Get:ers for scanInfo
143
static Uint8 getTakeOverScanFlag(const UintR & scanInfo);
144
static Uint16 getTakeOverScanFragment(const UintR & scanInfo);
145
static Uint32 getTakeOverScanInfo(const UintR & scanInfo);
149
* Set:ers for requestInfo
151
static void clearRequestInfo(UintR & requestInfo);
152
static void setAbortOption(UintR & requestInfo, Uint32 type);
153
static void setCommitFlag(UintR & requestInfo, Uint32 flag);
154
static void setStartFlag(UintR & requestInfo, Uint32 flag);
155
static void setSimpleFlag(UintR & requestInfo, Uint32 flag);
156
static void setDirtyFlag(UintR & requestInfo, Uint32 flag);
157
static void setInterpretedFlag(UintR & requestInfo, Uint32 flag);
158
static void setDistributionKeyFlag(UintR & requestInfo, Uint32 flag);
159
static void setScanIndFlag(UintR & requestInfo, Uint32 flag);
160
static void setExecuteFlag(UintR & requestInfo, Uint32 flag);
161
static void setOperationType(UintR & requestInfo, Uint32 type);
163
static void setKeyLength(UintR & requestInfo, Uint32 len);
164
static void setAIInTcKeyReq(UintR & requestInfo, Uint32 len);
165
static void setExecutingTrigger(UintR & requestInfo, Uint32 flag);
166
static void setNoDiskFlag(UintR & requestInfo, UintR val);
169
* Set:ers for scanInfo
171
static void setTakeOverScanFlag(UintR & scanInfo, Uint8 flag);
172
static void setTakeOverScanFragment(UintR & scanInfo, Uint16 fragment);
173
static void setTakeOverScanInfo(UintR & scanInfo, Uint32 aScanInfo);
179
a = Attr Info in TCKEYREQ - 3 Bits -> Max 7 (Bit 16-18)
180
b = Distribution Key Ind - 1 Bit 2
181
c = Commit Indicator - 1 Bit 4
182
d = Dirty Indicator - 1 Bit 0
183
e = Scan Indicator - 1 Bit 14
184
f = Execute fired trigger - 1 Bit 19
185
i = Interpreted Indicator - 1 Bit 15
186
k = Key length - 12 Bits -> Max 4095 (Bit 20 - 31)
187
o = Operation Type - 3 Bits -> Max 7 (Bit 5-7)
188
l = Execute - 1 Bit 10
189
p = Simple Indicator - 1 Bit 8
190
s = Start Indicator - 1 Bit 11
191
y = Commit Type - 2 Bit 12-13
192
n = No disk flag - 1 Bit 1
194
1111111111222222222233
195
01234567890123456789012345678901
196
dnb cooop lsyyeiaaafkkkkkkkkkkkk
199
#define TCKEY_NODISK_SHIFT (1)
200
#define COMMIT_SHIFT (4)
201
#define START_SHIFT (11)
202
#define SIMPLE_SHIFT (8)
203
#define DIRTY_SHIFT (0)
204
#define EXECUTE_SHIFT (10)
205
#define INTERPRETED_SHIFT (15)
206
#define DISTR_KEY_SHIFT (2)
207
#define SCAN_SHIFT (14)
209
#define OPERATION_SHIFT (5)
210
#define OPERATION_MASK (7)
212
#define AINFO_SHIFT (16)
213
#define AINFO_MASK (7)
215
#define KEY_LEN_SHIFT (20)
216
#define KEY_LEN_MASK (4095)
218
#define COMMIT_TYPE_SHIFT (12)
219
#define COMMIT_TYPE_MASK (3)
221
#define EXECUTING_TRIGGER_SHIFT (19)
226
t = Scan take over indicator - 1 Bit
227
n = Take over node - 12 Bits -> max 65535
228
p = Scan Info - 18 Bits -> max 4095
230
1111111111222222222233
231
01234567890123456789012345678901
232
tpppppppppppppppppp nnnnnnnnnnnn
235
#define TAKE_OVER_SHIFT (0)
237
#define TAKE_OVER_FRAG_SHIFT (20)
238
#define TAKE_OVER_FRAG_MASK (4095)
240
#define SCAN_INFO_SHIFT (1)
241
#define SCAN_INFO_MASK (262143)
246
n = Attrinfo length(words) - 16 Bits -> max 65535
247
a = API version no - 16 Bits -> max 65535
249
1111111111222222222233
250
01234567890123456789012345678901
251
aaaaaaaaaaaaaaaannnnnnnnnnnnnnnn
254
#define API_VER_NO_SHIFT (16)
255
#define API_VER_NO_MASK (65535)
257
#define ATTRLEN_SHIFT (0)
258
#define ATTRLEN_MASK (65535)
262
TcKeyReq::getCommitFlag(const UintR & requestInfo){
263
return (Uint8)((requestInfo >> COMMIT_SHIFT) & 1);
268
TcKeyReq::getAbortOption(const UintR & requestInfo){
269
return (Uint8)((requestInfo >> COMMIT_TYPE_SHIFT) & COMMIT_TYPE_MASK);
274
TcKeyReq::getStartFlag(const UintR & requestInfo){
275
return (Uint8)((requestInfo >> START_SHIFT) & 1);
280
TcKeyReq::getSimpleFlag(const UintR & requestInfo){
281
return (Uint8)((requestInfo >> SIMPLE_SHIFT) & 1);
286
TcKeyReq::getExecuteFlag(const UintR & requestInfo){
287
return (Uint8)((requestInfo >> EXECUTE_SHIFT) & 1);
292
TcKeyReq::getDirtyFlag(const UintR & requestInfo){
293
return (Uint8)((requestInfo >> DIRTY_SHIFT) & 1);
298
TcKeyReq::getInterpretedFlag(const UintR & requestInfo){
299
return (Uint8)((requestInfo >> INTERPRETED_SHIFT) & 1);
304
TcKeyReq::getDistributionKeyFlag(const UintR & requestInfo){
305
return (Uint8)((requestInfo >> DISTR_KEY_SHIFT) & 1);
310
TcKeyReq::getScanIndFlag(const UintR & requestInfo){
311
return (Uint8)((requestInfo >> SCAN_SHIFT) & 1);
316
TcKeyReq::getOperationType(const UintR & requestInfo){
317
return (Uint8)((requestInfo >> OPERATION_SHIFT) & OPERATION_MASK);
322
TcKeyReq::getKeyLength(const UintR & requestInfo){
323
return (Uint16)((requestInfo >> KEY_LEN_SHIFT) & KEY_LEN_MASK);
328
TcKeyReq::getAIInTcKeyReq(const UintR & requestInfo){
329
return (Uint8)((requestInfo >> AINFO_SHIFT) & AINFO_MASK);
334
TcKeyReq::getExecutingTrigger(const UintR & requestInfo){
335
return (Uint8)((requestInfo >> EXECUTING_TRIGGER_SHIFT) & 1);
340
TcKeyReq::clearRequestInfo(UintR & requestInfo){
346
TcKeyReq::setAbortOption(UintR & requestInfo, Uint32 type){
347
ASSERT_MAX(type, COMMIT_TYPE_MASK, "TcKeyReq::setAbortOption");
348
requestInfo &= ~(COMMIT_TYPE_MASK << COMMIT_TYPE_SHIFT);
349
requestInfo |= (type << COMMIT_TYPE_SHIFT);
354
TcKeyReq::setCommitFlag(UintR & requestInfo, Uint32 flag){
355
ASSERT_BOOL(flag, "TcKeyReq::setCommitFlag");
356
requestInfo &= ~(1 << COMMIT_SHIFT);
357
requestInfo |= (flag << COMMIT_SHIFT);
362
TcKeyReq::setStartFlag(UintR & requestInfo, Uint32 flag){
363
ASSERT_BOOL(flag, "TcKeyReq::setStartFlag");
364
requestInfo &= ~(1 << START_SHIFT);
365
requestInfo |= (flag << START_SHIFT);
370
TcKeyReq::setSimpleFlag(UintR & requestInfo, Uint32 flag){
371
ASSERT_BOOL(flag, "TcKeyReq::setSimpleFlag");
372
requestInfo &= ~(1 << SIMPLE_SHIFT);
373
requestInfo |= (flag << SIMPLE_SHIFT);
378
TcKeyReq::setDirtyFlag(UintR & requestInfo, Uint32 flag){
379
ASSERT_BOOL(flag, "TcKeyReq::setDirstFlag");
380
requestInfo &= ~(1 << DIRTY_SHIFT);
381
requestInfo |= (flag << DIRTY_SHIFT);
386
TcKeyReq::setExecuteFlag(UintR & requestInfo, Uint32 flag){
387
ASSERT_BOOL(flag, "TcKeyReq::setExecuteFlag");
388
requestInfo &= ~(1 << EXECUTE_SHIFT);
389
requestInfo |= (flag << EXECUTE_SHIFT);
394
TcKeyReq::setInterpretedFlag(UintR & requestInfo, Uint32 flag){
395
ASSERT_BOOL(flag, "TcKeyReq::setInterpretedFlag");
396
requestInfo &= ~(1 << INTERPRETED_SHIFT);
397
requestInfo |= (flag << INTERPRETED_SHIFT);
402
TcKeyReq::setDistributionKeyFlag(UintR & requestInfo, Uint32 flag){
403
ASSERT_BOOL(flag, "TcKeyReq::setDistributionKeyFlag");
404
requestInfo &= ~(1 << DISTR_KEY_SHIFT);
405
requestInfo |= (flag << DISTR_KEY_SHIFT);
410
TcKeyReq::setScanIndFlag(UintR & requestInfo, Uint32 flag){
411
ASSERT_BOOL(flag, "TcKeyReq::setScanIndFlag");
412
requestInfo &= ~(1 << SCAN_SHIFT);
413
requestInfo |= (flag << SCAN_SHIFT);
418
TcKeyReq::setOperationType(UintR & requestInfo, Uint32 type){
419
ASSERT_MAX(type, OPERATION_MASK, "TcKeyReq::setOperationType");
420
requestInfo &= ~(OPERATION_MASK << OPERATION_SHIFT);
421
requestInfo |= (type << OPERATION_SHIFT);
426
TcKeyReq::setKeyLength(UintR & requestInfo, Uint32 len){
427
ASSERT_MAX(len, KEY_LEN_MASK, "TcKeyReq::setKeyLength");
428
requestInfo &= ~(KEY_LEN_MASK << KEY_LEN_SHIFT);
429
requestInfo |= (len << KEY_LEN_SHIFT);
434
TcKeyReq::setAIInTcKeyReq(UintR & requestInfo, Uint32 len){
435
ASSERT_MAX(len, AINFO_MASK, "TcKeyReq::setAIInTcKeyReq");
436
requestInfo &= ~(AINFO_MASK << AINFO_SHIFT);
437
requestInfo |= (len << AINFO_SHIFT);
442
TcKeyReq::setExecutingTrigger(UintR & requestInfo, Uint32 flag){
443
ASSERT_BOOL(flag, "TcKeyReq::setExecutingTrigger");
444
requestInfo &= ~(1 << EXECUTING_TRIGGER_SHIFT);
445
requestInfo |= (flag << EXECUTING_TRIGGER_SHIFT);
450
TcKeyReq::getTakeOverScanFlag(const UintR & scanInfo){
451
return (Uint8)((scanInfo >> TAKE_OVER_SHIFT) & 1);
456
TcKeyReq::getTakeOverScanFragment(const UintR & scanInfo){
457
return (Uint16)((scanInfo >> TAKE_OVER_FRAG_SHIFT) & TAKE_OVER_FRAG_MASK);
462
TcKeyReq::getTakeOverScanInfo(const UintR & scanInfo){
463
return (Uint32)((scanInfo >> SCAN_INFO_SHIFT) & SCAN_INFO_MASK);
469
TcKeyReq::setTakeOverScanFlag(UintR & scanInfo, Uint8 flag){
470
ASSERT_BOOL(flag, "TcKeyReq::setTakeOverScanFlag");
471
scanInfo |= (flag << TAKE_OVER_SHIFT);
476
TcKeyReq::setTakeOverScanFragment(UintR & scanInfo, Uint16 node){
477
// ASSERT_MAX(node, TAKE_OVER_NODE_MASK, "TcKeyReq::setTakeOverScanNode");
478
scanInfo |= (node << TAKE_OVER_FRAG_SHIFT);
483
TcKeyReq::setTakeOverScanInfo(UintR & scanInfo, Uint32 aScanInfo){
484
// ASSERT_MAX(aScanInfo, SCAN_INFO_MASK, "TcKeyReq::setTakeOverScanInfo");
485
scanInfo |= (aScanInfo << SCAN_INFO_SHIFT);
491
TcKeyReq::getAPIVersion(const UintR & anAttrLen){
492
return (Uint16)((anAttrLen >> API_VER_NO_SHIFT) & API_VER_NO_MASK);
497
TcKeyReq::setAPIVersion(UintR & anAttrLen, Uint16 apiVersion){
498
// ASSERT_MAX(apiVersion, API_VER_NO_MASK, "TcKeyReq::setAPIVersion");
499
anAttrLen |= (apiVersion << API_VER_NO_SHIFT);
504
TcKeyReq::getAttrinfoLen(const UintR & anAttrLen){
505
return (Uint16)((anAttrLen) & ATTRLEN_MASK);
510
TcKeyReq::setAttrinfoLen(UintR & anAttrLen, Uint16 aiLen){
511
// ASSERT_MAX(aiLen, ATTRLEN_MASK, "TcKeyReq::setAttrinfoLen");
517
TcKeyReq::getNoDiskFlag(const UintR & requestInfo){
518
return (requestInfo >> TCKEY_NODISK_SHIFT) & 1;
523
TcKeyReq::setNoDiskFlag(UintR & requestInfo, Uint32 flag){
524
ASSERT_BOOL(flag, "TcKeyReq::setNoDiskFlag");
525
requestInfo &= ~(1 << TCKEY_NODISK_SHIFT);
526
requestInfo |= (flag << TCKEY_NODISK_SHIFT);