1 /* Copyright (c) 2003-2008 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
20 * Dict : Dictionary Block
22 #include <ndb_limits.h>
23 #include <trigger_definitions.h>
25 #include <DLHashTable.hpp>
26 #include <DLFifoList.hpp>
28 #include <KeyTable.hpp>
29 #include <KeyTable2.hpp>
30 #include <KeyTable2Ref.hpp>
31 #include <SimulatedBlock.hpp>
32 #include <SimpleProperties.hpp>
33 #include <SignalCounter.hpp>
34 #include <Bitmask.hpp>
35 #include <AttributeList.hpp>
36 #include <signaldata/GetTableId.hpp>
37 #include <signaldata/GetTabInfo.hpp>
38 #include <signaldata/DictTabInfo.hpp>
39 #include <signaldata/CreateTable.hpp>
40 #include <signaldata/CreateTab.hpp>
41 #include <signaldata/DropTable.hpp>
42 #include <signaldata/AlterTable.hpp>
43 #include <signaldata/AlterTab.hpp>
44 #include <signaldata/CreateIndx.hpp>
45 #include <signaldata/DropIndx.hpp>
46 #include <signaldata/AlterIndx.hpp>
47 #include <signaldata/BuildIndx.hpp>
48 #include <signaldata/UtilPrepare.hpp>
49 #include <signaldata/CreateEvnt.hpp>
50 #include <signaldata/CreateTrig.hpp>
51 #include <signaldata/DropTrig.hpp>
52 #include <signaldata/AlterTrig.hpp>
53 #include <signaldata/DictLock.hpp>
54 #include <signaldata/SumaImpl.hpp>
55 #include "SchemaFile.hpp"
56 #include <blocks/mutexes.hpp>
57 #include <SafeCounter.hpp>
58 #include <RequestTracker.hpp>
60 #include <signaldata/DictObjOp.hpp>
61 #include <signaldata/DropFilegroupImpl.hpp>
67 /*--------------------------------------------------------------*/
68 // Constants for CONTINUEB
69 /*--------------------------------------------------------------*/
70 #define ZPACK_TABLE_INTO_PAGES 0
71 #define ZSEND_GET_TAB_RESPONSE 3
72 #define ZDICT_LOCK_POLL 4
75 /*--------------------------------------------------------------*/
76 // Other constants in alphabetical order
77 /*--------------------------------------------------------------*/
78 #define ZNOMOREPHASES 255
80 /*--------------------------------------------------------------*/
81 // Schema file defines
82 /*--------------------------------------------------------------*/
83 #define ZSCHEMA_WORDS 4
85 /*--------------------------------------------------------------*/
87 /*--------------------------------------------------------------*/
88 #define ZBAT_SCHEMA_FILE 0 //Variable number of page for NDBFS
89 #define ZBAT_TABLE_FILE 1 //Variable number of page for NDBFS
90 #define ZPAGE_HEADER_SIZE 32
91 #define ZPOS_PAGE_SIZE 16
92 #define ZPOS_CHECKSUM 17
93 #define ZPOS_VERSION 18
94 #define ZPOS_PAGE_HEADER_SIZE 19
96 /*--------------------------------------------------------------*/
98 /*--------------------------------------------------------------*/
99 #define ZFS_CONNECT_SIZE 4
100 #define ZSIZE_OF_PAGES_IN_WORDS 8192
101 #define ZLOG_SIZE_OF_PAGES_IN_WORDS 13
102 #define ZMAX_PAGES_OF_TABLE_DEFINITION 8
103 #define ZNUMBER_OF_PAGES (ZMAX_PAGES_OF_TABLE_DEFINITION + 1)
104 #define ZNO_OF_FRAGRECORD 5
106 /*--------------------------------------------------------------*/
108 /*--------------------------------------------------------------*/
109 #define ZNODE_FAILURE_ERROR 704
113 * Systable NDB$EVENTS_0
115 #define EVENT_SYSTEM_TABLE_LENGTH 8
117 struct sysTab_NDBEVENTS_0
{
118 char NAME
[MAX_TAB_NAME_SIZE
];
122 char TABLE_NAME
[MAX_TAB_NAME_SIZE
];
123 Uint32 ATTRIBUTE_MASK
[MAXNROFATTRIBUTESINWORDS
];
129 * DICT - This blocks handles all metadata
131 class Dbdict
: public SimulatedBlock
{
134 * 2.3 RECORD AND FILESIZES
138 * Table attributes. Permanent data.
140 * Indexes have an attribute list which duplicates primary table
141 * attributes. This is wrong but convenient.
143 struct AttributeRecord
{
149 /* Attribute number within tuple key (counted from 1) */
152 /* Attribute name (unique within table) */
153 RopeHandle attributeName
;
155 /* Attribute description (old-style packed descriptor) */
156 Uint32 attributeDescriptor
;
158 /* Extended attributes */
164 /* Autoincrement flag, only for ODBC/SQL */
167 /* Default value as null-terminated string, only for ODBC/SQL */
168 RopeHandle defaultValue
;
172 const char * m_name_ptr
;
184 Uint32
hashValue() const { return attributeName
.hashValue();}
185 bool equal(const AttributeRecord
& obj
) const {
186 if(obj
.hashValue() == hashValue()){
187 ConstRope
r(* m_key
.m_pool
, obj
.attributeName
);
188 return r
.compare(m_key
.m_name_ptr
, m_key
.m_name_len
) == 0;
193 /** Singly linked in internal (attributeId) order */
194 // TODO use DL template when possible to have more than 1
195 Uint32 nextAttributeIdPtrI
;
197 typedef Ptr
<AttributeRecord
> AttributeRecordPtr
;
198 ArrayPool
<AttributeRecord
> c_attributeRecordPool
;
199 DLHashTable
<AttributeRecord
> c_attributeRecordHash
;
202 * Shared table / index record. Most of this is permanent data stored
203 * on disk. Index trigger ids are volatile.
211 /* Table id (array index in DICT and other blocks) */
215 /* Table version (incremented when tableId is re-used) */
218 /* Table name (may not be unique under "alter table") */
219 RopeHandle tableName
;
221 /* Type of table or index */
222 DictTabInfo::TableType tableType
;
224 /* Is table or index online (this flag is not used in DICT) */
227 /* Primary table of index otherwise RNIL */
228 Uint32 primaryTableId
;
230 /* Type of fragmentation (small/medium/large) */
231 DictTabInfo::FragmentType fragmentType
;
233 /* Global checkpoint identity when table created */
234 Uint32 gciTableCreated
;
236 /* Is the table logged (i.e. data survives system restart) */
241 TR_RowChecksum
= 0x4,
243 TR_ForceVarPart
= 0x10
247 /* Number of attibutes in table */
248 Uint16 noOfAttributes
;
250 /* Number of null attributes in table (should be computed) */
253 /* Number of primary key attributes (should be computed) */
256 /* Length of primary key in words (should be computed) */
257 /* For ordered index this is tree node size in words */
263 /* K value for LH**3 algorithm (only 6 allowed currently) */
266 /* Local key length in words (currently 1) */
270 * Parameter for hash algorithm that specifies the load factor in
271 * percentage of fill level in buckets. A high value means we are
272 * splitting early and that buckets are only lightly used. A high
273 * value means that we have fill the buckets more and get more
274 * likelihood of overflow buckets.
279 Flag to indicate default number of partitions
281 bool defaultNoPartFlag
;
284 Flag to indicate using linear hash function
289 * Used when shrinking to decide when to merge buckets. Hysteresis
290 * is thus possible. Should be smaller but not much smaller than
295 /* Convenience routines */
296 bool isTable() const;
297 bool isIndex() const;
298 bool isUniqueIndex() const;
299 bool isNonUniqueIndex() const;
300 bool isHashIndex() const;
301 bool isOrderedIndex() const;
303 /****************************************************
304 * Support variables for table handling
305 ****************************************************/
307 /* Active page which is sent to disk */
310 /** File pointer received from disk */
313 /** Pointer to first attribute in table */
314 DLFifoList
<AttributeRecord
>::Head m_attributes
;
316 /* Pointer to first page of table description */
325 PREPARE_DROPPING
= 5,
331 /* State when returning from TC_SCHVERREQ */
332 enum TabReturnState
{
335 SLAVE_SYSTEM_RESTART
= 2,
336 MASTER_SYSTEM_RESTART
= 3
338 TabReturnState tabReturnState
;
340 /** Number of words */
343 /** Index state (volatile data) */
345 IS_UNDEFINED
= 0, // initial
346 IS_OFFLINE
= 1, // index table created
347 IS_BUILDING
= 2, // building (local state)
348 IS_DROPPING
= 3, // dropping (local state)
349 IS_ONLINE
= 4, // online
350 IS_BROKEN
= 9 // build or drop aborted
352 IndexState indexState
;
354 /** Trigger ids of index (volatile data) */
355 Uint32 insertTriggerId
;
356 Uint32 updateTriggerId
;
357 Uint32 deleteTriggerId
;
358 Uint32 customTriggerId
; // ordered index
359 Uint32 buildTriggerId
; // temp during build
361 /** Index state in other blocks on this node */
363 IL_CREATED_TC
= 1 << 0 // created in TC
369 /** frm data for this table */
373 RopeHandle rangeData
;
375 Uint32 fragmentCount
;
376 Uint32 m_tablespace_id
;
379 * Access rights to table during single user mode
381 Uint8 singleUserMode
;
384 typedef Ptr
<TableRecord
> TableRecordPtr
;
385 ArrayPool
<TableRecord
> c_tableRecordPool
;
387 /** Node Group and Tablespace id+version + range or list data.
388 * This is only stored temporarily in DBDICT during an ongoing
390 * TODO RONM: Look into improvements of this
392 Uint32 c_fragDataLen
;
393 Uint16 c_fragData
[MAX_NDB_PARTITIONS
];
394 Uint32 c_tsIdData
[2*MAX_NDB_PARTITIONS
];
397 * Triggers. This is volatile data not saved on disk. Setting a
398 * trigger online creates the trigger in TC (if index) and LQH-TUP.
400 struct TriggerRecord
{
407 TS_OFFLINE
= 2, // created globally in DICT
410 TS_ONLINE
= 5 // activated globally
412 TriggerState triggerState
;
414 /** Trigger state in other blocks on this node */
416 TL_CREATED_TC
= 1 << 0, // created in TC
417 TL_CREATED_LQH
= 1 << 1 // created in LQH-TUP
421 /** Trigger name, used by DICT to identify the trigger */
422 RopeHandle triggerName
;
424 /** Trigger id, used by TRIX, TC, LQH, and TUP to identify the trigger */
428 /** Table id, the table the trigger is defined on */
431 /** Trigger type, defines what the trigger is used for */
432 TriggerType::Value triggerType
;
434 /** Trigger action time, defines when the trigger should fire */
435 TriggerActionTime::Value triggerActionTime
;
437 /** Trigger event, defines what events the trigger should monitor */
438 TriggerEvent::Value triggerEvent
;
440 /** Monitor all replicas */
441 bool monitorReplicas
;
443 /** Monitor all, the trigger monitors changes of all attributes in table */
444 bool monitorAllAttributes
;
446 /** Monitor all, the trigger monitors changes of all attributes in table */
447 bool reportAllMonitoredAttributes
;
450 * Attribute mask, defines what attributes are to be monitored.
451 * Can be seen as a compact representation of SQL column name list.
453 AttributeMask attributeMask
;
455 /** Index id, only used by secondary_index triggers */
458 /** Pointer to the next attribute used by ArrayPool */
462 Uint32 c_maxNoOfTriggers
;
463 typedef Ptr
<TriggerRecord
> TriggerRecordPtr
;
464 ArrayPool
<TriggerRecord
> c_triggerRecordPool
;
467 * Information for each FS connection.
468 ***************************************************************************/
469 struct FsConnectRecord
{
472 OPEN_WRITE_SCHEMA
= 1,
474 CLOSE_WRITE_SCHEMA
= 3,
475 OPEN_READ_SCHEMA1
= 4,
476 OPEN_READ_SCHEMA2
= 5,
479 CLOSE_READ_SCHEMA
= 8,
480 OPEN_READ_TAB_FILE1
= 9,
481 OPEN_READ_TAB_FILE2
= 10,
484 CLOSE_READ_TAB_FILE
= 13,
485 OPEN_WRITE_TAB_FILE
= 14,
487 CLOSE_WRITE_TAB_FILE
= 16
489 /** File Pointer for this file system connection */
492 /** Reference of owner record */
495 /** State of file system connection */
498 /** Used by Array Pool for free list handling */
502 typedef Ptr
<FsConnectRecord
> FsConnectRecordPtr
;
503 ArrayPool
<FsConnectRecord
> c_fsConnectRecordPool
;
506 * This record stores all the information about a node and all its attributes
507 ***************************************************************************/
518 typedef Ptr
<NodeRecord
> NodeRecordPtr
;
519 CArray
<NodeRecord
> c_nodes
;
520 NdbNodeBitmask c_aliveNodes
;
526 typedef Ptr
<PageRecord
> PageRecordPtr
;
527 CArray
<PageRecord
> c_pageRecordArray
;
529 struct SchemaPageRecord
{
530 Uint32 word
[NDB_SF_PAGE_SIZE_IN_WORDS
];
533 CArray
<SchemaPageRecord
> c_schemaPageRecordArray
;
535 DictTabInfo::Table c_tableDesc
;
538 * A page for create index table signal.
540 PageRecord c_indexPage
;
549 Uint32 m_filegroup_id
;
560 Uint32 nextHash
, prevHash
;
562 Uint32
hashValue() const { return key
;}
563 bool equal(const File
& obj
) const { return key
== obj
.key
;}
565 typedef Ptr
<File
> FilePtr
;
566 typedef RecordPool
<File
, RWPool
> File_pool
;
567 typedef DLListImpl
<File_pool
, File
> File_list
;
568 typedef LocalDLListImpl
<File_pool
, File
> Local_file_list
;
569 typedef KeyTableImpl
<File_pool
, File
> File_hash
;
584 Uint32 m_extent_size
;
585 Uint32 m_default_logfile_group_id
;
589 Uint32 m_undo_buffer_size
;
590 File_list::HeadPOD m_files
;
601 Uint32
hashValue() const { return key
;}
602 bool equal(const Filegroup
& obj
) const { return key
== obj
.key
;}
604 typedef Ptr
<Filegroup
> FilegroupPtr
;
605 typedef RecordPool
<Filegroup
, RWPool
> Filegroup_pool
;
606 typedef KeyTableImpl
<Filegroup_pool
, Filegroup
> Filegroup_hash
;
608 File_pool c_file_pool
;
609 Filegroup_pool c_filegroup_pool
;
610 File_hash c_file_hash
;
611 Filegroup_hash c_filegroup_hash
;
613 RopePool c_rope_pool
;
624 const char * m_name_ptr
;
633 Uint32
hashValue() const { return m_name
.hashValue();}
634 bool equal(const DictObject
& obj
) const {
635 if(obj
.hashValue() == hashValue()){
636 ConstRope
r(* m_key
.m_pool
, obj
.m_name
);
637 return r
.compare(m_key
.m_name_ptr
, m_key
.m_name_len
) == 0;
643 DLHashTable
<DictObject
> c_obj_hash
; // Name
644 ArrayPool
<DictObject
> c_obj_pool
;
646 DictObject
* get_object(const char * name
){
647 return get_object(name
, strlen(name
) + 1);
650 DictObject
* get_object(const char * name
, Uint32 len
){
651 return get_object(name
, len
, Rope::hash(name
, len
));
654 DictObject
* get_object(const char * name
, Uint32 len
, Uint32 hash
);
656 void release_object(Uint32 obj_ptr_i
){
657 release_object(obj_ptr_i
, c_obj_pool
.getPtr(obj_ptr_i
));
660 void release_object(Uint32 obj_ptr_i
, DictObject
* obj_ptr_p
);
662 void increase_ref_count(Uint32 obj_ptr_i
);
663 void decrease_ref_count(Uint32 obj_ptr_i
);
666 Dbdict(Block_context
& ctx
);
670 BLOCK_DEFINES(Dbdict
);
673 void execDICTSTARTREQ(Signal
* signal
);
675 void execGET_TABINFOREQ(Signal
* signal
);
676 void execGET_TABLEDID_REQ(Signal
* signal
);
677 void execGET_TABINFO_REF(Signal
* signal
);
678 void execGET_TABINFO_CONF(Signal
* signal
);
679 void execCONTINUEB(Signal
* signal
);
681 void execDUMP_STATE_ORD(Signal
* signal
);
682 void execHOT_SPAREREP(Signal
* signal
);
683 void execDIADDTABCONF(Signal
* signal
);
684 void execDIADDTABREF(Signal
* signal
);
685 void execTAB_COMMITCONF(Signal
* signal
);
686 void execTAB_COMMITREF(Signal
* signal
);
687 void execGET_SCHEMA_INFOREQ(Signal
* signal
);
688 void execSCHEMA_INFO(Signal
* signal
);
689 void execSCHEMA_INFOCONF(Signal
* signal
);
690 void execREAD_NODESCONF(Signal
* signal
);
691 void execFSCLOSECONF(Signal
* signal
);
692 void execFSOPENCONF(Signal
* signal
);
693 void execFSOPENREF(Signal
* signal
);
694 void execFSREADCONF(Signal
* signal
);
695 void execFSREADREF(Signal
* signal
);
696 void execFSWRITECONF(Signal
* signal
);
697 void execNDB_STTOR(Signal
* signal
);
698 void execREAD_CONFIG_REQ(Signal
* signal
);
699 void execSTTOR(Signal
* signal
);
700 void execTC_SCHVERCONF(Signal
* signal
);
701 void execNODE_FAILREP(Signal
* signal
);
702 void execINCL_NODEREQ(Signal
* signal
);
703 void execAPI_FAILREQ(Signal
* signal
);
705 void execWAIT_GCP_REF(Signal
* signal
);
706 void execWAIT_GCP_CONF(Signal
* signal
);
708 void execLIST_TABLES_REQ(Signal
* signal
);
711 void execCREATE_INDX_REQ(Signal
* signal
);
712 void execCREATE_INDX_CONF(Signal
* signal
);
713 void execCREATE_INDX_REF(Signal
* signal
);
715 void execALTER_INDX_REQ(Signal
* signal
);
716 void execALTER_INDX_CONF(Signal
* signal
);
717 void execALTER_INDX_REF(Signal
* signal
);
719 void execCREATE_TABLE_CONF(Signal
* signal
);
720 void execCREATE_TABLE_REF(Signal
* signal
);
722 void execDROP_INDX_REQ(Signal
* signal
);
723 void execDROP_INDX_CONF(Signal
* signal
);
724 void execDROP_INDX_REF(Signal
* signal
);
726 void execDROP_TABLE_CONF(Signal
* signal
);
727 void execDROP_TABLE_REF(Signal
* signal
);
729 void execBUILDINDXREQ(Signal
* signal
);
730 void execBUILDINDXCONF(Signal
* signal
);
731 void execBUILDINDXREF(Signal
* signal
);
733 void execBACKUP_FRAGMENT_REQ(Signal
*);
735 // Util signals used by Event code
736 void execUTIL_PREPARE_CONF(Signal
* signal
);
737 void execUTIL_PREPARE_REF (Signal
* signal
);
738 void execUTIL_EXECUTE_CONF(Signal
* signal
);
739 void execUTIL_EXECUTE_REF (Signal
* signal
);
740 void execUTIL_RELEASE_CONF(Signal
* signal
);
741 void execUTIL_RELEASE_REF (Signal
* signal
);
744 // Event signals from API
745 void execCREATE_EVNT_REQ (Signal
* signal
);
746 void execCREATE_EVNT_CONF(Signal
* signal
);
747 void execCREATE_EVNT_REF (Signal
* signal
);
749 void execDROP_EVNT_REQ (Signal
* signal
);
751 void execSUB_START_REQ (Signal
* signal
);
752 void execSUB_START_CONF (Signal
* signal
);
753 void execSUB_START_REF (Signal
* signal
);
755 void execSUB_STOP_REQ (Signal
* signal
);
756 void execSUB_STOP_CONF (Signal
* signal
);
757 void execSUB_STOP_REF (Signal
* signal
);
759 // Event signals from SUMA
761 void execCREATE_SUBID_CONF(Signal
* signal
);
762 void execCREATE_SUBID_REF (Signal
* signal
);
764 void execSUB_CREATE_CONF(Signal
* signal
);
765 void execSUB_CREATE_REF (Signal
* signal
);
767 void execSUB_REMOVE_REQ(Signal
* signal
);
768 void execSUB_REMOVE_CONF(Signal
* signal
);
769 void execSUB_REMOVE_REF(Signal
* signal
);
772 void execCREATE_TRIG_REQ(Signal
* signal
);
773 void execCREATE_TRIG_CONF(Signal
* signal
);
774 void execCREATE_TRIG_REF(Signal
* signal
);
775 void execALTER_TRIG_REQ(Signal
* signal
);
776 void execALTER_TRIG_CONF(Signal
* signal
);
777 void execALTER_TRIG_REF(Signal
* signal
);
778 void execDROP_TRIG_REQ(Signal
* signal
);
779 void execDROP_TRIG_CONF(Signal
* signal
);
780 void execDROP_TRIG_REF(Signal
* signal
);
782 void execDROP_TABLE_REQ(Signal
* signal
);
784 void execPREP_DROP_TAB_REQ(Signal
* signal
);
785 void execPREP_DROP_TAB_REF(Signal
* signal
);
786 void execPREP_DROP_TAB_CONF(Signal
* signal
);
788 void execDROP_TAB_REQ(Signal
* signal
);
789 void execDROP_TAB_REF(Signal
* signal
);
790 void execDROP_TAB_CONF(Signal
* signal
);
792 void execCREATE_TABLE_REQ(Signal
* signal
);
793 void execALTER_TABLE_REQ(Signal
* signal
);
794 void execCREATE_FRAGMENTATION_REF(Signal
*);
795 void execCREATE_FRAGMENTATION_CONF(Signal
*);
796 void execCREATE_TAB_REQ(Signal
* signal
);
797 void execADD_FRAGREQ(Signal
* signal
);
798 void execLQHFRAGREF(Signal
* signal
);
799 void execLQHFRAGCONF(Signal
* signal
);
800 void execLQHADDATTREF(Signal
* signal
);
801 void execLQHADDATTCONF(Signal
* signal
);
802 void execCREATE_TAB_REF(Signal
* signal
);
803 void execCREATE_TAB_CONF(Signal
* signal
);
804 void execALTER_TAB_REQ(Signal
* signal
);
805 void execALTER_TAB_REF(Signal
* signal
);
806 void execALTER_TAB_CONF(Signal
* signal
);
807 bool check_ndb_versions() const;
809 void execCREATE_FILE_REQ(Signal
* signal
);
810 void execCREATE_FILEGROUP_REQ(Signal
* signal
);
811 void execDROP_FILE_REQ(Signal
* signal
);
812 void execDROP_FILEGROUP_REQ(Signal
* signal
);
815 void execCREATE_FILE_REF(Signal
* signal
);
816 void execCREATE_FILE_CONF(Signal
* signal
);
817 void execCREATE_FILEGROUP_REF(Signal
* signal
);
818 void execCREATE_FILEGROUP_CONF(Signal
* signal
);
819 void execDROP_FILE_REF(Signal
* signal
);
820 void execDROP_FILE_CONF(Signal
* signal
);
821 void execDROP_FILEGROUP_REF(Signal
* signal
);
822 void execDROP_FILEGROUP_CONF(Signal
* signal
);
824 void execDICT_LOCK_REQ(Signal
* signal
);
825 void execDICT_UNLOCK_ORD(Signal
* signal
);
828 * 2.4 COMMON STORED VARIABLES
832 * This record stores all the state needed
833 * when the schema page is being sent to other nodes
834 ***************************************************************************/
835 struct SendSchemaRecord
{
836 /** Number of words of schema data */
838 /** Page Id of schema data */
842 SignalCounter m_SCHEMAINFO_Counter
;
844 Uint32 noOfWordsCurrentlySent
;
845 Uint32 noOfSignalsSentSinceDelay
;
849 SendSchemaRecord c_sendSchemaRecord
;
852 * This record stores all the state needed
853 * when a table file is being read from disk
854 ****************************************************************************/
855 struct ReadTableRecord
{
856 /** Number of Pages */
860 /** Table Id of read table */
866 ReadTableRecord c_readTableRecord
;
869 * This record stores all the state needed
870 * when a table file is being written to disk
871 ****************************************************************************/
872 struct WriteTableRecord
{
873 /** Number of Pages */
877 /** Table Files Handled, local state variable */
878 Uint32 noOfTableFilesHandled
;
879 /** Table Id of written table */
881 /** State, indicates from where it was called */
882 enum TableWriteState
{
884 WRITE_ADD_TABLE_MASTER
= 1,
885 WRITE_ADD_TABLE_SLAVE
= 2,
886 WRITE_RESTART_FROM_MASTER
= 3,
887 WRITE_RESTART_FROM_OWN
= 4,
890 TableWriteState tableWriteState
;
893 WriteTableRecord c_writeTableRecord
;
896 * This record stores all the state needed
897 * when a schema file is being read from disk
898 ****************************************************************************/
899 struct ReadSchemaRecord
{
900 /** Page Id of schema page */
902 /** First page to read */
904 /** Number of pages to read */
906 /** State, indicates from where it was called */
907 enum SchemaReadState
{
909 INITIAL_READ_HEAD
= 1,
912 SchemaReadState schemaReadState
;
914 ReadSchemaRecord c_readSchemaRecord
;
917 * This record stores all the state needed
918 * when a schema file is being written to disk
919 ****************************************************************************/
920 struct WriteSchemaRecord
{
921 /** Page Id of schema page */
923 /** Rewrite entire file */
925 /** First page to write */
927 /** Number of pages to write */
929 /** Schema Files Handled, local state variable */
930 Uint32 noOfSchemaFilesHandled
;
935 WriteSchemaRecord c_writeSchemaRecord
;
938 * This record stores all the information needed
939 * when a file is being read from disk
940 ****************************************************************************/
941 struct RestartRecord
{
942 /** Global check point identity */
945 /** The active table at restart process */
948 /** The active table at restart process */
949 BlockReference returnBlockRef
;
951 Uint32 m_pass
; // 0 tablespaces/logfilegroups, 1 tables, 2 indexes
953 RestartRecord c_restartRecord
;
956 * This record stores all the information needed
957 * when a file is being read from disk
958 ****************************************************************************/
959 struct RetrieveRecord
{
960 RetrieveRecord(){ noOfWaiters
= 0;}
962 /** Only one retrieve table definition at a time */
966 * No of waiting in time queue
970 /** Block Reference of retriever */
971 BlockReference blockRef
;
973 /** Id of retriever */
976 /** Table id of retrieved table */
981 /** Starting page to retrieve data from */
984 /** Number of pages retrieved */
985 Uint32 retrievedNoOfPages
;
987 /** Number of words retrieved */
988 Uint32 retrievedNoOfWords
;
990 /** Number of words sent currently */
998 RetrieveRecord c_retrieveRecord
;
1001 * This record stores all the information needed
1002 * when a file is being read from disk
1004 * This is the info stored in one entry of the schema
1005 * page. Each table has 4 words of info.
1006 * Word 1: Schema version (upper 16 bits)
1007 * Table State (lower 16 bits)
1008 * Word 2: Number of pages of table description
1009 * Word 3: Global checkpoint id table was created
1010 * Word 4: Currently zero
1011 ****************************************************************************/
1012 struct SchemaRecord
{
1013 /** Schema file first page (0) */
1016 /** Old Schema file first page (used at node restart) */
1017 Uint32 oldSchemaPage
;
1019 Callback m_callback
;
1021 SchemaRecord c_schemaRecord
;
1024 * Schema file, list of schema pages. Use an array until a pool
1025 * exists and NDBFS interface can use it.
1027 struct XSchemaFile
{
1028 SchemaFile
* schemaPage
;
1032 XSchemaFile c_schemaFile
[2];
1034 void initSchemaFile(XSchemaFile
*, Uint32 firstPage
, Uint32 lastPage
,
1036 void resizeSchemaFile(XSchemaFile
* xsf
, Uint32 noOfPages
);
1037 void computeChecksum(XSchemaFile
*, Uint32 pageNo
);
1038 bool validateChecksum(const XSchemaFile
*);
1039 SchemaFile::TableEntry
* getTableEntry(XSchemaFile
*, Uint32 tableId
);
1041 Uint32
computeChecksum(const Uint32
* src
, Uint32 len
);
1044 /* ----------------------------------------------------------------------- */
1046 /* ----------------------------------------------------------------------- */
1047 Uint16 c_masterNodeId
;
1049 /* ----------------------------------------------------------------------- */
1050 // Various current system properties
1051 /* ----------------------------------------------------------------------- */
1052 Uint16 c_numberNode
;
1053 Uint16 c_noHotSpareNodes
;
1054 Uint16 c_noNodesFailed
;
1057 /* ----------------------------------------------------------------------- */
1059 /* ----------------------------------------------------------------------- */
1061 #ifndef ndb_dbdict_log_block_state
1066 BS_NODE_FAILURE
= 3,
1069 #else // quick hack to log changes
1074 BS_NODE_FAILURE
= 3,
1078 friend struct BlockState
;
1083 BlockState(int value
) :
1086 operator int() const {
1089 BlockState
& operator=(const BlockState
& bs
) {
1090 Dbdict
* dict
= (Dbdict
*)globalData
.getBlock(DBDICT
);
1091 dict
->infoEvent("DICT: bs %d->%d", m_value
, bs
.m_value
);
1092 globalSignalLoggers
.log(DBDICT
, "bs %d->%d", m_value
, bs
.m_value
);
1093 m_value
= bs
.m_value
;
1099 BlockState c_blockState
;
1103 enum PackTableState
{
1110 Uint32 c_startPhase
;
1111 Uint32 c_restartType
;
1112 bool c_initialStart
;
1113 bool c_systemRestart
;
1115 bool c_initialNodeRestart
;
1116 Uint32 c_tabinfoReceived
;
1119 * Temporary structure used when parsing table info
1121 struct ParseDictTabInfoRecord
{
1122 DictTabInfo::RequestType requestType
;
1126 SimpleProperties::UnpackStatus status
;
1128 TableRecordPtr tablePtr
;
1131 // Operation records
1134 * Common part of operation records. Uses KeyTable2. Note that each
1135 * seize/release invokes ctor/dtor automatically.
1137 struct OpRecordCommon
{
1139 Uint32 key
; // key shared between master and slaves
1142 Uint32
hashValue() const {
1145 bool equal(const OpRecordCommon
& rec
) const {
1146 return key
== rec
.key
;
1151 * Create table record
1153 struct CreateTableRecord
: OpRecordCommon
{
1154 CreateTableRecord() {}
1156 Uint32 m_senderData
;
1157 Uint32 m_coordinatorRef
;
1160 void setErrorCode(Uint32 c
){ if(m_errorCode
== 0) m_errorCode
= c
;}
1163 Uint32 m_changeMask
;
1164 bool m_alterTableFailed
;
1165 AlterTableRef m_alterTableRef
;
1166 Uint32 m_alterTableId
;
1168 /* Previous table name (used for reverting failed table rename) */
1169 char previousTableName
[MAX_TAB_NAME_SIZE
];
1171 /* Previous table definition, frm (used for reverting) */
1172 /** TODO Could preferrably be made dynamic size */
1173 Uint32 previousFrmLen
;
1174 char previousFrmData
[MAX_FRM_DATA_SIZE
];
1177 Uint32 m_tabInfoPtrI
;
1178 Uint32 m_fragmentsPtrI
;
1180 Uint32 m_dihAddFragPtr
; // Connect ptr towards DIH
1181 Uint32 m_lqhFragPtr
; // Connect ptr towards LQH
1183 Callback m_callback
; // Who's using local create tab
1184 MutexHandle2
<DIH_START_LCP_MUTEX
> m_startLcpMutex
;
1186 struct CoordinatorData
{
1188 SafeCounterHandle m_counter
;
1189 CreateTabReq::RequestType m_requestType
;
1190 } m_coordinatorData
;
1192 typedef Ptr
<CreateTableRecord
> CreateTableRecordPtr
;
1197 struct DropTableRecord
: OpRecordCommon
{
1198 DropTableRecord() {}
1199 DropTableReq m_request
;
1201 Uint32 m_requestType
;
1202 Uint32 m_coordinatorRef
;
1205 void setErrorCode(Uint32 c
){ if(m_errorCode
== 0) m_errorCode
= c
;}
1207 MutexHandle2
<BACKUP_DEFINE_MUTEX
> m_define_backup_mutex
;
1210 * When sending stuff around
1212 struct CoordinatorData
{
1215 SignalCounter m_signalCounter
;
1216 } m_coordinatorData
;
1218 struct ParticipantData
{
1221 SignalCounter m_signalCounter
;
1223 Callback m_callback
;
1224 } m_participantData
;
1226 typedef Ptr
<DropTableRecord
> DropTableRecordPtr
;
1229 * Request flags passed in signals along with request type and
1230 * propagated across operations.
1232 struct RequestFlag
{
1234 RF_LOCAL
= 1 << 0, // create on local node only
1235 RF_NOBUILD
= 1 << 1, // no need to build index
1236 RF_NOTCTRIGGER
= 1 << 2, // alter trigger: no trigger in TC
1237 RF_FORCE
= 1 << 4 // force drop
1242 * Operation record for create index.
1244 struct OpCreateIndex
: OpRecordCommon
{
1245 // original request (index id will be added)
1246 CreateIndxReq m_request
;
1247 AttributeList m_attrList
;
1248 char m_indexName
[MAX_TAB_NAME_SIZE
];
1250 bool m_temporaryIndex
;
1252 Uint32 m_coordinatorRef
;
1255 CreateIndxReq::RequestType m_requestType
;
1256 Uint32 m_requestFlag
;
1258 CreateIndxRef::ErrorCode m_lastError
;
1259 CreateIndxRef::ErrorCode m_errorCode
;
1263 SignalCounter m_signalCounter
;
1266 memset(&m_request
, 0, sizeof(m_request
));
1267 m_coordinatorRef
= 0;
1268 m_requestType
= CreateIndxReq::RT_UNDEFINED
;
1270 m_lastError
= CreateIndxRef::NoError
;
1271 m_errorCode
= CreateIndxRef::NoError
;
1275 void save(const CreateIndxReq
* req
) {
1277 m_requestType
= req
->getRequestType();
1278 m_requestFlag
= req
->getRequestFlag();
1280 bool hasLastError() {
1281 return m_lastError
!= CreateIndxRef::NoError
;
1284 return m_errorCode
!= CreateIndxRef::NoError
;
1286 void setError(const CreateIndxRef
* ref
) {
1287 m_lastError
= CreateIndxRef::NoError
;
1289 m_lastError
= ref
->getErrorCode();
1291 m_errorCode
= m_lastError
;
1292 m_errorLine
= ref
->getErrorLine();
1293 m_errorNode
= ref
->getErrorNode();
1297 void setError(const CreateTableRef
* ref
) {
1298 m_lastError
= CreateIndxRef::NoError
;
1300 switch (ref
->getErrorCode()) {
1301 case CreateTableRef::TableAlreadyExist
:
1302 m_lastError
= CreateIndxRef::IndexExists
;
1305 m_lastError
= (CreateIndxRef::ErrorCode
)ref
->getErrorCode();
1309 m_errorCode
= m_lastError
;
1310 m_errorLine
= ref
->getErrorLine();
1314 void setError(const AlterIndxRef
* ref
) {
1315 m_lastError
= CreateIndxRef::NoError
;
1317 m_lastError
= (CreateIndxRef::ErrorCode
)ref
->getErrorCode();
1319 m_errorCode
= m_lastError
;
1320 m_errorLine
= ref
->getErrorLine();
1321 m_errorNode
= ref
->getErrorNode();
1326 typedef Ptr
<OpCreateIndex
> OpCreateIndexPtr
;
1329 * Operation record for drop index.
1331 struct OpDropIndex
: OpRecordCommon
{
1333 DropIndxReq m_request
;
1335 Uint32 m_coordinatorRef
;
1338 DropIndxReq::RequestType m_requestType
;
1339 Uint32 m_requestFlag
;
1341 DropIndxRef::ErrorCode m_lastError
;
1342 DropIndxRef::ErrorCode m_errorCode
;
1346 SignalCounter m_signalCounter
;
1349 memset(&m_request
, 0, sizeof(m_request
));
1350 m_coordinatorRef
= 0;
1351 m_requestType
= DropIndxReq::RT_UNDEFINED
;
1353 m_lastError
= DropIndxRef::NoError
;
1354 m_errorCode
= DropIndxRef::NoError
;
1358 void save(const DropIndxReq
* req
) {
1360 m_requestType
= req
->getRequestType();
1361 m_requestFlag
= req
->getRequestFlag();
1363 bool hasLastError() {
1364 return m_lastError
!= DropIndxRef::NoError
;
1367 return m_errorCode
!= DropIndxRef::NoError
;
1369 void setError(const DropIndxRef
* ref
) {
1370 m_lastError
= DropIndxRef::NoError
;
1372 m_lastError
= ref
->getErrorCode();
1374 m_errorCode
= ref
->getErrorCode();
1375 m_errorLine
= ref
->getErrorLine();
1376 m_errorNode
= ref
->getErrorNode();
1380 void setError(const AlterIndxRef
* ref
) {
1381 m_lastError
= DropIndxRef::NoError
;
1383 m_lastError
= (DropIndxRef::ErrorCode
)ref
->getErrorCode();
1385 m_errorCode
= m_lastError
;
1386 m_errorLine
= ref
->getErrorLine();
1387 m_errorNode
= ref
->getErrorNode();
1391 void setError(const DropTableRef
* ref
) {
1392 m_lastError
= DropIndxRef::NoError
;
1394 switch (ref
->errorCode
) {
1395 case DropTableRef::Busy
:
1396 m_lastError
= DropIndxRef::Busy
;
1398 case DropTableRef::NoSuchTable
:
1399 m_lastError
= DropIndxRef::IndexNotFound
;
1401 case DropTableRef::DropInProgress
:
1402 m_lastError
= DropIndxRef::Busy
;
1404 case DropTableRef::NoDropTableRecordAvailable
:
1405 m_lastError
= DropIndxRef::Busy
;
1408 m_lastError
= (DropIndxRef::ErrorCode
)ref
->errorCode
;
1412 m_errorCode
= m_lastError
;
1419 typedef Ptr
<OpDropIndex
> OpDropIndexPtr
;
1422 * Operation record for alter index.
1424 struct OpAlterIndex
: OpRecordCommon
{
1425 // original request plus buffer for attribute lists
1426 AlterIndxReq m_request
;
1427 AttributeList m_attrList
;
1428 AttributeList m_tableKeyList
;
1430 Uint32 m_coordinatorRef
;
1433 AlterIndxReq::RequestType m_requestType
;
1434 Uint32 m_requestFlag
;
1436 AlterIndxRef::ErrorCode m_lastError
;
1437 AlterIndxRef::ErrorCode m_errorCode
;
1441 SignalCounter m_signalCounter
;
1442 Uint32 m_triggerCounter
;
1445 memset(&m_request
, 0, sizeof(m_request
));
1446 m_coordinatorRef
= 0;
1447 m_requestType
= AlterIndxReq::RT_UNDEFINED
;
1449 m_lastError
= AlterIndxRef::NoError
;
1450 m_errorCode
= AlterIndxRef::NoError
;
1453 m_triggerCounter
= 0;
1455 void save(const AlterIndxReq
* req
) {
1457 m_requestType
= req
->getRequestType();
1458 m_requestFlag
= req
->getRequestFlag();
1460 bool hasLastError() {
1461 return m_lastError
!= AlterIndxRef::NoError
;
1464 return m_errorCode
!= AlterIndxRef::NoError
;
1466 void setError(const AlterIndxRef
* ref
) {
1467 m_lastError
= AlterIndxRef::NoError
;
1469 m_lastError
= ref
->getErrorCode();
1471 m_errorCode
= m_lastError
;
1472 m_errorLine
= ref
->getErrorLine();
1473 m_errorNode
= ref
->getErrorNode();
1477 void setError(const CreateIndxRef
* ref
) {
1478 m_lastError
= AlterIndxRef::NoError
;
1480 m_lastError
= (AlterIndxRef::ErrorCode
)ref
->getErrorCode();
1482 m_errorCode
= m_lastError
;
1483 m_errorLine
= ref
->getErrorLine();
1484 m_errorNode
= ref
->getErrorNode();
1488 void setError(const DropIndxRef
* ref
) {
1489 m_lastError
= AlterIndxRef::NoError
;
1491 m_lastError
= (AlterIndxRef::ErrorCode
)ref
->getErrorCode();
1493 m_errorCode
= m_lastError
;
1494 m_errorLine
= ref
->getErrorLine();
1495 m_errorNode
= ref
->getErrorNode();
1499 void setError(const BuildIndxRef
* ref
) {
1500 m_lastError
= AlterIndxRef::NoError
;
1502 m_lastError
= (AlterIndxRef::ErrorCode
)ref
->getErrorCode();
1504 m_errorCode
= m_lastError
;
1510 void setError(const CreateTrigRef
* ref
) {
1511 m_lastError
= AlterIndxRef::NoError
;
1513 m_lastError
= (AlterIndxRef::ErrorCode
)ref
->getErrorCode();
1515 m_errorCode
= m_lastError
;
1516 m_errorLine
= ref
->getErrorLine();
1517 m_errorNode
= ref
->getErrorNode();
1521 void setError(const DropTrigRef
* ref
) {
1522 m_lastError
= AlterIndxRef::NoError
;
1524 m_lastError
= (AlterIndxRef::ErrorCode
)ref
->getErrorCode();
1526 m_errorCode
= m_lastError
;
1527 m_errorLine
= ref
->getErrorLine();
1528 m_errorNode
= ref
->getErrorNode();
1533 typedef Ptr
<OpAlterIndex
> OpAlterIndexPtr
;
1536 * Operation record for build index.
1538 struct OpBuildIndex
: OpRecordCommon
{
1539 // original request plus buffer for attribute lists
1540 BuildIndxReq m_request
;
1541 AttributeList m_attrList
;
1542 Id_array
<MAX_ATTRIBUTES_IN_INDEX
+1> m_tableKeyList
;
1544 Uint32 m_coordinatorRef
;
1547 BuildIndxReq::RequestType m_requestType
;
1548 Uint32 m_requestFlag
;
1549 Uint32 m_constrTriggerId
;
1551 BuildIndxRef::ErrorCode m_lastError
;
1552 BuildIndxRef::ErrorCode m_errorCode
;
1556 SignalCounter m_signalCounter
;
1559 memset(&m_request
, 0, sizeof(m_request
));
1560 m_coordinatorRef
= 0;
1561 m_requestType
= BuildIndxReq::RT_UNDEFINED
;
1563 m_lastError
= BuildIndxRef::NoError
;
1564 m_errorCode
= BuildIndxRef::NoError
;
1568 void save(const BuildIndxReq
* req
) {
1570 m_requestType
= req
->getRequestType();
1571 m_requestFlag
= req
->getRequestFlag();
1573 bool hasLastError() {
1574 return m_lastError
!= BuildIndxRef::NoError
;
1577 return m_errorCode
!= BuildIndxRef::NoError
;
1579 void setError(const BuildIndxRef
* ref
) {
1580 m_lastError
= BuildIndxRef::NoError
;
1582 m_lastError
= ref
->getErrorCode();
1584 m_errorCode
= m_lastError
;
1590 void setError(const AlterIndxRef
* ref
) {
1591 m_lastError
= BuildIndxRef::NoError
;
1593 m_lastError
= (BuildIndxRef::ErrorCode
)ref
->getErrorCode();
1595 m_errorCode
= m_lastError
;
1596 m_errorLine
= ref
->getErrorLine();
1597 m_errorNode
= ref
->getErrorNode();
1601 void setError(const CreateTrigRef
* ref
) {
1602 m_lastError
= BuildIndxRef::NoError
;
1604 m_lastError
= (BuildIndxRef::ErrorCode
)ref
->getErrorCode();
1606 m_errorCode
= m_lastError
;
1607 m_errorLine
= ref
->getErrorLine();
1608 m_errorNode
= ref
->getErrorNode();
1612 void setError(const DropTrigRef
* ref
) {
1613 m_lastError
= BuildIndxRef::NoError
;
1615 m_lastError
= (BuildIndxRef::ErrorCode
)ref
->getErrorCode();
1617 m_errorCode
= m_lastError
;
1618 m_errorLine
= ref
->getErrorLine();
1619 m_errorNode
= ref
->getErrorNode();
1624 typedef Ptr
<OpBuildIndex
> OpBuildIndexPtr
;
1627 * Operation record for Util Signals.
1629 struct OpSignalUtil
: OpRecordCommon
{
1630 Callback m_callback
;
1633 typedef Ptr
<OpSignalUtil
> OpSignalUtilPtr
;
1636 * Operation record for subscribe-start-stop
1638 struct OpSubEvent
: OpRecordCommon
{
1640 Uint32 m_senderData
;
1643 SubStartConf m_sub_start_conf
;
1644 SubStopConf m_sub_stop_conf
;
1646 RequestTracker m_reqTracker
;
1648 typedef Ptr
<OpSubEvent
> OpSubEventPtr
;
1650 static const Uint32 sysTab_NDBEVENTS_0_szs
[];
1653 * Operation record for create event.
1655 struct OpCreateEvent
: OpRecordCommon
{
1656 // original request (event id will be added)
1657 CreateEvntReq m_request
;
1658 //AttributeMask m_attrListBitmask;
1659 // AttributeList m_attrList;
1660 sysTab_NDBEVENTS_0 m_eventRec
;
1661 // char m_eventName[MAX_TAB_NAME_SIZE];
1662 // char m_tableName[MAX_TAB_NAME_SIZE];
1665 RequestTracker m_reqTracker
;
1667 CreateEvntReq::RequestType m_requestType
;
1671 Uint32 m_errorNode
; /* also used to store master node id
1672 in case of NotMaster */
1675 memset(&m_request
, 0, sizeof(m_request
));
1676 m_requestType
= CreateEvntReq::RT_UNDEFINED
;
1677 m_errorCode
= CreateEvntRef::NoError
;
1681 void init(const CreateEvntReq
* req
, Dbdict
* dp
) {
1683 m_errorCode
= CreateEvntRef::NoError
;
1686 m_requestType
= req
->getRequestType();
1689 return m_errorCode
!= CreateEvntRef::NoError
;
1691 void setError(const CreateEvntRef
* ref
) {
1692 if (ref
!= 0 && ! hasError()) {
1693 m_errorCode
= ref
->getErrorCode();
1694 m_errorLine
= ref
->getErrorLine();
1695 m_errorNode
= ref
->getErrorNode();
1700 typedef Ptr
<OpCreateEvent
> OpCreateEventPtr
;
1703 * Operation record for drop event.
1705 struct OpDropEvent
: OpRecordCommon
{
1707 DropEvntReq m_request
;
1708 // char m_eventName[MAX_TAB_NAME_SIZE];
1709 sysTab_NDBEVENTS_0 m_eventRec
;
1710 RequestTracker m_reqTracker
;
1717 memset(&m_request
, 0, sizeof(m_request
));
1722 void init(const DropEvntReq
* req
) {
1729 return m_errorCode
!= 0;
1731 void setError(const DropEvntRef
* ref
) {
1732 if (ref
!= 0 && ! hasError()) {
1733 m_errorCode
= ref
->getErrorCode();
1734 m_errorLine
= ref
->getErrorLine();
1735 m_errorNode
= ref
->getErrorNode();
1739 typedef Ptr
<OpDropEvent
> OpDropEventPtr
;
1742 * Operation record for create trigger.
1744 struct OpCreateTrigger
: OpRecordCommon
{
1745 // original request (trigger id will be added)
1746 CreateTrigReq m_request
;
1747 char m_triggerName
[MAX_TAB_NAME_SIZE
];
1749 Uint32 m_coordinatorRef
;
1752 CreateTrigReq::RequestType m_requestType
;
1753 Uint32 m_requestFlag
;
1755 CreateTrigRef::ErrorCode m_lastError
;
1756 CreateTrigRef::ErrorCode m_errorCode
;
1760 SignalCounter m_signalCounter
;
1763 memset(&m_request
, 0, sizeof(m_request
));
1764 m_coordinatorRef
= 0;
1765 m_requestType
= CreateTrigReq::RT_UNDEFINED
;
1767 m_lastError
= CreateTrigRef::NoError
;
1768 m_errorCode
= CreateTrigRef::NoError
;
1772 void save(const CreateTrigReq
* req
) {
1774 m_requestType
= req
->getRequestType();
1775 m_requestFlag
= req
->getRequestFlag();
1777 bool hasLastError() {
1778 return m_lastError
!= CreateTrigRef::NoError
;
1781 return m_errorCode
!= CreateTrigRef::NoError
;
1783 void setError(const CreateTrigRef
* ref
) {
1784 m_lastError
= CreateTrigRef::NoError
;
1786 m_lastError
= ref
->getErrorCode();
1788 m_errorCode
= m_lastError
;
1789 m_errorLine
= ref
->getErrorLine();
1790 m_errorNode
= ref
->getErrorNode();
1794 void setError(const AlterTrigRef
* ref
) {
1795 m_lastError
= CreateTrigRef::NoError
;
1797 m_lastError
= (CreateTrigRef::ErrorCode
)ref
->getErrorCode();
1799 m_errorCode
= m_lastError
;
1800 m_errorLine
= ref
->getErrorLine();
1801 m_errorNode
= ref
->getErrorNode();
1806 typedef Ptr
<OpCreateTrigger
> OpCreateTriggerPtr
;
1809 * Operation record for drop trigger.
1811 struct OpDropTrigger
: OpRecordCommon
{
1813 DropTrigReq m_request
;
1815 Uint32 m_coordinatorRef
;
1818 DropTrigReq::RequestType m_requestType
;
1819 Uint32 m_requestFlag
;
1821 DropTrigRef::ErrorCode m_lastError
;
1822 DropTrigRef::ErrorCode m_errorCode
;
1826 SignalCounter m_signalCounter
;
1829 memset(&m_request
, 0, sizeof(m_request
));
1830 m_coordinatorRef
= 0;
1831 m_requestType
= DropTrigReq::RT_UNDEFINED
;
1833 m_lastError
= DropTrigRef::NoError
;
1834 m_errorCode
= DropTrigRef::NoError
;
1838 void save(const DropTrigReq
* req
) {
1840 m_requestType
= req
->getRequestType();
1841 m_requestFlag
= req
->getRequestFlag();
1843 bool hasLastError() {
1844 return m_lastError
!= DropTrigRef::NoError
;
1847 return m_errorCode
!= DropTrigRef::NoError
;
1849 void setError(const DropTrigRef
* ref
) {
1850 m_lastError
= DropTrigRef::NoError
;
1852 m_lastError
= ref
->getErrorCode();
1854 m_errorCode
= m_lastError
;
1855 m_errorLine
= ref
->getErrorLine();
1856 m_errorNode
= ref
->getErrorNode();
1860 void setError(const AlterTrigRef
* ref
) {
1861 m_lastError
= DropTrigRef::NoError
;
1863 m_lastError
= (DropTrigRef::ErrorCode
)ref
->getErrorCode();
1865 m_errorCode
= m_lastError
;
1866 m_errorLine
= ref
->getErrorLine();
1867 m_errorNode
= ref
->getErrorNode();
1872 typedef Ptr
<OpDropTrigger
> OpDropTriggerPtr
;
1875 * Operation record for alter trigger.
1877 struct OpAlterTrigger
: OpRecordCommon
{
1879 AlterTrigReq m_request
;
1880 // nodes participating in operation
1881 NdbNodeBitmask m_nodes
;
1883 Uint32 m_coordinatorRef
;
1886 AlterTrigReq::RequestType m_requestType
;
1887 Uint32 m_requestFlag
;
1889 AlterTrigRef::ErrorCode m_lastError
;
1890 AlterTrigRef::ErrorCode m_errorCode
;
1894 SignalCounter m_signalCounter
;
1897 memset(&m_request
, 0, sizeof(m_request
));
1898 m_coordinatorRef
= 0;
1899 m_requestType
= AlterTrigReq::RT_UNDEFINED
;
1901 m_lastError
= AlterTrigRef::NoError
;
1902 m_errorCode
= AlterTrigRef::NoError
;
1906 void save(const AlterTrigReq
* req
) {
1908 m_requestType
= req
->getRequestType();
1909 m_requestFlag
= req
->getRequestFlag();
1911 bool hasLastError() {
1912 return m_lastError
!= AlterTrigRef::NoError
;
1915 return m_errorCode
!= AlterTrigRef::NoError
;
1917 void setError(const AlterTrigRef
* ref
) {
1918 m_lastError
= AlterTrigRef::NoError
;
1920 m_lastError
= (AlterTrigRef::ErrorCode
)ref
->getErrorCode();
1922 m_errorCode
= m_lastError
;
1923 m_errorLine
= ref
->getErrorLine();
1924 m_errorNode
= ref
->getErrorNode();
1928 void setError(const CreateTrigRef
* ref
) {
1929 m_lastError
= AlterTrigRef::NoError
;
1931 m_lastError
= (AlterTrigRef::ErrorCode
)ref
->getErrorCode();
1933 m_errorCode
= m_lastError
;
1934 m_errorLine
= ref
->getErrorLine();
1935 m_errorNode
= ref
->getErrorNode();
1939 void setError(const DropTrigRef
* ref
) {
1940 m_lastError
= AlterTrigRef::NoError
;
1942 m_lastError
= (AlterTrigRef::ErrorCode
)ref
->getErrorCode();
1944 m_errorCode
= m_lastError
;
1945 m_errorLine
= ref
->getErrorLine();
1946 m_errorNode
= ref
->getErrorNode();
1951 typedef Ptr
<OpAlterTrigger
> OpAlterTriggerPtr
;
1954 struct SchemaOp
: OpRecordCommon
{
1956 Uint32 m_clientRef
; // API (for take-over)
1957 Uint32 m_clientData
;// API
1959 Uint32 m_senderRef
; //
1960 Uint32 m_senderData
;// transaction key value
1966 Uint32 m_obj_version
;
1969 Callback m_callback
;
1971 typedef Ptr
<SchemaOp
> SchemaOpPtr
;
1973 struct SchemaTransaction
: OpRecordCommon
{
1974 Uint32 m_senderRef
; // API
1975 Uint32 m_senderData
;// API
1977 Callback m_callback
;
1978 SafeCounterHandle m_counter
;
1979 NodeBitmask m_nodes
;
1982 SchemaTransaction() {}
1983 void setErrorCode(Uint32 c
){ if(m_errorCode
== 0) m_errorCode
= c
;}
1986 * This should contain "lists" with operations
1989 Uint32 m_key
; // Operation key
1990 Uint32 m_vt_index
; // Operation type
1992 DictObjOp::State m_state
;
1997 struct OpCreateObj
: public SchemaOp
{
1999 Uint32 m_obj_info_ptr_i
;
2002 typedef Ptr
<OpCreateObj
> CreateObjRecordPtr
;
2004 struct OpDropObj
: public SchemaOp
2007 typedef Ptr
<OpDropObj
> DropObjRecordPtr
;
2010 * Only used at coordinator/master
2012 // Common operation record pool
2014 STATIC_CONST( opCreateTableSize
= sizeof(CreateTableRecord
) );
2015 STATIC_CONST( opDropTableSize
= sizeof(DropTableRecord
) );
2016 STATIC_CONST( opCreateIndexSize
= sizeof(OpCreateIndex
) );
2017 STATIC_CONST( opDropIndexSize
= sizeof(OpDropIndex
) );
2018 STATIC_CONST( opAlterIndexSize
= sizeof(OpAlterIndex
) );
2019 STATIC_CONST( opBuildIndexSize
= sizeof(OpBuildIndex
) );
2020 STATIC_CONST( opCreateEventSize
= sizeof(OpCreateEvent
) );
2021 STATIC_CONST( opSubEventSize
= sizeof(OpSubEvent
) );
2022 STATIC_CONST( opDropEventSize
= sizeof(OpDropEvent
) );
2023 STATIC_CONST( opSignalUtilSize
= sizeof(OpSignalUtil
) );
2024 STATIC_CONST( opCreateTriggerSize
= sizeof(OpCreateTrigger
) );
2025 STATIC_CONST( opDropTriggerSize
= sizeof(OpDropTrigger
) );
2026 STATIC_CONST( opAlterTriggerSize
= sizeof(OpAlterTrigger
) );
2027 STATIC_CONST( opCreateObjSize
= sizeof(OpCreateObj
) );
2029 #define PTR_ALIGN(n) ((((n)+sizeof(void*)-1)>>2)&~((sizeof(void*)-1)>>2))
2030 union OpRecordUnion
{
2031 Uint32 u_opCreateTable
[PTR_ALIGN(opCreateTableSize
)];
2032 Uint32 u_opDropTable
[PTR_ALIGN(opDropTableSize
)];
2033 Uint32 u_opCreateIndex
[PTR_ALIGN(opCreateIndexSize
)];
2034 Uint32 u_opDropIndex
[PTR_ALIGN(opDropIndexSize
)];
2035 Uint32 u_opCreateEvent
[PTR_ALIGN(opCreateEventSize
)];
2036 Uint32 u_opSubEvent
[PTR_ALIGN(opSubEventSize
)];
2037 Uint32 u_opDropEvent
[PTR_ALIGN(opDropEventSize
)];
2038 Uint32 u_opSignalUtil
[PTR_ALIGN(opSignalUtilSize
)];
2039 Uint32 u_opAlterIndex
[PTR_ALIGN(opAlterIndexSize
)];
2040 Uint32 u_opBuildIndex
[PTR_ALIGN(opBuildIndexSize
)];
2041 Uint32 u_opCreateTrigger
[PTR_ALIGN(opCreateTriggerSize
)];
2042 Uint32 u_opDropTrigger
[PTR_ALIGN(opDropTriggerSize
)];
2043 Uint32 u_opAlterTrigger
[PTR_ALIGN(opAlterTriggerSize
)];
2044 Uint32 u_opCreateObj
[PTR_ALIGN(opCreateObjSize
)];
2047 ArrayPool
<OpRecordUnion
> c_opRecordPool
;
2049 // Operation records
2050 KeyTable2
<CreateTableRecord
, OpRecordUnion
> c_opCreateTable
;
2051 KeyTable2
<DropTableRecord
, OpRecordUnion
> c_opDropTable
;
2052 KeyTable2
<OpCreateIndex
, OpRecordUnion
> c_opCreateIndex
;
2053 KeyTable2
<OpDropIndex
, OpRecordUnion
> c_opDropIndex
;
2054 KeyTable2
<OpAlterIndex
, OpRecordUnion
> c_opAlterIndex
;
2055 KeyTable2
<OpBuildIndex
, OpRecordUnion
> c_opBuildIndex
;
2056 KeyTable2C
<OpCreateEvent
, OpRecordUnion
> c_opCreateEvent
;
2057 KeyTable2C
<OpSubEvent
, OpRecordUnion
> c_opSubEvent
;
2058 KeyTable2C
<OpDropEvent
, OpRecordUnion
> c_opDropEvent
;
2059 KeyTable2C
<OpSignalUtil
, OpRecordUnion
> c_opSignalUtil
;
2060 KeyTable2
<OpCreateTrigger
, OpRecordUnion
> c_opCreateTrigger
;
2061 KeyTable2
<OpDropTrigger
, OpRecordUnion
> c_opDropTrigger
;
2062 KeyTable2
<OpAlterTrigger
, OpRecordUnion
> c_opAlterTrigger
;
2063 KeyTable2
<SchemaOp
, OpRecordUnion
> c_schemaOp
;
2064 KeyTable2
<SchemaTransaction
, OpRecordUnion
> c_Trans
;
2065 KeyTable2Ref
<OpCreateObj
, SchemaOp
, OpRecordUnion
> c_opCreateObj
;
2066 KeyTable2Ref
<OpDropObj
, SchemaOp
, OpRecordUnion
> c_opDropObj
;
2068 // Unique key for operation XXX move to some system table
2069 Uint32 c_opRecordSequence
;
2072 * Master DICT can be locked in 2 mutually exclusive ways:
2074 * 1) for schema ops, via operation records
2075 * 2) against schema ops, via a lock queue
2077 * Current use of 2) is by a starting node, to prevent schema ops
2078 * until started. The ops are refused (BlockState != BS_IDLE),
2081 * Master failure is not handled, in node start case the starting
2082 * node will crash too anyway. Use lock table in future..
2084 * The lock queue is "serial" but other behaviour is possible
2085 * by checking lock types e.g. to allow parallel node starts.
2087 * Checking release of last op record is not convenient with
2088 * current structure (5.0). Instead we poll via continueB.
2090 * XXX only table ops check BlockState
2092 struct DictLockType
;
2093 friend struct DictLockType
;
2095 struct DictLockType
{
2096 DictLockReq::LockType lockType
;
2097 BlockState blockState
;
2101 struct DictLockRecord
;
2102 friend struct DictLockRecord
;
2104 struct DictLockRecord
{
2106 const DictLockType
* lt
;
2115 typedef Ptr
<DictLockRecord
> DictLockPtr
;
2116 ArrayPool
<DictLockRecord
> c_dictLockPool
;
2117 DLFifoList
<DictLockRecord
> c_dictLockQueue
;
2118 bool c_dictLockPoll
;
2120 static const DictLockType
* getDictLockType(Uint32 lockType
);
2121 void sendDictLockInfoEvent(Uint32 pollCount
);
2122 void sendDictLockInfoEvent(DictLockPtr lockPtr
, const char* text
);
2124 // check if any schema op exists (conflicting with dict lock)
2125 bool hasDictLockSchemaOp();
2127 void checkDictLockQueue(Signal
* signal
, bool poll
);
2128 void sendDictLockConf(Signal
* signal
, DictLockPtr lockPtr
);
2129 void sendDictLockRef(Signal
* signal
, DictLockReq req
, Uint32 errorCode
);
2131 // control polling i.e. continueB loop
2132 void setDictLockPoll(Signal
* signal
, bool on
, Uint32 pollCount
);
2135 void removeStaleDictLocks(Signal
* signal
, const Uint32
* theFailedNodes
);
2140 /* ------------------------------------------------------------ */
2141 // Start/Restart Handling
2142 /* ------------------------------------------------------------ */
2143 void sendSTTORRY(Signal
* signal
);
2144 void sendNDB_STTORRY(Signal
* signal
);
2145 void initSchemaFile(Signal
* signal
);
2147 /* ------------------------------------------------------------ */
2148 // Drop Table Handling
2149 /* ------------------------------------------------------------ */
2150 void releaseTableObject(Uint32 tableId
, bool removeFromHash
= true);
2152 /* ------------------------------------------------------------ */
2154 /* ------------------------------------------------------------ */
2155 Uint32
getFreeObjId(Uint32 minId
);
2156 Uint32
getFreeTableRecord(Uint32 primaryTableId
);
2157 Uint32
getFreeTriggerRecord();
2158 bool getNewAttributeRecord(TableRecordPtr tablePtr
,
2159 AttributeRecordPtr
& attrPtr
);
2160 void packTableIntoPages(Signal
* signal
);
2161 void packTableIntoPages(SimpleProperties::Writer
&, TableRecordPtr
, Signal
* =0);
2162 void packFilegroupIntoPages(SimpleProperties::Writer
&,
2164 const Uint32 undo_free_hi
,
2165 const Uint32 undo_free_lo
);
2166 void packFileIntoPages(SimpleProperties::Writer
&, FilePtr
, const Uint32
);
2168 void sendGET_TABINFOREQ(Signal
* signal
,
2170 void sendTC_SCHVERREQ(Signal
* signal
,
2172 BlockReference tcRef
);
2174 /* ------------------------------------------------------------ */
2175 // System Restart Handling
2176 /* ------------------------------------------------------------ */
2177 void initSendSchemaData(Signal
* signal
);
2178 void sendSchemaData(Signal
* signal
);
2179 Uint32
sendSCHEMA_INFO(Signal
* signal
, Uint32 nodeId
, Uint32
* pagePointer
);
2180 void checkSchemaStatus(Signal
* signal
);
2181 void sendDIHSTARTTAB_REQ(Signal
* signal
);
2183 /* ------------------------------------------------------------ */
2184 // Receive Table Handling
2185 /* ------------------------------------------------------------ */
2186 void handleTabInfoInit(SimpleProperties::Reader
&,
2187 ParseDictTabInfoRecord
*,
2188 bool checkExist
= true);
2189 void handleTabInfo(SimpleProperties::Reader
& it
, ParseDictTabInfoRecord
*,
2190 DictTabInfo::Table
& tableDesc
);
2192 void handleAddTableFailure(Signal
* signal
,
2195 bool verifyTableCorrect(Signal
* signal
, Uint32 tableId
);
2197 /* ------------------------------------------------------------ */
2198 // Add Table Handling
2199 /* ------------------------------------------------------------ */
2200 void releaseCreateTableOp(Signal
* signal
, CreateTableRecordPtr createTabPtr
);
2202 /* ------------------------------------------------------------ */
2203 // Add Fragment Handling
2204 /* ------------------------------------------------------------ */
2205 void sendLQHADDATTRREQ(Signal
*, CreateTableRecordPtr
, Uint32 attributePtrI
);
2207 /* ------------------------------------------------------------ */
2208 // Read/Write Schema and Table files
2209 /* ------------------------------------------------------------ */
2210 void updateSchemaState(Signal
* signal
, Uint32 tableId
,
2211 SchemaFile::TableEntry
*, Callback
*,
2212 bool savetodisk
= 1);
2213 void startWriteSchemaFile(Signal
* signal
);
2214 void openSchemaFile(Signal
* signal
,
2219 void writeSchemaFile(Signal
* signal
, Uint32 filePtr
, Uint32 fsPtr
);
2220 void writeSchemaConf(Signal
* signal
,
2221 FsConnectRecordPtr fsPtr
);
2222 void closeFile(Signal
* signal
, Uint32 filePtr
, Uint32 fsPtr
);
2223 void closeWriteSchemaConf(Signal
* signal
,
2224 FsConnectRecordPtr fsPtr
);
2225 void initSchemaFile_conf(Signal
* signal
, Uint32 i
, Uint32 returnCode
);
2227 void writeTableFile(Signal
* signal
, Uint32 tableId
,
2228 SegmentedSectionPtr tabInfo
, Callback
*);
2229 void startWriteTableFile(Signal
* signal
, Uint32 tableId
);
2230 void openTableFile(Signal
* signal
,
2235 void writeTableFile(Signal
* signal
, Uint32 filePtr
, Uint32 fsPtr
);
2236 void writeTableConf(Signal
* signal
,
2237 FsConnectRecordPtr fsPtr
);
2238 void closeWriteTableConf(Signal
* signal
,
2239 FsConnectRecordPtr fsPtr
);
2241 void startReadTableFile(Signal
* signal
, Uint32 tableId
);
2242 void openReadTableRef(Signal
* signal
,
2243 FsConnectRecordPtr fsPtr
);
2244 void readTableFile(Signal
* signal
, Uint32 filePtr
, Uint32 fsPtr
);
2245 void readTableConf(Signal
* signal
,
2246 FsConnectRecordPtr fsPtr
);
2247 void readTableRef(Signal
* signal
,
2248 FsConnectRecordPtr fsPtr
);
2249 void closeReadTableConf(Signal
* signal
,
2250 FsConnectRecordPtr fsPtr
);
2252 void startReadSchemaFile(Signal
* signal
);
2253 void openReadSchemaRef(Signal
* signal
,
2254 FsConnectRecordPtr fsPtr
);
2255 void readSchemaFile(Signal
* signal
, Uint32 filePtr
, Uint32 fsPtr
);
2256 void readSchemaConf(Signal
* signal
, FsConnectRecordPtr fsPtr
);
2257 void readSchemaRef(Signal
* signal
, FsConnectRecordPtr fsPtr
);
2258 void closeReadSchemaConf(Signal
* signal
,
2259 FsConnectRecordPtr fsPtr
);
2260 bool convertSchemaFileTo_5_0_6(XSchemaFile
*);
2262 /* ------------------------------------------------------------ */
2263 // Get table definitions
2264 /* ------------------------------------------------------------ */
2265 void sendGET_TABINFOREF(Signal
* signal
,
2267 GetTabInfoRef::ErrorCode errorCode
);
2269 void sendGET_TABLEID_REF(Signal
* signal
,
2270 GetTableIdReq
* req
,
2271 GetTableIdRef::ErrorCode errorCode
);
2273 void sendGetTabResponse(Signal
* signal
);
2275 /* ------------------------------------------------------------ */
2276 // Indexes and triggers
2277 /* ------------------------------------------------------------ */
2279 // reactivate and rebuild indexes on start up
2280 void activateIndexes(Signal
* signal
, Uint32 i
);
2281 void rebuildIndexes(Signal
* signal
, Uint32 i
);
2284 void createIndex_recvReply(Signal
* signal
, const CreateIndxConf
* conf
,
2285 const CreateIndxRef
* ref
);
2286 void createIndex_slavePrepare(Signal
* signal
, OpCreateIndexPtr opPtr
);
2287 void createIndex_toCreateTable(Signal
* signal
, OpCreateIndexPtr opPtr
);
2288 void createIndex_fromCreateTable(Signal
* signal
, OpCreateIndexPtr opPtr
);
2289 void createIndex_toAlterIndex(Signal
* signal
, OpCreateIndexPtr opPtr
);
2290 void createIndex_fromAlterIndex(Signal
* signal
, OpCreateIndexPtr opPtr
);
2291 void createIndex_slaveCommit(Signal
* signal
, OpCreateIndexPtr opPtr
);
2292 void createIndex_slaveAbort(Signal
* signal
, OpCreateIndexPtr opPtr
);
2293 void createIndex_sendSlaveReq(Signal
* signal
, OpCreateIndexPtr opPtr
);
2294 void createIndex_sendReply(Signal
* signal
, OpCreateIndexPtr opPtr
, bool);
2296 void dropIndex_recvReply(Signal
* signal
, const DropIndxConf
* conf
,
2297 const DropIndxRef
* ref
);
2298 void dropIndex_slavePrepare(Signal
* signal
, OpDropIndexPtr opPtr
);
2299 void dropIndex_toAlterIndex(Signal
* signal
, OpDropIndexPtr opPtr
);
2300 void dropIndex_fromAlterIndex(Signal
* signal
, OpDropIndexPtr opPtr
);
2301 void dropIndex_toDropTable(Signal
* signal
, OpDropIndexPtr opPtr
);
2302 void dropIndex_fromDropTable(Signal
* signal
, OpDropIndexPtr opPtr
);
2303 void dropIndex_slaveCommit(Signal
* signal
, OpDropIndexPtr opPtr
);
2304 void dropIndex_slaveAbort(Signal
* signal
, OpDropIndexPtr opPtr
);
2305 void dropIndex_sendSlaveReq(Signal
* signal
, OpDropIndexPtr opPtr
);
2306 void dropIndex_sendReply(Signal
* signal
, OpDropIndexPtr opPtr
, bool);
2308 void alterIndex_recvReply(Signal
* signal
, const AlterIndxConf
* conf
,
2309 const AlterIndxRef
* ref
);
2310 void alterIndex_slavePrepare(Signal
* signal
, OpAlterIndexPtr opPtr
);
2311 void alterIndex_toCreateTc(Signal
* signal
, OpAlterIndexPtr opPtr
);
2312 void alterIndex_fromCreateTc(Signal
* signal
, OpAlterIndexPtr opPtr
);
2313 void alterIndex_toDropTc(Signal
* signal
, OpAlterIndexPtr opPtr
);
2314 void alterIndex_fromDropTc(Signal
* signal
, OpAlterIndexPtr opPtr
);
2315 void alterIndex_toCreateTrigger(Signal
* signal
, OpAlterIndexPtr opPtr
);
2316 void alterIndex_fromCreateTrigger(Signal
* signal
, OpAlterIndexPtr opPtr
);
2317 void alterIndex_toDropTrigger(Signal
* signal
, OpAlterIndexPtr opPtr
);
2318 void alterIndex_fromDropTrigger(Signal
* signal
, OpAlterIndexPtr opPtr
);
2319 void alterIndex_toBuildIndex(Signal
* signal
, OpAlterIndexPtr opPtr
);
2320 void alterIndex_fromBuildIndex(Signal
* signal
, OpAlterIndexPtr opPtr
);
2321 void alterIndex_slaveCommit(Signal
* signal
, OpAlterIndexPtr opPtr
);
2322 void alterIndex_slaveAbort(Signal
* signal
, OpAlterIndexPtr opPtr
);
2323 void alterIndex_sendSlaveReq(Signal
* signal
, OpAlterIndexPtr opPtr
);
2324 void alterIndex_sendReply(Signal
* signal
, OpAlterIndexPtr opPtr
, bool);
2326 void buildIndex_recvReply(Signal
* signal
, const BuildIndxConf
* conf
,
2327 const BuildIndxRef
* ref
);
2328 void buildIndex_toCreateConstr(Signal
* signal
, OpBuildIndexPtr opPtr
);
2329 void buildIndex_fromCreateConstr(Signal
* signal
, OpBuildIndexPtr opPtr
);
2330 void buildIndex_buildTrix(Signal
* signal
, OpBuildIndexPtr opPtr
);
2331 void buildIndex_toDropConstr(Signal
* signal
, OpBuildIndexPtr opPtr
);
2332 void buildIndex_fromDropConstr(Signal
* signal
, OpBuildIndexPtr opPtr
);
2333 void buildIndex_toOnline(Signal
* signal
, OpBuildIndexPtr opPtr
);
2334 void buildIndex_fromOnline(Signal
* signal
, OpBuildIndexPtr opPtr
);
2335 void buildIndex_sendSlaveReq(Signal
* signal
, OpBuildIndexPtr opPtr
);
2336 void buildIndex_sendReply(Signal
* signal
, OpBuildIndexPtr opPtr
, bool);
2340 createEventUTIL_PREPARE(Signal
* signal
,
2341 Uint32 callbackData
,
2344 createEventUTIL_EXECUTE(Signal
*signal
,
2345 Uint32 callbackData
,
2348 dropEventUTIL_PREPARE_READ(Signal
* signal
,
2349 Uint32 callbackData
,
2352 dropEventUTIL_EXECUTE_READ(Signal
* signal
,
2353 Uint32 callbackData
,
2356 dropEventUTIL_PREPARE_DELETE(Signal
* signal
,
2357 Uint32 callbackData
,
2360 dropEventUTIL_EXECUTE_DELETE(Signal
*signal
,
2361 Uint32 callbackData
,
2364 dropEventUtilPrepareRef(Signal
* signal
,
2365 Uint32 callbackData
,
2368 dropEventUtilExecuteRef(Signal
* signal
,
2369 Uint32 callbackData
,
2372 sendSignalUtilReq(Callback
*c
,
2374 GlobalSignalNumber gsn
,
2377 JobBufferLevel jbuf
,
2378 LinearSectionPtr ptr
[3],
2379 Uint32 noOfSections
);
2381 recvSignalUtilReq(Signal
* signal
, Uint32 returnCode
);
2383 void completeSubStartReq(Signal
* signal
, Uint32 ptrI
, Uint32 returnCode
);
2384 void completeSubStopReq(Signal
* signal
, Uint32 ptrI
, Uint32 returnCode
);
2385 void completeSubRemoveReq(Signal
* signal
, Uint32 ptrI
, Uint32 returnCode
);
2387 void dropEvent_sendReply(Signal
* signal
,
2388 OpDropEventPtr evntRecPtr
);
2390 void createEvent_RT_USER_CREATE(Signal
* signal
, OpCreateEventPtr evntRecPtr
);
2391 void createEventComplete_RT_USER_CREATE(Signal
* signal
,
2392 OpCreateEventPtr evntRecPtr
);
2393 void createEvent_RT_USER_GET(Signal
* signal
, OpCreateEventPtr evntRecPtr
);
2394 void createEventComplete_RT_USER_GET(Signal
* signal
, OpCreateEventPtr evntRecPtr
);
2396 void createEvent_RT_DICT_AFTER_GET(Signal
* signal
, OpCreateEventPtr evntRecPtr
);
2398 void createEvent_nodeFailCallback(Signal
* signal
, Uint32 eventRecPtrI
,
2400 void createEvent_sendReply(Signal
* signal
, OpCreateEventPtr evntRecPtr
,
2401 LinearSectionPtr
*ptr
= NULL
, int noLSP
= 0);
2403 void prepareTransactionEventSysTable (Callback
*c
,
2406 UtilPrepareReq::OperationTypeValue prepReq
);
2407 void prepareUtilTransaction(Callback
*c
,
2411 const char *tableName
,
2412 UtilPrepareReq::OperationTypeValue prepReq
,
2415 const char *attrNames
[]);
2417 void executeTransEventSysTable(Callback
*c
,
2420 sysTab_NDBEVENTS_0
& m_eventRec
,
2421 const Uint32 prepareId
,
2422 UtilPrepareReq::OperationTypeValue prepReq
);
2423 void executeTransaction(Callback
*c
,
2428 LinearSectionPtr headerPtr
,
2429 LinearSectionPtr dataPtr
);
2431 void parseReadEventSys(Signal
*signal
, sysTab_NDBEVENTS_0
& m_eventRec
);
2434 void createTrigger_recvReply(Signal
* signal
, const CreateTrigConf
* conf
,
2435 const CreateTrigRef
* ref
);
2436 void createTrigger_slavePrepare(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2437 void createTrigger_masterSeize(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2438 void createTrigger_slaveCreate(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2439 void createTrigger_toAlterTrigger(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2440 void createTrigger_fromAlterTrigger(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2441 void createTrigger_slaveCommit(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2442 void createTrigger_slaveAbort(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2443 void createTrigger_sendSlaveReq(Signal
* signal
, OpCreateTriggerPtr opPtr
);
2444 void createTrigger_sendReply(Signal
* signal
, OpCreateTriggerPtr opPtr
, bool);
2446 void dropTrigger_recvReply(Signal
* signal
, const DropTrigConf
* conf
,
2447 const DropTrigRef
* ref
);
2448 void dropTrigger_slavePrepare(Signal
* signal
, OpDropTriggerPtr opPtr
);
2449 void dropTrigger_toAlterTrigger(Signal
* signal
, OpDropTriggerPtr opPtr
);
2450 void dropTrigger_fromAlterTrigger(Signal
* signal
, OpDropTriggerPtr opPtr
);
2451 void dropTrigger_slaveCommit(Signal
* signal
, OpDropTriggerPtr opPtr
);
2452 void dropTrigger_slaveAbort(Signal
* signal
, OpDropTriggerPtr opPtr
);
2453 void dropTrigger_sendSlaveReq(Signal
* signal
, OpDropTriggerPtr opPtr
);
2454 void dropTrigger_sendReply(Signal
* signal
, OpDropTriggerPtr opPtr
, bool);
2456 void alterTrigger_recvReply(Signal
* signal
, const AlterTrigConf
* conf
,
2457 const AlterTrigRef
* ref
);
2458 void alterTrigger_slavePrepare(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2459 void alterTrigger_toCreateLocal(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2460 void alterTrigger_fromCreateLocal(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2461 void alterTrigger_toDropLocal(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2462 void alterTrigger_fromDropLocal(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2463 void alterTrigger_slaveCommit(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2464 void alterTrigger_slaveAbort(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2465 void alterTrigger_sendSlaveReq(Signal
* signal
, OpAlterTriggerPtr opPtr
);
2466 void alterTrigger_sendReply(Signal
* signal
, OpAlterTriggerPtr opPtr
, bool);
2468 void getTableKeyList(TableRecordPtr
,
2469 Id_array
<MAX_ATTRIBUTES_IN_INDEX
+1>& list
);
2470 void getIndexAttr(TableRecordPtr indexPtr
, Uint32 itAttr
, Uint32
* id
);
2471 void getIndexAttrList(TableRecordPtr indexPtr
, AttributeList
& list
);
2472 void getIndexAttrMask(TableRecordPtr indexPtr
, AttributeMask
& mask
);
2474 /* ------------------------------------------------------------ */
2476 /* ------------------------------------------------------------ */
2477 void initCommonData();
2479 void initConnectRecord();
2480 void initRetrieveRecord(Signal
*, Uint32
, Uint32 returnCode
);
2481 void initSchemaRecord();
2482 void initRestartRecord();
2483 void initSendSchemaRecord();
2484 void initReadTableRecord();
2485 void initWriteTableRecord();
2486 void initReadSchemaRecord();
2487 void initWriteSchemaRecord();
2489 void initNodeRecords();
2490 void initTableRecords();
2491 void initialiseTableRecord(TableRecordPtr tablePtr
);
2492 void initTriggerRecords();
2493 void initialiseTriggerRecord(TriggerRecordPtr triggerPtr
);
2494 void initPageRecords();
2496 Uint32
getFsConnRecord();
2498 bool getIsFailed(Uint32 nodeId
) const;
2500 void dropTable_backup_mutex_locked(Signal
* signal
, Uint32
, Uint32
);
2501 void dropTableRef(Signal
* signal
, DropTableReq
*, DropTableRef::ErrorCode
);
2502 void printTables(); // For debugging only
2503 int handleAlterTab(AlterTabReq
* req
,
2504 CreateTableRecord
* regAlterTabPtr
,
2505 TableRecordPtr origTablePtr
,
2506 TableRecordPtr newTablePtr
);
2507 void revertAlterTable(Signal
* signal
,
2510 CreateTableRecord
* regAlterTabPtr
);
2511 void alterTable_backup_mutex_locked(Signal
* signal
, Uint32
, Uint32
);
2512 void alterTableRef(Signal
* signal
,
2513 AlterTableReq
*, AlterTableRef::ErrorCode
,
2514 ParseDictTabInfoRecord
* parseRecord
= NULL
);
2515 void alterTabRef(Signal
* signal
,
2516 AlterTabReq
*, AlterTableRef::ErrorCode
,
2517 ParseDictTabInfoRecord
* parseRecord
= NULL
);
2518 void alterTab_writeSchemaConf(Signal
* signal
,
2519 Uint32 callbackData
,
2521 void alterTab_writeTableConf(Signal
* signal
,
2522 Uint32 callbackData
,
2525 void prepDropTab_nextStep(Signal
* signal
, DropTableRecordPtr
);
2526 void prepDropTab_complete(Signal
* signal
, DropTableRecordPtr
);
2527 void prepDropTab_writeSchemaConf(Signal
* signal
, Uint32 dropTabPtrI
, Uint32
);
2529 void dropTab_localDROP_TAB_CONF(Signal
* signal
);
2530 void dropTab_nextStep(Signal
* signal
, DropTableRecordPtr
);
2531 void dropTab_complete(Signal
* signal
, Uint32 dropTabPtrI
, Uint32
);
2532 void dropTab_writeSchemaConf(Signal
* signal
, Uint32 dropTabPtrI
, Uint32
);
2534 void createTab_prepare(Signal
* signal
, CreateTabReq
* req
);
2535 void createTab_writeSchemaConf1(Signal
* signal
, Uint32 callback
, Uint32
);
2536 void createTab_writeTableConf(Signal
* signal
, Uint32 callbackData
, Uint32
);
2537 void createTab_dih(Signal
*, CreateTableRecordPtr
,
2538 SegmentedSectionPtr
, Callback
*);
2539 void createTab_dihComplete(Signal
* signal
, Uint32 callbackData
, Uint32
);
2541 void createTab_startLcpMutex_locked(Signal
* signal
, Uint32
, Uint32
);
2542 void createTab_startLcpMutex_unlocked(Signal
* signal
, Uint32
, Uint32
);
2544 void createTab_commit(Signal
* signal
, CreateTabReq
* req
);
2545 void createTab_writeSchemaConf2(Signal
* signal
, Uint32 callbackData
, Uint32
);
2546 void createTab_alterComplete(Signal
*, Uint32 callbackData
, Uint32
);
2548 void createTab_drop(Signal
* signal
, CreateTabReq
* req
);
2549 void createTab_dropComplete(Signal
* signal
, Uint32 callbackData
, Uint32
);
2551 void createTab_reply(Signal
* signal
, CreateTableRecordPtr
, Uint32 nodeId
);
2552 void alterTab_activate(Signal
*, CreateTableRecordPtr
, Callback
*);
2554 void restartCreateTab(Signal
*, Uint32
,
2555 const SchemaFile::TableEntry
*,
2556 const SchemaFile::TableEntry
*, bool);
2557 void restartCreateTab_readTableConf(Signal
* signal
, Uint32 callback
, Uint32
);
2558 void restartCreateTab_writeTableConf(Signal
* signal
, Uint32 callback
, Uint32
);
2559 void restartCreateTab_dihComplete(Signal
* signal
, Uint32 callback
, Uint32
);
2560 void restartCreateTab_activateComplete(Signal
*, Uint32 callback
, Uint32
);
2562 void restartDropTab(Signal
* signal
, Uint32 tableId
,
2563 const SchemaFile::TableEntry
*,
2564 const SchemaFile::TableEntry
*);
2565 void restartDropTab_complete(Signal
*, Uint32 callback
, Uint32
);
2567 void restartDropObj(Signal
*, Uint32
, const SchemaFile::TableEntry
*);
2568 void restartDropObj_prepare_start_done(Signal
*, Uint32
, Uint32
);
2569 void restartDropObj_prepare_complete_done(Signal
*, Uint32
, Uint32
);
2570 void restartDropObj_commit_start_done(Signal
*, Uint32
, Uint32
);
2571 void restartDropObj_commit_complete_done(Signal
*, Uint32
, Uint32
);
2573 void restart_checkSchemaStatusComplete(Signal
*, Uint32 callback
, Uint32
);
2574 void restart_writeSchemaConf(Signal
*, Uint32 callbackData
, Uint32
);
2575 void masterRestart_checkSchemaStatusComplete(Signal
*, Uint32
, Uint32
);
2577 void sendSchemaComplete(Signal
*, Uint32 callbackData
, Uint32
);
2579 void execCREATE_OBJ_REQ(Signal
* signal
);
2580 void execCREATE_OBJ_REF(Signal
* signal
);
2581 void execCREATE_OBJ_CONF(Signal
* signal
);
2583 void createObj_prepare_start_done(Signal
* signal
, Uint32 callback
, Uint32
);
2584 void createObj_writeSchemaConf1(Signal
* signal
, Uint32 callback
, Uint32
);
2585 void createObj_writeObjConf(Signal
* signal
, Uint32 callbackData
, Uint32
);
2586 void createObj_prepare_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2587 void createObj_commit_start_done(Signal
* signal
, Uint32 callback
, Uint32
);
2588 void createObj_writeSchemaConf2(Signal
* signal
, Uint32 callbackData
, Uint32
);
2589 void createObj_commit_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2590 void createObj_abort(Signal
*, struct CreateObjReq
*);
2591 void createObj_abort_start_done(Signal
*, Uint32 callbackData
, Uint32
);
2592 void createObj_abort_writeSchemaConf(Signal
*, Uint32 callbackData
, Uint32
);
2593 void createObj_abort_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2595 void schemaOp_reply(Signal
* signal
, SchemaTransaction
*, Uint32
);
2596 void trans_commit_start_done(Signal
*, Uint32 callbackData
, Uint32
);
2597 void trans_commit_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2598 void trans_abort_start_done(Signal
*, Uint32 callbackData
, Uint32
);
2599 void trans_abort_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2601 void execDROP_OBJ_REQ(Signal
* signal
);
2602 void execDROP_OBJ_REF(Signal
* signal
);
2603 void execDROP_OBJ_CONF(Signal
* signal
);
2605 void dropObj_prepare_start_done(Signal
* signal
, Uint32 callback
, Uint32
);
2606 void dropObj_prepare_writeSchemaConf(Signal
*, Uint32 callback
, Uint32
);
2607 void dropObj_prepare_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2608 void dropObj_commit_start_done(Signal
*, Uint32 callbackData
, Uint32
);
2609 void dropObj_commit_writeSchemaConf(Signal
*, Uint32 callback
, Uint32
);
2610 void dropObj_commit_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2611 void dropObj_abort_start_done(Signal
*, Uint32 callbackData
, Uint32
);
2612 void dropObj_abort_writeSchemaConf(Signal
*, Uint32 callback
, Uint32
);
2613 void dropObj_abort_complete_done(Signal
*, Uint32 callbackData
, Uint32
);
2615 void restartCreateObj(Signal
*, Uint32
,
2616 const SchemaFile::TableEntry
*,
2617 const SchemaFile::TableEntry
*, bool);
2618 void restartCreateObj_readConf(Signal
*, Uint32
, Uint32
);
2619 void restartCreateObj_getTabInfoConf(Signal
*);
2620 void restartCreateObj_prepare_start_done(Signal
*, Uint32
, Uint32
);
2621 void restartCreateObj_write_complete(Signal
*, Uint32
, Uint32
);
2622 void restartCreateObj_prepare_complete_done(Signal
*, Uint32
, Uint32
);
2623 void restartCreateObj_commit_start_done(Signal
*, Uint32
, Uint32
);
2624 void restartCreateObj_commit_complete_done(Signal
*, Uint32
, Uint32
);
2626 void execDICT_COMMIT_REQ(Signal
*);
2627 void execDICT_COMMIT_REF(Signal
*);
2628 void execDICT_COMMIT_CONF(Signal
*);
2630 void execDICT_ABORT_REQ(Signal
*);
2631 void execDICT_ABORT_REF(Signal
*);
2632 void execDICT_ABORT_CONF(Signal
*);
2635 void createObj_commit(Signal
*, struct SchemaOp
*);
2636 void createObj_abort(Signal
*, struct SchemaOp
*);
2638 void create_fg_prepare_start(Signal
* signal
, SchemaOp
*);
2639 void create_fg_prepare_complete(Signal
* signal
, SchemaOp
*);
2640 void create_fg_abort_start(Signal
* signal
, SchemaOp
*);
2641 void create_fg_abort_complete(Signal
* signal
, SchemaOp
*);
2643 void create_file_prepare_start(Signal
* signal
, SchemaOp
*);
2644 void create_file_prepare_complete(Signal
* signal
, SchemaOp
*);
2645 void create_file_commit_start(Signal
* signal
, SchemaOp
*);
2646 void create_file_abort_start(Signal
* signal
, SchemaOp
*);
2647 void create_file_abort_complete(Signal
* signal
, SchemaOp
*);
2649 void dropObj_commit(Signal
*, struct SchemaOp
*);
2650 void dropObj_abort(Signal
*, struct SchemaOp
*);
2651 void drop_file_prepare_start(Signal
* signal
, SchemaOp
*);
2652 void drop_file_commit_start(Signal
* signal
, SchemaOp
*);
2653 void drop_file_commit_complete(Signal
* signal
, SchemaOp
*);
2654 void drop_file_abort_start(Signal
* signal
, SchemaOp
*);
2655 void send_drop_file(Signal
*, SchemaOp
*, DropFileImplReq::RequestInfo
);
2657 void drop_fg_prepare_start(Signal
* signal
, SchemaOp
*);
2658 void drop_fg_commit_start(Signal
* signal
, SchemaOp
*);
2659 void drop_fg_commit_complete(Signal
* signal
, SchemaOp
*);
2660 void drop_fg_abort_start(Signal
* signal
, SchemaOp
*);
2661 void send_drop_fg(Signal
*, SchemaOp
*, DropFilegroupImplReq::RequestInfo
);
2663 void drop_undofile_prepare_start(Signal
* signal
, SchemaOp
*);
2664 void drop_undofile_commit_complete(Signal
* signal
, SchemaOp
*);
2666 int checkSingleUserMode(Uint32 senderRef
);
2670 Dbdict::TableRecord::isTable() const
2672 return DictTabInfo::isTable(tableType
);
2676 Dbdict::TableRecord::isIndex() const
2678 return DictTabInfo::isIndex(tableType
);
2682 Dbdict::TableRecord::isUniqueIndex() const
2684 return DictTabInfo::isUniqueIndex(tableType
);
2688 Dbdict::TableRecord::isNonUniqueIndex() const
2690 return DictTabInfo::isNonUniqueIndex(tableType
);
2694 Dbdict::TableRecord::isHashIndex() const
2696 return DictTabInfo::isHashIndex(tableType
);
2700 Dbdict::TableRecord::isOrderedIndex() const
2702 return DictTabInfo::isOrderedIndex(tableType
);