1 /* Copyright (c) 2003-2008 MySQL AB
2 Use is subject to license terms
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 Street, Fifth Floor, Boston, MA 02110-1301, USA */
16
17 #ifndef DBDICT_H
18 #define DBDICT_H
19
20 /**
21 * Dict : Dictionary Block
22 */
23 #include <ndb_limits.h>
24 #include <trigger_definitions.h>
25 #include <pc.hpp>
26 #include <DLHashTable.hpp>
27 #include <DLFifoList.hpp>
28 #include <CArray.hpp>
29 #include <KeyTable.hpp>
30 #include <KeyTable2.hpp>
31 #include <KeyTable2Ref.hpp>
32 #include <SimulatedBlock.hpp>
33 #include <SimpleProperties.hpp>
34 #include <SignalCounter.hpp>
35 #include <Bitmask.hpp>
36 #include <AttributeList.hpp>
37 #include <signaldata/GetTableId.hpp>
38 #include <signaldata/GetTabInfo.hpp>
39 #include <signaldata/DictTabInfo.hpp>
40 #include <signaldata/CreateTable.hpp>
41 #include <signaldata/CreateTab.hpp>
42 #include <signaldata/DropTable.hpp>
43 #include <signaldata/AlterTable.hpp>
44 #include <signaldata/AlterTab.hpp>
45 #include <signaldata/CreateIndx.hpp>
46 #include <signaldata/DropIndx.hpp>
47 #include <signaldata/AlterIndx.hpp>
48 #include <signaldata/BuildIndx.hpp>
49 #include <signaldata/UtilPrepare.hpp>
50 #include <signaldata/CreateEvnt.hpp>
51 #include <signaldata/CreateTrig.hpp>
52 #include <signaldata/DropTrig.hpp>
53 #include <signaldata/AlterTrig.hpp>
54 #include <signaldata/DictLock.hpp>
55 #include <signaldata/SumaImpl.hpp>
56 #include "SchemaFile.hpp"
57 #include <blocks/mutexes.hpp>
58 #include <SafeCounter.hpp>
59 #include <RequestTracker.hpp>
60 #include <Rope.hpp>
61 #include <signaldata/DictObjOp.hpp>
62 #include <signaldata/DropFilegroupImpl.hpp>
63 #include <SLList.hpp>
64
65 #ifdef DBDICT_C
66 // Debug Macros
67
68 /*--------------------------------------------------------------*/
69 // Constants for CONTINUEB
70 /*--------------------------------------------------------------*/
71 #define ZPACK_TABLE_INTO_PAGES 0
72 #define ZSEND_GET_TAB_RESPONSE 3
73 #define ZDICT_LOCK_POLL 4
74
75
76 /*--------------------------------------------------------------*/
77 // Other constants in alphabetical order
78 /*--------------------------------------------------------------*/
79 #define ZNOMOREPHASES 255
80
81 /*--------------------------------------------------------------*/
82 // Schema file defines
83 /*--------------------------------------------------------------*/
84 #define ZSCHEMA_WORDS 4
85
86 /*--------------------------------------------------------------*/
87 // Page constants
88 /*--------------------------------------------------------------*/
89 #define ZBAT_SCHEMA_FILE 0 //Variable number of page for NDBFS
90 #define ZBAT_TABLE_FILE 1 //Variable number of page for NDBFS
91 #define ZPAGE_HEADER_SIZE 32
92 #define ZPOS_PAGE_SIZE 16
93 #define ZPOS_CHECKSUM 17
94 #define ZPOS_VERSION 18
95 #define ZPOS_PAGE_HEADER_SIZE 19
96
97 /*--------------------------------------------------------------*/
98 // Size constants
99 /*--------------------------------------------------------------*/
100 #define ZFS_CONNECT_SIZE 4
101 #define ZSIZE_OF_PAGES_IN_WORDS 8192
102 #define ZLOG_SIZE_OF_PAGES_IN_WORDS 13
103 #define ZMAX_PAGES_OF_TABLE_DEFINITION 8
104 #define ZNUMBER_OF_PAGES (ZMAX_PAGES_OF_TABLE_DEFINITION + 1)
105 #define ZNO_OF_FRAGRECORD 5
106
107 /*--------------------------------------------------------------*/
108 // Error codes
109 /*--------------------------------------------------------------*/
110 #define ZNODE_FAILURE_ERROR 704
111 #endif
112
113 /**
114 * Systable NDB$EVENTS_0
115 */
116 #define EVENT_SYSTEM_TABLE_LENGTH 8
117
118 struct sysTab_NDBEVENTS_0 {
119 char NAME[MAX_TAB_NAME_SIZE];
120 Uint32 EVENT_TYPE;
121 Uint32 TABLEID;
122 Uint32 TABLEVERSION;
123 char TABLE_NAME[MAX_TAB_NAME_SIZE];
124 Uint32 ATTRIBUTE_MASK[MAXNROFATTRIBUTESINWORDS];
125 Uint32 SUBID;
126 Uint32 SUBKEY;
127 };
128
129 /**
130 * DICT - This blocks handles all metadata
131 */
132 class Dbdict: public SimulatedBlock {
133 public:
134 /*
135 * 2.3 RECORD AND FILESIZES
136 */
137
138 /**
139 * Table attributes. Permanent data.
140 *
141 * Indexes have an attribute list which duplicates primary table
142 * attributes. This is wrong but convenient.
143 */
144 struct AttributeRecord {
AttributeRecordDbdict::AttributeRecord145 AttributeRecord(){}
146
147 /* attribute id */
148 Uint16 attributeId;
149
150 /* Attribute number within tuple key (counted from 1) */
151 Uint16 tupleKey;
152
153 /* Attribute name (unique within table) */
154 RopeHandle attributeName;
155
156 /* Attribute description (old-style packed descriptor) */
157 Uint32 attributeDescriptor;
158
159 /* Extended attributes */
160 Uint32 extType;
161 Uint32 extPrecision;
162 Uint32 extScale;
163 Uint32 extLength;
164
165 /* Autoincrement flag, only for ODBC/SQL */
166 bool autoIncrement;
167
168 /* Default value as null-terminated string, only for ODBC/SQL */
169 RopeHandle defaultValue;
170
171 struct {
172 Uint32 m_name_len;
173 const char * m_name_ptr;
174 RopePool * m_pool;
175 } m_key;
176
177 union {
178 Uint32 nextPool;
179 Uint32 nextList;
180 };
181 Uint32 prevList;
182 Uint32 nextHash;
183 Uint32 prevHash;
184
hashValueDbdict::AttributeRecord185 Uint32 hashValue() const { return attributeName.hashValue();}
equalDbdict::AttributeRecord186 bool equal(const AttributeRecord& obj) const {
187 if(obj.hashValue() == hashValue()){
188 ConstRope r(* m_key.m_pool, obj.attributeName);
189 return r.compare(m_key.m_name_ptr, m_key.m_name_len) == 0;
190 }
191 return false;
192 }
193
194 /** Singly linked in internal (attributeId) order */
195 // TODO use DL template when possible to have more than 1
196 Uint32 nextAttributeIdPtrI;
197 };
198 typedef Ptr<AttributeRecord> AttributeRecordPtr;
199 ArrayPool<AttributeRecord> c_attributeRecordPool;
200 DLHashTable<AttributeRecord> c_attributeRecordHash;
201
202 /**
203 * Shared table / index record. Most of this is permanent data stored
204 * on disk. Index trigger ids are volatile.
205 */
206 struct TableRecord {
TableRecordDbdict::TableRecord207 TableRecord(){}
208 Uint32 maxRowsLow;
209 Uint32 maxRowsHigh;
210 Uint32 minRowsLow;
211 Uint32 minRowsHigh;
212 /* Table id (array index in DICT and other blocks) */
213 Uint32 tableId;
214 Uint32 m_obj_ptr_i;
215
216 /* Table version (incremented when tableId is re-used) */
217 Uint32 tableVersion;
218
219 /* Table name (may not be unique under "alter table") */
220 RopeHandle tableName;
221
222 /* Type of table or index */
223 DictTabInfo::TableType tableType;
224
225 /* Is table or index online (this flag is not used in DICT) */
226 bool online;
227
228 /* Primary table of index otherwise RNIL */
229 Uint32 primaryTableId;
230
231 /* Type of fragmentation (small/medium/large) */
232 DictTabInfo::FragmentType fragmentType;
233
234 /* Global checkpoint identity when table created */
235 Uint32 gciTableCreated;
236
237 /* Is the table logged (i.e. data survives system restart) */
238 enum Bits
239 {
240 TR_Logged = 0x1,
241 TR_RowGCI = 0x2,
242 TR_RowChecksum = 0x4,
243 TR_Temporary = 0x8,
244 TR_ForceVarPart = 0x10
245 };
246 Uint16 m_bits;
247
248 /* Number of attibutes in table */
249 Uint16 noOfAttributes;
250
251 /* Number of null attributes in table (should be computed) */
252 Uint16 noOfNullAttr;
253
254 /* Number of primary key attributes (should be computed) */
255 Uint16 noOfPrimkey;
256
257 /* Length of primary key in words (should be computed) */
258 /* For ordered index this is tree node size in words */
259 Uint16 tupKeyLength;
260
261 /** */
262 Uint16 noOfCharsets;
263
264 /* K value for LH**3 algorithm (only 6 allowed currently) */
265 Uint8 kValue;
266
267 /* Local key length in words (currently 1) */
268 Uint8 localKeyLen;
269
270 /*
271 * Parameter for hash algorithm that specifies the load factor in
272 * percentage of fill level in buckets. A high value means we are
273 * splitting early and that buckets are only lightly used. A high
274 * value means that we have fill the buckets more and get more
275 * likelihood of overflow buckets.
276 */
277 Uint8 maxLoadFactor;
278
279 /*
280 Flag to indicate default number of partitions
281 */
282 bool defaultNoPartFlag;
283
284 /*
285 Flag to indicate using linear hash function
286 */
287 bool linearHashFlag;
288
289 /*
290 * Used when shrinking to decide when to merge buckets. Hysteresis
291 * is thus possible. Should be smaller but not much smaller than
292 * maxLoadFactor
293 */
294 Uint8 minLoadFactor;
295
296 /* Convenience routines */
297 bool isTable() const;
298 bool isIndex() const;
299 bool isUniqueIndex() const;
300 bool isNonUniqueIndex() const;
301 bool isHashIndex() const;
302 bool isOrderedIndex() const;
303
304 /****************************************************
305 * Support variables for table handling
306 ****************************************************/
307
308 /* Active page which is sent to disk */
309 Uint32 activePage;
310
311 /** File pointer received from disk */
312 Uint32 filePtr[2];
313
314 /** Pointer to first attribute in table */
315 DLFifoList<AttributeRecord>::Head m_attributes;
316
317 /* Pointer to first page of table description */
318 Uint32 firstPage;
319
320 Uint32 nextPool;
321
322 enum TabState {
323 NOT_DEFINED = 0,
324 DEFINING = 2,
325 DEFINED = 4,
326 PREPARE_DROPPING = 5,
327 DROPPING = 6,
328 BACKUP_ONGOING = 7
329 };
330 TabState tabState;
331
332 /* State when returning from TC_SCHVERREQ */
333 enum TabReturnState {
334 TRS_IDLE = 0,
335 ADD_TABLE = 1,
336 SLAVE_SYSTEM_RESTART = 2,
337 MASTER_SYSTEM_RESTART = 3
338 };
339 TabReturnState tabReturnState;
340
341 /** Number of words */
342 Uint32 packedSize;
343
344 /** Index state (volatile data) */
345 enum IndexState {
346 IS_UNDEFINED = 0, // initial
347 IS_OFFLINE = 1, // index table created
348 IS_BUILDING = 2, // building (local state)
349 IS_DROPPING = 3, // dropping (local state)
350 IS_ONLINE = 4, // online
351 IS_BROKEN = 9 // build or drop aborted
352 };
353 IndexState indexState;
354
355 /** Trigger ids of index (volatile data) */
356 Uint32 insertTriggerId;
357 Uint32 updateTriggerId;
358 Uint32 deleteTriggerId;
359 Uint32 customTriggerId; // ordered index
360 Uint32 buildTriggerId; // temp during build
361
362 /** Index state in other blocks on this node */
363 enum IndexLocal {
364 IL_CREATED_TC = 1 << 0 // created in TC
365 };
366 Uint32 indexLocal;
367
368 Uint32 noOfNullBits;
369
370 /** frm data for this table */
371 RopeHandle frmData;
372 RopeHandle tsData;
373 RopeHandle ngData;
374 RopeHandle rangeData;
375
376 Uint32 fragmentCount;
377 Uint32 m_tablespace_id;
378
379 /*
380 * Access rights to table during single user mode
381 */
382 Uint8 singleUserMode;
383 };
384
385 typedef Ptr<TableRecord> TableRecordPtr;
386 ArrayPool<TableRecord> c_tableRecordPool;
387
388 /** Node Group and Tablespace id+version + range or list data.
389 * This is only stored temporarily in DBDICT during an ongoing
390 * change.
391 * TODO RONM: Look into improvements of this
392 */
393 Uint32 c_fragDataLen;
394 Uint16 c_fragData[MAX_NDB_PARTITIONS];
395 Uint32 c_tsIdData[2*MAX_NDB_PARTITIONS];
396
397 /**
398 * Triggers. This is volatile data not saved on disk. Setting a
399 * trigger online creates the trigger in TC (if index) and LQH-TUP.
400 */
401 struct TriggerRecord {
TriggerRecordDbdict::TriggerRecord402 TriggerRecord() {}
403
404 /** Trigger state */
405 enum TriggerState {
406 TS_NOT_DEFINED = 0,
407 TS_DEFINING = 1,
408 TS_OFFLINE = 2, // created globally in DICT
409 TS_BUILDING = 3,
410 TS_DROPPING = 4,
411 TS_ONLINE = 5 // activated globally
412 };
413 TriggerState triggerState;
414
415 /** Trigger state in other blocks on this node */
416 enum IndexLocal {
417 TL_CREATED_TC = 1 << 0, // created in TC
418 TL_CREATED_LQH = 1 << 1 // created in LQH-TUP
419 };
420 Uint32 triggerLocal;
421
422 /** Trigger name, used by DICT to identify the trigger */
423 RopeHandle triggerName;
424
425 /** Trigger id, used by TRIX, TC, LQH, and TUP to identify the trigger */
426 Uint32 triggerId;
427 Uint32 m_obj_ptr_i;
428
429 /** Table id, the table the trigger is defined on */
430 Uint32 tableId;
431
432 /** Trigger type, defines what the trigger is used for */
433 TriggerType::Value triggerType;
434
435 /** Trigger action time, defines when the trigger should fire */
436 TriggerActionTime::Value triggerActionTime;
437
438 /** Trigger event, defines what events the trigger should monitor */
439 TriggerEvent::Value triggerEvent;
440
441 /** Monitor all replicas */
442 bool monitorReplicas;
443
444 /** Monitor all, the trigger monitors changes of all attributes in table */
445 bool monitorAllAttributes;
446
447 /** Monitor all, the trigger monitors changes of all attributes in table */
448 bool reportAllMonitoredAttributes;
449
450 /**
451 * Attribute mask, defines what attributes are to be monitored.
452 * Can be seen as a compact representation of SQL column name list.
453 */
454 AttributeMask attributeMask;
455
456 /** Index id, only used by secondary_index triggers */
457 Uint32 indexId;
458
459 /** Pointer to the next attribute used by ArrayPool */
460 Uint32 nextPool;
461 };
462
463 Uint32 c_maxNoOfTriggers;
464 typedef Ptr<TriggerRecord> TriggerRecordPtr;
465 ArrayPool<TriggerRecord> c_triggerRecordPool;
466
467 /**
468 * Information for each FS connection.
469 ***************************************************************************/
470 struct FsConnectRecord {
471 enum FsState {
472 IDLE = 0,
473 OPEN_WRITE_SCHEMA = 1,
474 WRITE_SCHEMA = 2,
475 CLOSE_WRITE_SCHEMA = 3,
476 OPEN_READ_SCHEMA1 = 4,
477 OPEN_READ_SCHEMA2 = 5,
478 READ_SCHEMA1 = 6,
479 READ_SCHEMA2 = 7,
480 CLOSE_READ_SCHEMA = 8,
481 OPEN_READ_TAB_FILE1 = 9,
482 OPEN_READ_TAB_FILE2 = 10,
483 READ_TAB_FILE1 = 11,
484 READ_TAB_FILE2 = 12,
485 CLOSE_READ_TAB_FILE = 13,
486 OPEN_WRITE_TAB_FILE = 14,
487 WRITE_TAB_FILE = 15,
488 CLOSE_WRITE_TAB_FILE = 16
489 };
490 /** File Pointer for this file system connection */
491 Uint32 filePtr;
492
493 /** Reference of owner record */
494 Uint32 ownerPtr;
495
496 /** State of file system connection */
497 FsState fsState;
498
499 /** Used by Array Pool for free list handling */
500 Uint32 nextPool;
501 };
502
503 typedef Ptr<FsConnectRecord> FsConnectRecordPtr;
504 ArrayPool<FsConnectRecord> c_fsConnectRecordPool;
505
506 /**
507 * This record stores all the information about a node and all its attributes
508 ***************************************************************************/
509 struct NodeRecord {
510 enum NodeState {
511 API_NODE = 0,
512 NDB_NODE_ALIVE = 1,
513 NDB_NODE_DEAD = 2
514 };
515 bool hotSpare;
516 NodeState nodeState;
517 };
518
519 typedef Ptr<NodeRecord> NodeRecordPtr;
520 CArray<NodeRecord> c_nodes;
521 NdbNodeBitmask c_aliveNodes;
522
523 struct PageRecord {
524 Uint32 word[8192];
525 };
526
527 typedef Ptr<PageRecord> PageRecordPtr;
528 CArray<PageRecord> c_pageRecordArray;
529
530 struct SchemaPageRecord {
531 Uint32 word[NDB_SF_PAGE_SIZE_IN_WORDS];
532 };
533
534 CArray<SchemaPageRecord> c_schemaPageRecordArray;
535
536 DictTabInfo::Table c_tableDesc;
537
538 /**
539 * A page for create index table signal.
540 */
541 PageRecord c_indexPage;
542
543 struct File {
FileDbdict::File544 File() {}
545
546 Uint32 key;
547 Uint32 m_magic;
548 Uint32 m_version;
549 Uint32 m_obj_ptr_i;
550 Uint32 m_filegroup_id;
551 Uint32 m_type;
552 Uint64 m_file_size;
553 Uint64 m_file_free;
554 RopeHandle m_path;
555
556 Uint32 nextList;
557 union {
558 Uint32 prevList;
559 Uint32 nextPool;
560 };
561 Uint32 nextHash, prevHash;
562
hashValueDbdict::File563 Uint32 hashValue() const { return key;}
equalDbdict::File564 bool equal(const File& obj) const { return key == obj.key;}
565 };
566 typedef Ptr<File> FilePtr;
567 typedef RecordPool<File, RWPool> File_pool;
568 typedef DLListImpl<File_pool, File> File_list;
569 typedef LocalDLListImpl<File_pool, File> Local_file_list;
570 typedef KeyTableImpl<File_pool, File> File_hash;
571
572 struct Filegroup {
FilegroupDbdict::Filegroup573 Filegroup(){}
574
575 Uint32 key;
576 Uint32 m_obj_ptr_i;
577 Uint32 m_magic;
578
579 Uint32 m_type;
580 Uint32 m_version;
581 RopeHandle m_name;
582
583 union {
584 struct {
585 Uint32 m_extent_size;
586 Uint32 m_default_logfile_group_id;
587 } m_tablespace;
588
589 struct {
590 Uint32 m_undo_buffer_size;
591 File_list::HeadPOD m_files;
592 } m_logfilegroup;
593 };
594
595 union {
596 Uint32 nextPool;
597 Uint32 nextList;
598 Uint32 nextHash;
599 };
600 Uint32 prevHash;
601
hashValueDbdict::Filegroup602 Uint32 hashValue() const { return key;}
equalDbdict::Filegroup603 bool equal(const Filegroup& obj) const { return key == obj.key;}
604 };
605 typedef Ptr<Filegroup> FilegroupPtr;
606 typedef RecordPool<Filegroup, RWPool> Filegroup_pool;
607 typedef KeyTableImpl<Filegroup_pool, Filegroup> Filegroup_hash;
608
609 File_pool c_file_pool;
610 Filegroup_pool c_filegroup_pool;
611 File_hash c_file_hash;
612 Filegroup_hash c_filegroup_hash;
613
614 RopePool c_rope_pool;
615
616 struct DictObject {
DictObjectDbdict::DictObject617 DictObject() {}
618 Uint32 m_id;
619 Uint32 m_type;
620 Uint32 m_ref_count;
621 RopeHandle m_name;
622 union {
623 struct {
624 Uint32 m_name_len;
625 const char * m_name_ptr;
626 RopePool * m_pool;
627 } m_key;
628 Uint32 nextPool;
629 Uint32 nextList;
630 };
631 Uint32 nextHash;
632 Uint32 prevHash;
633
hashValueDbdict::DictObject634 Uint32 hashValue() const { return m_name.hashValue();}
equalDbdict::DictObject635 bool equal(const DictObject& obj) const {
636 if(obj.hashValue() == hashValue()){
637 ConstRope r(* m_key.m_pool, obj.m_name);
638 return r.compare(m_key.m_name_ptr, m_key.m_name_len) == 0;
639 }
640 return false;
641 }
642 };
643
644 DLHashTable<DictObject> c_obj_hash; // Name
645 ArrayPool<DictObject> c_obj_pool;
646
get_object(const char * name)647 DictObject * get_object(const char * name){
648 return get_object(name, strlen(name) + 1);
649 }
650
get_object(const char * name,Uint32 len)651 DictObject * get_object(const char * name, Uint32 len){
652 return get_object(name, len, Rope::hash(name, len));
653 }
654
655 DictObject * get_object(const char * name, Uint32 len, Uint32 hash);
656
release_object(Uint32 obj_ptr_i)657 void release_object(Uint32 obj_ptr_i){
658 release_object(obj_ptr_i, c_obj_pool.getPtr(obj_ptr_i));
659 }
660
661 void release_object(Uint32 obj_ptr_i, DictObject* obj_ptr_p);
662
663 void increase_ref_count(Uint32 obj_ptr_i);
664 void decrease_ref_count(Uint32 obj_ptr_i);
665
666 public:
667 Dbdict(Block_context& ctx);
668 virtual ~Dbdict();
669
670 private:
671 BLOCK_DEFINES(Dbdict);
672
673 // Signal receivers
674 void execDICTSTARTREQ(Signal* signal);
675
676 void execGET_TABINFOREQ(Signal* signal);
677 void execGET_TABLEDID_REQ(Signal* signal);
678 void execGET_TABINFO_REF(Signal* signal);
679 void execGET_TABINFO_CONF(Signal* signal);
680 void execCONTINUEB(Signal* signal);
681
682 void execDUMP_STATE_ORD(Signal* signal);
683 void execHOT_SPAREREP(Signal* signal);
684 void execDIADDTABCONF(Signal* signal);
685 void execDIADDTABREF(Signal* signal);
686 void execTAB_COMMITCONF(Signal* signal);
687 void execTAB_COMMITREF(Signal* signal);
688 void execGET_SCHEMA_INFOREQ(Signal* signal);
689 void execSCHEMA_INFO(Signal* signal);
690 void execSCHEMA_INFOCONF(Signal* signal);
691 void execREAD_NODESCONF(Signal* signal);
692 void execFSCLOSECONF(Signal* signal);
693 void execFSOPENCONF(Signal* signal);
694 void execFSOPENREF(Signal* signal);
695 void execFSREADCONF(Signal* signal);
696 void execFSREADREF(Signal* signal);
697 void execFSWRITECONF(Signal* signal);
698 void execNDB_STTOR(Signal* signal);
699 void execREAD_CONFIG_REQ(Signal* signal);
700 void execSTTOR(Signal* signal);
701 void execTC_SCHVERCONF(Signal* signal);
702 void execNODE_FAILREP(Signal* signal);
703 void execINCL_NODEREQ(Signal* signal);
704 void execAPI_FAILREQ(Signal* signal);
705
706 void execWAIT_GCP_REF(Signal* signal);
707 void execWAIT_GCP_CONF(Signal* signal);
708
709 void execLIST_TABLES_REQ(Signal* signal);
710
711 // Index signals
712 void execCREATE_INDX_REQ(Signal* signal);
713 void execCREATE_INDX_CONF(Signal* signal);
714 void execCREATE_INDX_REF(Signal* signal);
715
716 void execALTER_INDX_REQ(Signal* signal);
717 void execALTER_INDX_CONF(Signal* signal);
718 void execALTER_INDX_REF(Signal* signal);
719
720 void execCREATE_TABLE_CONF(Signal* signal);
721 void execCREATE_TABLE_REF(Signal* signal);
722
723 void execDROP_INDX_REQ(Signal* signal);
724 void execDROP_INDX_CONF(Signal* signal);
725 void execDROP_INDX_REF(Signal* signal);
726
727 void execDROP_TABLE_CONF(Signal* signal);
728 void execDROP_TABLE_REF(Signal* signal);
729
730 void execBUILDINDXREQ(Signal* signal);
731 void execBUILDINDXCONF(Signal* signal);
732 void execBUILDINDXREF(Signal* signal);
733
734 void execBACKUP_FRAGMENT_REQ(Signal*);
735
736 // Util signals used by Event code
737 void execUTIL_PREPARE_CONF(Signal* signal);
738 void execUTIL_PREPARE_REF (Signal* signal);
739 void execUTIL_EXECUTE_CONF(Signal* signal);
740 void execUTIL_EXECUTE_REF (Signal* signal);
741 void execUTIL_RELEASE_CONF(Signal* signal);
742 void execUTIL_RELEASE_REF (Signal* signal);
743
744
745 // Event signals from API
746 void execCREATE_EVNT_REQ (Signal* signal);
747 void execCREATE_EVNT_CONF(Signal* signal);
748 void execCREATE_EVNT_REF (Signal* signal);
749
750 void execDROP_EVNT_REQ (Signal* signal);
751
752 void execSUB_START_REQ (Signal* signal);
753 void execSUB_START_CONF (Signal* signal);
754 void execSUB_START_REF (Signal* signal);
755
756 void execSUB_STOP_REQ (Signal* signal);
757 void execSUB_STOP_CONF (Signal* signal);
758 void execSUB_STOP_REF (Signal* signal);
759
760 // Event signals from SUMA
761
762 void execCREATE_SUBID_CONF(Signal* signal);
763 void execCREATE_SUBID_REF (Signal* signal);
764
765 void execSUB_CREATE_CONF(Signal* signal);
766 void execSUB_CREATE_REF (Signal* signal);
767
768 void execSUB_REMOVE_REQ(Signal* signal);
769 void execSUB_REMOVE_CONF(Signal* signal);
770 void execSUB_REMOVE_REF(Signal* signal);
771
772 // Trigger signals
773 void execCREATE_TRIG_REQ(Signal* signal);
774 void execCREATE_TRIG_CONF(Signal* signal);
775 void execCREATE_TRIG_REF(Signal* signal);
776 void execALTER_TRIG_REQ(Signal* signal);
777 void execALTER_TRIG_CONF(Signal* signal);
778 void execALTER_TRIG_REF(Signal* signal);
779 void execDROP_TRIG_REQ(Signal* signal);
780 void execDROP_TRIG_CONF(Signal* signal);
781 void execDROP_TRIG_REF(Signal* signal);
782
783 void execDROP_TABLE_REQ(Signal* signal);
784
785 void execPREP_DROP_TAB_REQ(Signal* signal);
786 void execPREP_DROP_TAB_REF(Signal* signal);
787 void execPREP_DROP_TAB_CONF(Signal* signal);
788
789 void execDROP_TAB_REQ(Signal* signal);
790 void execDROP_TAB_REF(Signal* signal);
791 void execDROP_TAB_CONF(Signal* signal);
792
793 void execCREATE_TABLE_REQ(Signal* signal);
794 void execALTER_TABLE_REQ(Signal* signal);
795 void execCREATE_FRAGMENTATION_REF(Signal*);
796 void execCREATE_FRAGMENTATION_CONF(Signal*);
797 void execCREATE_TAB_REQ(Signal* signal);
798 void execADD_FRAGREQ(Signal* signal);
799 void execLQHFRAGREF(Signal* signal);
800 void execLQHFRAGCONF(Signal* signal);
801 void execLQHADDATTREF(Signal* signal);
802 void execLQHADDATTCONF(Signal* signal);
803 void execCREATE_TAB_REF(Signal* signal);
804 void execCREATE_TAB_CONF(Signal* signal);
805 void execALTER_TAB_REQ(Signal* signal);
806 void execALTER_TAB_REF(Signal* signal);
807 void execALTER_TAB_CONF(Signal* signal);
808 bool check_ndb_versions() const;
809
810 void execCREATE_FILE_REQ(Signal* signal);
811 void execCREATE_FILEGROUP_REQ(Signal* signal);
812 void execDROP_FILE_REQ(Signal* signal);
813 void execDROP_FILEGROUP_REQ(Signal* signal);
814
815 // Internal
816 void execCREATE_FILE_REF(Signal* signal);
817 void execCREATE_FILE_CONF(Signal* signal);
818 void execCREATE_FILEGROUP_REF(Signal* signal);
819 void execCREATE_FILEGROUP_CONF(Signal* signal);
820 void execDROP_FILE_REF(Signal* signal);
821 void execDROP_FILE_CONF(Signal* signal);
822 void execDROP_FILEGROUP_REF(Signal* signal);
823 void execDROP_FILEGROUP_CONF(Signal* signal);
824
825 void execDICT_LOCK_REQ(Signal* signal);
826 void execDICT_UNLOCK_ORD(Signal* signal);
827
828 /*
829 * 2.4 COMMON STORED VARIABLES
830 */
831
832 /**
833 * This record stores all the state needed
834 * when the schema page is being sent to other nodes
835 ***************************************************************************/
836 struct SendSchemaRecord {
837 /** Number of words of schema data */
838 Uint32 noOfWords;
839 /** Page Id of schema data */
840 Uint32 pageId;
841
842 Uint32 nodeId;
843 SignalCounter m_SCHEMAINFO_Counter;
844
845 Uint32 noOfWordsCurrentlySent;
846 Uint32 noOfSignalsSentSinceDelay;
847
848 bool inUse;
849 };
850 SendSchemaRecord c_sendSchemaRecord;
851
852 /**
853 * This record stores all the state needed
854 * when a table file is being read from disk
855 ****************************************************************************/
856 struct ReadTableRecord {
857 /** Number of Pages */
858 Uint32 no_of_words;
859 /** Page Id*/
860 Uint32 pageId;
861 /** Table Id of read table */
862 Uint32 tableId;
863
864 bool inUse;
865 Callback m_callback;
866 };
867 ReadTableRecord c_readTableRecord;
868
869 /**
870 * This record stores all the state needed
871 * when a table file is being written to disk
872 ****************************************************************************/
873 struct WriteTableRecord {
874 /** Number of Pages */
875 Uint32 no_of_words;
876 /** Page Id*/
877 Uint32 pageId;
878 /** Table Files Handled, local state variable */
879 Uint32 noOfTableFilesHandled;
880 /** Table Id of written table */
881 Uint32 tableId;
882 /** State, indicates from where it was called */
883 enum TableWriteState {
884 IDLE = 0,
885 WRITE_ADD_TABLE_MASTER = 1,
886 WRITE_ADD_TABLE_SLAVE = 2,
887 WRITE_RESTART_FROM_MASTER = 3,
888 WRITE_RESTART_FROM_OWN = 4,
889 TWR_CALLBACK = 5
890 };
891 TableWriteState tableWriteState;
892 Callback m_callback;
893 };
894 WriteTableRecord c_writeTableRecord;
895
896 /**
897 * This record stores all the state needed
898 * when a schema file is being read from disk
899 ****************************************************************************/
900 struct ReadSchemaRecord {
901 /** Page Id of schema page */
902 Uint32 pageId;
903 /** First page to read */
904 Uint32 firstPage;
905 /** Number of pages to read */
906 Uint32 noOfPages;
907 /** State, indicates from where it was called */
908 enum SchemaReadState {
909 IDLE = 0,
910 INITIAL_READ_HEAD = 1,
911 INITIAL_READ = 2
912 };
913 SchemaReadState schemaReadState;
914 };
915 ReadSchemaRecord c_readSchemaRecord;
916
917 /**
918 * This record stores all the state needed
919 * when a schema file is being written to disk
920 ****************************************************************************/
921 struct WriteSchemaRecord {
922 /** Page Id of schema page */
923 Uint32 pageId;
924 /** Rewrite entire file */
925 Uint32 newFile;
926 /** First page to write */
927 Uint32 firstPage;
928 /** Number of pages to write */
929 Uint32 noOfPages;
930 /** Schema Files Handled, local state variable */
931 Uint32 noOfSchemaFilesHandled;
932
933 bool inUse;
934 Callback m_callback;
935 };
936 WriteSchemaRecord c_writeSchemaRecord;
937
938 /**
939 * This record stores all the information needed
940 * when a file is being read from disk
941 ****************************************************************************/
942 struct RestartRecord {
943 /** Global check point identity */
944 Uint32 gciToRestart;
945
946 /** The active table at restart process */
947 Uint32 activeTable;
948
949 /** The active table at restart process */
950 BlockReference returnBlockRef;
951
952 Uint32 m_pass; // 0 tablespaces/logfilegroups, 1 tables, 2 indexes
953 };
954 RestartRecord c_restartRecord;
955
956 /**
957 * This record stores all the information needed
958 * when a file is being read from disk
959 ****************************************************************************/
960 struct RetrieveRecord {
RetrieveRecordDbdict::RetrieveRecord961 RetrieveRecord(){ noOfWaiters = 0;}
962
963 /** Only one retrieve table definition at a time */
964 bool busyState;
965
966 /**
967 * No of waiting in time queue
968 */
969 Uint32 noOfWaiters;
970
971 /** Block Reference of retriever */
972 BlockReference blockRef;
973
974 /** Id of retriever */
975 Uint32 m_senderData;
976
977 /** Table id of retrieved table */
978 Uint32 tableId;
979
980 Uint32 m_table_type;
981
982 /** Starting page to retrieve data from */
983 Uint32 retrievePage;
984
985 /** Number of pages retrieved */
986 Uint32 retrievedNoOfPages;
987
988 /** Number of words retrieved */
989 Uint32 retrievedNoOfWords;
990
991 /** Number of words sent currently */
992 Uint32 currentSent;
993
994 /**
995 * Long signal stuff
996 */
997 bool m_useLongSig;
998 };
999 RetrieveRecord c_retrieveRecord;
1000
1001 /**
1002 * This record stores all the information needed
1003 * when a file is being read from disk
1004 *
1005 * This is the info stored in one entry of the schema
1006 * page. Each table has 4 words of info.
1007 * Word 1: Schema version (upper 16 bits)
1008 * Table State (lower 16 bits)
1009 * Word 2: Number of pages of table description
1010 * Word 3: Global checkpoint id table was created
1011 * Word 4: Currently zero
1012 ****************************************************************************/
1013 struct SchemaRecord {
1014 /** Schema file first page (0) */
1015 Uint32 schemaPage;
1016
1017 /** Old Schema file first page (used at node restart) */
1018 Uint32 oldSchemaPage;
1019
1020 Callback m_callback;
1021 };
1022 SchemaRecord c_schemaRecord;
1023
1024 /*
1025 * Schema file, list of schema pages. Use an array until a pool
1026 * exists and NDBFS interface can use it.
1027 */
1028 struct XSchemaFile {
1029 SchemaFile* schemaPage;
1030 Uint32 noOfPages;
1031 };
1032 // 0-normal 1-old
1033 XSchemaFile c_schemaFile[2];
1034
1035 void initSchemaFile(XSchemaFile *, Uint32 firstPage, Uint32 lastPage,
1036 bool initEntries);
1037 void resizeSchemaFile(XSchemaFile * xsf, Uint32 noOfPages);
1038 void computeChecksum(XSchemaFile *, Uint32 pageNo);
1039 bool validateChecksum(const XSchemaFile *);
1040 SchemaFile::TableEntry * getTableEntry(XSchemaFile *, Uint32 tableId);
1041
1042 Uint32 computeChecksum(const Uint32 * src, Uint32 len);
1043
1044
1045 /* ----------------------------------------------------------------------- */
1046 // Node References
1047 /* ----------------------------------------------------------------------- */
1048 Uint16 c_masterNodeId;
1049
1050 /* ----------------------------------------------------------------------- */
1051 // Various current system properties
1052 /* ----------------------------------------------------------------------- */
1053 Uint16 c_numberNode;
1054 Uint16 c_noHotSpareNodes;
1055 Uint16 c_noNodesFailed;
1056 Uint32 c_failureNr;
1057
1058 /* ----------------------------------------------------------------------- */
1059 // State variables
1060 /* ----------------------------------------------------------------------- */
1061
1062 #ifndef ndb_dbdict_log_block_state
1063 enum BlockState {
1064 BS_IDLE = 0,
1065 BS_CREATE_TAB = 1,
1066 BS_BUSY = 2,
1067 BS_NODE_FAILURE = 3,
1068 BS_NODE_RESTART = 4
1069 };
1070 #else // quick hack to log changes
1071 enum {
1072 BS_IDLE = 0,
1073 BS_CREATE_TAB = 1,
1074 BS_BUSY = 2,
1075 BS_NODE_FAILURE = 3,
1076 BS_NODE_RESTART = 4
1077 };
1078 struct BlockState;
1079 friend struct BlockState;
1080 struct BlockState {
BlockStateDbdict::BlockState1081 BlockState() :
1082 m_value(BS_IDLE) {
1083 }
BlockStateDbdict::BlockState1084 BlockState(int value) :
1085 m_value(value) {
1086 }
operator intDbdict::BlockState1087 operator int() const {
1088 return m_value;
1089 }
operator =Dbdict::BlockState1090 BlockState& operator=(const BlockState& bs) {
1091 Dbdict* dict = (Dbdict*)globalData.getBlock(DBDICT);
1092 dict->infoEvent("DICT: bs %d->%d", m_value, bs.m_value);
1093 globalSignalLoggers.log(DBDICT, "bs %d->%d", m_value, bs.m_value);
1094 m_value = bs.m_value;
1095 return *this;
1096 }
1097 int m_value;
1098 };
1099 #endif
1100 BlockState c_blockState;
1101
1102 struct PackTable {
1103
1104 enum PackTableState {
1105 PTS_IDLE = 0,
1106 PTS_GET_TAB = 3
1107 } m_state;
1108
1109 } c_packTable;
1110
1111 Uint32 c_startPhase;
1112 Uint32 c_restartType;
1113 bool c_initialStart;
1114 bool c_systemRestart;
1115 bool c_nodeRestart;
1116 bool c_initialNodeRestart;
1117 Uint32 c_tabinfoReceived;
1118
1119 /**
1120 * Temporary structure used when parsing table info
1121 */
1122 struct ParseDictTabInfoRecord {
1123 DictTabInfo::RequestType requestType;
1124 Uint32 errorCode;
1125 Uint32 errorLine;
1126
1127 SimpleProperties::UnpackStatus status;
1128 Uint32 errorKey;
1129 TableRecordPtr tablePtr;
1130 };
1131
1132 // Operation records
1133
1134 /**
1135 * Common part of operation records. Uses KeyTable2. Note that each
1136 * seize/release invokes ctor/dtor automatically.
1137 */
1138 struct OpRecordCommon {
OpRecordCommonDbdict::OpRecordCommon1139 OpRecordCommon() {}
1140 Uint32 key; // key shared between master and slaves
1141 Uint32 nextHash;
1142 Uint32 prevHash;
hashValueDbdict::OpRecordCommon1143 Uint32 hashValue() const {
1144 return key;
1145 }
equalDbdict::OpRecordCommon1146 bool equal(const OpRecordCommon& rec) const {
1147 return key == rec.key;
1148 }
1149 };
1150
1151 /**
1152 * Create table record
1153 */
1154 struct CreateTableRecord : OpRecordCommon {
CreateTableRecordDbdict::CreateTableRecord1155 CreateTableRecord() {}
1156 Uint32 m_senderRef;
1157 Uint32 m_senderData;
1158 Uint32 m_coordinatorRef;
1159
1160 Uint32 m_errorCode;
setErrorCodeDbdict::CreateTableRecord1161 void setErrorCode(Uint32 c){ if(m_errorCode == 0) m_errorCode = c;}
1162
1163 // For alter table
1164 Uint32 m_changeMask;
1165 bool m_alterTableFailed;
1166 AlterTableRef m_alterTableRef;
1167 Uint32 m_alterTableId;
1168
1169 /* Previous table name (used for reverting failed table rename) */
1170 char previousTableName[MAX_TAB_NAME_SIZE];
1171
1172 /* Previous table definition, frm (used for reverting) */
1173 /** TODO Could preferrably be made dynamic size */
1174 Uint32 previousFrmLen;
1175 char previousFrmData[MAX_FRM_DATA_SIZE];
1176
1177 Uint32 m_tablePtrI;
1178 Uint32 m_tabInfoPtrI;
1179 Uint32 m_fragmentsPtrI;
1180
1181 Uint32 m_dihAddFragPtr; // Connect ptr towards DIH
1182 Uint32 m_lqhFragPtr; // Connect ptr towards LQH
1183
1184 Callback m_callback; // Who's using local create tab
1185 MutexHandle2<DIH_START_LCP_MUTEX> m_startLcpMutex;
1186
1187 struct CoordinatorData {
1188 Uint32 m_gsn;
1189 SafeCounterHandle m_counter;
1190 CreateTabReq::RequestType m_requestType;
1191 } m_coordinatorData;
1192 };
1193 typedef Ptr<CreateTableRecord> CreateTableRecordPtr;
1194
1195 /**
1196 * Drop table record
1197 */
1198 struct DropTableRecord : OpRecordCommon {
DropTableRecordDbdict::DropTableRecord1199 DropTableRecord() {}
1200 DropTableReq m_request;
1201
1202 Uint32 m_requestType;
1203 Uint32 m_coordinatorRef;
1204
1205 Uint32 m_errorCode;
setErrorCodeDbdict::DropTableRecord1206 void setErrorCode(Uint32 c){ if(m_errorCode == 0) m_errorCode = c;}
1207
1208 MutexHandle2<BACKUP_DEFINE_MUTEX> m_define_backup_mutex;
1209
1210 /**
1211 * When sending stuff around
1212 */
1213 struct CoordinatorData {
1214 Uint32 m_gsn;
1215 Uint32 m_block;
1216 SignalCounter m_signalCounter;
1217 } m_coordinatorData;
1218
1219 struct ParticipantData {
1220 Uint32 m_gsn;
1221 Uint32 m_block;
1222 SignalCounter m_signalCounter;
1223
1224 Callback m_callback;
1225 } m_participantData;
1226 };
1227 typedef Ptr<DropTableRecord> DropTableRecordPtr;
1228
1229 /**
1230 * Request flags passed in signals along with request type and
1231 * propagated across operations.
1232 */
1233 struct RequestFlag {
1234 enum {
1235 RF_LOCAL = 1 << 0, // create on local node only
1236 RF_NOBUILD = 1 << 1, // no need to build index
1237 RF_NOTCTRIGGER = 1 << 2, // alter trigger: no trigger in TC
1238 RF_FORCE = 1 << 4 // force drop
1239 };
1240 };
1241
1242 /**
1243 * Operation record for create index.
1244 */
1245 struct OpCreateIndex : OpRecordCommon {
1246 // original request (index id will be added)
1247 CreateIndxReq m_request;
1248 AttributeList m_attrList;
1249 char m_indexName[MAX_TAB_NAME_SIZE];
1250 bool m_loggedIndex;
1251 bool m_temporaryIndex;
1252 // coordinator DICT
1253 Uint32 m_coordinatorRef;
1254 bool m_isMaster;
1255 // state info
1256 CreateIndxReq::RequestType m_requestType;
1257 Uint32 m_requestFlag;
1258 // error info
1259 CreateIndxRef::ErrorCode m_lastError;
1260 CreateIndxRef::ErrorCode m_errorCode;
1261 Uint32 m_errorLine;
1262 Uint32 m_errorNode;
1263 // counters
1264 SignalCounter m_signalCounter;
1265 // ctor
OpCreateIndexDbdict::OpCreateIndex1266 OpCreateIndex() {
1267 memset(&m_request, 0, sizeof(m_request));
1268 m_coordinatorRef = 0;
1269 m_requestType = CreateIndxReq::RT_UNDEFINED;
1270 m_requestFlag = 0;
1271 m_lastError = CreateIndxRef::NoError;
1272 m_errorCode = CreateIndxRef::NoError;
1273 m_errorLine = 0;
1274 m_errorNode = 0;
1275 }
saveDbdict::OpCreateIndex1276 void save(const CreateIndxReq* req) {
1277 m_request = *req;
1278 m_requestType = req->getRequestType();
1279 m_requestFlag = req->getRequestFlag();
1280 }
hasLastErrorDbdict::OpCreateIndex1281 bool hasLastError() {
1282 return m_lastError != CreateIndxRef::NoError;
1283 }
hasErrorDbdict::OpCreateIndex1284 bool hasError() {
1285 return m_errorCode != CreateIndxRef::NoError;
1286 }
setErrorDbdict::OpCreateIndex1287 void setError(const CreateIndxRef* ref) {
1288 m_lastError = CreateIndxRef::NoError;
1289 if (ref != 0) {
1290 m_lastError = ref->getErrorCode();
1291 if (! hasError()) {
1292 m_errorCode = m_lastError;
1293 m_errorLine = ref->getErrorLine();
1294 m_errorNode = ref->getErrorNode();
1295 }
1296 }
1297 }
setErrorDbdict::OpCreateIndex1298 void setError(const CreateTableRef* ref) {
1299 m_lastError = CreateIndxRef::NoError;
1300 if (ref != 0) {
1301 switch (ref->getErrorCode()) {
1302 case CreateTableRef::TableAlreadyExist:
1303 m_lastError = CreateIndxRef::IndexExists;
1304 break;
1305 default:
1306 m_lastError = (CreateIndxRef::ErrorCode)ref->getErrorCode();
1307 break;
1308 }
1309 if (! hasError()) {
1310 m_errorCode = m_lastError;
1311 m_errorLine = ref->getErrorLine();
1312 }
1313 }
1314 }
setErrorDbdict::OpCreateIndex1315 void setError(const AlterIndxRef* ref) {
1316 m_lastError = CreateIndxRef::NoError;
1317 if (ref != 0) {
1318 m_lastError = (CreateIndxRef::ErrorCode)ref->getErrorCode();
1319 if (! hasError()) {
1320 m_errorCode = m_lastError;
1321 m_errorLine = ref->getErrorLine();
1322 m_errorNode = ref->getErrorNode();
1323 }
1324 }
1325 }
1326 };
1327 typedef Ptr<OpCreateIndex> OpCreateIndexPtr;
1328
1329 /**
1330 * Operation record for drop index.
1331 */
1332 struct OpDropIndex : OpRecordCommon {
1333 // original request
1334 DropIndxReq m_request;
1335 // coordinator DICT
1336 Uint32 m_coordinatorRef;
1337 bool m_isMaster;
1338 // state info
1339 DropIndxReq::RequestType m_requestType;
1340 Uint32 m_requestFlag;
1341 // error info
1342 DropIndxRef::ErrorCode m_lastError;
1343 DropIndxRef::ErrorCode m_errorCode;
1344 Uint32 m_errorLine;
1345 Uint32 m_errorNode;
1346 // counters
1347 SignalCounter m_signalCounter;
1348 // ctor
OpDropIndexDbdict::OpDropIndex1349 OpDropIndex() {
1350 memset(&m_request, 0, sizeof(m_request));
1351 m_coordinatorRef = 0;
1352 m_requestType = DropIndxReq::RT_UNDEFINED;
1353 m_requestFlag = 0;
1354 m_lastError = DropIndxRef::NoError;
1355 m_errorCode = DropIndxRef::NoError;
1356 m_errorLine = 0;
1357 m_errorNode = 0;
1358 }
saveDbdict::OpDropIndex1359 void save(const DropIndxReq* req) {
1360 m_request = *req;
1361 m_requestType = req->getRequestType();
1362 m_requestFlag = req->getRequestFlag();
1363 }
hasLastErrorDbdict::OpDropIndex1364 bool hasLastError() {
1365 return m_lastError != DropIndxRef::NoError;
1366 }
hasErrorDbdict::OpDropIndex1367 bool hasError() {
1368 return m_errorCode != DropIndxRef::NoError;
1369 }
setErrorDbdict::OpDropIndex1370 void setError(const DropIndxRef* ref) {
1371 m_lastError = DropIndxRef::NoError;
1372 if (ref != 0) {
1373 m_lastError = ref->getErrorCode();
1374 if (! hasError()) {
1375 m_errorCode = ref->getErrorCode();
1376 m_errorLine = ref->getErrorLine();
1377 m_errorNode = ref->getErrorNode();
1378 }
1379 }
1380 }
setErrorDbdict::OpDropIndex1381 void setError(const AlterIndxRef* ref) {
1382 m_lastError = DropIndxRef::NoError;
1383 if (ref != 0) {
1384 m_lastError = (DropIndxRef::ErrorCode)ref->getErrorCode();
1385 if (! hasError()) {
1386 m_errorCode = m_lastError;
1387 m_errorLine = ref->getErrorLine();
1388 m_errorNode = ref->getErrorNode();
1389 }
1390 }
1391 }
setErrorDbdict::OpDropIndex1392 void setError(const DropTableRef* ref) {
1393 m_lastError = DropIndxRef::NoError;
1394 if (ref != 0) {
1395 switch (ref->errorCode) {
1396 case DropTableRef::Busy:
1397 m_lastError = DropIndxRef::Busy;
1398 break;
1399 case DropTableRef::NoSuchTable:
1400 m_lastError = DropIndxRef::IndexNotFound;
1401 break;
1402 case DropTableRef::DropInProgress:
1403 m_lastError = DropIndxRef::Busy;
1404 break;
1405 case DropTableRef::NoDropTableRecordAvailable:
1406 m_lastError = DropIndxRef::Busy;
1407 break;
1408 default:
1409 m_lastError = (DropIndxRef::ErrorCode)ref->errorCode;
1410 break;
1411 }
1412 if (! hasError()) {
1413 m_errorCode = m_lastError;
1414 m_errorLine = 0;
1415 m_errorNode = 0;
1416 }
1417 }
1418 }
1419 };
1420 typedef Ptr<OpDropIndex> OpDropIndexPtr;
1421
1422 /**
1423 * Operation record for alter index.
1424 */
1425 struct OpAlterIndex : OpRecordCommon {
1426 // original request plus buffer for attribute lists
1427 AlterIndxReq m_request;
1428 AttributeList m_attrList;
1429 AttributeList m_tableKeyList;
1430 // coordinator DICT
1431 Uint32 m_coordinatorRef;
1432 bool m_isMaster;
1433 // state info
1434 AlterIndxReq::RequestType m_requestType;
1435 Uint32 m_requestFlag;
1436 // error info
1437 AlterIndxRef::ErrorCode m_lastError;
1438 AlterIndxRef::ErrorCode m_errorCode;
1439 Uint32 m_errorLine;
1440 Uint32 m_errorNode;
1441 // counters
1442 SignalCounter m_signalCounter;
1443 Uint32 m_triggerCounter;
1444 // ctor
OpAlterIndexDbdict::OpAlterIndex1445 OpAlterIndex() {
1446 memset(&m_request, 0, sizeof(m_request));
1447 m_coordinatorRef = 0;
1448 m_requestType = AlterIndxReq::RT_UNDEFINED;
1449 m_requestFlag = 0;
1450 m_lastError = AlterIndxRef::NoError;
1451 m_errorCode = AlterIndxRef::NoError;
1452 m_errorLine = 0;
1453 m_errorNode = 0;
1454 m_triggerCounter = 0;
1455 }
saveDbdict::OpAlterIndex1456 void save(const AlterIndxReq* req) {
1457 m_request = *req;
1458 m_requestType = req->getRequestType();
1459 m_requestFlag = req->getRequestFlag();
1460 }
hasLastErrorDbdict::OpAlterIndex1461 bool hasLastError() {
1462 return m_lastError != AlterIndxRef::NoError;
1463 }
hasErrorDbdict::OpAlterIndex1464 bool hasError() {
1465 return m_errorCode != AlterIndxRef::NoError;
1466 }
setErrorDbdict::OpAlterIndex1467 void setError(const AlterIndxRef* ref) {
1468 m_lastError = AlterIndxRef::NoError;
1469 if (ref != 0) {
1470 m_lastError = ref->getErrorCode();
1471 if (! hasError()) {
1472 m_errorCode = m_lastError;
1473 m_errorLine = ref->getErrorLine();
1474 m_errorNode = ref->getErrorNode();
1475 }
1476 }
1477 }
setErrorDbdict::OpAlterIndex1478 void setError(const CreateIndxRef* ref) {
1479 m_lastError = AlterIndxRef::NoError;
1480 if (ref != 0) {
1481 m_lastError = (AlterIndxRef::ErrorCode)ref->getErrorCode();
1482 if (! hasError()) {
1483 m_errorCode = m_lastError;
1484 m_errorLine = ref->getErrorLine();
1485 m_errorNode = ref->getErrorNode();
1486 }
1487 }
1488 }
setErrorDbdict::OpAlterIndex1489 void setError(const DropIndxRef* ref) {
1490 m_lastError = AlterIndxRef::NoError;
1491 if (ref != 0) {
1492 m_lastError = (AlterIndxRef::ErrorCode)ref->getErrorCode();
1493 if (! hasError()) {
1494 m_errorCode = m_lastError;
1495 m_errorLine = ref->getErrorLine();
1496 m_errorNode = ref->getErrorNode();
1497 }
1498 }
1499 }
setErrorDbdict::OpAlterIndex1500 void setError(const BuildIndxRef* ref) {
1501 m_lastError = AlterIndxRef::NoError;
1502 if (ref != 0) {
1503 m_lastError = (AlterIndxRef::ErrorCode)ref->getErrorCode();
1504 if (! hasError()) {
1505 m_errorCode = m_lastError;
1506 m_errorLine = 0;
1507 m_errorNode = 0;
1508 }
1509 }
1510 }
setErrorDbdict::OpAlterIndex1511 void setError(const CreateTrigRef* ref) {
1512 m_lastError = AlterIndxRef::NoError;
1513 if (ref != 0) {
1514 m_lastError = (AlterIndxRef::ErrorCode)ref->getErrorCode();
1515 if (! hasError()) {
1516 m_errorCode = m_lastError;
1517 m_errorLine = ref->getErrorLine();
1518 m_errorNode = ref->getErrorNode();
1519 }
1520 }
1521 }
setErrorDbdict::OpAlterIndex1522 void setError(const DropTrigRef* ref) {
1523 m_lastError = AlterIndxRef::NoError;
1524 if (ref != 0) {
1525 m_lastError = (AlterIndxRef::ErrorCode)ref->getErrorCode();
1526 if (! hasError()) {
1527 m_errorCode = m_lastError;
1528 m_errorLine = ref->getErrorLine();
1529 m_errorNode = ref->getErrorNode();
1530 }
1531 }
1532 }
1533 };
1534 typedef Ptr<OpAlterIndex> OpAlterIndexPtr;
1535
1536 /**
1537 * Operation record for build index.
1538 */
1539 struct OpBuildIndex : OpRecordCommon {
1540 // original request plus buffer for attribute lists
1541 BuildIndxReq m_request;
1542 AttributeList m_attrList;
1543 Id_array<MAX_ATTRIBUTES_IN_INDEX+1> m_tableKeyList;
1544 // coordinator DICT
1545 Uint32 m_coordinatorRef;
1546 bool m_isMaster;
1547 // state info
1548 BuildIndxReq::RequestType m_requestType;
1549 Uint32 m_requestFlag;
1550 Uint32 m_constrTriggerId;
1551 // error info
1552 BuildIndxRef::ErrorCode m_lastError;
1553 BuildIndxRef::ErrorCode m_errorCode;
1554 Uint32 m_errorLine;
1555 Uint32 m_errorNode;
1556 // counters
1557 SignalCounter m_signalCounter;
1558 // ctor
OpBuildIndexDbdict::OpBuildIndex1559 OpBuildIndex() {
1560 memset(&m_request, 0, sizeof(m_request));
1561 m_coordinatorRef = 0;
1562 m_requestType = BuildIndxReq::RT_UNDEFINED;
1563 m_requestFlag = 0;
1564 m_lastError = BuildIndxRef::NoError;
1565 m_errorCode = BuildIndxRef::NoError;
1566 m_errorLine = 0;
1567 m_errorNode = 0;
1568 }
saveDbdict::OpBuildIndex1569 void save(const BuildIndxReq* req) {
1570 m_request = *req;
1571 m_requestType = req->getRequestType();
1572 m_requestFlag = req->getRequestFlag();
1573 }
hasLastErrorDbdict::OpBuildIndex1574 bool hasLastError() {
1575 return m_lastError != BuildIndxRef::NoError;
1576 }
hasErrorDbdict::OpBuildIndex1577 bool hasError() {
1578 return m_errorCode != BuildIndxRef::NoError;
1579 }
setErrorDbdict::OpBuildIndex1580 void setError(const BuildIndxRef* ref) {
1581 m_lastError = BuildIndxRef::NoError;
1582 if (ref != 0) {
1583 m_lastError = ref->getErrorCode();
1584 if (! hasError()) {
1585 m_errorCode = m_lastError;
1586 m_errorLine = 0;
1587 m_errorNode = 0;
1588 }
1589 }
1590 }
setErrorDbdict::OpBuildIndex1591 void setError(const AlterIndxRef* ref) {
1592 m_lastError = BuildIndxRef::NoError;
1593 if (ref != 0) {
1594 m_lastError = (BuildIndxRef::ErrorCode)ref->getErrorCode();
1595 if (! hasError()) {
1596 m_errorCode = m_lastError;
1597 m_errorLine = ref->getErrorLine();
1598 m_errorNode = ref->getErrorNode();
1599 }
1600 }
1601 }
setErrorDbdict::OpBuildIndex1602 void setError(const CreateTrigRef* ref) {
1603 m_lastError = BuildIndxRef::NoError;
1604 if (ref != 0) {
1605 m_lastError = (BuildIndxRef::ErrorCode)ref->getErrorCode();
1606 if (! hasError()) {
1607 m_errorCode = m_lastError;
1608 m_errorLine = ref->getErrorLine();
1609 m_errorNode = ref->getErrorNode();
1610 }
1611 }
1612 }
setErrorDbdict::OpBuildIndex1613 void setError(const DropTrigRef* ref) {
1614 m_lastError = BuildIndxRef::NoError;
1615 if (ref != 0) {
1616 m_lastError = (BuildIndxRef::ErrorCode)ref->getErrorCode();
1617 if (! hasError()) {
1618 m_errorCode = m_lastError;
1619 m_errorLine = ref->getErrorLine();
1620 m_errorNode = ref->getErrorNode();
1621 }
1622 }
1623 }
1624 };
1625 typedef Ptr<OpBuildIndex> OpBuildIndexPtr;
1626
1627 /**
1628 * Operation record for Util Signals.
1629 */
1630 struct OpSignalUtil : OpRecordCommon{
1631 Callback m_callback;
1632 Uint32 m_userData;
1633 };
1634 typedef Ptr<OpSignalUtil> OpSignalUtilPtr;
1635
1636 /**
1637 * Operation record for subscribe-start-stop
1638 */
1639 struct OpSubEvent : OpRecordCommon {
1640 Uint32 m_senderRef;
1641 Uint32 m_senderData;
1642 Uint32 m_errorCode;
1643 union {
1644 SubStartConf m_sub_start_conf;
1645 SubStopConf m_sub_stop_conf;
1646 };
1647 RequestTracker m_reqTracker;
1648 };
1649 typedef Ptr<OpSubEvent> OpSubEventPtr;
1650
1651 static const Uint32 sysTab_NDBEVENTS_0_szs[];
1652
1653 /**
1654 * Operation record for create event.
1655 */
1656 struct OpCreateEvent : OpRecordCommon {
1657 // original request (event id will be added)
1658 CreateEvntReq m_request;
1659 //AttributeMask m_attrListBitmask;
1660 // AttributeList m_attrList;
1661 sysTab_NDBEVENTS_0 m_eventRec;
1662 // char m_eventName[MAX_TAB_NAME_SIZE];
1663 // char m_tableName[MAX_TAB_NAME_SIZE];
1664
1665 // coordinator DICT
1666 RequestTracker m_reqTracker;
1667 // state info
1668 CreateEvntReq::RequestType m_requestType;
1669 // error info
1670 Uint32 m_errorCode;
1671 Uint32 m_errorLine;
1672 Uint32 m_errorNode; /* also used to store master node id
1673 in case of NotMaster */
1674 // ctor
OpCreateEventDbdict::OpCreateEvent1675 OpCreateEvent() {
1676 memset(&m_request, 0, sizeof(m_request));
1677 m_requestType = CreateEvntReq::RT_UNDEFINED;
1678 m_errorCode = CreateEvntRef::NoError;
1679 m_errorLine = 0;
1680 m_errorNode = 0;
1681 }
initDbdict::OpCreateEvent1682 void init(const CreateEvntReq* req, Dbdict* dp) {
1683 m_request = *req;
1684 m_errorCode = CreateEvntRef::NoError;
1685 m_errorLine = 0;
1686 m_errorNode = 0;
1687 m_requestType = req->getRequestType();
1688 }
hasErrorDbdict::OpCreateEvent1689 bool hasError() {
1690 return m_errorCode != CreateEvntRef::NoError;
1691 }
setErrorDbdict::OpCreateEvent1692 void setError(const CreateEvntRef* ref) {
1693 if (ref != 0 && ! hasError()) {
1694 m_errorCode = ref->getErrorCode();
1695 m_errorLine = ref->getErrorLine();
1696 m_errorNode = ref->getErrorNode();
1697 }
1698 }
1699
1700 };
1701 typedef Ptr<OpCreateEvent> OpCreateEventPtr;
1702
1703 /**
1704 * Operation record for drop event.
1705 */
1706 struct OpDropEvent : OpRecordCommon {
1707 // original request
1708 DropEvntReq m_request;
1709 // char m_eventName[MAX_TAB_NAME_SIZE];
1710 sysTab_NDBEVENTS_0 m_eventRec;
1711 RequestTracker m_reqTracker;
1712 // error info
1713 Uint32 m_errorCode;
1714 Uint32 m_errorLine;
1715 Uint32 m_errorNode;
1716 // ctor
OpDropEventDbdict::OpDropEvent1717 OpDropEvent() {
1718 memset(&m_request, 0, sizeof(m_request));
1719 m_errorCode = 0;
1720 m_errorLine = 0;
1721 m_errorNode = 0;
1722 }
initDbdict::OpDropEvent1723 void init(const DropEvntReq* req) {
1724 m_request = *req;
1725 m_errorCode = 0;
1726 m_errorLine = 0;
1727 m_errorNode = 0;
1728 }
hasErrorDbdict::OpDropEvent1729 bool hasError() {
1730 return m_errorCode != 0;
1731 }
setErrorDbdict::OpDropEvent1732 void setError(const DropEvntRef* ref) {
1733 if (ref != 0 && ! hasError()) {
1734 m_errorCode = ref->getErrorCode();
1735 m_errorLine = ref->getErrorLine();
1736 m_errorNode = ref->getErrorNode();
1737 }
1738 }
1739 };
1740 typedef Ptr<OpDropEvent> OpDropEventPtr;
1741
1742 /**
1743 * Operation record for create trigger.
1744 */
1745 struct OpCreateTrigger : OpRecordCommon {
1746 // original request (trigger id will be added)
1747 CreateTrigReq m_request;
1748 char m_triggerName[MAX_TAB_NAME_SIZE];
1749 // coordinator DICT
1750 Uint32 m_coordinatorRef;
1751 bool m_isMaster;
1752 // state info
1753 CreateTrigReq::RequestType m_requestType;
1754 Uint32 m_requestFlag;
1755 // error info
1756 CreateTrigRef::ErrorCode m_lastError;
1757 CreateTrigRef::ErrorCode m_errorCode;
1758 Uint32 m_errorLine;
1759 Uint32 m_errorNode;
1760 // counters
1761 SignalCounter m_signalCounter;
1762 // ctor
OpCreateTriggerDbdict::OpCreateTrigger1763 OpCreateTrigger() {
1764 memset(&m_request, 0, sizeof(m_request));
1765 m_coordinatorRef = 0;
1766 m_requestType = CreateTrigReq::RT_UNDEFINED;
1767 m_requestFlag = 0;
1768 m_lastError = CreateTrigRef::NoError;
1769 m_errorCode = CreateTrigRef::NoError;
1770 m_errorLine = 0;
1771 m_errorNode = 0;
1772 }
saveDbdict::OpCreateTrigger1773 void save(const CreateTrigReq* req) {
1774 m_request = *req;
1775 m_requestType = req->getRequestType();
1776 m_requestFlag = req->getRequestFlag();
1777 }
hasLastErrorDbdict::OpCreateTrigger1778 bool hasLastError() {
1779 return m_lastError != CreateTrigRef::NoError;
1780 }
hasErrorDbdict::OpCreateTrigger1781 bool hasError() {
1782 return m_errorCode != CreateTrigRef::NoError;
1783 }
setErrorDbdict::OpCreateTrigger1784 void setError(const CreateTrigRef* ref) {
1785 m_lastError = CreateTrigRef::NoError;
1786 if (ref != 0) {
1787 m_lastError = ref->getErrorCode();
1788 if (! hasError()) {
1789 m_errorCode = m_lastError;
1790 m_errorLine = ref->getErrorLine();
1791 m_errorNode = ref->getErrorNode();
1792 }
1793 }
1794 }
setErrorDbdict::OpCreateTrigger1795 void setError(const AlterTrigRef* ref) {
1796 m_lastError = CreateTrigRef::NoError;
1797 if (ref != 0) {
1798 m_lastError = (CreateTrigRef::ErrorCode)ref->getErrorCode();
1799 if (! hasError()) {
1800 m_errorCode = m_lastError;
1801 m_errorLine = ref->getErrorLine();
1802 m_errorNode = ref->getErrorNode();
1803 }
1804 }
1805 }
1806 };
1807 typedef Ptr<OpCreateTrigger> OpCreateTriggerPtr;
1808
1809 /**
1810 * Operation record for drop trigger.
1811 */
1812 struct OpDropTrigger : OpRecordCommon {
1813 // original request
1814 DropTrigReq m_request;
1815 // coordinator DICT
1816 Uint32 m_coordinatorRef;
1817 bool m_isMaster;
1818 // state info
1819 DropTrigReq::RequestType m_requestType;
1820 Uint32 m_requestFlag;
1821 // error info
1822 DropTrigRef::ErrorCode m_lastError;
1823 DropTrigRef::ErrorCode m_errorCode;
1824 Uint32 m_errorLine;
1825 Uint32 m_errorNode;
1826 // counters
1827 SignalCounter m_signalCounter;
1828 // ctor
OpDropTriggerDbdict::OpDropTrigger1829 OpDropTrigger() {
1830 memset(&m_request, 0, sizeof(m_request));
1831 m_coordinatorRef = 0;
1832 m_requestType = DropTrigReq::RT_UNDEFINED;
1833 m_requestFlag = 0;
1834 m_lastError = DropTrigRef::NoError;
1835 m_errorCode = DropTrigRef::NoError;
1836 m_errorLine = 0;
1837 m_errorNode = 0;
1838 }
saveDbdict::OpDropTrigger1839 void save(const DropTrigReq* req) {
1840 m_request = *req;
1841 m_requestType = req->getRequestType();
1842 m_requestFlag = req->getRequestFlag();
1843 }
hasLastErrorDbdict::OpDropTrigger1844 bool hasLastError() {
1845 return m_lastError != DropTrigRef::NoError;
1846 }
hasErrorDbdict::OpDropTrigger1847 bool hasError() {
1848 return m_errorCode != DropTrigRef::NoError;
1849 }
setErrorDbdict::OpDropTrigger1850 void setError(const DropTrigRef* ref) {
1851 m_lastError = DropTrigRef::NoError;
1852 if (ref != 0) {
1853 m_lastError = ref->getErrorCode();
1854 if (! hasError()) {
1855 m_errorCode = m_lastError;
1856 m_errorLine = ref->getErrorLine();
1857 m_errorNode = ref->getErrorNode();
1858 }
1859 }
1860 }
setErrorDbdict::OpDropTrigger1861 void setError(const AlterTrigRef* ref) {
1862 m_lastError = DropTrigRef::NoError;
1863 if (ref != 0) {
1864 m_lastError = (DropTrigRef::ErrorCode)ref->getErrorCode();
1865 if (! hasError()) {
1866 m_errorCode = m_lastError;
1867 m_errorLine = ref->getErrorLine();
1868 m_errorNode = ref->getErrorNode();
1869 }
1870 }
1871 }
1872 };
1873 typedef Ptr<OpDropTrigger> OpDropTriggerPtr;
1874
1875 /**
1876 * Operation record for alter trigger.
1877 */
1878 struct OpAlterTrigger : OpRecordCommon {
1879 // original request
1880 AlterTrigReq m_request;
1881 // nodes participating in operation
1882 NdbNodeBitmask m_nodes;
1883 // coordinator DICT
1884 Uint32 m_coordinatorRef;
1885 bool m_isMaster;
1886 // state info
1887 AlterTrigReq::RequestType m_requestType;
1888 Uint32 m_requestFlag;
1889 // error info
1890 AlterTrigRef::ErrorCode m_lastError;
1891 AlterTrigRef::ErrorCode m_errorCode;
1892 Uint32 m_errorLine;
1893 Uint32 m_errorNode;
1894 // counters
1895 SignalCounter m_signalCounter;
1896 // ctor
OpAlterTriggerDbdict::OpAlterTrigger1897 OpAlterTrigger() {
1898 memset(&m_request, 0, sizeof(m_request));
1899 m_coordinatorRef = 0;
1900 m_requestType = AlterTrigReq::RT_UNDEFINED;
1901 m_requestFlag = 0;
1902 m_lastError = AlterTrigRef::NoError;
1903 m_errorCode = AlterTrigRef::NoError;
1904 m_errorLine = 0;
1905 m_errorNode = 0;
1906 }
saveDbdict::OpAlterTrigger1907 void save(const AlterTrigReq* req) {
1908 m_request = *req;
1909 m_requestType = req->getRequestType();
1910 m_requestFlag = req->getRequestFlag();
1911 }
hasLastErrorDbdict::OpAlterTrigger1912 bool hasLastError() {
1913 return m_lastError != AlterTrigRef::NoError;
1914 }
hasErrorDbdict::OpAlterTrigger1915 bool hasError() {
1916 return m_errorCode != AlterTrigRef::NoError;
1917 }
setErrorDbdict::OpAlterTrigger1918 void setError(const AlterTrigRef* ref) {
1919 m_lastError = AlterTrigRef::NoError;
1920 if (ref != 0) {
1921 m_lastError = (AlterTrigRef::ErrorCode)ref->getErrorCode();
1922 if (! hasError()) {
1923 m_errorCode = m_lastError;
1924 m_errorLine = ref->getErrorLine();
1925 m_errorNode = ref->getErrorNode();
1926 }
1927 }
1928 }
setErrorDbdict::OpAlterTrigger1929 void setError(const CreateTrigRef* ref) {
1930 m_lastError = AlterTrigRef::NoError;
1931 if (ref != 0) {
1932 m_lastError = (AlterTrigRef::ErrorCode)ref->getErrorCode();
1933 if (! hasError()) {
1934 m_errorCode = m_lastError;
1935 m_errorLine = ref->getErrorLine();
1936 m_errorNode = ref->getErrorNode();
1937 }
1938 }
1939 }
setErrorDbdict::OpAlterTrigger1940 void setError(const DropTrigRef* ref) {
1941 m_lastError = AlterTrigRef::NoError;
1942 if (ref != 0) {
1943 m_lastError = (AlterTrigRef::ErrorCode)ref->getErrorCode();
1944 if (! hasError()) {
1945 m_errorCode = m_lastError;
1946 m_errorLine = ref->getErrorLine();
1947 m_errorNode = ref->getErrorNode();
1948 }
1949 }
1950 }
1951 };
1952 typedef Ptr<OpAlterTrigger> OpAlterTriggerPtr;
1953
1954 public:
1955 struct SchemaOp : OpRecordCommon {
1956
1957 Uint32 m_clientRef; // API (for take-over)
1958 Uint32 m_clientData;// API
1959
1960 Uint32 m_senderRef; //
1961 Uint32 m_senderData;// transaction key value
1962
1963 Uint32 m_errorCode;
1964
1965 Uint32 m_obj_id;
1966 Uint32 m_obj_type;
1967 Uint32 m_obj_version;
1968 Uint32 m_obj_ptr_i;
1969 Uint32 m_vt_index;
1970 Callback m_callback;
1971 };
1972 typedef Ptr<SchemaOp> SchemaOpPtr;
1973
1974 struct SchemaTransaction : OpRecordCommon {
1975 Uint32 m_senderRef; // API
1976 Uint32 m_senderData;// API
1977
1978 Callback m_callback;
1979 SafeCounterHandle m_counter;
1980 NodeBitmask m_nodes;
1981
1982 Uint32 m_errorCode;
SchemaTransactionDbdict::SchemaTransaction1983 SchemaTransaction() {}
setErrorCodeDbdict::SchemaTransaction1984 void setErrorCode(Uint32 c){ if(m_errorCode == 0) m_errorCode = c;}
1985
1986 /**
1987 * This should contain "lists" with operations
1988 */
1989 struct {
1990 Uint32 m_key; // Operation key
1991 Uint32 m_vt_index; // Operation type
1992 Uint32 m_obj_id;
1993 DictObjOp::State m_state;
1994 } m_op;
1995 };
1996 private:
1997
1998 struct OpCreateObj : public SchemaOp {
1999 Uint32 m_gci;
2000 Uint32 m_obj_info_ptr_i;
2001 Uint32 m_restart;
2002 };
2003 typedef Ptr<OpCreateObj> CreateObjRecordPtr;
2004
2005 struct OpDropObj : public SchemaOp
2006 {
2007 };
2008 typedef Ptr<OpDropObj> DropObjRecordPtr;
2009
2010 /**
2011 * Only used at coordinator/master
2012 */
2013 // Common operation record pool
2014 public:
2015 STATIC_CONST( opCreateTableSize = sizeof(CreateTableRecord) );
2016 STATIC_CONST( opDropTableSize = sizeof(DropTableRecord) );
2017 STATIC_CONST( opCreateIndexSize = sizeof(OpCreateIndex) );
2018 STATIC_CONST( opDropIndexSize = sizeof(OpDropIndex) );
2019 STATIC_CONST( opAlterIndexSize = sizeof(OpAlterIndex) );
2020 STATIC_CONST( opBuildIndexSize = sizeof(OpBuildIndex) );
2021 STATIC_CONST( opCreateEventSize = sizeof(OpCreateEvent) );
2022 STATIC_CONST( opSubEventSize = sizeof(OpSubEvent) );
2023 STATIC_CONST( opDropEventSize = sizeof(OpDropEvent) );
2024 STATIC_CONST( opSignalUtilSize = sizeof(OpSignalUtil) );
2025 STATIC_CONST( opCreateTriggerSize = sizeof(OpCreateTrigger) );
2026 STATIC_CONST( opDropTriggerSize = sizeof(OpDropTrigger) );
2027 STATIC_CONST( opAlterTriggerSize = sizeof(OpAlterTrigger) );
2028 STATIC_CONST( opCreateObjSize = sizeof(OpCreateObj) );
2029 private:
2030 #define PTR_ALIGN(n) ((((n)+sizeof(void*)-1)>>2)&~((sizeof(void*)-1)>>2))
2031 union OpRecordUnion {
2032 Uint32 u_opCreateTable [PTR_ALIGN(opCreateTableSize)];
2033 Uint32 u_opDropTable [PTR_ALIGN(opDropTableSize)];
2034 Uint32 u_opCreateIndex [PTR_ALIGN(opCreateIndexSize)];
2035 Uint32 u_opDropIndex [PTR_ALIGN(opDropIndexSize)];
2036 Uint32 u_opCreateEvent [PTR_ALIGN(opCreateEventSize)];
2037 Uint32 u_opSubEvent [PTR_ALIGN(opSubEventSize)];
2038 Uint32 u_opDropEvent [PTR_ALIGN(opDropEventSize)];
2039 Uint32 u_opSignalUtil [PTR_ALIGN(opSignalUtilSize)];
2040 Uint32 u_opAlterIndex [PTR_ALIGN(opAlterIndexSize)];
2041 Uint32 u_opBuildIndex [PTR_ALIGN(opBuildIndexSize)];
2042 Uint32 u_opCreateTrigger[PTR_ALIGN(opCreateTriggerSize)];
2043 Uint32 u_opDropTrigger [PTR_ALIGN(opDropTriggerSize)];
2044 Uint32 u_opAlterTrigger [PTR_ALIGN(opAlterTriggerSize)];
2045 Uint32 u_opCreateObj [PTR_ALIGN(opCreateObjSize)];
2046 Uint32 nextPool;
2047 };
2048 ArrayPool<OpRecordUnion> c_opRecordPool;
2049
2050 // Operation records
2051 KeyTable2<CreateTableRecord, OpRecordUnion> c_opCreateTable;
2052 KeyTable2<DropTableRecord, OpRecordUnion> c_opDropTable;
2053 KeyTable2<OpCreateIndex, OpRecordUnion> c_opCreateIndex;
2054 KeyTable2<OpDropIndex, OpRecordUnion> c_opDropIndex;
2055 KeyTable2<OpAlterIndex, OpRecordUnion> c_opAlterIndex;
2056 KeyTable2<OpBuildIndex, OpRecordUnion> c_opBuildIndex;
2057 KeyTable2C<OpCreateEvent, OpRecordUnion> c_opCreateEvent;
2058 KeyTable2C<OpSubEvent, OpRecordUnion> c_opSubEvent;
2059 KeyTable2C<OpDropEvent, OpRecordUnion> c_opDropEvent;
2060 KeyTable2C<OpSignalUtil, OpRecordUnion> c_opSignalUtil;
2061 KeyTable2<OpCreateTrigger, OpRecordUnion> c_opCreateTrigger;
2062 KeyTable2<OpDropTrigger, OpRecordUnion> c_opDropTrigger;
2063 KeyTable2<OpAlterTrigger, OpRecordUnion> c_opAlterTrigger;
2064 KeyTable2<SchemaOp, OpRecordUnion> c_schemaOp;
2065 KeyTable2<SchemaTransaction, OpRecordUnion> c_Trans;
2066 KeyTable2Ref<OpCreateObj, SchemaOp, OpRecordUnion> c_opCreateObj;
2067 KeyTable2Ref<OpDropObj, SchemaOp, OpRecordUnion> c_opDropObj;
2068
2069 // Unique key for operation XXX move to some system table
2070 Uint32 c_opRecordSequence;
2071
2072 /*
2073 * Master DICT can be locked in 2 mutually exclusive ways:
2074 *
2075 * 1) for schema ops, via operation records
2076 * 2) against schema ops, via a lock queue
2077 *
2078 * Current use of 2) is by a starting node, to prevent schema ops
2079 * until started. The ops are refused (BlockState != BS_IDLE),
2080 * not queued.
2081 *
2082 * Master failure is not handled, in node start case the starting
2083 * node will crash too anyway. Use lock table in future..
2084 *
2085 * The lock queue is "serial" but other behaviour is possible
2086 * by checking lock types e.g. to allow parallel node starts.
2087 *
2088 * Checking release of last op record is not convenient with
2089 * current structure (5.0). Instead we poll via continueB.
2090 *
2091 * XXX only table ops check BlockState
2092 */
2093 struct DictLockType;
2094 friend struct DictLockType;
2095
2096 struct DictLockType {
2097 DictLockReq::LockType lockType;
2098 BlockState blockState;
2099 const char* text;
2100 };
2101
2102 struct DictLockRecord;
2103 friend struct DictLockRecord;
2104
2105 struct DictLockRecord {
2106 DictLockReq req;
2107 const DictLockType* lt;
2108 bool locked;
2109 union {
2110 Uint32 nextPool;
2111 Uint32 nextList;
2112 };
2113 Uint32 prevList;
2114 };
2115
2116 typedef Ptr<DictLockRecord> DictLockPtr;
2117 ArrayPool<DictLockRecord> c_dictLockPool;
2118 DLFifoList<DictLockRecord> c_dictLockQueue;
2119 bool c_dictLockPoll;
2120
2121 static const DictLockType* getDictLockType(Uint32 lockType);
2122 void sendDictLockInfoEvent(Uint32 pollCount);
2123 void sendDictLockInfoEvent(DictLockPtr lockPtr, const char* text);
2124
2125 // check if any schema op exists (conflicting with dict lock)
2126 bool hasDictLockSchemaOp();
2127
2128 void checkDictLockQueue(Signal* signal, bool poll);
2129 void sendDictLockConf(Signal* signal, DictLockPtr lockPtr);
2130 void sendDictLockRef(Signal* signal, DictLockReq req, Uint32 errorCode);
2131
2132 // control polling i.e. continueB loop
2133 void setDictLockPoll(Signal* signal, bool on, Uint32 pollCount);
2134
2135 // NF handling
2136 void removeStaleDictLocks(Signal* signal, const Uint32* theFailedNodes);
2137
2138
2139 // Statement blocks
2140
2141 /* ------------------------------------------------------------ */
2142 // Start/Restart Handling
2143 /* ------------------------------------------------------------ */
2144 void sendSTTORRY(Signal* signal);
2145 void sendNDB_STTORRY(Signal* signal);
2146 void initSchemaFile(Signal* signal);
2147
2148 /* ------------------------------------------------------------ */
2149 // Drop Table Handling
2150 /* ------------------------------------------------------------ */
2151 void releaseTableObject(Uint32 tableId, bool removeFromHash = true);
2152
2153 /* ------------------------------------------------------------ */
2154 // General Stuff
2155 /* ------------------------------------------------------------ */
2156 Uint32 getFreeObjId(Uint32 minId);
2157 Uint32 getFreeTableRecord(Uint32 primaryTableId);
2158 Uint32 getFreeTriggerRecord();
2159 bool getNewAttributeRecord(TableRecordPtr tablePtr,
2160 AttributeRecordPtr & attrPtr);
2161 void packTableIntoPages(Signal* signal);
2162 void packTableIntoPages(SimpleProperties::Writer &, TableRecordPtr, Signal* =0);
2163 void packFilegroupIntoPages(SimpleProperties::Writer &,
2164 FilegroupPtr,
2165 const Uint32 undo_free_hi,
2166 const Uint32 undo_free_lo);
2167 void packFileIntoPages(SimpleProperties::Writer &, FilePtr, const Uint32);
2168
2169 void sendGET_TABINFOREQ(Signal* signal,
2170 Uint32 tableId);
2171 void sendTC_SCHVERREQ(Signal* signal,
2172 Uint32 tableId,
2173 BlockReference tcRef);
2174
2175 /* ------------------------------------------------------------ */
2176 // System Restart Handling
2177 /* ------------------------------------------------------------ */
2178 void initSendSchemaData(Signal* signal);
2179 void sendSchemaData(Signal* signal);
2180 Uint32 sendSCHEMA_INFO(Signal* signal, Uint32 nodeId, Uint32* pagePointer);
2181 void checkSchemaStatus(Signal* signal);
2182 void sendDIHSTARTTAB_REQ(Signal* signal);
2183
2184 /* ------------------------------------------------------------ */
2185 // Receive Table Handling
2186 /* ------------------------------------------------------------ */
2187 void handleTabInfoInit(SimpleProperties::Reader &,
2188 ParseDictTabInfoRecord *,
2189 bool checkExist = true);
2190 void handleTabInfo(SimpleProperties::Reader & it, ParseDictTabInfoRecord *,
2191 DictTabInfo::Table & tableDesc);
2192
2193 void handleAddTableFailure(Signal* signal,
2194 Uint32 failureLine,
2195 Uint32 tableId);
2196 bool verifyTableCorrect(Signal* signal, Uint32 tableId);
2197
2198 /* ------------------------------------------------------------ */
2199 // Add Table Handling
2200 /* ------------------------------------------------------------ */
2201 void releaseCreateTableOp(Signal* signal, CreateTableRecordPtr createTabPtr);
2202
2203 /* ------------------------------------------------------------ */
2204 // Add Fragment Handling
2205 /* ------------------------------------------------------------ */
2206 void sendLQHADDATTRREQ(Signal*, CreateTableRecordPtr, Uint32 attributePtrI);
2207
2208 /* ------------------------------------------------------------ */
2209 // Read/Write Schema and Table files
2210 /* ------------------------------------------------------------ */
2211 void updateSchemaState(Signal* signal, Uint32 tableId,
2212 SchemaFile::TableEntry*, Callback*,
2213 bool savetodisk = 1);
2214 void startWriteSchemaFile(Signal* signal);
2215 void openSchemaFile(Signal* signal,
2216 Uint32 fileNo,
2217 Uint32 fsPtr,
2218 bool writeFlag,
2219 bool newFile);
2220 void writeSchemaFile(Signal* signal, Uint32 filePtr, Uint32 fsPtr);
2221 void writeSchemaConf(Signal* signal,
2222 FsConnectRecordPtr fsPtr);
2223 void closeFile(Signal* signal, Uint32 filePtr, Uint32 fsPtr);
2224 void closeWriteSchemaConf(Signal* signal,
2225 FsConnectRecordPtr fsPtr);
2226 void initSchemaFile_conf(Signal* signal, Uint32 i, Uint32 returnCode);
2227
2228 void writeTableFile(Signal* signal, Uint32 tableId,
2229 SegmentedSectionPtr tabInfo, Callback*);
2230 void startWriteTableFile(Signal* signal, Uint32 tableId);
2231 void openTableFile(Signal* signal,
2232 Uint32 fileNo,
2233 Uint32 fsPtr,
2234 Uint32 tableId,
2235 bool writeFlag);
2236 void writeTableFile(Signal* signal, Uint32 filePtr, Uint32 fsPtr);
2237 void writeTableConf(Signal* signal,
2238 FsConnectRecordPtr fsPtr);
2239 void closeWriteTableConf(Signal* signal,
2240 FsConnectRecordPtr fsPtr);
2241
2242 void startReadTableFile(Signal* signal, Uint32 tableId);
2243 void openReadTableRef(Signal* signal,
2244 FsConnectRecordPtr fsPtr);
2245 void readTableFile(Signal* signal, Uint32 filePtr, Uint32 fsPtr);
2246 void readTableConf(Signal* signal,
2247 FsConnectRecordPtr fsPtr);
2248 void readTableRef(Signal* signal,
2249 FsConnectRecordPtr fsPtr);
2250 void closeReadTableConf(Signal* signal,
2251 FsConnectRecordPtr fsPtr);
2252
2253 void startReadSchemaFile(Signal* signal);
2254 void openReadSchemaRef(Signal* signal,
2255 FsConnectRecordPtr fsPtr);
2256 void readSchemaFile(Signal* signal, Uint32 filePtr, Uint32 fsPtr);
2257 void readSchemaConf(Signal* signal, FsConnectRecordPtr fsPtr);
2258 void readSchemaRef(Signal* signal, FsConnectRecordPtr fsPtr);
2259 void closeReadSchemaConf(Signal* signal,
2260 FsConnectRecordPtr fsPtr);
2261 bool convertSchemaFileTo_5_0_6(XSchemaFile*);
2262
2263 /* ------------------------------------------------------------ */
2264 // Get table definitions
2265 /* ------------------------------------------------------------ */
2266 void sendGET_TABINFOREF(Signal* signal,
2267 GetTabInfoReq*,
2268 GetTabInfoRef::ErrorCode errorCode);
2269
2270 void sendGET_TABLEID_REF(Signal* signal,
2271 GetTableIdReq * req,
2272 GetTableIdRef::ErrorCode errorCode);
2273
2274 void sendGetTabResponse(Signal* signal);
2275
2276 /* ------------------------------------------------------------ */
2277 // Indexes and triggers
2278 /* ------------------------------------------------------------ */
2279
2280 // reactivate and rebuild indexes on start up
2281 void activateIndexes(Signal* signal, Uint32 i);
2282 void rebuildIndexes(Signal* signal, Uint32 i);
2283
2284 // create index
2285 void createIndex_recvReply(Signal* signal, const CreateIndxConf* conf,
2286 const CreateIndxRef* ref);
2287 void createIndex_slavePrepare(Signal* signal, OpCreateIndexPtr opPtr);
2288 void createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr);
2289 void createIndex_fromCreateTable(Signal* signal, OpCreateIndexPtr opPtr);
2290 void createIndex_toAlterIndex(Signal* signal, OpCreateIndexPtr opPtr);
2291 void createIndex_fromAlterIndex(Signal* signal, OpCreateIndexPtr opPtr);
2292 void createIndex_slaveCommit(Signal* signal, OpCreateIndexPtr opPtr);
2293 void createIndex_slaveAbort(Signal* signal, OpCreateIndexPtr opPtr);
2294 void createIndex_sendSlaveReq(Signal* signal, OpCreateIndexPtr opPtr);
2295 void createIndex_sendReply(Signal* signal, OpCreateIndexPtr opPtr, bool);
2296 // drop index
2297 void dropIndex_recvReply(Signal* signal, const DropIndxConf* conf,
2298 const DropIndxRef* ref);
2299 void dropIndex_slavePrepare(Signal* signal, OpDropIndexPtr opPtr);
2300 void dropIndex_toAlterIndex(Signal* signal, OpDropIndexPtr opPtr);
2301 void dropIndex_fromAlterIndex(Signal* signal, OpDropIndexPtr opPtr);
2302 void dropIndex_toDropTable(Signal* signal, OpDropIndexPtr opPtr);
2303 void dropIndex_fromDropTable(Signal* signal, OpDropIndexPtr opPtr);
2304 void dropIndex_slaveCommit(Signal* signal, OpDropIndexPtr opPtr);
2305 void dropIndex_slaveAbort(Signal* signal, OpDropIndexPtr opPtr);
2306 void dropIndex_sendSlaveReq(Signal* signal, OpDropIndexPtr opPtr);
2307 void dropIndex_sendReply(Signal* signal, OpDropIndexPtr opPtr, bool);
2308 // alter index
2309 void alterIndex_recvReply(Signal* signal, const AlterIndxConf* conf,
2310 const AlterIndxRef* ref);
2311 void alterIndex_slavePrepare(Signal* signal, OpAlterIndexPtr opPtr);
2312 void alterIndex_toCreateTc(Signal* signal, OpAlterIndexPtr opPtr);
2313 void alterIndex_fromCreateTc(Signal* signal, OpAlterIndexPtr opPtr);
2314 void alterIndex_toDropTc(Signal* signal, OpAlterIndexPtr opPtr);
2315 void alterIndex_fromDropTc(Signal* signal, OpAlterIndexPtr opPtr);
2316 void alterIndex_toCreateTrigger(Signal* signal, OpAlterIndexPtr opPtr);
2317 void alterIndex_fromCreateTrigger(Signal* signal, OpAlterIndexPtr opPtr);
2318 void alterIndex_toDropTrigger(Signal* signal, OpAlterIndexPtr opPtr);
2319 void alterIndex_fromDropTrigger(Signal* signal, OpAlterIndexPtr opPtr);
2320 void alterIndex_toBuildIndex(Signal* signal, OpAlterIndexPtr opPtr);
2321 void alterIndex_fromBuildIndex(Signal* signal, OpAlterIndexPtr opPtr);
2322 void alterIndex_slaveCommit(Signal* signal, OpAlterIndexPtr opPtr);
2323 void alterIndex_slaveAbort(Signal* signal, OpAlterIndexPtr opPtr);
2324 void alterIndex_sendSlaveReq(Signal* signal, OpAlterIndexPtr opPtr);
2325 void alterIndex_sendReply(Signal* signal, OpAlterIndexPtr opPtr, bool);
2326 // build index
2327 void buildIndex_recvReply(Signal* signal, const BuildIndxConf* conf,
2328 const BuildIndxRef* ref);
2329 void buildIndex_toCreateConstr(Signal* signal, OpBuildIndexPtr opPtr);
2330 void buildIndex_fromCreateConstr(Signal* signal, OpBuildIndexPtr opPtr);
2331 void buildIndex_buildTrix(Signal* signal, OpBuildIndexPtr opPtr);
2332 void buildIndex_toDropConstr(Signal* signal, OpBuildIndexPtr opPtr);
2333 void buildIndex_fromDropConstr(Signal* signal, OpBuildIndexPtr opPtr);
2334 void buildIndex_toOnline(Signal* signal, OpBuildIndexPtr opPtr);
2335 void buildIndex_fromOnline(Signal* signal, OpBuildIndexPtr opPtr);
2336 void buildIndex_sendSlaveReq(Signal* signal, OpBuildIndexPtr opPtr);
2337 void buildIndex_sendReply(Signal* signal, OpBuildIndexPtr opPtr, bool);
2338
2339 // Events
2340 void
2341 createEventUTIL_PREPARE(Signal* signal,
2342 Uint32 callbackData,
2343 Uint32 returnCode);
2344 void
2345 createEventUTIL_EXECUTE(Signal *signal,
2346 Uint32 callbackData,
2347 Uint32 returnCode);
2348 void
2349 dropEventUTIL_PREPARE_READ(Signal* signal,
2350 Uint32 callbackData,
2351 Uint32 returnCode);
2352 void
2353 dropEventUTIL_EXECUTE_READ(Signal* signal,
2354 Uint32 callbackData,
2355 Uint32 returnCode);
2356 void
2357 dropEventUTIL_PREPARE_DELETE(Signal* signal,
2358 Uint32 callbackData,
2359 Uint32 returnCode);
2360 void
2361 dropEventUTIL_EXECUTE_DELETE(Signal *signal,
2362 Uint32 callbackData,
2363 Uint32 returnCode);
2364 void
2365 dropEventUtilPrepareRef(Signal* signal,
2366 Uint32 callbackData,
2367 Uint32 returnCode);
2368 void
2369 dropEventUtilExecuteRef(Signal* signal,
2370 Uint32 callbackData,
2371 Uint32 returnCode);
2372 int
2373 sendSignalUtilReq(Callback *c,
2374 BlockReference ref,
2375 GlobalSignalNumber gsn,
2376 Signal* signal,
2377 Uint32 length,
2378 JobBufferLevel jbuf,
2379 LinearSectionPtr ptr[3],
2380 Uint32 noOfSections);
2381 int
2382 recvSignalUtilReq(Signal* signal, Uint32 returnCode);
2383
2384 void completeSubStartReq(Signal* signal, Uint32 ptrI, Uint32 returnCode);
2385 void completeSubStopReq(Signal* signal, Uint32 ptrI, Uint32 returnCode);
2386 void completeSubRemoveReq(Signal* signal, Uint32 ptrI, Uint32 returnCode);
2387
2388 void dropEvent_sendReply(Signal* signal,
2389 OpDropEventPtr evntRecPtr);
2390
2391 void createEvent_RT_USER_CREATE(Signal* signal, OpCreateEventPtr evntRecPtr);
2392 void createEventComplete_RT_USER_CREATE(Signal* signal,
2393 OpCreateEventPtr evntRecPtr);
2394 void createEvent_RT_USER_GET(Signal* signal, OpCreateEventPtr evntRecPtr);
2395 void createEventComplete_RT_USER_GET(Signal* signal, OpCreateEventPtr evntRecPtr);
2396
2397 void createEvent_RT_DICT_AFTER_GET(Signal* signal, OpCreateEventPtr evntRecPtr);
2398
2399 void createEvent_nodeFailCallback(Signal* signal, Uint32 eventRecPtrI,
2400 Uint32 returnCode);
2401 void createEvent_sendReply(Signal* signal, OpCreateEventPtr evntRecPtr,
2402 LinearSectionPtr *ptr = NULL, int noLSP = 0);
2403
2404 void prepareTransactionEventSysTable (Callback *c,
2405 Signal* signal,
2406 Uint32 senderData,
2407 UtilPrepareReq::OperationTypeValue prepReq);
2408 void prepareUtilTransaction(Callback *c,
2409 Signal* signal,
2410 Uint32 senderData,
2411 Uint32 tableId,
2412 const char *tableName,
2413 UtilPrepareReq::OperationTypeValue prepReq,
2414 Uint32 noAttr,
2415 Uint32 attrIds[],
2416 const char *attrNames[]);
2417
2418 void executeTransEventSysTable(Callback *c,
2419 Signal *signal,
2420 const Uint32 ptrI,
2421 sysTab_NDBEVENTS_0& m_eventRec,
2422 const Uint32 prepareId,
2423 UtilPrepareReq::OperationTypeValue prepReq);
2424 void executeTransaction(Callback *c,
2425 Signal* signal,
2426 Uint32 senderData,
2427 Uint32 prepareId,
2428 Uint32 noAttr,
2429 LinearSectionPtr headerPtr,
2430 LinearSectionPtr dataPtr);
2431
2432 void parseReadEventSys(Signal *signal, sysTab_NDBEVENTS_0& m_eventRec);
2433
2434 // create trigger
2435 void createTrigger_recvReply(Signal* signal, const CreateTrigConf* conf,
2436 const CreateTrigRef* ref);
2437 void createTrigger_slavePrepare(Signal* signal, OpCreateTriggerPtr opPtr);
2438 void createTrigger_masterSeize(Signal* signal, OpCreateTriggerPtr opPtr);
2439 void createTrigger_slaveCreate(Signal* signal, OpCreateTriggerPtr opPtr);
2440 void createTrigger_toAlterTrigger(Signal* signal, OpCreateTriggerPtr opPtr);
2441 void createTrigger_fromAlterTrigger(Signal* signal, OpCreateTriggerPtr opPtr);
2442 void createTrigger_slaveCommit(Signal* signal, OpCreateTriggerPtr opPtr);
2443 void createTrigger_slaveAbort(Signal* signal, OpCreateTriggerPtr opPtr);
2444 void createTrigger_sendSlaveReq(Signal* signal, OpCreateTriggerPtr opPtr);
2445 void createTrigger_sendReply(Signal* signal, OpCreateTriggerPtr opPtr, bool);
2446 // drop trigger
2447 void dropTrigger_recvReply(Signal* signal, const DropTrigConf* conf,
2448 const DropTrigRef* ref);
2449 void dropTrigger_slavePrepare(Signal* signal, OpDropTriggerPtr opPtr);
2450 void dropTrigger_toAlterTrigger(Signal* signal, OpDropTriggerPtr opPtr);
2451 void dropTrigger_fromAlterTrigger(Signal* signal, OpDropTriggerPtr opPtr);
2452 void dropTrigger_slaveCommit(Signal* signal, OpDropTriggerPtr opPtr);
2453 void dropTrigger_slaveAbort(Signal* signal, OpDropTriggerPtr opPtr);
2454 void dropTrigger_sendSlaveReq(Signal* signal, OpDropTriggerPtr opPtr);
2455 void dropTrigger_sendReply(Signal* signal, OpDropTriggerPtr opPtr, bool);
2456 // alter trigger
2457 void alterTrigger_recvReply(Signal* signal, const AlterTrigConf* conf,
2458 const AlterTrigRef* ref);
2459 void alterTrigger_slavePrepare(Signal* signal, OpAlterTriggerPtr opPtr);
2460 void alterTrigger_toCreateLocal(Signal* signal, OpAlterTriggerPtr opPtr);
2461 void alterTrigger_fromCreateLocal(Signal* signal, OpAlterTriggerPtr opPtr);
2462 void alterTrigger_toDropLocal(Signal* signal, OpAlterTriggerPtr opPtr);
2463 void alterTrigger_fromDropLocal(Signal* signal, OpAlterTriggerPtr opPtr);
2464 void alterTrigger_slaveCommit(Signal* signal, OpAlterTriggerPtr opPtr);
2465 void alterTrigger_slaveAbort(Signal* signal, OpAlterTriggerPtr opPtr);
2466 void alterTrigger_sendSlaveReq(Signal* signal, OpAlterTriggerPtr opPtr);
2467 void alterTrigger_sendReply(Signal* signal, OpAlterTriggerPtr opPtr, bool);
2468 // support
2469 void getTableKeyList(TableRecordPtr,
2470 Id_array<MAX_ATTRIBUTES_IN_INDEX+1>& list);
2471 void getIndexAttr(TableRecordPtr indexPtr, Uint32 itAttr, Uint32* id);
2472 void getIndexAttrList(TableRecordPtr indexPtr, AttributeList& list);
2473 void getIndexAttrMask(TableRecordPtr indexPtr, AttributeMask& mask);
2474
2475 /* ------------------------------------------------------------ */
2476 // Initialisation
2477 /* ------------------------------------------------------------ */
2478 void initCommonData();
2479 void initRecords();
2480 void initConnectRecord();
2481 void initRetrieveRecord(Signal*, Uint32, Uint32 returnCode);
2482 void initSchemaRecord();
2483 void initRestartRecord();
2484 void initSendSchemaRecord();
2485 void initReadTableRecord();
2486 void initWriteTableRecord();
2487 void initReadSchemaRecord();
2488 void initWriteSchemaRecord();
2489
2490 void initNodeRecords();
2491 void initTableRecords();
2492 void initialiseTableRecord(TableRecordPtr tablePtr);
2493 void initTriggerRecords();
2494 void initialiseTriggerRecord(TriggerRecordPtr triggerPtr);
2495 void initPageRecords();
2496
2497 Uint32 getFsConnRecord();
2498
2499 bool getIsFailed(Uint32 nodeId) const;
2500
2501 void dropTable_backup_mutex_locked(Signal* signal, Uint32, Uint32);
2502 void dropTableRef(Signal * signal, DropTableReq *, DropTableRef::ErrorCode);
2503 void printTables(); // For debugging only
2504 int handleAlterTab(AlterTabReq * req,
2505 CreateTableRecord * regAlterTabPtr,
2506 TableRecordPtr origTablePtr,
2507 TableRecordPtr newTablePtr);
2508 void revertAlterTable(Signal * signal,
2509 Uint32 changeMask,
2510 Uint32 tableId,
2511 CreateTableRecord * regAlterTabPtr);
2512 void alterTable_backup_mutex_locked(Signal* signal, Uint32, Uint32);
2513 void alterTableRef(Signal * signal,
2514 AlterTableReq *, AlterTableRef::ErrorCode,
2515 ParseDictTabInfoRecord* parseRecord = NULL);
2516 void alterTabRef(Signal * signal,
2517 AlterTabReq *, AlterTableRef::ErrorCode,
2518 ParseDictTabInfoRecord* parseRecord = NULL);
2519 void alterTab_writeSchemaConf(Signal* signal,
2520 Uint32 callbackData,
2521 Uint32 returnCode);
2522 void alterTab_writeTableConf(Signal* signal,
2523 Uint32 callbackData,
2524 Uint32 returnCode);
2525
2526 void prepDropTab_nextStep(Signal* signal, DropTableRecordPtr);
2527 void prepDropTab_complete(Signal* signal, DropTableRecordPtr);
2528 void prepDropTab_writeSchemaConf(Signal* signal, Uint32 dropTabPtrI, Uint32);
2529
2530 void dropTab_localDROP_TAB_CONF(Signal* signal);
2531 void dropTab_nextStep(Signal* signal, DropTableRecordPtr);
2532 void dropTab_complete(Signal* signal, Uint32 dropTabPtrI, Uint32);
2533 void dropTab_writeSchemaConf(Signal* signal, Uint32 dropTabPtrI, Uint32);
2534
2535 void createTab_prepare(Signal* signal, CreateTabReq * req);
2536 void createTab_writeSchemaConf1(Signal* signal, Uint32 callback, Uint32);
2537 void createTab_writeTableConf(Signal* signal, Uint32 callbackData, Uint32);
2538 void createTab_dih(Signal*, CreateTableRecordPtr,
2539 SegmentedSectionPtr, Callback*);
2540 void createTab_dihComplete(Signal* signal, Uint32 callbackData, Uint32);
2541
2542 void createTab_startLcpMutex_locked(Signal* signal, Uint32, Uint32);
2543 void createTab_startLcpMutex_unlocked(Signal* signal, Uint32, Uint32);
2544
2545 void createTab_commit(Signal* signal, CreateTabReq * req);
2546 void createTab_writeSchemaConf2(Signal* signal, Uint32 callbackData, Uint32);
2547 void createTab_alterComplete(Signal*, Uint32 callbackData, Uint32);
2548
2549 void createTab_drop(Signal* signal, CreateTabReq * req);
2550 void createTab_dropComplete(Signal* signal, Uint32 callbackData, Uint32);
2551
2552 void createTab_reply(Signal* signal, CreateTableRecordPtr, Uint32 nodeId);
2553 void alterTab_activate(Signal*, CreateTableRecordPtr, Callback*);
2554
2555 void restartCreateTab(Signal*, Uint32,
2556 const SchemaFile::TableEntry *,
2557 const SchemaFile::TableEntry *, bool);
2558 void restartCreateTab_readTableConf(Signal* signal, Uint32 callback, Uint32);
2559 void restartCreateTab_writeTableConf(Signal* signal, Uint32 callback, Uint32);
2560 void restartCreateTab_dihComplete(Signal* signal, Uint32 callback, Uint32);
2561 void restartCreateTab_activateComplete(Signal*, Uint32 callback, Uint32);
2562
2563 void restartDropTab(Signal* signal, Uint32 tableId,
2564 const SchemaFile::TableEntry *,
2565 const SchemaFile::TableEntry *);
2566 void restartDropTab_complete(Signal*, Uint32 callback, Uint32);
2567
2568 void restartDropObj(Signal*, Uint32, const SchemaFile::TableEntry *);
2569 void restartDropObj_prepare_start_done(Signal*, Uint32, Uint32);
2570 void restartDropObj_prepare_complete_done(Signal*, Uint32, Uint32);
2571 void restartDropObj_commit_start_done(Signal*, Uint32, Uint32);
2572 void restartDropObj_commit_complete_done(Signal*, Uint32, Uint32);
2573
2574 void restart_checkSchemaStatusComplete(Signal*, Uint32 callback, Uint32);
2575 void restart_writeSchemaConf(Signal*, Uint32 callbackData, Uint32);
2576 void masterRestart_checkSchemaStatusComplete(Signal*, Uint32, Uint32);
2577
2578 void sendSchemaComplete(Signal*, Uint32 callbackData, Uint32);
2579
2580 void execCREATE_OBJ_REQ(Signal* signal);
2581 void execCREATE_OBJ_REF(Signal* signal);
2582 void execCREATE_OBJ_CONF(Signal* signal);
2583
2584 void createObj_prepare_start_done(Signal* signal, Uint32 callback, Uint32);
2585 void createObj_writeSchemaConf1(Signal* signal, Uint32 callback, Uint32);
2586 void createObj_writeObjConf(Signal* signal, Uint32 callbackData, Uint32);
2587 void createObj_prepare_complete_done(Signal*, Uint32 callbackData, Uint32);
2588 void createObj_commit_start_done(Signal* signal, Uint32 callback, Uint32);
2589 void createObj_writeSchemaConf2(Signal* signal, Uint32 callbackData, Uint32);
2590 void createObj_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
2591 void createObj_abort(Signal*, struct CreateObjReq*);
2592 void createObj_abort_start_done(Signal*, Uint32 callbackData, Uint32);
2593 void createObj_abort_writeSchemaConf(Signal*, Uint32 callbackData, Uint32);
2594 void createObj_abort_complete_done(Signal*, Uint32 callbackData, Uint32);
2595
2596 void schemaOp_reply(Signal* signal, SchemaTransaction *, Uint32);
2597 void trans_commit_start_done(Signal*, Uint32 callbackData, Uint32);
2598 void trans_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
2599 void trans_abort_start_done(Signal*, Uint32 callbackData, Uint32);
2600 void trans_abort_complete_done(Signal*, Uint32 callbackData, Uint32);
2601
2602 void execDROP_OBJ_REQ(Signal* signal);
2603 void execDROP_OBJ_REF(Signal* signal);
2604 void execDROP_OBJ_CONF(Signal* signal);
2605
2606 void dropObj_prepare_start_done(Signal* signal, Uint32 callback, Uint32);
2607 void dropObj_prepare_writeSchemaConf(Signal*, Uint32 callback, Uint32);
2608 void dropObj_prepare_complete_done(Signal*, Uint32 callbackData, Uint32);
2609 void dropObj_commit_start_done(Signal*, Uint32 callbackData, Uint32);
2610 void dropObj_commit_writeSchemaConf(Signal*, Uint32 callback, Uint32);
2611 void dropObj_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
2612 void dropObj_abort_start_done(Signal*, Uint32 callbackData, Uint32);
2613 void dropObj_abort_writeSchemaConf(Signal*, Uint32 callback, Uint32);
2614 void dropObj_abort_complete_done(Signal*, Uint32 callbackData, Uint32);
2615
2616 void restartCreateObj(Signal*, Uint32,
2617 const SchemaFile::TableEntry *,
2618 const SchemaFile::TableEntry *, bool);
2619 void restartCreateObj_readConf(Signal*, Uint32, Uint32);
2620 void restartCreateObj_getTabInfoConf(Signal*);
2621 void restartCreateObj_prepare_start_done(Signal*, Uint32, Uint32);
2622 void restartCreateObj_write_complete(Signal*, Uint32, Uint32);
2623 void restartCreateObj_prepare_complete_done(Signal*, Uint32, Uint32);
2624 void restartCreateObj_commit_start_done(Signal*, Uint32, Uint32);
2625 void restartCreateObj_commit_complete_done(Signal*, Uint32, Uint32);
2626
2627 void execDICT_COMMIT_REQ(Signal*);
2628 void execDICT_COMMIT_REF(Signal*);
2629 void execDICT_COMMIT_CONF(Signal*);
2630
2631 void execDICT_ABORT_REQ(Signal*);
2632 void execDICT_ABORT_REF(Signal*);
2633 void execDICT_ABORT_CONF(Signal*);
2634
2635 public:
2636 void createObj_commit(Signal*, struct SchemaOp*);
2637 void createObj_abort(Signal*, struct SchemaOp*);
2638
2639 void create_fg_prepare_start(Signal* signal, SchemaOp*);
2640 void create_fg_prepare_complete(Signal* signal, SchemaOp*);
2641 void create_fg_abort_start(Signal* signal, SchemaOp*);
2642 void create_fg_abort_complete(Signal* signal, SchemaOp*);
2643
2644 void create_file_prepare_start(Signal* signal, SchemaOp*);
2645 void create_file_prepare_complete(Signal* signal, SchemaOp*);
2646 void create_file_commit_start(Signal* signal, SchemaOp*);
2647 void create_file_abort_start(Signal* signal, SchemaOp*);
2648 void create_file_abort_complete(Signal* signal, SchemaOp*);
2649
2650 void dropObj_commit(Signal*, struct SchemaOp*);
2651 void dropObj_abort(Signal*, struct SchemaOp*);
2652 void drop_file_prepare_start(Signal* signal, SchemaOp*);
2653 void drop_file_commit_start(Signal* signal, SchemaOp*);
2654 void drop_file_commit_complete(Signal* signal, SchemaOp*);
2655 void drop_file_abort_start(Signal* signal, SchemaOp*);
2656 void send_drop_file(Signal*, SchemaOp*, DropFileImplReq::RequestInfo);
2657
2658 void drop_fg_prepare_start(Signal* signal, SchemaOp*);
2659 void drop_fg_commit_start(Signal* signal, SchemaOp*);
2660 void drop_fg_commit_complete(Signal* signal, SchemaOp*);
2661 void drop_fg_abort_start(Signal* signal, SchemaOp*);
2662 void send_drop_fg(Signal*, SchemaOp*, DropFilegroupImplReq::RequestInfo);
2663
2664 void drop_undofile_prepare_start(Signal* signal, SchemaOp*);
2665 void drop_undofile_commit_complete(Signal* signal, SchemaOp*);
2666
2667 int checkSingleUserMode(Uint32 senderRef);
2668 };
2669
2670 inline bool
isTable() const2671 Dbdict::TableRecord::isTable() const
2672 {
2673 return DictTabInfo::isTable(tableType);
2674 }
2675
2676 inline bool
isIndex() const2677 Dbdict::TableRecord::isIndex() const
2678 {
2679 return DictTabInfo::isIndex(tableType);
2680 }
2681
2682 inline bool
isUniqueIndex() const2683 Dbdict::TableRecord::isUniqueIndex() const
2684 {
2685 return DictTabInfo::isUniqueIndex(tableType);
2686 }
2687
2688 inline bool
isNonUniqueIndex() const2689 Dbdict::TableRecord::isNonUniqueIndex() const
2690 {
2691 return DictTabInfo::isNonUniqueIndex(tableType);
2692 }
2693
2694 inline bool
isHashIndex() const2695 Dbdict::TableRecord::isHashIndex() const
2696 {
2697 return DictTabInfo::isHashIndex(tableType);
2698 }
2699
2700 inline bool
isOrderedIndex() const2701 Dbdict::TableRecord::isOrderedIndex() const
2702 {
2703 return DictTabInfo::isOrderedIndex(tableType);
2704 }
2705
2706
2707 #endif
2708