MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SumaImpl.hpp
1 /*
2  Copyright (c) 2003, 2010, 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 as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef SUMA_IMPL_HPP
19 #define SUMA_IMPL_HPP
20 
21 #include "SignalData.hpp"
22 #include <NodeBitmask.hpp>
23 
24 
25 struct SubCreateReq {
26 
27  friend bool printSUB_CREATE_REQ(FILE *, const Uint32 *, Uint32, Uint16);
28  STATIC_CONST( SignalLength = 7 );
29 
30  enum SubscriptionType {
31  SingleTableScan = 1, //
32  DatabaseSnapshot = 2, // All tables/all data (including new ones)
33  TableEvent = 3, //
34  SelectiveTableSnapshot = 4, // User defines tables
35  RemoveFlags = 0xff,
36  GetFlags = 0xff << 16,
37  RestartFlag = 0x2 << 16,
38  ReportAll = 0x4 << 16,
39  ReportSubscribe= 0x8 << 16,
40  NoReportDDL = 0x10 << 16,
41  NR_Sub_Dropped = 0x1 << 24 // sub is dropped but needs to be copied
42  };
43 
44  Uint32 senderRef;
45  Uint32 senderData;
46  Uint32 subscriptionId;
47  Uint32 subscriptionKey;
48  Uint32 subscriptionType;
49  Uint32 tableId;
50  Uint32 schemaTransId;
51 };
52 
53 struct SubCreateRef {
54  friend bool printSUB_CREATE_REF(FILE *, const Uint32 *, Uint32, Uint16);
55  STATIC_CONST( SignalLength = 3 );
56 
57  Uint32 senderRef;
58  Uint32 senderData;
59  Uint32 errorCode;
60 
61  enum ErrorCode
62  {
63  SubscriptionAlreadyExist = 1415
64  ,OutOfSubscriptionRecords = 1422
65  ,OutOfTableRecords = 1423
66  ,TableDropped = 1417
67  ,NF_FakeErrorREF = 11
68  ,NotStarted = 1428
69  };
70 };
71 
72 struct SubCreateConf {
73  friend bool printSUB_CREATE_CONF(FILE *, const Uint32 *, Uint32, Uint16);
74  STATIC_CONST( SignalLength = 2 );
75 
76  Uint32 senderRef;
77  Uint32 senderData;
78 };
79 
81  enum Part {
82  MetaData = 1,
83  TableData = 2
84  };
85 };
86 
87 struct SubStartReq {
91  friend class Suma;
92 
93  friend bool printSUB_START_REQ(FILE *, const Uint32 *, Uint32, Uint16);
94  STATIC_CONST( SignalLength = 7 );
95 
96  Uint32 senderRef;
97  Uint32 senderData;
98  Uint32 subscriptionId;
99  Uint32 subscriptionKey;
100  Uint32 part; // SubscriptionData::Part
101  Uint32 subscriberData;
102  Uint32 subscriberRef;
103 };
104 
105 struct SubStartRef {
109  friend class Suma;
110 
111  friend bool printSUB_START_REF(FILE *, const Uint32 *, Uint32, Uint16);
112  enum ErrorCode {
113  Undefined = 1,
114  NF_FakeErrorREF = 11,
115  Busy = 701,
116  PartiallyConnected = 1421,
117  NoSuchSubscription = 1407,
118  Locked = 1411,
119  Dropped = 1418,
120  Defining = 1418,
121  OutOfSubscriberRecords = 1412,
122  OutOfSubOpRecords = 1424,
123  NotMaster = 702, // For API/DICT communication
124  BusyWithNR = 1405,
125  NodeDied = 1427
126  ,NotStarted = 1428
127  };
128 
129  STATIC_CONST( SignalLength = 7 );
130  STATIC_CONST( SignalLength2 = SignalLength+1 );
131  STATIC_CONST( SL_MasterNode = 9 );
132 
133  Uint32 senderRef;
134  Uint32 senderData;
135  Uint32 subscriptionId;
136  Uint32 subscriptionKey;
137  Uint32 part; // SubscriptionData::Part
138  Uint32 subscriberData;
139  // do not change the order here!
140  Uint32 errorCode;
141  // with SignalLength2
142  union {
143  Uint32 subscriberRef;
144  Uint32 m_masterNodeId;
145  };
146 };
147 
148 struct SubStartConf {
153  friend bool printSUB_START_CONF(FILE *, const Uint32 *, Uint32, Uint16);
154  STATIC_CONST( SignalLength = 9 );
155 
156  Uint32 senderRef;
157  Uint32 senderData;
158  Uint32 subscriptionId;
159  Uint32 subscriptionKey;
160  Uint32 firstGCI;
161  Uint32 part; // SubscriptionData::Part
162  Uint32 subscriberData;
163  Uint32 bucketCount;
164  Uint32 nodegroup;
165 };
166 
167 struct SubStopReq {
171  friend class Suma;
172 
173  enum RequestInfo
174  {
175  RI_ABORT_START = 0x1
176  };
177 
178  friend bool printSUB_STOP_REQ(FILE *, const Uint32 *, Uint32, Uint16);
179  STATIC_CONST( SignalLength = 8 );
180  Uint32 senderRef;
181  Uint32 senderData;
182  Uint32 subscriptionId;
183  Uint32 subscriptionKey;
184  Uint32 part; // SubscriptionData::Part
185  Uint32 subscriberData;
186  Uint32 subscriberRef;
187  Uint32 requestInfo;
188 };
189 
190 struct SubStopRef {
194  friend class Suma;
195 
196  friend bool printSUB_STOP_REF(FILE *, const Uint32 *, Uint32, Uint16);
197  enum ErrorCode {
198  Undefined = 1,
199  NF_FakeErrorREF = 11,
200  Busy = 701,
201  NoSuchSubscription = 1407,
202  Locked = 1411,
203  Defining = 1425,
204  OutOfSubOpRecords = 1424,
205  NoSuchSubscriber = 1426,
206  NotMaster = 702,
207  BusyWithNR = 1405
208  ,NotStarted = 1428
209  };
210 
211  STATIC_CONST( SignalLength = 8 );
212  STATIC_CONST( SL_MasterNode = 9 );
213 
214  Uint32 senderRef;
215  Uint32 senderData;
216  Uint32 subscriptionId;
217  Uint32 subscriptionKey;
218  Uint32 part; // SubscriptionData::Part
219  Uint32 subscriberData;
220  Uint32 subscriberRef;
221  Uint32 errorCode;
222  Uint32 m_masterNodeId;
223 };
224 
225 struct SubStopConf {
230  friend bool printSUB_STOP_CONF(FILE *, const Uint32 *, Uint32, Uint16);
231  STATIC_CONST( SignalLengthWithGci = 9 );
232  STATIC_CONST( SignalLength = 9 );
233 
234  Uint32 senderRef;
235  Uint32 senderData;
236  Uint32 subscriptionId;
237  Uint32 subscriptionKey;
238  Uint32 part; // SubscriptionData::Part
239  Uint32 subscriberData;
240  Uint32 subscriberRef;
241  //
242  Uint32 gci_hi;
243  Uint32 gci_lo;
244 };
245 
246 struct SubSyncReq {
250  friend class Suma;
251 
252  friend bool printSUB_SYNC_REQ(FILE *, const Uint32 *, Uint32, Uint16);
253  STATIC_CONST( SignalLength = 8 );
254 
255  Uint32 senderRef;
256  Uint32 senderData;
257  Uint32 subscriptionId;
258  Uint32 subscriptionKey;
259  Uint32 part; // SubscriptionData::Part
260  Uint32 requestInfo;
261  Uint32 fragCount;
262  Uint32 fragId; // ZNIL if not used
263 
264  enum {
265  LM_Exclusive = 0x1
266  ,Reorg = 0x2
267  ,NoDisk = 0x4
268  ,TupOrder = 0x8
269  ,LM_CommittedRead = 0x10
270  ,RangeScan = 0x20
271  ,StatScan = 0x40
272  };
273 
274  SECTION( ATTRIBUTE_LIST = 0); // Used when doing SingelTableScan
275  SECTION( TABLE_LIST = 1 );
276  SECTION( TUX_BOUND_INFO = 1); // If range scan
277 };
278 
279 struct SubSyncRef {
283  friend class Suma;
284 
285  friend bool printSUB_SYNC_REF(FILE *, const Uint32 *, Uint32, Uint16);
286  enum ErrorCode {
287  Undefined = 1
288  };
289  STATIC_CONST( SignalLength = 3 );
290 
291  Uint32 senderRef;
292  Uint32 senderData;
293  Uint32 errorCode;
294  Uint32 masterNodeId;
295 };
296 
297 struct SubSyncConf {
298 
302  friend class Suma;
303 
304  friend bool printSUB_SYNC_CONF(FILE *, const Uint32 *, Uint32, Uint16);
305  STATIC_CONST( SignalLength = 2 );
306 
307  Uint32 senderRef;
308  Uint32 senderData;
309 };
310 
311 struct SubTableData {
312  friend bool printSUB_TABLE_DATA(FILE *, const Uint32 *, Uint32, Uint16);
313  STATIC_CONST( SignalLength = 8 );
314  STATIC_CONST( SignalLengthWithTransId = 10 );
315  SECTION( DICT_TAB_INFO = 0 );
316  SECTION( ATTR_INFO = 0 );
317  SECTION( AFTER_VALUES = 1 );
318  SECTION( BEFORE_VALUES = 2 );
319 
320  enum Flags {
321  SCAN = 1,
322  LOG = 2,
323  REMOVE_FLAGS = 0xff
324  };
325 
326  Uint32 senderData;
327  Uint32 gci_hi;
328  Uint32 tableId;
329  Uint32 requestInfo;
330  Uint32 flags;
331  union {
332  Uint32 changeMask;
333  Uint32 anyValue;
334  Uint32 takeOver;
335  };
336  Uint32 totalLen;
337  Uint32 gci_lo;
338  Uint32 transId1;
339  Uint32 transId2;
340 
341  static void setOperation(Uint32& ri, Uint32 val) {
342  ri = (ri & 0xFFFFFF00) | val;
343  }
344  static void setReqNodeId(Uint32& ri, Uint32 val) {
345  ri = (ri & 0xFFFF00FF) | (val << 8);
346  }
347  static void setNdbdNodeId(Uint32& ri, Uint32 val) {
348  ri = (ri & 0xFF00FFFF) | (val << 16);
349  }
350 
351  static Uint32 getOperation(const Uint32 & ri){
352  return (ri & 0xFF);
353  }
354 
355  static Uint32 getReqNodeId(const Uint32 & ri){
356  return (ri >> 8) & 0xFF;
357  }
358 
359  static Uint32 getNdbdNodeId(const Uint32 & ri){
360  return (ri >> 16) & 0xFF;
361  }
362 };
363 
368  friend class Trix;
369 
370  friend bool printSUB_SYNC_CONTINUE_REQ(FILE *, const Uint32 *, Uint32, Uint16);
371  STATIC_CONST( SignalLength = 3 );
372 
373  Uint32 subscriberData;
374  Uint32 noOfRowsSent;
375  Uint32 senderData;
376 };
377 
382  friend class Trix;
383 
384  friend bool printSUB_SYNC_CONTINUE_REF(FILE *, const Uint32 *, Uint32, Uint16);
385  STATIC_CONST( SignalLength = 3 );
386 
387  Uint32 subscriptionId;
388  Uint32 subscriptionKey;
389  Uint32 senderData;
390 };
391 
396  friend class Trix;
397 
398  friend bool printSUB_SYNC_CONTINUE_CONF(FILE *, const Uint32 *, Uint32, Uint16);
399  STATIC_CONST( SignalLength = 3 );
400 
401  Uint32 subscriptionId;
402  Uint32 subscriptionKey;
403  Uint32 senderData;
404 };
405 
407 
411  friend class Dbdih;
412  friend class Trix;
413 
414  friend bool printSUB_GCP_COMPLETE_REP(FILE *, const Uint32 *, Uint32, Uint16);
415  STATIC_CONST( SignalLength = 5 );
416  STATIC_CONST( ON_DISK = 1 );
417  STATIC_CONST( IN_MEMORY = 2 );
418  STATIC_CONST( MISSING_DATA = 4 );
419  STATIC_CONST( ADD_CNT = 8 ); // Uses hi 16-bit for delta
420  STATIC_CONST( SUB_CNT = 16); // Uses hi 16-bit for delta
421 
422  Uint32 gci_hi;
423  Uint32 senderRef;
424  Uint32 gcp_complete_rep_count;
425  Uint32 gci_lo;
426  Uint32 flags;
427 };
428 
433  STATIC_CONST( SignalLength = SubGcpCompleteRep::SignalLength );
434 
435  SubGcpCompleteRep rep;
436 };
437 
438 struct SubRemoveReq {
439  friend bool printSUB_REMOVE_REQ(FILE *, const Uint32 *, Uint32, Uint16);
440  STATIC_CONST( SignalLength = 4 );
441 
442  Uint32 senderRef;
443  Uint32 senderData;
444  Uint32 subscriptionId;
445  Uint32 subscriptionKey;
446 };
447 
448 struct SubRemoveRef {
449  friend bool printSUB_REMOVE_REF(FILE *, const Uint32 *, Uint32, Uint16);
450  STATIC_CONST( SignalLength = 5 );
451  enum ErrorCode {
452  Undefined = 1,
453  NF_FakeErrorREF = 11,
454  Busy = 701,
455  NoSuchSubscription = 1407,
456  Locked = 1411,
457  Defining = 1418,
458  AlreadyDropped = 1419
459  ,NotStarted = 1428
460  };
461 
462  Uint32 senderRef;
463  Uint32 subscriptionId;
464  Uint32 subscriptionKey;
465  Uint32 errorCode;
466  Uint32 senderData;
467 };
468 
470  friend bool printSUB_REMOVE_CONF(FILE *, const Uint32 *, Uint32, Uint16);
471  STATIC_CONST( SignalLength = 5 );
472 
473  Uint32 senderRef;
474  Uint32 subscriptionId;
475  Uint32 subscriptionKey;
476  Uint32 errorCode;
477  Uint32 senderData;
478 };
479 
480 
482  friend bool printCREATE_SUBSCRIPTION_ID_REQ(FILE *, const Uint32 *,
483  Uint32, Uint16);
484  STATIC_CONST( SignalLength = 2 );
485 
486  Uint32 senderRef;
487  Uint32 senderData;
488 };
489 
490 
492  friend bool printCREATE_SUBSCRIPTION_ID_CONF(FILE *, const Uint32 *,
493  Uint32, Uint16);
494  STATIC_CONST( SignalLength = 4 );
495 
496  Uint32 senderRef;
497  Uint32 senderData;
498  Uint32 subscriptionId;
499  Uint32 subscriptionKey;
500 };
501 
502 
504  friend bool printCREATE_SUBSCRIPTION_ID_REF(FILE *, const Uint32 *,
505  Uint32, Uint16);
506  STATIC_CONST( SignalLength = 3 );
507 
508  Uint32 senderRef;
509  Uint32 senderData;
510  Uint32 errorCode;
511 };
512 
514  STATIC_CONST( SignalLength = 1 );
515  Uint32 unused;
516 };
517 
519  STATIC_CONST( SignalLength = 1 );
520  Uint32 errorCode;
521  enum {
522  Busy = 0x1
523  ,NotStarted = 0x2
524  };
525 };
526 
528  STATIC_CONST( SignalLength = 1 );
529  Uint32 unused;
530 };
531 
533 {
534  STATIC_CONST( SignalLength = 4 );
535  Uint32 gci;
536  Uint32 nodeId;
537  Uint32 theBucketMask[1];
538  Uint32 requestType;
539 
540  enum RequestType
541  {
542  RT_START_NODE = 0,
543  RT_STOP_NODE = 1
544  };
545 };
546 
548 {
549  STATIC_CONST( SignalLength = 4 );
550  Uint32 gci;
551  Uint32 nodeId;
552  Uint32 theBucketMask[1];
553  Uint32 requestType;
554 };
555 
557 {
558  enum
559  {
560  RESEND_BUCKET = 1
561  ,RELEASE_GCI = 2
562  ,OUT_OF_BUFFER_RELEASE = 3
563  ,API_FAIL_GCI_LIST = 4
564  ,API_FAIL_SUBSCRIBER_LIST = 5
565  ,API_FAIL_SUBSCRIPTION = 6
566  ,SUB_STOP_REQ = 7
567  ,RETRY_DICT_LOCK = 8
568  };
569 };
570 
571 #endif