18 #include <ndb_global.h>
23 #include "diskpage.hpp"
25 #include <ndb_limits.h>
27 #include <OutputStream.hpp>
28 #include <Properties.hpp>
29 #include <Configuration.hpp>
30 #include <SectionReader.hpp>
31 #include <SimpleProperties.hpp>
32 #include <AttributeHeader.hpp>
33 #include <KeyDescriptor.hpp>
34 #include <signaldata/DictSchemaInfo.hpp>
35 #include <signaldata/DictTabInfo.hpp>
36 #include <signaldata/DropTabFile.hpp>
38 #include <signaldata/EventReport.hpp>
39 #include <signaldata/FsCloseReq.hpp>
40 #include <signaldata/FsConf.hpp>
41 #include <signaldata/FsOpenReq.hpp>
42 #include <signaldata/FsReadWriteReq.hpp>
43 #include <signaldata/FsRef.hpp>
44 #include <signaldata/GetTabInfo.hpp>
45 #include <signaldata/GetTableId.hpp>
46 #include <signaldata/HotSpareRep.hpp>
47 #include <signaldata/NFCompleteRep.hpp>
48 #include <signaldata/NodeFailRep.hpp>
49 #include <signaldata/ReadNodesConf.hpp>
50 #include <signaldata/RelTabMem.hpp>
51 #include <signaldata/WaitGCP.hpp>
52 #include <signaldata/ListTables.hpp>
54 #include <signaldata/CreateTrig.hpp>
55 #include <signaldata/DropTrig.hpp>
56 #include <signaldata/CreateIndx.hpp>
57 #include <signaldata/DropIndx.hpp>
58 #include <signaldata/BuildIndx.hpp>
60 #include <signaldata/DropFilegroup.hpp>
61 #include <signaldata/CreateFilegroup.hpp>
62 #include <signaldata/CreateFilegroupImpl.hpp>
64 #include <signaldata/CreateEvnt.hpp>
65 #include <signaldata/UtilPrepare.hpp>
66 #include <signaldata/UtilExecute.hpp>
67 #include <signaldata/UtilRelease.hpp>
68 #include <signaldata/SumaImpl.hpp>
70 #include <signaldata/LqhFrag.hpp>
71 #include <signaldata/DictStart.hpp>
72 #include <signaldata/DiAddTab.hpp>
73 #include <signaldata/DihStartTab.hpp>
75 #include <signaldata/DropTable.hpp>
76 #include <signaldata/DropTab.hpp>
77 #include <signaldata/PrepDropTab.hpp>
79 #include <signaldata/CreateTable.hpp>
80 #include <signaldata/AlterTable.hpp>
81 #include <signaldata/AlterTab.hpp>
82 #include <signaldata/CreateFragmentation.hpp>
83 #include <signaldata/CreateTab.hpp>
85 #include <signaldata/ApiBroadcast.hpp>
86 #include <signaldata/DictLock.hpp>
87 #include <signaldata/BackupLockTab.hpp>
90 #include <signaldata/DumpStateOrd.hpp>
91 #include <signaldata/CheckNodeGroups.hpp>
95 #include <EventLogger.hpp>
98 #include <signaldata/SchemaTrans.hpp>
99 #include <DebuggerNames.hpp>
101 #include <signaldata/DbinfoScan.hpp>
102 #include <signaldata/TransIdAI.hpp>
104 #include <signaldata/IndexStatSignal.hpp>
106 #define ZNOT_FOUND 626
107 #define ZALREADYEXIST 630
109 #define ZRESTART_OPS_PER_TRANS 25
110 #define ZRESTART_NO_WRITE_AFTER_READ 1
116 static const char EVENT_SYSTEM_TABLE_NAME[] =
"sys/def/NDB$EVENTS_0";
118 #define EVENT_TRACE \
119 // ndbout_c("Event debug trace: File: %s Line: %u", __FILE__, __LINE__)
121 #define DIV(x,y) (((x)+(y)-1)/(y))
122 #define WORDS2PAGES(x) DIV(x, (ZSIZE_OF_PAGES_IN_WORDS - ZPAGE_HEADER_SIZE))
123 #include <ndb_version.h>
127 alter_obj_inc_schema_version(Uint32 old)
129 return (old & 0x00FFFFFF) + ((old + 0x1000000) & 0xFF000000);
134 alter_obj_dec_schema_version(Uint32 old)
136 return (old & 0x00FFFFFF) + ((old - 0x1000000) & 0xFF000000);
141 create_obj_inc_schema_version(Uint32 old)
143 return (old + 0x00000001) & 0x00FFFFFF;
148 do_swap(Uint32 & v0, Uint32 & v1)
171 Dbdict::execDUMP_STATE_ORD(
Signal* signal)
176 if(signal->theData[0] == 1222){
177 const Uint32 tab = signal->theData[1];
179 req->senderRef = reference();
180 req->senderData = 1222;
182 sendSignal(DBLQH_REF, GSN_PREP_DROP_TAB_REQ, signal,
183 PrepDropTabReq::SignalLength, JBB);
186 if(signal->theData[0] == 1223){
187 const Uint32 tab = signal->theData[1];
189 req->senderRef = reference();
190 req->senderData = 1222;
192 sendSignal(DBTC_REF, GSN_PREP_DROP_TAB_REQ, signal,
193 PrepDropTabReq::SignalLength, JBB);
196 if(signal->theData[0] == 1224){
197 const Uint32 tab = signal->theData[1];
199 req->senderRef = reference();
200 req->senderData = 1222;
202 sendSignal(DBDIH_REF, GSN_PREP_DROP_TAB_REQ, signal,
203 PrepDropTabReq::SignalLength, JBB);
206 if(signal->theData[0] == 1225){
207 const Uint32 tab = signal->theData[1];
208 const Uint32 ver = signal->theData[2];
209 TableRecordPtr tabRecPtr;
210 c_tableRecordPool.
getPtr(tabRecPtr, tab);
212 req->senderData = 1225;
213 req->senderRef = numberToRef(1,1);
215 req->tableVersion = tabRecPtr.p->tableVersion + ver;
216 sendSignal(DBDICT_REF, GSN_DROP_TABLE_REQ, signal,
217 DropTableReq::SignalLength, JBB);
220 #define MEMINFO(x, y) infoEvent(x ": %d %d", y.getSize(), y.getNoOfFree())
221 if(signal->theData[0] == 1226){
222 MEMINFO(
"c_obj_pool", c_obj_pool);
223 MEMINFO(
"c_opRecordPool", c_opRecordPool);
224 MEMINFO(
"c_rope_pool", c_rope_pool);
227 if (signal->theData[0] == 1227)
230 bool ok = c_obj_hash.
first(iter);
231 for(;
ok; ok = c_obj_hash.
next(iter))
233 Rope name(c_rope_pool, iter.curr.p->m_name);
236 ndbout_c(
"%s m_ref_count: %d", buf, iter.curr.p->m_ref_count);
237 if (iter.curr.p->m_trans_key != 0)
238 ndbout_c(
"- m_trans_key: %u m_op_ref_count: %u",
239 iter.curr.p->m_trans_key, iter.curr.p->m_op_ref_count);
243 if (signal->theData[0] == 8004)
245 infoEvent(
"DICT: c_counterMgr size: %u free: %u",
246 c_counterMgr.getSize(),
247 c_counterMgr.getNoOfFree());
248 c_counterMgr.printNODE_FAILREP();
251 if (signal->theData[0] == DumpStateOrd::SchemaResourceSnapshot)
253 RSS_AP_SNAPSHOT_SAVE(c_rope_pool);
254 RSS_AP_SNAPSHOT_SAVE(c_attributeRecordPool);
255 RSS_AP_SNAPSHOT_SAVE(c_tableRecordPool);
256 RSS_AP_SNAPSHOT_SAVE(c_triggerRecordPool);
257 RSS_AP_SNAPSHOT_SAVE(c_obj_pool);
258 RSS_AP_SNAPSHOT_SAVE(c_hash_map_pool);
259 RSS_AP_SNAPSHOT_SAVE(g_hash_map);
262 if (signal->theData[0] == DumpStateOrd::SchemaResourceCheckLeak)
264 RSS_AP_SNAPSHOT_CHECK(c_rope_pool);
265 RSS_AP_SNAPSHOT_CHECK(c_attributeRecordPool);
266 RSS_AP_SNAPSHOT_CHECK(c_tableRecordPool);
267 RSS_AP_SNAPSHOT_CHECK(c_triggerRecordPool);
268 RSS_AP_SNAPSHOT_CHECK(c_obj_pool);
269 RSS_AP_SNAPSHOT_CHECK(c_hash_map_pool);
270 RSS_AP_SNAPSHOT_CHECK(g_hash_map);
278 void Dbdict::execDBINFO_SCANREQ(
Signal *signal)
288 case Ndbinfo::POOLS_TABLEID:
292 {
"Attribute Record",
293 c_attributeRecordPool.getUsed(),
294 c_attributeRecordPool.getSize(),
295 c_attributeRecordPool.getEntrySize(),
296 c_attributeRecordPool.getUsedHi(),
297 { CFG_DB_NO_ATTRIBUTES,0,0,0 }},
299 c_tableRecordPool.getUsed(),
300 c_tableRecordPool.getSize(),
301 c_tableRecordPool.getEntrySize(),
302 c_tableRecordPool.getUsedHi(),
303 { CFG_DB_NO_TABLES,0,0,0 }},
305 c_triggerRecordPool.getUsed(),
306 c_triggerRecordPool.getSize(),
307 c_triggerRecordPool.getEntrySize(),
308 c_triggerRecordPool.getUsedHi(),
309 { CFG_DB_NO_TRIGGERS,0,0,0 }},
310 {
"FS Connect Record",
311 c_fsConnectRecordPool.getUsed(),
312 c_fsConnectRecordPool.getSize(),
313 c_fsConnectRecordPool.getEntrySize(),
314 c_fsConnectRecordPool.getUsedHi(),
317 c_obj_pool.getUsed(),
318 c_obj_pool.getSize(),
319 c_obj_pool.getEntrySize(),
320 c_obj_pool.getUsedHi(),
322 CFG_DB_NO_ORDERED_INDEXES,
323 CFG_DB_NO_UNIQUE_HASH_INDEXES,
324 CFG_DB_NO_TRIGGERS }},
325 {
"Schema Operation",
326 c_schemaOpPool.getUsed(),
327 c_schemaOpPool.getSize(),
328 c_schemaOpPool.getEntrySize(),
329 c_schemaOpPool.getUsedHi(),
331 {
"Schema Transaction",
332 c_schemaTransPool.getUsed(),
333 c_schemaTransPool.getSize(),
334 c_schemaTransPool.getEntrySize(),
335 c_schemaTransPool.getUsedHi(),
337 {
"Transaction Handle",
338 c_txHandlePool.getUsed(),
339 c_txHandlePool.getSize(),
340 c_txHandlePool.getEntrySize(),
341 c_txHandlePool.getUsedHi(),
343 {
"Create Table Record",
344 c_createTableRecPool.getUsed(),
345 c_createTableRecPool.getSize(),
346 c_createTableRecPool.getEntrySize(),
347 c_createTableRecPool.getUsedHi(),
349 {
"Drop Table Record",
350 c_dropTableRecPool.getUsed(),
351 c_dropTableRecPool.getSize(),
352 c_dropTableRecPool.getEntrySize(),
353 c_dropTableRecPool.getUsedHi(),
355 {
"Alter Table Record",
356 c_alterTableRecPool.getUsed(),
357 c_alterTableRecPool.getSize(),
358 c_alterTableRecPool.getEntrySize(),
359 c_alterTableRecPool.getUsedHi(),
361 {
"Create Index Record",
362 c_createIndexRecPool.getUsed(),
363 c_createIndexRecPool.getSize(),
364 c_createIndexRecPool.getEntrySize(),
365 c_createIndexRecPool.getUsedHi(),
367 {
"Drop Index Record",
368 c_dropIndexRecPool.getUsed(),
369 c_dropIndexRecPool.getSize(),
370 c_dropIndexRecPool.getEntrySize(),
371 c_dropIndexRecPool.getUsedHi(),
373 {
"Alter Index Record",
374 c_alterIndexRecPool.getUsed(),
375 c_alterIndexRecPool.getSize(),
376 c_alterIndexRecPool.getEntrySize(),
377 c_alterIndexRecPool.getUsedHi(),
379 {
"Build Index Record",
380 c_buildIndexRecPool.getUsed(),
381 c_buildIndexRecPool.getSize(),
382 c_buildIndexRecPool.getEntrySize(),
383 c_buildIndexRecPool.getUsedHi(),
385 {
"Index Stat Record",
386 c_indexStatRecPool.getUsed(),
387 c_indexStatRecPool.getSize(),
388 c_indexStatRecPool.getEntrySize(),
389 c_indexStatRecPool.getUsedHi(),
391 {
"Create Hash Map Record",
392 c_createHashMapRecPool.getUsed(),
393 c_createHashMapRecPool.getSize(),
394 c_createHashMapRecPool.getEntrySize(),
395 c_createHashMapRecPool.getUsedHi(),
397 {
"Copy Data Record",
398 c_copyDataRecPool.getUsed(),
399 c_copyDataRecPool.getSize(),
400 c_copyDataRecPool.getEntrySize(),
401 c_copyDataRecPool.getUsedHi(),
403 {
"Create Trigger Record",
404 c_createTriggerRecPool.getUsed(),
405 c_createTriggerRecPool.getSize(),
406 c_createTriggerRecPool.getEntrySize(),
407 c_createTriggerRecPool.getUsedHi(),
409 {
"Drop Trigger Record",
410 c_dropTriggerRecPool.getUsed(),
411 c_dropTriggerRecPool.getSize(),
412 c_dropTriggerRecPool.getEntrySize(),
413 c_dropTriggerRecPool.getUsedHi(),
415 {
"Create Filegroup Record",
416 c_createFilegroupRecPool.getUsed(),
417 c_createFilegroupRecPool.getSize(),
418 c_createFilegroupRecPool.getEntrySize(),
419 c_createFilegroupRecPool.getUsedHi(),
421 {
"Create File Record",
422 c_createFileRecPool.getUsed(),
423 c_createFileRecPool.getSize(),
424 c_createFileRecPool.getEntrySize(),
425 c_createFileRecPool.getUsedHi(),
427 {
"Drop Filegroup Record",
428 c_dropFilegroupRecPool.getUsed(),
429 c_dropFilegroupRecPool.getSize(),
430 c_dropFilegroupRecPool.getEntrySize(),
431 c_dropFilegroupRecPool.getUsedHi(),
433 {
"Drop File Record",
434 c_dropFileRecPool.getUsed(),
435 c_dropFileRecPool.getSize(),
436 c_dropFileRecPool.getEntrySize(),
437 c_dropFileRecPool.getUsedHi(),
439 {
"Operation Record",
440 c_opRecordPool.getUsed(),
441 c_opRecordPool.getSize(),
442 c_opRecordPool.getEntrySize(),
443 c_opRecordPool.getUsedHi(),
445 { NULL, 0,0,0,0,{0,0,0,0}}
448 const size_t num_config_params =
449 sizeof(pools[0].config_params) /
sizeof(pools[0].config_params[0]);
450 Uint32 pool =
cursor->data[0];
451 BlockNumber bn = blockToMain(number());
452 while(pools[pool].poolname)
456 row.write_uint32(getOwnNodeId());
457 row.write_uint32(bn);
458 row.write_uint32(instance());
459 row.write_string(pools[pool].poolname);
460 row.write_uint64(pools[pool].used);
461 row.write_uint64(pools[pool].total);
462 row.write_uint64(pools[pool].used_hi);
463 row.write_uint64(pools[pool].entry_size);
464 for (
size_t i = 0;
i < num_config_params;
i++)
465 row.write_uint32(pools[pool].config_params[
i]);
466 ndbinfo_send_row(signal, req, row, rl);
468 if (rl.need_break(req))
471 ndbinfo_send_scan_break(signal, req, rl, pool);
481 ndbinfo_send_scan_conf(signal, req, rl);
491 void Dbdict::execCONTINUEB(
Signal* signal)
494 switch (signal->theData[0]) {
495 case ZPACK_TABLE_INTO_PAGES :
497 packTableIntoPages(signal);
500 case ZSEND_GET_TAB_RESPONSE :
502 sendGetTabResponse(signal);
504 case ZWAIT_SUBSTARTSTOP:
506 wait_substartstop(signal, signal->theData[1]);
508 case ZDICT_TAKEOVER_REQ :
511 Uint32* data = &signal->theData[0];
512 memmove(&data[0], &data[1], DictTakeoverReq::SignalLength << 2);
513 execDICT_TAKEOVER_REQ(signal);
516 case ZINDEX_STAT_BG_PROCESS:
518 indexStatBg_process(signal);
524 Uint32* data = &signal->theData[0];
525 Uint32 masterRef = data[1];
526 memmove(&data[0], &data[2], SchemaTransImplConf::SignalLength << 2);
527 sendSignal(masterRef, GSN_SCHEMA_TRANS_IMPL_CONF, signal,
528 SchemaTransImplConf::SignalLength, JBB);
532 ERROR_INSERTED(signal->theData[1]);
533 CRASH_INSERTION(ERROR_INSERT_VALUE);
536 case ZCOMMIT_WAIT_GCI:
538 trans_commit_wait_gci(signal);
553 void Dbdict::packTableIntoPages(
Signal* signal)
555 const Uint32 tableId= signal->theData[1];
556 const Uint32
type= signal->theData[2];
557 const Uint32 pageId= signal->theData[3];
559 Uint32 transId = c_retrieveRecord.schemaTransId;
561 req_copy.senderRef = c_retrieveRecord.blockRef;
562 req_copy.senderData = c_retrieveRecord.m_senderData;
563 req_copy.schemaTransId = c_retrieveRecord.schemaTransId;
564 req_copy.requestType = c_retrieveRecord.requestType;
565 req_copy.tableId = tableId;
571 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
572 objEntry = getTableEntry(xsf, tableId);
579 sendGET_TABINFOREF(signal, &req_copy,
580 GetTabInfoRef::TableNotDefined, __LINE__);
581 initRetrieveRecord(0, 0, 0);
585 if (transId != 0 && transId == objEntry->m_transId)
590 else if (refToBlock(req_copy.senderRef) != DBUTIL &&
591 refToBlock(req_copy.senderRef) != SUMA)
595 if ((err = check_read_obj(objEntry)))
599 sendGET_TABINFOREF(signal, &req_copy,
600 (GetTabInfoRef::ErrorCode)err, __LINE__);
601 initRetrieveRecord(0, 0, 0);
607 PageRecordPtr pagePtr;
608 c_pageRecordArray.
getPtr(pagePtr, pageId);
610 memset(&pagePtr.p->word[0], 0, 4 * ZPAGE_HEADER_SIZE);
612 ZMAX_PAGES_OF_TABLE_DEFINITION * ZSIZE_OF_PAGES_IN_WORDS);
615 case DictTabInfo::SystemTable:
616 case DictTabInfo::UserTable:
617 case DictTabInfo::UniqueHashIndex:
618 case DictTabInfo::HashIndex:
619 case DictTabInfo::UniqueOrderedIndex:
620 case DictTabInfo::OrderedIndex:{
622 TableRecordPtr tablePtr;
623 c_tableRecordPool.
getPtr(tablePtr, tableId);
624 if (tablePtr.p->m_obj_ptr_i == RNIL)
627 sendGET_TABINFOREF(signal, &req_copy,
628 GetTabInfoRef::TableNotDefined, __LINE__);
629 initRetrieveRecord(0, 0, 0);
633 packTableIntoPages(w, tablePtr, signal);
634 if (unlikely(signal->theData[0] != 0))
637 Uint32 err = signal->theData[0];
639 ref->tableId = c_retrieveRecord.tableId;
640 ref->senderRef = reference();
641 ref->senderData = c_retrieveRecord.m_senderData;
642 ref->errorCode = err;
643 Uint32 dstRef = c_retrieveRecord.blockRef;
644 sendSignal(dstRef, GSN_GET_TABINFOREF, signal,
645 GetTabInfoRef::SignalLength, JBB);
646 initRetrieveRecord(0,0,0);
654 ndbrequire(c_filegroup_hash.
find(fg_ptr, tableId));
655 const Uint32 free_hi= signal->theData[4];
656 const Uint32 free_lo= signal->theData[5];
657 packFilegroupIntoPages(w, fg_ptr, free_hi, free_lo);
662 ndbrequire(c_file_hash.
find(fg_ptr, tableId));
663 const Uint32 free_extents= signal->theData[4];
664 packFileIntoPages(w, fg_ptr, free_extents);
669 ndbrequire(c_file_hash.
find(fg_ptr, tableId));
670 packFileIntoPages(w, fg_ptr, 0);
673 case DictTabInfo::HashMap:{
675 ndbrequire(c_hash_map_hash.
find(hm_ptr, tableId));
676 packHashMapIntoPages(w, hm_ptr);
679 case DictTabInfo::UndefTableType:
680 case DictTabInfo::HashIndexTrigger:
681 case DictTabInfo::SubscriptionTrigger:
682 case DictTabInfo::ReadOnlyConstraint:
683 case DictTabInfo::IndexTrigger:
684 case DictTabInfo::SchemaTransaction:
685 case DictTabInfo::ReorgTrigger:
689 Uint32 wordsOfTable = w.getWordsUsed();
690 Uint32 pagesUsed = WORDS2PAGES(wordsOfTable);
691 pagePtr.p->word[ZPOS_CHECKSUM] =
692 computeChecksum(&pagePtr.p->word[0], pagesUsed * ZSIZE_OF_PAGES_IN_WORDS);
694 switch (c_packTable.m_state) {
695 case PackTable::PTS_IDLE:
698 case PackTable::PTS_GET_TAB:
700 c_retrieveRecord.retrievedNoOfPages = pagesUsed;
701 c_retrieveRecord.retrievedNoOfWords = wordsOfTable;
702 sendGetTabResponse(signal);
712 TableRecordPtr tablePtr,
716 char tableName[MAX_TAB_NAME_SIZE];
717 char frmData[MAX_FRM_DATA_SIZE];
718 char rangeData[16*MAX_NDB_PARTITIONS];
719 char ngData[2*MAX_NDB_PARTITIONS];
720 char defaultValue[MAX_ATTR_DEFAULT_VALUE_SIZE];
721 char attributeName[MAX_ATTR_NAME_SIZE];
723 ConstRope r(c_rope_pool, tablePtr.p->tableName);
725 w.add(DictTabInfo::TableName, tableName);
726 w.add(DictTabInfo::TableId, tablePtr.p->tableId);
727 w.add(DictTabInfo::TableVersion, tablePtr.p->tableVersion);
728 w.add(DictTabInfo::NoOfKeyAttr, tablePtr.p->noOfPrimkey);
729 w.add(DictTabInfo::NoOfAttributes, tablePtr.p->noOfAttributes);
730 w.add(DictTabInfo::NoOfNullable, tablePtr.p->noOfNullAttr);
731 w.add(DictTabInfo::NoOfVariable, (Uint32)0);
732 w.add(DictTabInfo::KeyLength, tablePtr.p->tupKeyLength);
734 w.add(DictTabInfo::TableLoggedFlag,
735 !!(tablePtr.p->m_bits & TableRecord::TR_Logged));
736 w.add(DictTabInfo::RowGCIFlag,
737 !!(tablePtr.p->m_bits & TableRecord::TR_RowGCI));
738 w.add(DictTabInfo::RowChecksumFlag,
739 !!(tablePtr.p->m_bits & TableRecord::TR_RowChecksum));
740 w.add(DictTabInfo::TableTemporaryFlag,
741 !!(tablePtr.p->m_bits & TableRecord::TR_Temporary));
742 w.add(DictTabInfo::ForceVarPartFlag,
743 !!(tablePtr.p->m_bits & TableRecord::TR_ForceVarPart));
745 w.add(DictTabInfo::MinLoadFactor, tablePtr.p->minLoadFactor);
746 w.add(DictTabInfo::MaxLoadFactor, tablePtr.p->maxLoadFactor);
747 w.add(DictTabInfo::TableKValue, tablePtr.p->kValue);
748 w.add(DictTabInfo::FragmentTypeVal, tablePtr.p->fragmentType);
749 w.add(DictTabInfo::TableTypeVal, tablePtr.p->tableType);
750 w.add(DictTabInfo::MaxRowsLow, tablePtr.p->maxRowsLow);
751 w.add(DictTabInfo::MaxRowsHigh, tablePtr.p->maxRowsHigh);
752 w.add(DictTabInfo::DefaultNoPartFlag, tablePtr.p->defaultNoPartFlag);
753 w.add(DictTabInfo::LinearHashFlag, tablePtr.p->linearHashFlag);
754 w.add(DictTabInfo::FragmentCount, tablePtr.p->fragmentCount);
755 w.add(DictTabInfo::MinRowsLow, tablePtr.p->minRowsLow);
756 w.add(DictTabInfo::MinRowsHigh, tablePtr.p->minRowsHigh);
757 w.add(DictTabInfo::SingleUserMode, tablePtr.p->singleUserMode);
758 w.add(DictTabInfo::HashMapObjectId, tablePtr.p->hashMapObjectId);
759 w.add(DictTabInfo::TableStorageType, tablePtr.p->storageType);
760 w.add(DictTabInfo::ExtraRowGCIBits, tablePtr.p->m_extra_row_gci_bits);
761 w.add(DictTabInfo::ExtraRowAuthorBits, tablePtr.p->m_extra_row_author_bits);
764 if (tablePtr.p->hashMapObjectId != RNIL)
767 ndbrequire(c_hash_map_hash.
find(hm_ptr, tablePtr.p->hashMapObjectId));
768 w.add(DictTabInfo::HashMapVersion, hm_ptr.p->m_object_version);
776 if (!ERROR_INSERTED(6025))
778 err = get_fragmentation(signal, tablePtr.p->tableId);
782 err = CreateFragmentationRef::InvalidPrimaryTable;
784 if (unlikely(err != 0))
787 signal->theData[0] = err;
791 ndbrequire(err == 0);
792 Uint16 *data = (Uint16*)&signal->theData[25];
793 Uint32 count = 2 + (1 + data[0]) * data[1];
794 w.add(DictTabInfo::ReplicaDataLen, 2*count);
795 for (Uint32
i = 0;
i < count;
i++)
796 data[
i] = htons(data[
i]);
797 w.add(DictTabInfo::ReplicaData, data, 2*count);
805 if (tablePtr.p->primaryTableId != RNIL)
808 TableRecordPtr primTab;
809 c_tableRecordPool.
getPtr(primTab, tablePtr.p->primaryTableId);
810 ConstRope r2(c_rope_pool, primTab.p->tableName);
812 w.add(DictTabInfo::PrimaryTable, tableName);
813 w.add(DictTabInfo::PrimaryTableId, tablePtr.p->primaryTableId);
814 w.add(DictTabInfo::IndexState, tablePtr.p->indexState);
815 w.add(DictTabInfo::CustomTriggerId, tablePtr.p->triggerId);
818 ConstRope frm(c_rope_pool, tablePtr.p->frmData);
820 w.add(DictTabInfo::FrmLen, frm.size());
821 w.add(DictTabInfo::FrmData, frmData, frm.size());
825 w.add(DictTabInfo::TablespaceDataLen, (Uint32)0);
827 ConstRope ng(c_rope_pool, tablePtr.p->ngData);
829 w.add(DictTabInfo::FragmentDataLen, ng.size());
830 w.add(DictTabInfo::FragmentData, ngData, ng.size());
832 ConstRope range(c_rope_pool, tablePtr.p->rangeData);
833 range.copy(rangeData);
834 w.add(DictTabInfo::RangeListDataLen, range.size());
835 w.add(DictTabInfo::RangeListData, rangeData, range.size());
838 if(tablePtr.p->m_tablespace_id != RNIL)
840 w.add(DictTabInfo::TablespaceId, tablePtr.p->m_tablespace_id);
842 ndbrequire(c_filegroup_hash.
find(tsPtr, tablePtr.p->m_tablespace_id));
843 w.add(DictTabInfo::TablespaceVersion, tsPtr.p->m_version);
846 AttributeRecordPtr attrPtr;
848 tablePtr.p->m_attributes);
849 for(list.first(attrPtr); !attrPtr.isNull(); list.next(attrPtr)){
853 name.copy(attributeName);
855 w.add(DictTabInfo::AttributeName, attributeName);
856 w.add(DictTabInfo::AttributeId, attrPtr.p->attributeId);
857 w.add(DictTabInfo::AttributeKeyFlag, attrPtr.p->tupleKey > 0);
859 const Uint32 desc = attrPtr.p->attributeDescriptor;
861 const Uint32 attrSize = AttributeDescriptor::getSize(desc);
862 const Uint32 arraySize = AttributeDescriptor::getArraySize(desc);
863 const Uint32 arrayType = AttributeDescriptor::getArrayType(desc);
864 const Uint32 nullable = AttributeDescriptor::getNullable(desc);
865 const Uint32 DKey = AttributeDescriptor::getDKey(desc);
866 const Uint32 disk= AttributeDescriptor::getDiskBased(desc);
867 const Uint32 dynamic= AttributeDescriptor::getDynamic(desc);
871 w.add(DictTabInfo::AttributeSize, attrSize);
872 w.add(DictTabInfo::AttributeArraySize, arraySize);
873 w.add(DictTabInfo::AttributeArrayType, arrayType);
874 w.add(DictTabInfo::AttributeNullableFlag, nullable);
875 w.add(DictTabInfo::AttributeDynamic, dynamic);
876 w.add(DictTabInfo::AttributeDKey, DKey);
877 w.add(DictTabInfo::AttributeExtType, attrType);
878 w.add(DictTabInfo::AttributeExtPrecision, attrPtr.p->extPrecision);
879 w.add(DictTabInfo::AttributeExtScale, attrPtr.p->extScale);
880 w.add(DictTabInfo::AttributeExtLength, attrPtr.p->extLength);
881 w.add(DictTabInfo::AttributeAutoIncrement,
882 (Uint32)attrPtr.p->autoIncrement);
885 w.add(DictTabInfo::AttributeStorageType, (Uint32)NDB_STORAGETYPE_DISK);
887 w.add(DictTabInfo::AttributeStorageType, (Uint32)NDB_STORAGETYPE_MEMORY);
889 ConstRope def(c_rope_pool, attrPtr.p->defaultValue);
890 def.copy(defaultValue);
896 ndbrequire(def.size() >=
sizeof(Uint32));
898 memcpy(&a, defaultValue,
sizeof(Uint32));
900 memcpy(defaultValue, &a,
sizeof(Uint32));
902 Uint32 remainBytes = def.size() -
sizeof(Uint32);
909 (uchar*) defaultValue +
sizeof(Uint32),
913 w.add(DictTabInfo::AttributeDefaultValueLen, def.size());
914 w.add(DictTabInfo::AttributeDefaultValue, defaultValue, def.size());
915 w.add(DictTabInfo::AttributeEnd, 1);
918 w.add(DictTabInfo::TableEnd, 1);
924 const Uint32 undo_free_hi,
925 const Uint32 undo_free_lo){
928 ConstRope r(c_rope_pool, fg_ptr.p->m_name);
929 r.copy(fg.FilegroupName);
931 fg.FilegroupId = fg_ptr.p->key;
932 fg.FilegroupType = fg_ptr.p->m_type;
933 fg.FilegroupVersion = fg_ptr.p->m_version;
935 switch(fg.FilegroupType){
938 fg.TS_ExtentSize = fg_ptr.p->m_tablespace.m_extent_size;
939 fg.TS_LogfileGroupId = fg_ptr.p->m_tablespace.m_default_logfile_group_id;
940 FilegroupPtr lfg_ptr;
941 ndbrequire(c_filegroup_hash.
find(lfg_ptr, fg.TS_LogfileGroupId));
942 fg.TS_LogfileGroupVersion = lfg_ptr.p->m_version;
945 fg.LF_UndoBufferSize = fg_ptr.p->m_logfilegroup.m_undo_buffer_size;
946 fg.LF_UndoFreeWordsHi= undo_free_hi;
947 fg.LF_UndoFreeWordsLo= undo_free_lo;
955 s = SimpleProperties::pack(w,
957 DictFilegroupInfo::Mapping,
958 DictFilegroupInfo::MappingSize,
true);
960 ndbrequire(s == SimpleProperties::Eof);
965 FilePtr f_ptr,
const Uint32 free_extents){
968 ConstRope r(c_rope_pool, f_ptr.p->m_path);
971 f.FileType = f_ptr.p->m_type;
972 f.FilegroupId = f_ptr.p->m_filegroup_id;;
973 f.FileSizeHi = (Uint32)(f_ptr.p->m_file_size >> 32);
974 f.FileSizeLo = (Uint32)(f_ptr.p->m_file_size & 0xFFFFFFFF);
975 f.FileFreeExtents= free_extents;
976 f.FileId = f_ptr.p->key;
977 f.FileVersion = f_ptr.p->m_version;
979 FilegroupPtr lfg_ptr;
980 ndbrequire(c_filegroup_hash.
find(lfg_ptr, f.FilegroupId));
981 f.FilegroupVersion = lfg_ptr.p->m_version;
984 s = SimpleProperties::pack(w,
986 DictFilegroupInfo::FileMapping,
987 DictFilegroupInfo::FileMappingSize,
true);
989 ndbrequire(s == SimpleProperties::Eof);
993 Dbdict::execCREATE_FRAGMENTATION_REQ(
Signal* signal)
997 if (req->primaryTableId == RNIL) {
1000 CreateFragmentationReq::SignalLength);
1004 TableRecordPtr tablePtr;
1005 c_tableRecordPool.
getPtr(tablePtr, req->primaryTableId);
1006 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
1008 if (te->m_tableState != SchemaFile::SF_CREATE)
1011 if (req->requestInfo == 0)
1014 req->requestInfo |= CreateFragmentationReq::RI_GET_FRAGMENTATION;
1017 CreateFragmentationReq::SignalLength);
1021 DictObjectPtr obj_ptr;
1022 c_obj_pool.
getPtr(obj_ptr, tablePtr.p->m_obj_ptr_i);
1025 findDictObjectOp(op_ptr, obj_ptr);
1026 ndbrequire(!op_ptr.isNull());
1027 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
1028 ndbrequire(memcmp(oprec_ptr.p->m_opType,
"CTa", 4) == 0);
1030 Uint32 *theData = &signal->theData[0];
1031 const OpSection& fragSection =
1032 getOpSection(op_ptr, CreateTabReq::FRAGMENTATION);
1033 copyOut(fragSection, &theData[25], ZNIL);
1046 void Dbdict::execFSCLOSECONF(
Signal* signal)
1048 FsConnectRecordPtr fsPtr;
1051 c_fsConnectRecordPool.
getPtr(fsPtr, fsConf->userPointer);
1052 switch (fsPtr.p->fsState) {
1053 case FsConnectRecord::CLOSE_WRITE_SCHEMA:
1055 closeWriteSchemaConf(signal, fsPtr);
1057 case FsConnectRecord::CLOSE_READ_SCHEMA:
1059 closeReadSchemaConf(signal, fsPtr);
1061 case FsConnectRecord::CLOSE_READ_TAB_FILE:
1063 closeReadTableConf(signal, fsPtr);
1065 case FsConnectRecord::CLOSE_WRITE_TAB_FILE:
1067 closeWriteTableConf(signal, fsPtr);
1069 case FsConnectRecord::OPEN_READ_SCHEMA2:
1070 openSchemaFile(signal, 1, fsPtr.i,
false,
false);
1072 case FsConnectRecord::OPEN_READ_TAB_FILE2:
1073 openTableFile(signal, 1, fsPtr.i, c_readTableRecord.tableId,
false);
1076 jamLine((fsPtr.p->fsState & 0xFFF));
1086 void Dbdict::execFSOPENCONF(
Signal* signal)
1088 FsConnectRecordPtr fsPtr;
1091 c_fsConnectRecordPool.
getPtr(fsPtr, fsConf->userPointer);
1093 Uint32 filePointer = fsConf->filePointer;
1094 fsPtr.p->filePtr = filePointer;
1095 switch (fsPtr.p->fsState) {
1096 case FsConnectRecord::OPEN_WRITE_SCHEMA:
1098 fsPtr.p->fsState = FsConnectRecord::WRITE_SCHEMA;
1099 writeSchemaFile(signal, filePointer, fsPtr.i);
1101 case FsConnectRecord::OPEN_READ_SCHEMA1:
1103 fsPtr.p->fsState = FsConnectRecord::READ_SCHEMA1;
1104 readSchemaFile(signal, filePointer, fsPtr.i);
1106 case FsConnectRecord::OPEN_READ_SCHEMA2:
1108 fsPtr.p->fsState = FsConnectRecord::READ_SCHEMA2;
1109 readSchemaFile(signal, filePointer, fsPtr.i);
1111 case FsConnectRecord::OPEN_READ_TAB_FILE1:
1113 fsPtr.p->fsState = FsConnectRecord::READ_TAB_FILE1;
1114 readTableFile(signal, filePointer, fsPtr.i);
1116 case FsConnectRecord::OPEN_READ_TAB_FILE2:
1118 fsPtr.p->fsState = FsConnectRecord::READ_TAB_FILE2;
1119 readTableFile(signal, filePointer, fsPtr.i);
1121 case FsConnectRecord::OPEN_WRITE_TAB_FILE:
1123 fsPtr.p->fsState = FsConnectRecord::WRITE_TAB_FILE;
1124 writeTableFile(signal, filePointer, fsPtr.i);
1127 jamLine((fsPtr.p->fsState & 0xFFF));
1136 void Dbdict::execFSOPENREF(
Signal* signal)
1139 FsRef *
const fsRef = (
FsRef *)&signal->theData[0];
1140 FsConnectRecordPtr fsPtr;
1142 switch (fsPtr.p->fsState) {
1143 case FsConnectRecord::OPEN_READ_SCHEMA1:
1145 openReadSchemaRef(signal, fsPtr);
1147 case FsConnectRecord::OPEN_READ_TAB_FILE1:
1149 openReadTableRef(signal, fsPtr);
1156 sprintf(msg,
"File system open failed during FsConnectRecord state %d", (Uint32)fsPtr.p->fsState);
1157 fsRefError(signal,__LINE__,msg);
1164 void Dbdict::execFSREADCONF(
Signal* signal)
1168 FsConnectRecordPtr fsPtr;
1169 c_fsConnectRecordPool.
getPtr(fsPtr, fsConf->userPointer);
1170 switch (fsPtr.p->fsState) {
1171 case FsConnectRecord::READ_SCHEMA1:
1172 case FsConnectRecord::READ_SCHEMA2:
1173 readSchemaConf(signal ,fsPtr);
1175 case FsConnectRecord::READ_TAB_FILE1:
1176 if(ERROR_INSERTED(6024))
1179 CLEAR_ERROR_INSERT_VALUE;
1180 FsRef *
const fsRef = (
FsRef *)&signal->theData[0];
1182 fsRef->setErrorCode(fsRef->errorCode, NDBD_EXIT_AFS_UNKNOWN);
1183 fsRef->osErrorCode = ~0;
1184 execFSREADREF(signal);
1187 case FsConnectRecord::READ_TAB_FILE2:
1189 readTableConf(signal ,fsPtr);
1192 jamLine((fsPtr.p->fsState & 0xFFF));
1201 void Dbdict::execFSREADREF(
Signal* signal)
1204 FsRef *
const fsRef = (
FsRef *)&signal->theData[0];
1205 FsConnectRecordPtr fsPtr;
1207 switch (fsPtr.p->fsState) {
1208 case FsConnectRecord::READ_SCHEMA1:
1210 readSchemaRef(signal, fsPtr);
1212 case FsConnectRecord::READ_TAB_FILE1:
1214 readTableRef(signal, fsPtr);
1221 sprintf(msg,
"File system read failed during FsConnectRecord state %d", (Uint32)fsPtr.p->fsState);
1222 fsRefError(signal,__LINE__,msg);
1229 void Dbdict::execFSWRITECONF(
Signal* signal)
1232 FsConnectRecordPtr fsPtr;
1234 c_fsConnectRecordPool.
getPtr(fsPtr, fsConf->userPointer);
1235 switch (fsPtr.p->fsState) {
1236 case FsConnectRecord::WRITE_TAB_FILE:
1237 writeTableConf(signal, fsPtr);
1239 case FsConnectRecord::WRITE_SCHEMA:
1241 writeSchemaConf(signal, fsPtr);
1244 jamLine((fsPtr.p->fsState & 0xFFF));
1255 Dbdict::writeTableFile(
Signal* signal, Uint32 tableId,
1258 ndbrequire(c_writeTableRecord.tableWriteState == WriteTableRecord::IDLE);
1260 Uint32 pages = WORDS2PAGES(tabInfoPtr.sz);
1261 c_writeTableRecord.no_of_words = tabInfoPtr.sz;
1262 c_writeTableRecord.tableWriteState = WriteTableRecord::TWR_CALLBACK;
1263 c_writeTableRecord.m_callback = * callback;
1265 c_writeTableRecord.pageId = 0;
1266 ndbrequire(pages == 1);
1268 PageRecordPtr pageRecPtr;
1269 c_pageRecordArray.
getPtr(pageRecPtr, c_writeTableRecord.pageId);
1270 copy(&pageRecPtr.p->word[ZPAGE_HEADER_SIZE], tabInfoPtr);
1272 memset(&pageRecPtr.p->word[0], 0, 4 * ZPAGE_HEADER_SIZE);
1273 pageRecPtr.p->word[ZPOS_CHECKSUM] =
1274 computeChecksum(&pageRecPtr.p->word[0],
1275 pages * ZSIZE_OF_PAGES_IN_WORDS);
1277 startWriteTableFile(signal, tableId);
1282 Dbdict::writeTableFile(
Signal* signal, Uint32 tableId,
1283 OpSection tabInfoSec, Callback* callback)
1285 ndbrequire(c_writeTableRecord.tableWriteState == WriteTableRecord::IDLE);
1288 const Uint32
size = tabInfoSec.getSize();
1289 const Uint32 pages = WORDS2PAGES(size);
1291 c_writeTableRecord.no_of_words =
size;
1292 c_writeTableRecord.tableWriteState = WriteTableRecord::TWR_CALLBACK;
1293 c_writeTableRecord.m_callback = * callback;
1295 c_writeTableRecord.pageId = 0;
1297 PageRecordPtr pageRecPtr;
1298 c_pageRecordArray.
getPtr(pageRecPtr, c_writeTableRecord.pageId);
1300 Uint32* dst = &pageRecPtr.p->word[ZPAGE_HEADER_SIZE];
1301 Uint32 dstSize = (ZMAX_PAGES_OF_TABLE_DEFINITION * ZSIZE_OF_PAGES_IN_WORDS)
1302 - ZPAGE_HEADER_SIZE;
1303 bool ok = copyOut(tabInfoSec, dst, dstSize);
1306 memset(&pageRecPtr.p->word[0], 0, 4 * ZPAGE_HEADER_SIZE);
1307 pageRecPtr.p->word[ZPOS_CHECKSUM] =
1308 computeChecksum(&pageRecPtr.p->word[0],
1309 pages * ZSIZE_OF_PAGES_IN_WORDS);
1312 startWriteTableFile(signal, tableId);
1315 void Dbdict::startWriteTableFile(
Signal* signal, Uint32 tableId)
1317 FsConnectRecordPtr fsPtr;
1318 c_writeTableRecord.tableId = tableId;
1319 c_fsConnectRecordPool.
getPtr(fsPtr, getFsConnRecord());
1320 fsPtr.p->fsState = FsConnectRecord::OPEN_WRITE_TAB_FILE;
1321 openTableFile(signal, 0, fsPtr.i, tableId,
true);
1322 c_writeTableRecord.noOfTableFilesHandled = 0;
1325 void Dbdict::openTableFile(
Signal* signal,
1333 fsOpenReq->userReference = reference();
1334 fsOpenReq->userPointer = fsConPtr;
1337 fsOpenReq->fileFlags =
1338 FsOpenReq::OM_WRITEONLY |
1339 FsOpenReq::OM_TRUNCATE |
1340 FsOpenReq::OM_CREATE |
1344 fsOpenReq->fileFlags = FsOpenReq::OM_READONLY;
1346 fsOpenReq->fileNumber[3] = 0;
1347 FsOpenReq::setVersion(fsOpenReq->fileNumber, 1);
1348 FsOpenReq::setSuffix(fsOpenReq->fileNumber, FsOpenReq::S_TABLELIST);
1349 FsOpenReq::v1_setDisk(fsOpenReq->fileNumber, (fileNo + 1));
1350 FsOpenReq::v1_setTable(fsOpenReq->fileNumber, tableId);
1351 FsOpenReq::v1_setFragment(fsOpenReq->fileNumber, (Uint32)-1);
1352 FsOpenReq::v1_setS(fsOpenReq->fileNumber, 0);
1353 FsOpenReq::v1_setP(fsOpenReq->fileNumber, 255);
1361 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
1364 void Dbdict::writeTableFile(
Signal* signal, Uint32 filePtr, Uint32 fsConPtr)
1368 fsRWReq->filePointer = filePtr;
1369 fsRWReq->userReference = reference();
1370 fsRWReq->userPointer = fsConPtr;
1371 fsRWReq->operationFlag = 0;
1372 FsReadWriteReq::setSyncFlag(fsRWReq->operationFlag, 1);
1373 FsReadWriteReq::setFormatFlag(fsRWReq->operationFlag,
1374 FsReadWriteReq::fsFormatArrayOfPages);
1375 fsRWReq->varIndex = ZBAT_TABLE_FILE;
1376 fsRWReq->numberOfPages = WORDS2PAGES(c_writeTableRecord.no_of_words);
1377 fsRWReq->data.arrayOfPages.varIndex = c_writeTableRecord.pageId;
1378 fsRWReq->data.arrayOfPages.fileOffset = 0;
1379 sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 8, JBA);
1382 void Dbdict::writeTableConf(
Signal* signal,
1383 FsConnectRecordPtr fsPtr)
1385 fsPtr.p->fsState = FsConnectRecord::CLOSE_WRITE_TAB_FILE;
1386 closeFile(signal, fsPtr.p->filePtr, fsPtr.i);
1390 void Dbdict::closeWriteTableConf(
Signal* signal,
1391 FsConnectRecordPtr fsPtr)
1393 c_writeTableRecord.noOfTableFilesHandled++;
1394 if (c_writeTableRecord.noOfTableFilesHandled < 2) {
1396 fsPtr.p->fsState = FsConnectRecord::OPEN_WRITE_TAB_FILE;
1397 openTableFile(signal, 1, fsPtr.i, c_writeTableRecord.tableId,
true);
1400 ndbrequire(c_writeTableRecord.noOfTableFilesHandled == 2);
1401 c_fsConnectRecordPool.
release(fsPtr);
1402 WriteTableRecord::TableWriteState state = c_writeTableRecord.tableWriteState;
1403 c_writeTableRecord.tableWriteState = WriteTableRecord::IDLE;
1405 case WriteTableRecord::IDLE:
1406 case WriteTableRecord::WRITE_ADD_TABLE_MASTER :
1407 case WriteTableRecord::WRITE_ADD_TABLE_SLAVE :
1408 case WriteTableRecord::WRITE_RESTART_FROM_MASTER :
1409 case WriteTableRecord::WRITE_RESTART_FROM_OWN :
1412 case WriteTableRecord::TWR_CALLBACK:
1414 execute(signal, c_writeTableRecord.m_callback, 0);
1420 void Dbdict::startReadTableFile(
Signal* signal, Uint32 tableId)
1423 ndbrequire(!c_readTableRecord.inUse);
1425 FsConnectRecordPtr fsPtr;
1426 c_fsConnectRecordPool.
getPtr(fsPtr, getFsConnRecord());
1427 c_readTableRecord.inUse =
true;
1428 c_readTableRecord.tableId = tableId;
1429 fsPtr.p->fsState = FsConnectRecord::OPEN_READ_TAB_FILE1;
1430 openTableFile(signal, 0, fsPtr.i, tableId,
false);
1433 void Dbdict::openReadTableRef(
Signal* signal,
1434 FsConnectRecordPtr fsPtr)
1436 fsPtr.p->fsState = FsConnectRecord::OPEN_READ_TAB_FILE2;
1437 openTableFile(signal, 1, fsPtr.i, c_readTableRecord.tableId,
false);
1441 void Dbdict::readTableFile(
Signal* signal, Uint32 filePtr, Uint32 fsConPtr)
1445 fsRWReq->filePointer = filePtr;
1446 fsRWReq->userReference = reference();
1447 fsRWReq->userPointer = fsConPtr;
1448 fsRWReq->operationFlag = 0;
1449 FsReadWriteReq::setSyncFlag(fsRWReq->operationFlag, 0);
1450 FsReadWriteReq::setFormatFlag(fsRWReq->operationFlag,
1451 FsReadWriteReq::fsFormatArrayOfPages);
1452 fsRWReq->varIndex = ZBAT_TABLE_FILE;
1453 fsRWReq->numberOfPages = WORDS2PAGES(c_readTableRecord.no_of_words);
1454 fsRWReq->data.arrayOfPages.varIndex = c_readTableRecord.pageId;
1455 fsRWReq->data.arrayOfPages.fileOffset = 0;
1456 sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 8, JBA);
1459 void Dbdict::readTableConf(
Signal* signal,
1460 FsConnectRecordPtr fsPtr)
1466 if (fsPtr.p->fsState == FsConnectRecord::READ_TAB_FILE1) {
1474 PageRecordPtr tmpPagePtr;
1475 c_pageRecordArray.
getPtr(tmpPagePtr, c_readTableRecord.pageId);
1477 WORDS2PAGES(c_readTableRecord.no_of_words)*ZSIZE_OF_PAGES_IN_WORDS;
1478 Uint32 chk = computeChecksum((
const Uint32*)tmpPagePtr.p, sz);
1480 ndbrequire((chk == 0) || !crashInd);
1483 ndbrequire(fsPtr.p->fsState == FsConnectRecord::READ_TAB_FILE1);
1484 readTableRef(signal, fsPtr);
1488 fsPtr.p->fsState = FsConnectRecord::CLOSE_READ_TAB_FILE;
1489 closeFile(signal, fsPtr.p->filePtr, fsPtr.i);
1493 void Dbdict::readTableRef(
Signal* signal,
1494 FsConnectRecordPtr fsPtr)
1499 fsPtr.p->fsState = FsConnectRecord::OPEN_READ_TAB_FILE2;
1500 closeFile(signal, fsPtr.p->filePtr, fsPtr.i);
1504 void Dbdict::closeReadTableConf(
Signal* signal,
1505 FsConnectRecordPtr fsPtr)
1507 c_fsConnectRecordPool.
release(fsPtr);
1508 c_readTableRecord.inUse =
false;
1510 execute(signal, c_readTableRecord.m_callback, 0);
1520 Dbdict::updateSchemaState(
Signal* signal, Uint32 tableId,
1522 bool savetodisk,
bool dicttrans)
1525 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
1536 D(
"updateSchemaState" << V(tableId));
1537 D(
"old:" << *tableEntry);
1541 * tableEntry = * te;
1542 computeChecksum(xsf, tableId / NDB_SF_PAGE_ENTRIES);
1544 SchemaFile::TableState newState =
1545 (SchemaFile::TableState)te->m_tableState;
1546 SchemaFile::TableState oldState =
1547 (SchemaFile::TableState)tableEntry->m_tableState;
1549 Uint32 newVersion = te->m_tableVersion;
1550 Uint32 oldVersion = tableEntry->m_tableVersion;
1554 case SchemaFile::CREATE_PARSED:
1557 ndbrequire(create_obj_inc_schema_version(oldVersion) == newVersion);
1558 ndbrequire(oldState == SchemaFile::INIT ||
1559 oldState == SchemaFile::DROP_TABLE_COMMITTED);
1561 case SchemaFile::DROP_PARSED:
1564 case SchemaFile::ALTER_PARSED:
1568 case SchemaFile::ADD_STARTED:
1572 ndbrequire(oldVersion == newVersion);
1573 ndbrequire(oldState == SchemaFile::CREATE_PARSED);
1576 ndbrequire(create_obj_inc_schema_version(oldVersion) == newVersion);
1577 ndbrequire(oldState == SchemaFile::INIT ||
1578 oldState == SchemaFile::DROP_TABLE_COMMITTED);
1580 case SchemaFile::TABLE_ADD_COMMITTED:
1583 ndbrequire(newVersion == oldVersion);
1584 ndbrequire(oldState == SchemaFile::ADD_STARTED ||
1585 oldState == SchemaFile::DROP_TABLE_STARTED);
1587 case SchemaFile::ALTER_TABLE_COMMITTED:
1590 ndbrequire(alter_obj_inc_schema_version(oldVersion) == newVersion);
1591 ndbrequire(oldState == SchemaFile::TABLE_ADD_COMMITTED ||
1592 oldState == SchemaFile::ALTER_TABLE_COMMITTED);
1594 case SchemaFile::DROP_TABLE_STARTED:
1596 case SchemaFile::DROP_TABLE_COMMITTED:
1600 case SchemaFile::TEMPORARY_TABLE_COMMITTED:
1602 ndbrequire(oldState == SchemaFile::ADD_STARTED ||
1603 oldState == SchemaFile::TEMPORARY_TABLE_COMMITTED);
1606 case SchemaFile::INIT:
1610 ndbrequire((oldState == SchemaFile::CREATE_PARSED));
1613 ndbrequire((oldState == SchemaFile::ADD_STARTED));
1617 * tableEntry = * te;
1618 computeChecksum(xsf, tableId / NDB_SF_PAGE_ENTRIES);
1622 ndbrequire(c_writeSchemaRecord.inUse ==
false);
1623 c_writeSchemaRecord.inUse =
true;
1625 c_writeSchemaRecord.pageId = c_schemaRecord.schemaPage;
1626 c_writeSchemaRecord.newFile =
false;
1627 c_writeSchemaRecord.firstPage = tableId / NDB_SF_PAGE_ENTRIES;
1628 c_writeSchemaRecord.noOfPages = 1;
1629 c_writeSchemaRecord.m_callback = * callback;
1631 startWriteSchemaFile(signal);
1636 if (callback != 0) {
1638 execute(signal, *callback, 0);
1644 void Dbdict::startWriteSchemaFile(
Signal* signal)
1646 FsConnectRecordPtr fsPtr;
1647 c_fsConnectRecordPool.
getPtr(fsPtr, getFsConnRecord());
1648 fsPtr.p->fsState = FsConnectRecord::OPEN_WRITE_SCHEMA;
1649 openSchemaFile(signal, 0, fsPtr.i,
true, c_writeSchemaRecord.newFile);
1650 c_writeSchemaRecord.noOfSchemaFilesHandled = 0;
1653 void Dbdict::openSchemaFile(
Signal* signal,
1660 fsOpenReq->userReference = reference();
1661 fsOpenReq->userPointer = fsConPtr;
1664 fsOpenReq->fileFlags =
1665 FsOpenReq::OM_WRITEONLY |
1668 fsOpenReq->fileFlags |=
1669 FsOpenReq::OM_TRUNCATE |
1670 FsOpenReq::OM_CREATE;
1673 fsOpenReq->fileFlags = FsOpenReq::OM_READONLY;
1675 fsOpenReq->fileNumber[3] = 0;
1676 FsOpenReq::setVersion(fsOpenReq->fileNumber, 1);
1677 FsOpenReq::setSuffix(fsOpenReq->fileNumber, FsOpenReq::S_SCHEMALOG);
1678 FsOpenReq::v1_setDisk(fsOpenReq->fileNumber, (fileNo + 1));
1679 FsOpenReq::v1_setTable(fsOpenReq->fileNumber, (Uint32)-1);
1680 FsOpenReq::v1_setFragment(fsOpenReq->fileNumber, (Uint32)-1);
1681 FsOpenReq::v1_setS(fsOpenReq->fileNumber, (Uint32)-1);
1682 FsOpenReq::v1_setP(fsOpenReq->fileNumber, 0);
1688 sendSignal(NDBFS_REF, GSN_FSOPENREQ, signal, FsOpenReq::SignalLength, JBA);
1691 void Dbdict::writeSchemaFile(
Signal* signal, Uint32 filePtr, Uint32 fsConPtr)
1696 WriteSchemaRecord & wr = c_writeSchemaRecord;
1697 ndbrequire(wr.pageId == (wr.pageId != 0) * NDB_SF_MAX_PAGES);
1698 ndbrequire(wr.noOfPages != 0);
1699 ndbrequire(wr.firstPage + wr.noOfPages <= NDB_SF_MAX_PAGES);
1701 fsRWReq->filePointer = filePtr;
1702 fsRWReq->userReference = reference();
1703 fsRWReq->userPointer = fsConPtr;
1704 fsRWReq->operationFlag = 0;
1705 FsReadWriteReq::setSyncFlag(fsRWReq->operationFlag, 1);
1706 FsReadWriteReq::setFormatFlag(fsRWReq->operationFlag,
1707 FsReadWriteReq::fsFormatArrayOfPages);
1708 fsRWReq->varIndex = ZBAT_SCHEMA_FILE;
1709 fsRWReq->numberOfPages = wr.noOfPages;
1711 fsRWReq->data.arrayOfPages.varIndex = wr.pageId + wr.firstPage;
1712 fsRWReq->data.arrayOfPages.fileOffset = wr.firstPage;
1713 sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 8, JBA);
1716 void Dbdict::writeSchemaConf(
Signal* signal,
1717 FsConnectRecordPtr fsPtr)
1719 fsPtr.p->fsState = FsConnectRecord::CLOSE_WRITE_SCHEMA;
1720 closeFile(signal, fsPtr.p->filePtr, fsPtr.i);
1724 void Dbdict::closeFile(
Signal* signal, Uint32 filePtr, Uint32 fsConPtr)
1727 fsCloseReq->filePointer = filePtr;
1728 fsCloseReq->userReference = reference();
1729 fsCloseReq->userPointer = fsConPtr;
1730 FsCloseReq::setRemoveFileFlag(fsCloseReq->fileFlag,
false);
1731 sendSignal(NDBFS_REF, GSN_FSCLOSEREQ, signal, FsCloseReq::SignalLength, JBA);
1735 void Dbdict::closeWriteSchemaConf(
Signal* signal,
1736 FsConnectRecordPtr fsPtr)
1738 c_writeSchemaRecord.noOfSchemaFilesHandled++;
1739 if (c_writeSchemaRecord.noOfSchemaFilesHandled < 2) {
1741 fsPtr.p->fsState = FsConnectRecord::OPEN_WRITE_SCHEMA;
1742 openSchemaFile(signal, 1, fsPtr.i,
true, c_writeSchemaRecord.newFile);
1745 ndbrequire(c_writeSchemaRecord.noOfSchemaFilesHandled == 2);
1747 c_fsConnectRecordPool.
release(fsPtr);
1749 c_writeSchemaRecord.inUse =
false;
1750 execute(signal, c_writeSchemaRecord.m_callback, 0);
1754 void Dbdict::startReadSchemaFile(
Signal* signal)
1757 FsConnectRecordPtr fsPtr;
1758 c_fsConnectRecordPool.
getPtr(fsPtr, getFsConnRecord());
1759 fsPtr.p->fsState = FsConnectRecord::OPEN_READ_SCHEMA1;
1760 openSchemaFile(signal, 0, fsPtr.i,
false,
false);
1763 void Dbdict::openReadSchemaRef(
Signal* signal,
1764 FsConnectRecordPtr fsPtr)
1766 fsPtr.p->fsState = FsConnectRecord::OPEN_READ_SCHEMA2;
1767 openSchemaFile(signal, 1, fsPtr.i,
false,
false);
1770 void Dbdict::readSchemaFile(
Signal* signal, Uint32 filePtr, Uint32 fsConPtr)
1775 ReadSchemaRecord & rr = c_readSchemaRecord;
1776 ndbrequire(rr.pageId == (rr.pageId != 0) * NDB_SF_MAX_PAGES);
1777 ndbrequire(rr.noOfPages != 0);
1778 ndbrequire(rr.firstPage + rr.noOfPages <= NDB_SF_MAX_PAGES);
1780 fsRWReq->filePointer = filePtr;
1781 fsRWReq->userReference = reference();
1782 fsRWReq->userPointer = fsConPtr;
1783 fsRWReq->operationFlag = 0;
1784 FsReadWriteReq::setSyncFlag(fsRWReq->operationFlag, 0);
1785 FsReadWriteReq::setFormatFlag(fsRWReq->operationFlag,
1786 FsReadWriteReq::fsFormatArrayOfPages);
1787 fsRWReq->varIndex = ZBAT_SCHEMA_FILE;
1788 fsRWReq->numberOfPages = rr.noOfPages;
1789 fsRWReq->data.arrayOfPages.varIndex = rr.pageId + rr.firstPage;
1790 fsRWReq->data.arrayOfPages.fileOffset = rr.firstPage;
1791 sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 8, JBA);
1794 void Dbdict::readSchemaConf(
Signal* signal,
1795 FsConnectRecordPtr fsPtr)
1801 if (fsPtr.p->fsState == FsConnectRecord::READ_SCHEMA1) {
1809 ReadSchemaRecord & rr = c_readSchemaRecord;
1810 XSchemaFile * xsf = &c_schemaFile[rr.pageId != 0];
1812 if (rr.schemaReadState == ReadSchemaRecord::INITIAL_READ_HEAD) {
1814 ndbrequire(rr.firstPage == 0);
1817 if (sf->NdbVersion < NDB_SF_VERSION_5_0_6) {
1819 const Uint32 pageSize_old = 32 * 1024;
1820 noOfPages = pageSize_old / NDB_SF_PAGE_SIZE - 1;
1822 noOfPages = sf->FileSize / NDB_SF_PAGE_SIZE - 1;
1824 rr.schemaReadState = ReadSchemaRecord::INITIAL_READ;
1825 if (noOfPages != 0) {
1827 rr.noOfPages = noOfPages;
1828 readSchemaFile(signal, fsPtr.p->filePtr, fsPtr.i);
1834 xsf->noOfPages = sf0->FileSize / NDB_SF_PAGE_SIZE;
1836 if (sf0->NdbVersion < NDB_SF_VERSION_5_0_6 &&
1837 ! convertSchemaFileTo_5_0_6(xsf)) {
1839 ndbrequire(! crashInd);
1840 ndbrequire(fsPtr.p->fsState == FsConnectRecord::READ_SCHEMA1);
1841 readSchemaRef(signal, fsPtr);
1845 if (sf0->NdbVersion < NDB_MAKE_VERSION(6,4,0) &&
1846 ! convertSchemaFileTo_6_4(xsf))
1849 ndbrequire(! crashInd);
1850 ndbrequire(fsPtr.p->fsState == FsConnectRecord::READ_SCHEMA1);
1851 readSchemaRef(signal, fsPtr);
1856 for (Uint32
n = 0;
n < xsf->noOfPages;
n++) {
1860 if (memcmp(sf->Magic, NDB_SF_MAGIC,
sizeof(sf->Magic)) != 0)
1861 { jam(); reason =
"magic code"; }
1862 else if (sf->FileSize == 0)
1863 { jam(); reason =
"file size == 0"; }
1864 else if (sf->FileSize % NDB_SF_PAGE_SIZE != 0)
1865 { jam(); reason =
"invalid size multiple"; }
1866 else if (sf->FileSize != sf0->FileSize)
1867 { jam(); reason =
"invalid size"; }
1868 else if (sf->PageNumber !=
n)
1869 { jam(); reason =
"invalid page number"; }
1870 else if (computeChecksum((Uint32*)sf, NDB_SF_PAGE_SIZE_IN_WORDS) != 0)
1871 { jam(); reason =
"invalid checksum"; }
1877 char reason_msg[128];
1879 "schema file corrupt, page %u (%s, "
1880 "sz=%u sz0=%u pn=%u)",
1881 n, reason, sf->FileSize, sf0->FileSize, sf->PageNumber);
1883 progError(__LINE__, NDBD_EXIT_SR_SCHEMAFILE, reason_msg);
1884 ndbrequireErr(fsPtr.p->fsState == FsConnectRecord::READ_SCHEMA1,
1885 NDBD_EXIT_SR_SCHEMAFILE);
1887 infoEvent(
"primary %s, trying backup", reason_msg);
1888 readSchemaRef(signal, fsPtr);
1893 fsPtr.p->fsState = FsConnectRecord::CLOSE_READ_SCHEMA;
1894 closeFile(signal, fsPtr.p->filePtr, fsPtr.i);
1898 void Dbdict::readSchemaRef(
Signal* signal,
1899 FsConnectRecordPtr fsPtr)
1904 fsPtr.p->fsState = FsConnectRecord::OPEN_READ_SCHEMA2;
1905 closeFile(signal, fsPtr.p->filePtr, fsPtr.i);
1909 void Dbdict::closeReadSchemaConf(
Signal* signal,
1910 FsConnectRecordPtr fsPtr)
1912 c_fsConnectRecordPool.
release(fsPtr);
1913 ReadSchemaRecord::SchemaReadState state = c_readSchemaRecord.schemaReadState;
1914 c_readSchemaRecord.schemaReadState = ReadSchemaRecord::IDLE;
1917 case ReadSchemaRecord::INITIAL_READ :
1922 ndbrequire(c_writeSchemaRecord.inUse ==
false);
1923 XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.oldSchemaPage != 0 ];
1925 (c_tableRecordPool.getSize() + NDB_SF_PAGE_ENTRIES - 1) /
1926 NDB_SF_PAGE_ENTRIES;
1927 resizeSchemaFile(xsf, noOfPages);
1929 c_writeSchemaRecord.inUse =
true;
1930 c_writeSchemaRecord.pageId = c_schemaRecord.oldSchemaPage;
1931 c_writeSchemaRecord.newFile =
true;
1932 c_writeSchemaRecord.firstPage = 0;
1933 c_writeSchemaRecord.noOfPages = xsf->noOfPages;
1935 c_writeSchemaRecord.m_callback.m_callbackFunction =
1936 safe_cast(&Dbdict::initSchemaFile_conf);
1938 startWriteSchemaFile(signal);
1950 Dbdict::convertSchemaFileTo_5_0_6(XSchemaFile * xsf)
1952 const Uint32 pageSize_old = 32 * 1024;
1954 Uint32 page_old[pageSize_old >> 2];
1960 if (xsf->noOfPages * NDB_SF_PAGE_SIZE != pageSize_old)
1963 memcpy(sf_old, sf0, pageSize_old);
1966 xsf->noOfPages = (sf_old->NoOfTableEntries + NDB_SF_PAGE_ENTRIES - 1) /
1967 NDB_SF_PAGE_ENTRIES;
1968 initSchemaFile(xsf, 0, xsf->noOfPages,
true);
1970 Uint32 noOfPages = 1;
1972 for (n = 0; n < xsf->noOfPages; n++) {
1974 for (i = 0; i < NDB_SF_PAGE_ENTRIES; i++) {
1975 j = n * NDB_SF_PAGE_ENTRIES +
i;
1976 if (j >= sf_old->NoOfTableEntries)
1979 if (te_old.m_tableState == SchemaFile::SF_UNUSED ||
1980 te_old.m_noOfPages == 0)
1984 te.m_tableState = te_old.m_tableState;
1985 te.m_tableVersion = te_old.m_tableVersion;
1986 te.m_tableType = te_old.m_tableType;
1987 te.m_info_words = te_old.m_noOfPages * ZSIZE_OF_PAGES_IN_WORDS -
1989 te.m_gcp = te_old.m_gcp;
1994 xsf->noOfPages = noOfPages;
1995 initSchemaFile(xsf, 0, xsf->noOfPages,
false);
2001 Dbdict::convertSchemaFileTo_6_4(XSchemaFile * xsf)
2003 for (Uint32 i = 0; i < xsf->noOfPages; i++)
2005 xsf->schemaPage[
i].NdbVersion = NDB_VERSION_D;
2006 for (Uint32 j = 0; j < NDB_SF_PAGE_ENTRIES; j++)
2008 Uint32 n = i * NDB_SF_PAGE_ENTRIES + j;
2011 switch(SchemaFile::Old::TableState(transEntry->m_tableState)) {
2012 case SchemaFile::Old::INIT:
2013 transEntry->m_tableState = SchemaFile::SF_UNUSED;
2015 case SchemaFile::Old::ADD_STARTED:
2016 transEntry->m_tableState = SchemaFile::SF_UNUSED;
2018 case SchemaFile::Old::TABLE_ADD_COMMITTED:
2019 transEntry->m_tableState = SchemaFile::SF_IN_USE;
2021 case SchemaFile::Old::DROP_TABLE_STARTED:
2022 transEntry->m_tableState = SchemaFile::SF_UNUSED;
2024 case SchemaFile::Old::DROP_TABLE_COMMITTED:
2025 transEntry->m_tableState = SchemaFile::SF_UNUSED;
2027 case SchemaFile::Old::ALTER_TABLE_COMMITTED:
2028 transEntry->m_tableState = SchemaFile::SF_IN_USE;
2030 case SchemaFile::Old::TEMPORARY_TABLE_COMMITTED:
2031 transEntry->m_tableState = SchemaFile::SF_IN_USE;
2034 transEntry->m_tableState = SchemaFile::SF_UNUSED;
2038 computeChecksum(xsf, i);
2054 c_attributeRecordHash(c_attributeRecordPool),
2055 c_file_hash(c_file_pool),
2056 c_filegroup_hash(c_filegroup_pool),
2057 c_obj_hash(c_obj_pool),
2058 c_schemaOpHash(c_schemaOpPool),
2059 c_schemaTransHash(c_schemaTransPool),
2060 c_schemaTransList(c_schemaTransPool),
2061 c_schemaTransCount(0),
2062 c_txHandleHash(c_txHandlePool),
2063 c_hash_map_hash(c_hash_map_pool),
2064 c_opCreateEvent(c_opRecordPool),
2065 c_opSubEvent(c_opRecordPool),
2066 c_opDropEvent(c_opRecordPool),
2067 c_opSignalUtil(c_opRecordPool),
2068 c_opRecordSequence(0)
2070 BLOCK_CONSTRUCTOR(
Dbdict);
2073 addRecSignal(GSN_DUMP_STATE_ORD, &Dbdict::execDUMP_STATE_ORD);
2074 addRecSignal(GSN_GET_TABINFOREQ, &Dbdict::execGET_TABINFOREQ);
2075 addRecSignal(GSN_GET_TABLEID_REQ, &Dbdict::execGET_TABLEDID_REQ);
2076 addRecSignal(GSN_GET_TABINFO_CONF, &Dbdict::execGET_TABINFO_CONF);
2077 addRecSignal(GSN_CONTINUEB, &Dbdict::execCONTINUEB);
2079 addRecSignal(GSN_DBINFO_SCANREQ, &Dbdict::execDBINFO_SCANREQ);
2081 addRecSignal(GSN_CREATE_TABLE_REQ, &Dbdict::execCREATE_TABLE_REQ);
2082 addRecSignal(GSN_CREATE_TAB_REQ, &Dbdict::execCREATE_TAB_REQ);
2083 addRecSignal(GSN_CREATE_TAB_REF, &Dbdict::execCREATE_TAB_REF);
2084 addRecSignal(GSN_CREATE_TAB_CONF, &Dbdict::execCREATE_TAB_CONF);
2085 addRecSignal(GSN_CREATE_FRAGMENTATION_REQ, &Dbdict::execCREATE_FRAGMENTATION_REQ);
2086 addRecSignal(GSN_CREATE_FRAGMENTATION_REF, &Dbdict::execCREATE_FRAGMENTATION_REF);
2087 addRecSignal(GSN_CREATE_FRAGMENTATION_CONF, &Dbdict::execCREATE_FRAGMENTATION_CONF);
2088 addRecSignal(GSN_DIADDTABCONF, &Dbdict::execDIADDTABCONF);
2089 addRecSignal(GSN_DIADDTABREF, &Dbdict::execDIADDTABREF);
2090 addRecSignal(GSN_ADD_FRAGREQ, &Dbdict::execADD_FRAGREQ);
2091 addRecSignal(GSN_TAB_COMMITCONF, &Dbdict::execTAB_COMMITCONF);
2092 addRecSignal(GSN_TAB_COMMITREF, &Dbdict::execTAB_COMMITREF);
2093 addRecSignal(GSN_ALTER_TABLE_REQ, &Dbdict::execALTER_TABLE_REQ);
2094 addRecSignal(GSN_ALTER_TAB_REF, &Dbdict::execALTER_TAB_REF);
2095 addRecSignal(GSN_ALTER_TAB_CONF, &Dbdict::execALTER_TAB_CONF);
2096 addRecSignal(GSN_ALTER_TABLE_REF, &Dbdict::execALTER_TABLE_REF);
2097 addRecSignal(GSN_ALTER_TABLE_CONF, &Dbdict::execALTER_TABLE_CONF);
2100 addRecSignal(GSN_CREATE_INDX_REQ, &Dbdict::execCREATE_INDX_REQ);
2101 addRecSignal(GSN_CREATE_INDX_IMPL_CONF, &Dbdict::execCREATE_INDX_IMPL_CONF);
2102 addRecSignal(GSN_CREATE_INDX_IMPL_REF, &Dbdict::execCREATE_INDX_IMPL_REF);
2104 addRecSignal(GSN_ALTER_INDX_REQ, &Dbdict::execALTER_INDX_REQ);
2105 addRecSignal(GSN_ALTER_INDX_CONF, &Dbdict::execALTER_INDX_CONF);
2106 addRecSignal(GSN_ALTER_INDX_REF, &Dbdict::execALTER_INDX_REF);
2107 addRecSignal(GSN_ALTER_INDX_IMPL_CONF, &Dbdict::execALTER_INDX_IMPL_CONF);
2108 addRecSignal(GSN_ALTER_INDX_IMPL_REF, &Dbdict::execALTER_INDX_IMPL_REF);
2110 addRecSignal(GSN_CREATE_TABLE_CONF, &Dbdict::execCREATE_TABLE_CONF);
2111 addRecSignal(GSN_CREATE_TABLE_REF, &Dbdict::execCREATE_TABLE_REF);
2113 addRecSignal(GSN_DROP_INDX_REQ, &Dbdict::execDROP_INDX_REQ);
2114 addRecSignal(GSN_DROP_INDX_IMPL_CONF, &Dbdict::execDROP_INDX_IMPL_CONF);
2115 addRecSignal(GSN_DROP_INDX_IMPL_REF, &Dbdict::execDROP_INDX_IMPL_REF);
2117 addRecSignal(GSN_DROP_TABLE_CONF, &Dbdict::execDROP_TABLE_CONF);
2118 addRecSignal(GSN_DROP_TABLE_REF, &Dbdict::execDROP_TABLE_REF);
2120 addRecSignal(GSN_BUILDINDXREQ, &Dbdict::execBUILDINDXREQ);
2121 addRecSignal(GSN_BUILDINDXCONF, &Dbdict::execBUILDINDXCONF);
2122 addRecSignal(GSN_BUILDINDXREF, &Dbdict::execBUILDINDXREF);
2123 addRecSignal(GSN_BUILD_INDX_IMPL_CONF, &Dbdict::execBUILD_INDX_IMPL_CONF);
2124 addRecSignal(GSN_BUILD_INDX_IMPL_REF, &Dbdict::execBUILD_INDX_IMPL_REF);
2127 addRecSignal(GSN_UTIL_PREPARE_CONF, &Dbdict::execUTIL_PREPARE_CONF);
2128 addRecSignal(GSN_UTIL_PREPARE_REF, &Dbdict::execUTIL_PREPARE_REF);
2130 addRecSignal(GSN_UTIL_EXECUTE_CONF, &Dbdict::execUTIL_EXECUTE_CONF);
2131 addRecSignal(GSN_UTIL_EXECUTE_REF, &Dbdict::execUTIL_EXECUTE_REF);
2133 addRecSignal(GSN_UTIL_RELEASE_CONF, &Dbdict::execUTIL_RELEASE_CONF);
2134 addRecSignal(GSN_UTIL_RELEASE_REF, &Dbdict::execUTIL_RELEASE_REF);
2137 addRecSignal(GSN_CREATE_EVNT_REQ, &Dbdict::execCREATE_EVNT_REQ);
2138 addRecSignal(GSN_CREATE_EVNT_CONF, &Dbdict::execCREATE_EVNT_CONF);
2139 addRecSignal(GSN_CREATE_EVNT_REF, &Dbdict::execCREATE_EVNT_REF);
2141 addRecSignal(GSN_CREATE_SUBID_CONF, &Dbdict::execCREATE_SUBID_CONF);
2142 addRecSignal(GSN_CREATE_SUBID_REF, &Dbdict::execCREATE_SUBID_REF);
2144 addRecSignal(GSN_SUB_CREATE_CONF, &Dbdict::execSUB_CREATE_CONF);
2145 addRecSignal(GSN_SUB_CREATE_REF, &Dbdict::execSUB_CREATE_REF);
2147 addRecSignal(GSN_SUB_START_REQ, &Dbdict::execSUB_START_REQ);
2148 addRecSignal(GSN_SUB_START_CONF, &Dbdict::execSUB_START_CONF);
2149 addRecSignal(GSN_SUB_START_REF, &Dbdict::execSUB_START_REF);
2151 addRecSignal(GSN_SUB_STOP_REQ, &Dbdict::execSUB_STOP_REQ);
2152 addRecSignal(GSN_SUB_STOP_CONF, &Dbdict::execSUB_STOP_CONF);
2153 addRecSignal(GSN_SUB_STOP_REF, &Dbdict::execSUB_STOP_REF);
2155 addRecSignal(GSN_DROP_EVNT_REQ, &Dbdict::execDROP_EVNT_REQ);
2157 addRecSignal(GSN_SUB_REMOVE_REQ, &Dbdict::execSUB_REMOVE_REQ);
2158 addRecSignal(GSN_SUB_REMOVE_CONF, &Dbdict::execSUB_REMOVE_CONF);
2159 addRecSignal(GSN_SUB_REMOVE_REF, &Dbdict::execSUB_REMOVE_REF);
2162 addRecSignal(GSN_CREATE_TRIG_REQ, &Dbdict::execCREATE_TRIG_REQ);
2163 addRecSignal(GSN_CREATE_TRIG_CONF, &Dbdict::execCREATE_TRIG_CONF);
2164 addRecSignal(GSN_CREATE_TRIG_REF, &Dbdict::execCREATE_TRIG_REF);
2165 addRecSignal(GSN_DROP_TRIG_REQ, &Dbdict::execDROP_TRIG_REQ);
2166 addRecSignal(GSN_DROP_TRIG_CONF, &Dbdict::execDROP_TRIG_CONF);
2167 addRecSignal(GSN_DROP_TRIG_REF, &Dbdict::execDROP_TRIG_REF);
2169 addRecSignal(GSN_CREATE_TRIG_IMPL_CONF, &Dbdict::execCREATE_TRIG_IMPL_CONF);
2170 addRecSignal(GSN_CREATE_TRIG_IMPL_REF, &Dbdict::execCREATE_TRIG_IMPL_REF);
2171 addRecSignal(GSN_DROP_TRIG_IMPL_CONF, &Dbdict::execDROP_TRIG_IMPL_CONF);
2172 addRecSignal(GSN_DROP_TRIG_IMPL_REF, &Dbdict::execDROP_TRIG_IMPL_REF);
2175 addRecSignal(GSN_GET_SCHEMA_INFOREQ, &Dbdict::execGET_SCHEMA_INFOREQ);
2176 addRecSignal(GSN_SCHEMA_INFO, &Dbdict::execSCHEMA_INFO);
2177 addRecSignal(GSN_SCHEMA_INFOCONF, &Dbdict::execSCHEMA_INFOCONF);
2178 addRecSignal(GSN_DICTSTARTREQ, &Dbdict::execDICTSTARTREQ);
2179 addRecSignal(GSN_READ_NODESCONF, &Dbdict::execREAD_NODESCONF);
2180 addRecSignal(GSN_FSOPENCONF, &Dbdict::execFSOPENCONF);
2181 addRecSignal(GSN_FSOPENREF, &Dbdict::execFSOPENREF,
true);
2182 addRecSignal(GSN_FSCLOSECONF, &Dbdict::execFSCLOSECONF);
2183 addRecSignal(GSN_FSWRITECONF, &Dbdict::execFSWRITECONF);
2184 addRecSignal(GSN_FSREADCONF, &Dbdict::execFSREADCONF);
2185 addRecSignal(GSN_FSREADREF, &Dbdict::execFSREADREF,
true);
2186 addRecSignal(GSN_LQHFRAGCONF, &Dbdict::execLQHFRAGCONF);
2187 addRecSignal(GSN_LQHADDATTCONF, &Dbdict::execLQHADDATTCONF);
2188 addRecSignal(GSN_LQHADDATTREF, &Dbdict::execLQHADDATTREF);
2189 addRecSignal(GSN_LQHFRAGREF, &Dbdict::execLQHFRAGREF);
2190 addRecSignal(GSN_NDB_STTOR, &Dbdict::execNDB_STTOR);
2191 addRecSignal(GSN_READ_CONFIG_REQ, &Dbdict::execREAD_CONFIG_REQ,
true);
2192 addRecSignal(GSN_STTOR, &Dbdict::execSTTOR);
2193 addRecSignal(GSN_TC_SCHVERCONF, &Dbdict::execTC_SCHVERCONF);
2194 addRecSignal(GSN_NODE_FAILREP, &Dbdict::execNODE_FAILREP);
2195 addRecSignal(GSN_INCL_NODEREQ, &Dbdict::execINCL_NODEREQ);
2196 addRecSignal(GSN_API_FAILREQ, &Dbdict::execAPI_FAILREQ);
2198 addRecSignal(GSN_WAIT_GCP_REF, &Dbdict::execWAIT_GCP_REF);
2199 addRecSignal(GSN_WAIT_GCP_CONF, &Dbdict::execWAIT_GCP_CONF);
2201 addRecSignal(GSN_LIST_TABLES_REQ, &Dbdict::execLIST_TABLES_REQ);
2203 addRecSignal(GSN_DROP_TABLE_REQ, &Dbdict::execDROP_TABLE_REQ);
2205 addRecSignal(GSN_PREP_DROP_TAB_REQ, &Dbdict::execPREP_DROP_TAB_REQ);
2206 addRecSignal(GSN_PREP_DROP_TAB_REF, &Dbdict::execPREP_DROP_TAB_REF);
2207 addRecSignal(GSN_PREP_DROP_TAB_CONF, &Dbdict::execPREP_DROP_TAB_CONF);
2209 addRecSignal(GSN_DROP_TAB_REF, &Dbdict::execDROP_TAB_REF);
2210 addRecSignal(GSN_DROP_TAB_CONF, &Dbdict::execDROP_TAB_CONF);
2212 addRecSignal(GSN_CREATE_FILE_REQ, &Dbdict::execCREATE_FILE_REQ);
2213 addRecSignal(GSN_CREATE_FILEGROUP_REQ, &Dbdict::execCREATE_FILEGROUP_REQ);
2215 addRecSignal(GSN_DROP_FILE_REQ, &Dbdict::execDROP_FILE_REQ);
2216 addRecSignal(GSN_DROP_FILEGROUP_REQ, &Dbdict::execDROP_FILEGROUP_REQ);
2218 addRecSignal(GSN_DROP_FILE_IMPL_REF, &Dbdict::execDROP_FILE_IMPL_REF);
2219 addRecSignal(GSN_DROP_FILE_IMPL_CONF, &Dbdict::execDROP_FILE_IMPL_CONF);
2221 addRecSignal(GSN_DROP_FILEGROUP_IMPL_REF,
2222 &Dbdict::execDROP_FILEGROUP_IMPL_REF);
2223 addRecSignal(GSN_DROP_FILEGROUP_IMPL_CONF,
2224 &Dbdict::execDROP_FILEGROUP_IMPL_CONF);
2226 addRecSignal(GSN_CREATE_FILE_IMPL_REF, &Dbdict::execCREATE_FILE_IMPL_REF);
2227 addRecSignal(GSN_CREATE_FILE_IMPL_CONF, &Dbdict::execCREATE_FILE_IMPL_CONF);
2228 addRecSignal(GSN_CREATE_FILEGROUP_IMPL_REF,
2229 &Dbdict::execCREATE_FILEGROUP_IMPL_REF);
2230 addRecSignal(GSN_CREATE_FILEGROUP_IMPL_CONF,
2231 &Dbdict::execCREATE_FILEGROUP_IMPL_CONF);
2233 addRecSignal(GSN_BACKUP_LOCK_TAB_REQ, &Dbdict::execBACKUP_LOCK_TAB_REQ);
2235 addRecSignal(GSN_SCHEMA_TRANS_BEGIN_REQ, &Dbdict::execSCHEMA_TRANS_BEGIN_REQ);
2236 addRecSignal(GSN_SCHEMA_TRANS_BEGIN_CONF, &Dbdict::execSCHEMA_TRANS_BEGIN_CONF);
2237 addRecSignal(GSN_SCHEMA_TRANS_BEGIN_REF, &Dbdict::execSCHEMA_TRANS_BEGIN_REF);
2238 addRecSignal(GSN_SCHEMA_TRANS_END_REQ, &Dbdict::execSCHEMA_TRANS_END_REQ);
2239 addRecSignal(GSN_SCHEMA_TRANS_END_CONF, &Dbdict::execSCHEMA_TRANS_END_CONF);
2240 addRecSignal(GSN_SCHEMA_TRANS_END_REF, &Dbdict::execSCHEMA_TRANS_END_REF);
2241 addRecSignal(GSN_SCHEMA_TRANS_END_REP, &Dbdict::execSCHEMA_TRANS_END_REP);
2242 addRecSignal(GSN_SCHEMA_TRANS_IMPL_REQ, &Dbdict::execSCHEMA_TRANS_IMPL_REQ);
2243 addRecSignal(GSN_SCHEMA_TRANS_IMPL_CONF, &Dbdict::execSCHEMA_TRANS_IMPL_CONF);
2244 addRecSignal(GSN_SCHEMA_TRANS_IMPL_REF, &Dbdict::execSCHEMA_TRANS_IMPL_REF);
2246 addRecSignal(GSN_DICT_LOCK_REQ, &Dbdict::execDICT_LOCK_REQ);
2247 addRecSignal(GSN_DICT_UNLOCK_ORD, &Dbdict::execDICT_UNLOCK_ORD);
2249 addRecSignal(GSN_DICT_TAKEOVER_REQ, &Dbdict::execDICT_TAKEOVER_REQ);
2250 addRecSignal(GSN_DICT_TAKEOVER_REF, &Dbdict::execDICT_TAKEOVER_REF);
2251 addRecSignal(GSN_DICT_TAKEOVER_CONF, &Dbdict::execDICT_TAKEOVER_CONF);
2253 addRecSignal(GSN_CREATE_HASH_MAP_REQ, &Dbdict::execCREATE_HASH_MAP_REQ);
2255 addRecSignal(GSN_COPY_DATA_REQ, &Dbdict::execCOPY_DATA_REQ);
2256 addRecSignal(GSN_COPY_DATA_REF, &Dbdict::execCOPY_DATA_REF);
2257 addRecSignal(GSN_COPY_DATA_CONF, &Dbdict::execCOPY_DATA_CONF);
2259 addRecSignal(GSN_COPY_DATA_IMPL_REF, &Dbdict::execCOPY_DATA_IMPL_REF);
2260 addRecSignal(GSN_COPY_DATA_IMPL_CONF, &Dbdict::execCOPY_DATA_IMPL_CONF);
2262 addRecSignal(GSN_CREATE_NODEGROUP_REQ, &Dbdict::execCREATE_NODEGROUP_REQ);
2263 addRecSignal(GSN_CREATE_NODEGROUP_IMPL_REF, &Dbdict::execCREATE_NODEGROUP_IMPL_REF);
2264 addRecSignal(GSN_CREATE_NODEGROUP_IMPL_CONF, &Dbdict::execCREATE_NODEGROUP_IMPL_CONF);
2266 addRecSignal(GSN_CREATE_HASH_MAP_REF, &Dbdict::execCREATE_HASH_MAP_REF);
2267 addRecSignal(GSN_CREATE_HASH_MAP_CONF, &Dbdict::execCREATE_HASH_MAP_CONF);
2269 addRecSignal(GSN_DROP_NODEGROUP_REQ, &Dbdict::execDROP_NODEGROUP_REQ);
2270 addRecSignal(GSN_DROP_NODEGROUP_IMPL_REF, &Dbdict::execDROP_NODEGROUP_IMPL_REF);
2271 addRecSignal(GSN_DROP_NODEGROUP_IMPL_CONF, &Dbdict::execDROP_NODEGROUP_IMPL_CONF);
2274 addRecSignal(GSN_INDEX_STAT_REQ, &Dbdict::execINDEX_STAT_REQ);
2275 addRecSignal(GSN_INDEX_STAT_CONF, &Dbdict::execINDEX_STAT_CONF);
2276 addRecSignal(GSN_INDEX_STAT_REF, &Dbdict::execINDEX_STAT_REF);
2277 addRecSignal(GSN_INDEX_STAT_IMPL_CONF, &Dbdict::execINDEX_STAT_IMPL_CONF);
2278 addRecSignal(GSN_INDEX_STAT_IMPL_REF, &Dbdict::execINDEX_STAT_IMPL_REF);
2279 addRecSignal(GSN_INDEX_STAT_REP, &Dbdict::execINDEX_STAT_REP);
2289 Dbdict::getParam(const
char *
name, Uint32 * count)
2291 if (name != 0 && count != 0)
2293 if (strcmp(name,
"ActiveCounters") == 0)
2302 void Dbdict::initCommonData()
2307 initRetrieveRecord(0, 0, 0);
2309 initRestartRecord();
2310 initSendSchemaRecord();
2311 initReadTableRecord();
2312 initWriteTableRecord();
2313 initReadSchemaRecord();
2314 initWriteSchemaRecord();
2316 c_masterNodeId = ZNIL;
2318 c_noNodesFailed = 0;
2320 c_packTable.m_state = PackTable::PTS_IDLE;
2322 c_restartType = 255;
2323 c_tabinfoReceived = 0;
2324 c_initialStart =
false;
2325 c_systemRestart =
false;
2326 c_initialNodeRestart =
false;
2327 c_nodeRestart =
false;
2329 c_outstanding_sub_startstop = 0;
2330 c_sub_startstop_lock.
clear();
2332 #if defined VM_TRACE || defined ERROR_INSERT
2340 void Dbdict::initRecords()
2345 initTriggerRecords();
2348 void Dbdict::initSendSchemaRecord()
2350 c_sendSchemaRecord.noOfWords = (Uint32)-1;
2351 c_sendSchemaRecord.pageId = RNIL;
2352 c_sendSchemaRecord.noOfWordsCurrentlySent = 0;
2353 c_sendSchemaRecord.noOfSignalsSentSinceDelay = 0;
2354 c_sendSchemaRecord.inUse =
false;
2358 void Dbdict::initReadTableRecord()
2360 c_readTableRecord.no_of_words= 0;
2361 c_readTableRecord.pageId = RNIL;
2362 c_readTableRecord.tableId = ZNIL;
2363 c_readTableRecord.inUse =
false;
2366 void Dbdict::initWriteTableRecord()
2368 c_writeTableRecord.no_of_words= 0;
2369 c_writeTableRecord.pageId = RNIL;
2370 c_writeTableRecord.noOfTableFilesHandled = 3;
2371 c_writeTableRecord.tableId = ZNIL;
2372 c_writeTableRecord.tableWriteState = WriteTableRecord::IDLE;
2375 void Dbdict::initReadSchemaRecord()
2377 c_readSchemaRecord.pageId = RNIL;
2378 c_readSchemaRecord.schemaReadState = ReadSchemaRecord::IDLE;
2381 void Dbdict::initWriteSchemaRecord()
2383 c_writeSchemaRecord.inUse =
false;
2384 c_writeSchemaRecord.pageId = RNIL;
2385 c_writeSchemaRecord.noOfSchemaFilesHandled = 3;
2388 void Dbdict::initRetrieveRecord(
Signal* signal, Uint32 i, Uint32 returnCode)
2390 c_retrieveRecord.busyState =
false;
2391 c_retrieveRecord.blockRef = 0;
2392 c_retrieveRecord.m_senderData = RNIL;
2393 c_retrieveRecord.tableId = RNIL;
2394 c_retrieveRecord.currentSent = 0;
2395 c_retrieveRecord.retrievedNoOfPages = 0;
2396 c_retrieveRecord.retrievedNoOfWords = 0;
2397 c_retrieveRecord.m_useLongSig =
false;
2400 void Dbdict::initSchemaRecord()
2402 c_schemaRecord.schemaPage = RNIL;
2403 c_schemaRecord.oldSchemaPage = RNIL;
2406 void Dbdict::initNodeRecords()
2409 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
2410 NodeRecordPtr nodePtr;
2411 c_nodes.
getPtr(nodePtr, i);
2412 new (nodePtr.p) NodeRecord();
2413 nodePtr.p->hotSpare =
false;
2414 nodePtr.p->nodeState = NodeRecord::API_NODE;
2418 void Dbdict::initPageRecords()
2420 c_retrieveRecord.retrievePage = ZMAX_PAGES_OF_TABLE_DEFINITION;
2421 ndbrequire(ZNUMBER_OF_PAGES >= (ZMAX_PAGES_OF_TABLE_DEFINITION + 1));
2422 c_schemaRecord.schemaPage = 0;
2423 c_schemaRecord.oldSchemaPage = NDB_SF_MAX_PAGES;
2426 void Dbdict::initTableRecords()
2428 TableRecordPtr tablePtr;
2432 c_tableRecordPool.
seize(tablePtr);
2433 if (tablePtr.i == RNIL) {
2437 initialiseTableRecord(tablePtr);
2441 void Dbdict::initialiseTableRecord(TableRecordPtr tablePtr)
2443 new (tablePtr.p) TableRecord();
2444 tablePtr.p->filePtr[0] = RNIL;
2445 tablePtr.p->filePtr[1] = RNIL;
2446 tablePtr.p->tableId = tablePtr.i;
2447 tablePtr.p->tableVersion = (Uint32)-1;
2448 tablePtr.p->fragmentType = DictTabInfo::AllNodesSmallTable;
2449 tablePtr.p->gciTableCreated = 0;
2450 tablePtr.p->noOfAttributes = ZNIL;
2451 tablePtr.p->noOfNullAttr = 0;
2452 tablePtr.p->fragmentCount = 0;
2458 tablePtr.p->kValue = 6;
2459 tablePtr.p->localKeyLen = 1;
2460 tablePtr.p->maxLoadFactor = 80;
2461 tablePtr.p->minLoadFactor = 70;
2462 tablePtr.p->noOfPrimkey = 1;
2463 tablePtr.p->tupKeyLength = 1;
2464 tablePtr.p->maxRowsLow = 0;
2465 tablePtr.p->maxRowsHigh = 0;
2466 tablePtr.p->defaultNoPartFlag =
true;
2467 tablePtr.p->linearHashFlag =
true;
2468 tablePtr.p->m_bits = 0;
2469 tablePtr.p->minRowsLow = 0;
2470 tablePtr.p->minRowsHigh = 0;
2471 tablePtr.p->singleUserMode = 0;
2472 tablePtr.p->tableType = DictTabInfo::UserTable;
2473 tablePtr.p->primaryTableId = RNIL;
2475 tablePtr.p->indexState = TableRecord::IS_UNDEFINED;
2476 tablePtr.p->triggerId = RNIL;
2477 tablePtr.p->buildTriggerId = RNIL;
2478 tablePtr.p->m_read_locked= 0;
2479 tablePtr.p->storageType = NDB_STORAGETYPE_DEFAULT;
2480 tablePtr.p->indexStatFragId = ZNIL;
2481 tablePtr.p->indexStatNodeId = ZNIL;
2482 tablePtr.p->indexStatBgRequest = 0;
2485 void Dbdict::initTriggerRecords()
2487 TriggerRecordPtr triggerPtr;
2491 c_triggerRecordPool.
seize(triggerPtr);
2492 if (triggerPtr.i == RNIL) {
2496 initialiseTriggerRecord(triggerPtr);
2500 void Dbdict::initialiseTriggerRecord(TriggerRecordPtr triggerPtr)
2502 new (triggerPtr.p) TriggerRecord();
2503 triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
2504 triggerPtr.p->triggerId = RNIL;
2505 triggerPtr.p->tableId = RNIL;
2506 triggerPtr.p->attributeMask.clear();
2507 triggerPtr.p->indexId = RNIL;
2510 Uint32 Dbdict::getFsConnRecord()
2512 FsConnectRecordPtr fsPtr;
2513 c_fsConnectRecordPool.
seize(fsPtr);
2514 ndbrequire(fsPtr.i != RNIL);
2515 fsPtr.p->filePtr = (Uint32)-1;
2516 fsPtr.p->ownerPtr = RNIL;
2517 fsPtr.p->fsState = FsConnectRecord::IDLE;
2525 Uint32 Dbdict::getFreeObjId(Uint32 minId,
bool both)
2527 const XSchemaFile * newxsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
2528 const XSchemaFile * oldxsf = &c_schemaFile[SchemaRecord::OLD_SCHEMA_FILE];
2529 const Uint32 noOfEntries = newxsf->noOfPages * NDB_SF_PAGE_ENTRIES;
2530 for (Uint32 i = minId; i<noOfEntries; i++)
2534 if (newentry->m_tableState == (Uint32)SchemaFile::SF_UNUSED)
2537 if (both ==
false ||
2538 oldentry->m_tableState == (Uint32)SchemaFile::SF_UNUSED)
2548 Uint32 Dbdict::getFreeTableRecord(Uint32 primaryTableId)
2550 Uint32 minId = (primaryTableId == RNIL ? 0 : primaryTableId + 1);
2551 if (ERROR_INSERTED(6012) && minId < 4096){
2553 CLEAR_ERROR_INSERT_VALUE;
2555 Uint32 i = getFreeObjId(0);
2560 if (i >= c_tableRecordPool.getSize()) {
2565 TableRecordPtr tablePtr;
2566 c_tableRecordPool.
getPtr(tablePtr, i);
2567 initialiseTableRecord(tablePtr);
2571 Uint32 Dbdict::getFreeTriggerRecord()
2573 const Uint32 size = c_triggerRecordPool.getSize();
2574 TriggerRecordPtr triggerPtr;
2575 for (triggerPtr.i = 0; triggerPtr.i < size; triggerPtr.i++) {
2577 c_triggerRecordPool.
getPtr(triggerPtr);
2578 if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED) {
2580 initialiseTriggerRecord(triggerPtr);
2581 return triggerPtr.i;
2588 Dbdict::check_read_obj(Uint32 objId, Uint32 transId)
2590 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
2591 if (objId < (NDB_SF_PAGE_ENTRIES * xsf->noOfPages))
2594 return check_read_obj(getTableEntry(xsf, objId), transId);
2596 return GetTabInfoRef::InvalidTableId;
2602 if (te->m_tableState == SchemaFile::SF_UNUSED)
2605 return GetTabInfoRef::TableNotDefined;
2608 if (te->m_transId == 0 || te->m_transId == transId)
2614 switch(te->m_tableState){
2615 case SchemaFile::SF_CREATE:
2617 return GetTabInfoRef::TableNotDefined;
2619 case SchemaFile::SF_ALTER:
2622 case SchemaFile::SF_DROP:
2625 return DropTableRef::ActiveSchemaTrans;
2626 case SchemaFile::SF_IN_USE:
2631 return GetTabInfoRef::TableNotDefined;
2637 Dbdict::check_write_obj(Uint32 objId, Uint32 transId)
2639 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
2640 if (objId < (NDB_SF_PAGE_ENTRIES * xsf->noOfPages))
2645 if (te->m_tableState == SchemaFile::SF_UNUSED)
2648 return GetTabInfoRef::TableNotDefined;
2651 if (te->m_transId == 0 || te->m_transId == transId)
2657 return DropTableRef::ActiveSchemaTrans;
2659 return GetTabInfoRef::InvalidTableId;
2663 Dbdict::check_write_obj(Uint32 objId, Uint32 transId,
2664 SchemaFile::EntryState op,
2667 Uint32 err = check_write_obj(objId, transId);
2671 setError(error, err, __LINE__);
2692 void Dbdict::execSTTOR(
Signal* signal)
2695 c_startPhase = signal->theData[1];
2696 switch (c_startPhase) {
2700 c_restartType = signal->theData[7];
2701 ndbrequire(c_restartType == NodeState::ST_INITIAL_START ||
2702 c_restartType == NodeState::ST_SYSTEM_RESTART ||
2703 c_restartType == NodeState::ST_INITIAL_NODE_RESTART ||
2704 c_restartType == NodeState::ST_NODE_RESTART);
2711 c_indexStatBgId = 0;
2712 indexStatBg_sendContinueB(signal);
2715 sendSTTORRY(signal);
2718 void Dbdict::sendSTTORRY(
Signal* signal)
2720 signal->theData[0] = 0;
2721 signal->theData[1] = 0;
2722 signal->theData[2] = 0;
2723 signal->theData[3] = 1;
2724 signal->theData[4] = 3;
2725 signal->theData[5] = 7;
2726 signal->theData[6] = ZNOMOREPHASES;
2727 sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 7, JBB);
2733 void Dbdict::execREAD_CONFIG_REQ(
Signal* signal)
2736 Uint32 ref = req->senderRef;
2737 Uint32 senderData = req->senderData;
2738 ndbrequire(req->noOfParameters == 0);
2743 m_ctx.m_config.getOwnConfigIterator();
2746 Uint32 attributesize, tablerecSize;
2747 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TRIGGERS,
2748 &c_maxNoOfTriggers));
2749 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_ATTRIBUTE,&attributesize));
2750 ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_TABLE, &tablerecSize));
2751 c_indexStatAutoCreate = 0;
2752 ndb_mgm_get_int_parameter(p, CFG_DB_INDEX_STAT_AUTO_CREATE,
2753 &c_indexStatAutoCreate);
2754 c_indexStatAutoUpdate = 0;
2755 ndb_mgm_get_int_parameter(p, CFG_DB_INDEX_STAT_AUTO_UPDATE,
2756 &c_indexStatAutoUpdate);
2758 c_attributeRecordPool.
setSize(attributesize);
2759 c_attributeRecordHash.
setSize(64);
2760 c_fsConnectRecordPool.
setSize(ZFS_CONNECT_SIZE);
2761 c_nodes.
setSize(MAX_NDB_NODES);
2762 c_pageRecordArray.
setSize(ZNUMBER_OF_PAGES);
2763 c_schemaPageRecordArray.
setSize(2 * NDB_SF_MAX_PAGES);
2764 c_tableRecordPool.
setSize(tablerecSize);
2765 g_key_descriptor_pool.setSize(tablerecSize);
2766 c_triggerRecordPool.
setSize(c_maxNoOfTriggers);
2768 c_opSectionBufferPool.
setSize(1024);
2769 c_schemaOpHash.
setSize(MAX_SCHEMA_OPERATIONS);
2770 c_schemaTransPool.
setSize(MAX_SCHEMA_TRANSACTIONS);
2775 c_obj_pool.
setSize(tablerecSize+c_maxNoOfTriggers);
2776 c_obj_hash.
setSize((tablerecSize+c_maxNoOfTriggers+1)/2);
2777 m_dict_lock_pool.
setSize(MAX_NDB_NODES);
2785 c_file_pool.init(RT_DBDICT_FILE, pc);
2786 c_filegroup_pool.init(RT_DBDICT_FILEGROUP, pc);
2795 c_createTableRecPool.
setSize(1 + 2 * MAX_INDEXES);
2796 c_dropTableRecPool.
setSize(1 + 2 * MAX_INDEXES);
2797 c_alterTableRecPool.
setSize(32);
2798 c_createTriggerRecPool.
setSize(4 * 2 * MAX_INDEXES);
2799 c_dropTriggerRecPool.
setSize(3 * 2 * MAX_INDEXES);
2800 c_createIndexRecPool.
setSize(2*MAX_INDEXES);
2801 c_dropIndexRecPool.
setSize(2 * MAX_INDEXES);
2802 c_alterIndexRecPool.
setSize(2 * MAX_INDEXES);
2803 c_buildIndexRecPool.
setSize(2 * 2 * MAX_INDEXES);
2804 c_indexStatRecPool.
setSize((1 + 4) * MAX_INDEXES);
2805 c_createFilegroupRecPool.
setSize(32);
2806 c_createFileRecPool.
setSize(32);
2807 c_dropFilegroupRecPool.
setSize(32);
2808 c_dropFileRecPool.
setSize(32);
2809 c_createHashMapRecPool.
setSize(32);
2810 c_copyDataRecPool.
setSize(32);
2811 c_schemaOpPool.
setSize(1 + 32 * MAX_INDEXES);
2815 g_hash_map.setSize(32);
2817 c_createNodegroupRecPool.
setSize(2);
2818 c_dropNodegroupRecPool.
setSize(2);
2827 c_schemaFile[0].schemaPage =
2829 c_schemaFile[0].noOfPages = 0;
2830 c_schemaFile[1].schemaPage =
2832 c_schemaFile[1].noOfPages = 0;
2835 rps += tablerecSize * (MAX_TAB_NAME_SIZE + MAX_FRM_DATA_SIZE);
2836 rps += attributesize * (MAX_ATTR_NAME_SIZE + MAX_ATTR_DEFAULT_VALUE_SIZE);
2837 rps += c_maxNoOfTriggers * MAX_TAB_NAME_SIZE;
2838 rps += (10 + 10) * MAX_TAB_NAME_SIZE;
2841 ndb_mgm_get_int_parameter(p, CFG_DB_STRING_MEMORY, &sm);
2848 sb = (Uint64(rps) * Uint64(sm)) / 100;
2855 sb /= (Rope::getSegmentSize() *
sizeof(Uint32));
2857 ndbrequire(sb < (Uint64(1) << 32));
2858 c_rope_pool.setSize(Uint32(sb));
2862 bat[0].WA = &c_schemaPageRecordArray.
getPtr(0)->word[0];
2863 bat[0].nrr = 2 * NDB_SF_MAX_PAGES;
2864 bat[0].ClusterSize = NDB_SF_PAGE_SIZE;
2865 bat[0].bits.q = NDB_SF_PAGE_SIZE_IN_WORDS_LOG2;
2867 bat[1].WA = &c_pageRecordArray.
getPtr(0)->word[0];
2868 bat[1].nrr = ZNUMBER_OF_PAGES;
2869 bat[1].ClusterSize = ZSIZE_OF_PAGES_IN_WORDS * 4;
2870 bat[1].bits.q = ZLOG_SIZE_OF_PAGES_IN_WORDS;
2877 conf->senderRef = reference();
2878 conf->senderData = senderData;
2879 sendSignal(ref, GSN_READ_CONFIG_CONF, signal,
2880 ReadConfigConf::SignalLength, JBB);
2885 while(objs.seize(ptr))
2892 if (NdbEnv_GetEnv(
"DICT_TRACE", buf,
sizeof(buf)))
2895 g_trace = (unsigned)atoi(buf);
2897 else if (ndb_mgm_get_int_parameter(p, CFG_DB_DICT_TRACE, &trace) == 0)
2907 void Dbdict::execNDB_STTOR(
Signal* signal)
2910 c_startPhase = signal->theData[2];
2911 const Uint32 restartType = signal->theData[3];
2912 if (restartType == NodeState::ST_INITIAL_START) {
2914 c_initialStart =
true;
2915 }
else if (restartType == NodeState::ST_SYSTEM_RESTART) {
2917 c_systemRestart =
true;
2918 }
else if (restartType == NodeState::ST_INITIAL_NODE_RESTART) {
2920 c_initialNodeRestart =
true;
2921 }
else if (restartType == NodeState::ST_NODE_RESTART) {
2923 c_nodeRestart =
true;
2927 switch (c_startPhase) {
2930 initSchemaFile(signal);
2934 signal->theData[0] = reference();
2935 sendSignal(NDBCNTR_REF, GSN_READ_NODESREQ, signal, 1, JBB);
2939 c_initialStart =
false;
2940 c_systemRestart =
false;
2941 c_initialNodeRestart =
false;
2942 c_nodeRestart =
false;
2943 sendNDB_STTORRY(signal);
2946 sendNDB_STTORRY(signal);
2950 sendNDB_STTORRY(signal);
2955 void Dbdict::sendNDB_STTORRY(
Signal* signal)
2957 signal->theData[0] = reference();
2958 sendSignal(NDBCNTR_REF, GSN_NDB_STTORRY, signal, 1, JBB);
2965 void Dbdict::execREAD_NODESCONF(
Signal* signal)
2970 c_numberNode = readNodes->noOfNodes;
2971 c_masterNodeId = readNodes->masterNodeId;
2973 c_noNodesFailed = 0;
2974 c_aliveNodes.
clear();
2975 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
2977 NodeRecordPtr nodePtr;
2978 c_nodes.
getPtr(nodePtr, i);
2982 nodePtr.p->nodeState = NodeRecord::NDB_NODE_ALIVE;
2992 nodePtr.p->nodeState = NodeRecord::NDB_NODE_DEAD;
2995 c_aliveNodes.
set(i);
2999 sendNDB_STTORRY(signal);
3002 void Dbdict::initSchemaFile(
Signal* signal)
3004 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
3005 xsf->noOfPages = (c_tableRecordPool.getSize() + NDB_SF_PAGE_ENTRIES - 1)
3006 / NDB_SF_PAGE_ENTRIES;
3007 initSchemaFile(xsf, 0, xsf->noOfPages,
true);
3009 XSchemaFile * oldxsf = &c_schemaFile[SchemaRecord::OLD_SCHEMA_FILE];
3010 oldxsf->noOfPages = xsf->noOfPages;
3011 memcpy(&oldxsf->schemaPage[0], &xsf->schemaPage[0], xsf->schemaPage[0].FileSize);
3013 if (c_initialStart || c_initialNodeRestart) {
3015 ndbrequire(c_writeSchemaRecord.inUse ==
false);
3016 c_writeSchemaRecord.inUse =
true;
3017 c_writeSchemaRecord.pageId = c_schemaRecord.schemaPage;
3018 c_writeSchemaRecord.newFile =
true;
3019 c_writeSchemaRecord.firstPage = 0;
3020 c_writeSchemaRecord.noOfPages = xsf->noOfPages;
3022 c_writeSchemaRecord.m_callback.m_callbackFunction =
3023 safe_cast(&Dbdict::initSchemaFile_conf);
3025 startWriteSchemaFile(signal);
3026 }
else if (c_systemRestart || c_nodeRestart) {
3028 ndbrequire(c_readSchemaRecord.schemaReadState == ReadSchemaRecord::IDLE);
3029 c_readSchemaRecord.pageId = c_schemaRecord.oldSchemaPage;
3030 c_readSchemaRecord.firstPage = 0;
3031 c_readSchemaRecord.noOfPages = 1;
3032 c_readSchemaRecord.schemaReadState = ReadSchemaRecord::INITIAL_READ_HEAD;
3033 startReadSchemaFile(signal);
3040 Dbdict::initSchemaFile_conf(
Signal* signal, Uint32 callbackData, Uint32 rv){
3042 sendNDB_STTORRY(signal);
3046 Dbdict::activateIndexes(
Signal* signal, Uint32 i)
3049 D(
"activateIndexes start");
3051 Uint32 requestFlags = 0;
3053 switch (c_restartType) {
3054 case NodeState::ST_SYSTEM_RESTART:
3056 if (c_masterNodeId != getOwnNodeId()) {
3057 D(
"activateIndexes not master");
3060 requestFlags |= DictSignal::RF_NO_BUILD;
3062 case NodeState::ST_NODE_RESTART:
3063 case NodeState::ST_INITIAL_NODE_RESTART:
3065 requestFlags |= DictSignal::RF_LOCAL_TRANS;
3066 requestFlags |= DictSignal::RF_NO_BUILD;
3073 TableRecordPtr indexPtr;
3075 for (; indexPtr.i < c_tableRecordPool.getSize(); indexPtr.i++)
3077 c_tableRecordPool.
getPtr(indexPtr);
3079 if (check_read_obj(indexPtr.i))
3084 if (!indexPtr.p->isIndex())
3089 if ((requestFlags & DictSignal::RF_LOCAL_TRANS) &&
3090 indexPtr.p->indexState != TableRecord::IS_ONLINE)
3097 D(
"activateIndexes i=" << indexPtr.i);
3100 seizeTxHandle(tx_ptr);
3101 ndbrequire(!tx_ptr.isNull());
3103 tx_ptr.p->m_requestInfo = 0;
3104 tx_ptr.p->m_requestInfo |= requestFlags;
3105 tx_ptr.p->m_userData = indexPtr.i;
3108 safe_cast(&Dbdict::activateIndex_fromBeginTrans),
3111 tx_ptr.p->m_callback = c;
3112 beginSchemaTrans(signal, tx_ptr);
3116 D(
"activateIndexes done");
3118 check_consistency();
3121 signal->theData[0] = reference();
3122 signal->theData[1] = c_restartRecord.m_senderData;
3123 sendSignal(c_restartRecord.returnBlockRef, GSN_DICTSTARTCONF,
3128 Dbdict::activateIndex_fromBeginTrans(
Signal* signal, Uint32 tx_key, Uint32
ret)
3130 D(
"activateIndex_fromBeginTrans" << V(tx_key) << V(ret));
3132 ndbrequire(ret == 0);
3135 findTxHandle(tx_ptr, tx_key);
3136 ndbrequire(!tx_ptr.isNull());
3138 TableRecordPtr indexPtr;
3139 indexPtr.i = tx_ptr.p->m_userData;
3140 c_tableRecordPool.
getPtr(indexPtr);
3144 Uint32 requestInfo = 0;
3145 DictSignal::setRequestType(requestInfo, AlterIndxImplReq::AlterIndexOnline);
3146 DictSignal::addRequestFlagsGlobal(requestInfo, tx_ptr.p->m_requestInfo);
3148 req->clientRef = reference();
3149 req->clientData = tx_ptr.p->tx_key;
3150 req->transId = tx_ptr.p->m_transId;
3151 req->transKey = tx_ptr.p->m_transKey;
3152 req->requestInfo = requestInfo;
3153 req->indexId = indexPtr.i;
3154 req->indexVersion = indexPtr.p->tableVersion;
3157 safe_cast(&Dbdict::activateIndex_fromAlterIndex),
3160 tx_ptr.p->m_callback = c;
3162 sendSignal(reference(), GSN_ALTER_INDX_REQ, signal,
3163 AlterIndxReq::SignalLength, JBB);
3167 Dbdict::activateIndex_fromAlterIndex(
Signal* signal, Uint32 tx_key, Uint32 ret)
3169 D(
"activateIndex_fromAlterIndex" << V(tx_key) << V(ret));
3171 ndbrequire(ret == 0);
3174 findTxHandle(tx_ptr, tx_key);
3175 ndbrequire(!tx_ptr.isNull());
3178 setError(tx_ptr.p->m_error, ret, __LINE__);
3181 safe_cast(&Dbdict::activateIndex_fromEndTrans),
3184 tx_ptr.p->m_callback = c;
3187 if (hasError(tx_ptr.p->m_error))
3188 flags |= SchemaTransEndReq::SchemaTransAbort;
3189 endSchemaTrans(signal, tx_ptr, flags);
3193 Dbdict::activateIndex_fromEndTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
3195 D(
"activateIndex_fromEndTrans" << V(tx_key) << V(ret));
3197 ndbrequire(ret == 0);
3200 findTxHandle(tx_ptr, tx_key);
3201 ndbrequire(!tx_ptr.isNull());
3203 TableRecordPtr indexPtr;
3204 c_tableRecordPool.
getPtr(indexPtr, tx_ptr.p->m_userData);
3206 char indexName[MAX_TAB_NAME_SIZE];
3208 DictObjectPtr obj_ptr;
3209 c_obj_pool.
getPtr(obj_ptr, indexPtr.p->m_obj_ptr_i);
3210 Rope name(c_rope_pool, obj_ptr.p->m_name);
3211 name.copy(indexName);
3214 ErrorInfo error = tx_ptr.p->m_error;
3215 if (!hasError(error))
3218 infoEvent(
"DICT: activate index %u done (%s)",
3219 indexPtr.i, indexName);
3224 warningEvent(
"DICT: activate index %u error: code=%u line=%u node=%u (%s)",
3226 error.errorCode, error.errorLine, error.errorNodeId,
3230 releaseTxHandle(tx_ptr);
3231 activateIndexes(signal, indexPtr.i + 1);
3235 Dbdict::rebuildIndexes(
Signal* signal, Uint32 i)
3238 D(
"rebuildIndexes start");
3240 TableRecordPtr indexPtr;
3242 for (; indexPtr.i < c_tableRecordPool.getSize(); indexPtr.i++) {
3243 c_tableRecordPool.
getPtr(indexPtr);
3244 if (check_read_obj(indexPtr.i))
3246 if (!indexPtr.p->isIndex())
3250 D(
"rebuildIndexes i=" << indexPtr.i);
3253 seizeTxHandle(tx_ptr);
3254 ndbrequire(!tx_ptr.isNull());
3256 Uint32 requestInfo = 0;
3257 if (indexPtr.p->m_bits & TableRecord::TR_Logged) {
3259 requestInfo |= DictSignal::RF_NO_BUILD;
3261 tx_ptr.p->m_requestInfo = requestInfo;
3262 tx_ptr.p->m_userData = indexPtr.i;
3265 safe_cast(&Dbdict::rebuildIndex_fromBeginTrans),
3268 tx_ptr.p->m_callback = c;
3269 beginSchemaTrans(signal, tx_ptr);
3273 D(
"rebuildIndexes done");
3274 sendNDB_STTORRY(signal);
3278 Dbdict::rebuildIndex_fromBeginTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
3280 D(
"rebuildIndex_fromBeginTrans" << V(tx_key) << V(ret));
3282 ndbrequire(ret == 0);
3285 findTxHandle(tx_ptr, tx_key);
3286 ndbrequire(!tx_ptr.isNull());
3288 TableRecordPtr indexPtr;
3289 indexPtr.i = tx_ptr.p->m_userData;
3290 c_tableRecordPool.
getPtr(indexPtr);
3294 Uint32 requestInfo = 0;
3295 DictSignal::setRequestType(requestInfo, BuildIndxReq::MainOp);
3296 DictSignal::addRequestFlagsGlobal(requestInfo, tx_ptr.p->m_requestInfo);
3298 req->clientRef = reference();
3299 req->clientData = tx_ptr.p->tx_key;
3300 req->transId = tx_ptr.p->m_transId;
3301 req->transKey = tx_ptr.p->m_transKey;
3302 req->requestInfo = requestInfo;
3305 req->tableId = indexPtr.p->primaryTableId;
3306 req->indexId = indexPtr.i;
3307 req->indexType = indexPtr.p->tableType;
3308 req->parallelism = 16;
3311 safe_cast(&Dbdict::rebuildIndex_fromBuildIndex),
3314 tx_ptr.p->m_callback = c;
3316 sendSignal(reference(), GSN_BUILDINDXREQ, signal,
3317 BuildIndxReq::SignalLength, JBB);
3321 Dbdict::rebuildIndex_fromBuildIndex(
Signal* signal, Uint32 tx_key, Uint32 ret)
3323 D(
"rebuildIndex_fromBuildIndex" << V(tx_key) << V(ret));
3325 ndbrequire(ret == 0);
3328 findTxHandle(tx_ptr, tx_key);
3329 ndbrequire(!tx_ptr.isNull());
3332 setError(tx_ptr.p->m_error, ret, __LINE__);
3335 safe_cast(&Dbdict::rebuildIndex_fromEndTrans),
3338 tx_ptr.p->m_callback = c;
3341 if (hasError(tx_ptr.p->m_error))
3342 flags |= SchemaTransEndReq::SchemaTransAbort;
3343 endSchemaTrans(signal, tx_ptr, flags);
3347 Dbdict::rebuildIndex_fromEndTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
3349 D(
"rebuildIndex_fromEndTrans" << V(tx_key) << V(ret));
3351 ndbrequire(ret == 0);
3354 findTxHandle(tx_ptr, tx_key);
3355 ndbrequire(!tx_ptr.isNull());
3357 TableRecordPtr indexPtr;
3358 c_tableRecordPool.
getPtr(indexPtr, tx_ptr.p->m_userData);
3360 const char* actionName;
3362 Uint32 requestInfo = tx_ptr.p->m_requestInfo;
3363 bool noBuild = (requestInfo & DictSignal::RF_NO_BUILD);
3364 actionName = !noBuild ?
"rebuild" :
"online";
3367 char indexName[MAX_TAB_NAME_SIZE];
3369 DictObjectPtr obj_ptr;
3370 c_obj_pool.
getPtr(obj_ptr, indexPtr.p->m_obj_ptr_i);
3371 Rope name(c_rope_pool, obj_ptr.p->m_name);
3372 name.copy(indexName);
3375 ErrorInfo error = tx_ptr.p->m_error;
3376 if (!hasError(error)) {
3379 "DICT: %s index %u done (%s)",
3380 actionName, indexPtr.i, indexName);
3384 "DICT: %s index %u error: code=%u line=%u node=%u (%s)",
3386 indexPtr.i, error.errorCode, error.errorLine, error.errorNodeId,
3390 Uint32 i = tx_ptr.p->m_userData;
3391 releaseTxHandle(tx_ptr);
3393 rebuildIndexes(signal, i + 1);
3411 void Dbdict::execDICTSTARTREQ(
Signal* signal)
3414 c_restartRecord.gciToRestart = signal->theData[0];
3415 c_restartRecord.returnBlockRef = signal->theData[1];
3416 c_restartRecord.m_senderData = signal->theData[2];
3417 if (signal->getLength() < DictStartReq::SignalLength)
3420 c_restartRecord.m_senderData = 0;
3422 if (c_nodeRestart || c_initialNodeRestart) {
3425 CRASH_INSERTION(6000);
3427 BlockReference dictRef = calcDictBlockRef(c_masterNodeId);
3428 signal->theData[0] = getOwnNodeId();
3429 sendSignal(dictRef, GSN_GET_SCHEMA_INFOREQ, signal, 1, JBB);
3432 ndbrequire(c_systemRestart);
3433 ndbrequire(c_masterNodeId == getOwnNodeId());
3435 c_schemaRecord.m_callback.m_callbackData = 0;
3436 c_schemaRecord.m_callback.m_callbackFunction =
3437 safe_cast(&Dbdict::masterRestart_checkSchemaStatusComplete);
3444 XSchemaFile * oldxsf = &c_schemaFile[SchemaRecord::OLD_SCHEMA_FILE];
3445 checkPendingSchemaTrans(oldxsf);
3446 XSchemaFile * newxsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
3447 newxsf->noOfPages = oldxsf->noOfPages;
3448 memcpy(&newxsf->schemaPage[0],
3449 &oldxsf->schemaPage[0],
3450 oldxsf->schemaPage[0].FileSize);
3454 { safe_cast(&Dbdict::masterRestart_checkSchemaStatusComplete), 0 };
3455 startRestoreSchema(signal, cb);
3459 Dbdict::masterRestart_checkSchemaStatusComplete(
Signal* signal,
3460 Uint32 callbackData,
3463 XSchemaFile * oldxsf = &c_schemaFile[SchemaRecord::OLD_SCHEMA_FILE];
3464 ndbrequire(oldxsf->noOfPages != 0);
3467 ptr[0].p = (Uint32*)&oldxsf->schemaPage[0];
3468 ptr[0].sz = oldxsf->noOfPages * NDB_SF_PAGE_SIZE_IN_WORDS;
3470 c_sendSchemaRecord.m_SCHEMAINFO_Counter = c_aliveNodes;
3473 rg.m_nodes.
clear(getOwnNodeId());
3474 Callback c = { 0, 0 };
3475 sendFragmentedSignal(rg,
3484 XSchemaFile * newxsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
3485 newxsf->noOfPages = oldxsf->noOfPages;
3486 memcpy(&newxsf->schemaPage[0], &oldxsf->schemaPage[0],
3487 oldxsf->noOfPages * NDB_SF_PAGE_SIZE);
3489 signal->theData[0] = getOwnNodeId();
3490 sendSignal(reference(), GSN_SCHEMA_INFOCONF, signal, 1, JBB);
3494 Dbdict::execGET_SCHEMA_INFOREQ(
Signal* signal){
3496 const Uint32 ref = signal->getSendersBlockRef();
3499 ndbrequire(c_sendSchemaRecord.inUse ==
false);
3500 c_sendSchemaRecord.inUse =
true;
3504 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
3505 ndbrequire(xsf->noOfPages != 0);
3507 ptr[0].p = (Uint32*)&xsf->schemaPage[0];
3508 ptr[0].sz = xsf->noOfPages * NDB_SF_PAGE_SIZE_IN_WORDS;
3510 Callback c = { safe_cast(&Dbdict::sendSchemaComplete), 0 };
3511 sendFragmentedSignal(ref,
3522 Dbdict::sendSchemaComplete(
Signal * signal,
3523 Uint32 callbackData,
3525 ndbrequire(c_sendSchemaRecord.inUse ==
true);
3526 c_sendSchemaRecord.inUse =
false;
3535 void Dbdict::execSCHEMA_INFO(
Signal* signal)
3544 CRASH_INSERTION(6001);
3551 XSchemaFile * oldxsf = &c_schemaFile[SchemaRecord::OLD_SCHEMA_FILE];
3552 XSchemaFile * newxsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
3553 memcpy(&newxsf->schemaPage[0],
3554 &oldxsf->schemaPage[0],
3555 oldxsf->schemaPage[0].FileSize);
3560 handle.getSection(schemaDataPtr, 0);
3562 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::OLD_SCHEMA_FILE];
3563 ndbrequire(schemaDataPtr.sz % NDB_SF_PAGE_SIZE_IN_WORDS == 0);
3564 xsf->noOfPages = schemaDataPtr.sz / NDB_SF_PAGE_SIZE_IN_WORDS;
3565 copy((Uint32*)&xsf->schemaPage[0], schemaDataPtr);
3566 releaseSections(handle);
3569 if (sf0->NdbVersion < NDB_SF_VERSION_5_0_6) {
3570 bool ok = convertSchemaFileTo_5_0_6(xsf);
3574 if (sf0->NdbVersion < NDB_MAKE_VERSION(6,4,0))
3577 bool ok = convertSchemaFileTo_6_4(xsf);
3581 validateChecksum(xsf);
3583 XSchemaFile * ownxsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
3584 checkPendingSchemaTrans(ownxsf);
3585 resizeSchemaFile(xsf, ownxsf->noOfPages);
3587 ndbrequire(signal->getSendersBlockRef() != reference());
3597 { safe_cast(&Dbdict::restart_checkSchemaStatusComplete), 0 };
3598 startRestoreSchema(signal, cb);
3602 Dbdict::restart_checkSchemaStatusComplete(
Signal * signal,
3603 Uint32 callbackData,
3611 signal->theData[0] = getOwnNodeId();
3612 sendSignal(calcDictBlockRef(c_masterNodeId), GSN_SCHEMA_INFOCONF,
3617 ndbrequire(c_restartRecord.m_op_cnt == 0);
3618 ndbrequire(c_nodeRestart || c_initialNodeRestart);
3619 activateIndexes(signal, 0);
3623 void Dbdict::execSCHEMA_INFOCONF(
Signal* signal)
3626 ndbrequire(signal->getNoOfSections() == 0);
3633 const Uint32 nodeId = signal->theData[0];
3634 c_sendSchemaRecord.m_SCHEMAINFO_Counter.clearWaitingFor(nodeId);
3636 if (!c_sendSchemaRecord.m_SCHEMAINFO_Counter.done()){
3640 activateIndexes(signal, 0);
3644 checkSchemaStatus(Uint32 tableType, Uint32 pass)
3647 case DictTabInfo::UndefTableType:
3649 case DictTabInfo::HashIndexTrigger:
3650 case DictTabInfo::SubscriptionTrigger:
3651 case DictTabInfo::ReadOnlyConstraint:
3652 case DictTabInfo::IndexTrigger:
3655 return pass == 0 || pass == 11 || pass == 12;
3657 return pass == 1 || pass == 10 || pass == 13;
3660 return pass == 2 || pass == 9 || pass == 14;
3661 case DictTabInfo::HashMap:
3662 return pass == 3 || pass == 8 || pass == 15;
3663 case DictTabInfo::SystemTable:
3664 case DictTabInfo::UserTable:
3666 case DictTabInfo::UniqueHashIndex:
3667 case DictTabInfo::HashIndex:
3668 case DictTabInfo::UniqueOrderedIndex:
3669 case DictTabInfo::OrderedIndex:
3676 static const Uint32 CREATE_OLD_PASS = 5;
3677 static const Uint32 DROP_OLD_PASS = 11;
3678 static const Uint32 CREATE_NEW_PASS = 17;
3679 static const Uint32 LAST_PASS = 17;
3685 out <<
" state: " << entry.m_tableState;
3686 out <<
" version: " << hex << entry.m_tableVersion << dec;
3687 out <<
" type: " << entry.m_tableType;
3688 out <<
" words: " << entry.m_info_words;
3689 out <<
" gcp: " << entry.m_gcp;
3690 out <<
" trans: " << entry.m_transId;
3695 void Dbdict::initRestartRecord(Uint32 startpass, Uint32 lastpass,
3696 const char * sb,
const char * eb)
3698 c_restartRecord.gciToRestart = 0;
3699 c_restartRecord.activeTable = 0;
3700 c_restartRecord.m_op_cnt = 0;
3701 if (startpass == 0 && lastpass == 0)
3704 c_restartRecord.m_pass = 0;
3705 c_restartRecord.m_end_pass = LAST_PASS;
3706 c_restartRecord.m_start_banner =
"Starting to restore schema";
3707 c_restartRecord.m_end_banner =
"Restore of schema complete";
3712 c_restartRecord.m_pass = startpass;
3713 c_restartRecord.m_end_pass = lastpass;
3714 c_restartRecord.m_start_banner = sb;
3715 c_restartRecord.m_end_banner = eb;
3742 void Dbdict::checkSchemaStatus(
Signal* signal)
3746 XSchemaFile * masterxsf = &c_schemaFile[SchemaRecord::OLD_SCHEMA_FILE];
3747 XSchemaFile * ownxsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
3749 ndbrequire(masterxsf->noOfPages == ownxsf->noOfPages);
3750 const Uint32 noOfEntries = masterxsf->noOfPages * NDB_SF_PAGE_ENTRIES;
3752 for (; c_restartRecord.activeTable < noOfEntries;
3753 c_restartRecord.activeTable++)
3757 Uint32 tableId = c_restartRecord.activeTable;
3760 SchemaFile::EntryState masterState =
3761 (SchemaFile::EntryState)masterEntry->m_tableState;
3762 SchemaFile::EntryState ownState =
3763 (SchemaFile::EntryState)ownEntry->m_tableState;
3765 if (c_restartRecord.activeTable >= c_tableRecordPool.getSize())
3768 ndbrequire(masterState == SchemaFile::SF_UNUSED);
3769 ndbrequire(ownState == SchemaFile::SF_UNUSED);
3773 D(
"checkSchemaStatus" << V(*ownEntry) << V(*masterEntry));
3776 #ifdef PRINT_SCHEMA_RESTART
3777 printf(
"checkSchemaStatus: pass: %d table: %d",
3778 c_restartRecord.m_pass, tableId);
3779 ndbout <<
"old: " << *ownEntry <<
" new: " << *masterEntry << endl;
3782 if (c_restartRecord.m_pass <= CREATE_OLD_PASS)
3784 if (!::checkSchemaStatus(ownEntry->m_tableType, c_restartRecord.m_pass))
3788 if (ownState == SchemaFile::SF_UNUSED)
3791 restartCreateObj(signal, tableId, ownEntry,
true);
3795 if (c_restartRecord.m_pass <= DROP_OLD_PASS)
3797 if (!::checkSchemaStatus(ownEntry->m_tableType, c_restartRecord.m_pass))
3800 if (ownState != SchemaFile::SF_IN_USE)
3803 if (* ownEntry == * masterEntry)
3806 restartDropObj(signal, tableId, ownEntry);
3810 if (c_restartRecord.m_pass <= CREATE_NEW_PASS)
3812 if (!::checkSchemaStatus(masterEntry->m_tableType, c_restartRecord.m_pass))
3815 if (masterState != SchemaFile::SF_IN_USE)
3817 if (ownEntry->m_tableType != DictTabInfo::SchemaTransaction)
3829 if (DictTabInfo::isIndex(masterEntry->m_tableType) ||
3830 DictTabInfo::isTable(masterEntry->m_tableType))
3832 bool file = * ownEntry == *masterEntry &&
3833 (!DictTabInfo::isIndex(masterEntry->m_tableType) || c_systemRestart);
3835 restartCreateObj(signal, tableId, masterEntry, file);
3839 if (* ownEntry == *masterEntry)
3842 restartCreateObj(signal, tableId, masterEntry,
false);
3847 if (c_restartRecord.m_op_cnt == 0)
3850 restartNextPass(signal);
3857 c_restartRecord.m_op_cnt = 0;
3860 c_txHandleHash.
getPtr(tx_ptr, c_restartRecord.m_tx_ptr_i);
3863 safe_cast(&Dbdict::restartEndPass_fromEndTrans),
3866 tx_ptr.p->m_callback = c;
3869 endSchemaTrans(signal, tx_ptr, flags);
3875 Dbdict::checkPendingSchemaTrans(XSchemaFile* xsf)
3877 for (Uint32 i = 0; i < xsf->noOfPages * NDB_SF_PAGE_ENTRIES; i++)
3881 if (transEntry->m_tableType == DictTabInfo::SchemaTransaction &&
3882 transEntry->m_transId != 0)
3886 bool commit =
false;
3887 switch(transEntry->m_tableState){
3888 case SchemaFile::SF_STARTED:
3889 case SchemaFile::SF_PREPARE:
3890 case SchemaFile::SF_ABORT:
3892 ndbout_c(
"Found pending trans (%u) - aborting", i);
3894 case SchemaFile::SF_COMMIT:
3895 case SchemaFile::SF_COMPLETE:
3898 ndbout_c(
"Found pending trans (%u) - committing", i);
3902 const Uint32 transId = transEntry->m_transId;
3903 for (Uint32 j = 0; j<xsf->noOfPages * NDB_SF_PAGE_ENTRIES; j++)
3906 if (tmp->m_transId == transId &&
3907 tmp->m_tableType != DictTabInfo::SchemaTransaction)
3911 switch(tmp->m_tableState){
3912 case SchemaFile::SF_CREATE:
3916 tmp->m_tableState = SchemaFile::SF_IN_USE;
3917 ndbout_c(
"commit create %u", j);
3922 tmp->m_tableState = SchemaFile::SF_UNUSED;
3923 ndbout_c(
"abort create %u", j);
3926 case SchemaFile::SF_ALTER:
3927 tmp->m_tableState = SchemaFile::SF_IN_USE;
3931 ndbout_c(
"commit alter %u", j);
3936 ndbout_c(
"abort alter %u", j);
3937 tmp->m_tableVersion =
3938 alter_obj_dec_schema_version(tmp->m_tableVersion);
3941 case SchemaFile::SF_DROP:
3945 tmp->m_tableState = SchemaFile::SF_UNUSED;
3946 ndbout_c(
"commit drop %u", j);
3951 tmp->m_tableState = SchemaFile::SF_IN_USE;
3952 ndbout_c(
"abort drop %u", j);
3959 transEntry->m_tableType = DictTabInfo::UndefTableType;
3960 transEntry->m_tableState = SchemaFile::SF_UNUSED;
3961 transEntry->m_transId = 0;
3967 Dbdict::startRestoreSchema(
Signal* signal, Callback cb)
3971 initRestartRecord();
3972 c_schemaRecord.m_callback = cb;
3975 seizeTxHandle(tx_ptr);
3976 ndbrequire(!tx_ptr.isNull());
3978 c_restartRecord.m_tx_ptr_i = tx_ptr.i;
3979 tx_ptr.p->m_requestInfo = DictSignal::RF_LOCAL_TRANS;
3980 tx_ptr.p->m_userData = 0;
3983 safe_cast(&Dbdict::restart_fromBeginTrans),
3986 tx_ptr.p->m_callback = c;
3987 beginSchemaTrans(signal, tx_ptr);
3989 if (c_restartRecord.m_start_banner)
3992 infoEvent(
"%s", c_restartRecord.m_start_banner);
3997 Dbdict::restart_fromBeginTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
3999 ndbrequire(ret == 0);
4002 findTxHandle(tx_ptr, tx_key);
4003 ndbrequire(!tx_ptr.isNull());
4005 checkSchemaStatus(signal);
4009 Dbdict::restart_nextOp(
Signal* signal,
bool commit)
4011 c_restartRecord.m_op_cnt++;
4014 c_opSectionBufferPool.getNoOfFree() < MAX_WORDS_META_FILE)
4021 c_restartRecord.m_op_cnt = ZRESTART_OPS_PER_TRANS;
4024 if (commit || c_restartRecord.m_op_cnt >= ZRESTART_OPS_PER_TRANS)
4027 c_restartRecord.m_op_cnt = 0;
4030 c_txHandleHash.
getPtr(tx_ptr, c_restartRecord.m_tx_ptr_i);
4033 safe_cast(&Dbdict::restart_fromEndTrans),
4036 tx_ptr.p->m_callback = c;
4039 endSchemaTrans(signal, tx_ptr, flags);
4044 c_restartRecord.activeTable++;
4045 checkSchemaStatus(signal);
4050 Dbdict::restart_fromEndTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
4053 findTxHandle(tx_ptr, tx_key);
4054 ndbrequire(!tx_ptr.isNull());
4056 if (unlikely(hasError(tx_ptr.p->m_error)))
4063 ndbout <<
"error: " << tx_ptr.p->m_error << endl;
4067 "Failed to restore schema during restart, error %u."
4068 ,tx_ptr.p->m_error.errorCode);
4069 progError(__LINE__, NDBD_EXIT_RESTORE_SCHEMA, msg);
4071 ndbrequire(ret == 0);
4073 releaseTxHandle(tx_ptr);
4075 ndbrequire(c_restartRecord.m_op_cnt == 0);
4076 c_restartRecord.activeTable++;
4078 seizeTxHandle(tx_ptr);
4079 ndbrequire(!tx_ptr.isNull());
4080 c_restartRecord.m_tx_ptr_i = tx_ptr.i;
4081 tx_ptr.p->m_requestInfo = DictSignal::RF_LOCAL_TRANS;
4082 tx_ptr.p->m_userData = 0;
4085 safe_cast(&Dbdict::restart_fromBeginTrans),
4088 tx_ptr.p->m_callback = c;
4089 beginSchemaTrans(signal, tx_ptr);
4093 Dbdict::restartEndPass_fromEndTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
4096 findTxHandle(tx_ptr, tx_key);
4097 ndbrequire(!tx_ptr.isNull());
4099 if (unlikely(hasError(tx_ptr.p->m_error)))
4106 ndbout <<
"error: " << tx_ptr.p->m_error << endl;
4110 "Failed to restore schema during restart, error %u."
4111 ,tx_ptr.p->m_error.errorCode);
4112 progError(__LINE__, NDBD_EXIT_RESTORE_SCHEMA, msg);
4114 ndbrequire(ret == 0);
4116 releaseTxHandle(tx_ptr);
4117 c_restartRecord.m_tx_ptr_i = RNIL;
4119 restartNextPass(signal);
4123 Dbdict::restartNextPass(
Signal* signal)
4125 c_restartRecord.m_pass++;
4126 c_restartRecord.activeTable= 0;
4128 if (c_restartRecord.m_pass <= c_restartRecord.m_end_pass)
4131 if (c_restartRecord.m_tx_ptr_i == RNIL)
4134 seizeTxHandle(tx_ptr);
4135 ndbrequire(!tx_ptr.isNull());
4136 c_restartRecord.m_tx_ptr_i = tx_ptr.i;
4137 tx_ptr.p->m_requestInfo = DictSignal::RF_LOCAL_TRANS;
4138 tx_ptr.p->m_userData = 0;
4141 safe_cast(&Dbdict::restart_fromBeginTrans),
4144 tx_ptr.p->m_callback = c;
4145 beginSchemaTrans(signal, tx_ptr);
4151 c_txHandleHash.
getPtr(tx_ptr, c_restartRecord.m_tx_ptr_i);
4152 restart_fromBeginTrans(signal, tx_ptr.p->tx_key, 0);
4156 else if (c_restartRecord.m_tx_ptr_i != RNIL)
4163 c_restartRecord.m_pass--;
4164 c_restartRecord.m_op_cnt = 0;
4167 c_txHandleHash.
getPtr(tx_ptr, c_restartRecord.m_tx_ptr_i);
4170 safe_cast(&Dbdict::restartEndPass_fromEndTrans),
4173 tx_ptr.p->m_callback = c;
4176 endSchemaTrans(signal, tx_ptr, flags);
4183 ndbrequire(c_restartRecord.m_op_cnt == 0);
4188 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
4189 ndbrequire(c_writeSchemaRecord.inUse ==
false);
4190 c_writeSchemaRecord.inUse =
true;
4191 c_writeSchemaRecord.pageId = c_schemaRecord.schemaPage;
4192 c_writeSchemaRecord.newFile =
false;
4193 c_writeSchemaRecord.firstPage = 0;
4194 c_writeSchemaRecord.noOfPages = xsf->noOfPages;
4195 c_writeSchemaRecord.m_callback.m_callbackData = 0;
4196 c_writeSchemaRecord.m_callback.m_callbackFunction =
4197 safe_cast(&Dbdict::restart_fromWriteSchemaFile);
4199 for(Uint32 i = 0; i<xsf->noOfPages; i++)
4200 computeChecksum(xsf, i);
4202 startWriteSchemaFile(signal);
4207 Dbdict::restart_fromWriteSchemaFile(
Signal* signal,
4211 if (c_restartRecord.m_end_banner)
4214 infoEvent(
"%s", c_restartRecord.m_end_banner);
4217 execute(signal, c_schemaRecord.m_callback, retCode);
4221 Dbdict::execGET_TABINFO_CONF(
Signal* signal)
4232 switch(conf->tableType){
4233 case DictTabInfo::UndefTableType:
4234 case DictTabInfo::HashIndexTrigger:
4235 case DictTabInfo::SubscriptionTrigger:
4236 case DictTabInfo::ReadOnlyConstraint:
4237 case DictTabInfo::IndexTrigger:
4239 case DictTabInfo::SystemTable:
4240 case DictTabInfo::UserTable:
4241 case DictTabInfo::UniqueHashIndex:
4242 case DictTabInfo::HashIndex:
4243 case DictTabInfo::UniqueOrderedIndex:
4244 case DictTabInfo::OrderedIndex:
4250 if(refToBlock(conf->senderRef) == TSMAN
4251 && (refToNode(conf->senderRef) == 0
4252 || refToNode(conf->senderRef) == getOwnNodeId()))
4256 ndbrequire(c_file_hash.
find(fg_ptr, conf->tableId));
4257 const Uint32 free_extents= conf->freeExtents;
4258 const Uint32
id= conf->tableId;
4259 const Uint32 type= conf->tableType;
4260 const Uint32 data= conf->senderData;
4261 signal->theData[0]= ZPACK_TABLE_INTO_PAGES;
4262 signal->theData[1]=
id;
4263 signal->theData[2]=
type;
4264 signal->theData[3]= data;
4265 signal->theData[4]= free_extents;
4266 sendSignal(reference(), GSN_CONTINUEB, signal, 5, JBB);
4268 else if(refToBlock(conf->senderRef) == LGMAN
4269 && (refToNode(conf->senderRef) == 0
4270 || refToNode(conf->senderRef) == getOwnNodeId()))
4273 FilegroupPtr fg_ptr;
4274 ndbrequire(c_filegroup_hash.
find(fg_ptr, conf->tableId));
4275 const Uint32 free_hi= conf->freeWordsHi;
4276 const Uint32 free_lo= conf->freeWordsLo;
4277 const Uint32
id= conf->tableId;
4278 const Uint32 type= conf->tableType;
4279 const Uint32 data= conf->senderData;
4280 signal->theData[0]= ZPACK_TABLE_INTO_PAGES;
4281 signal->theData[1]=
id;
4282 signal->theData[2]=
type;
4283 signal->theData[3]= data;
4284 signal->theData[4]= free_hi;
4285 signal->theData[5]= free_lo;
4286 sendSignal(reference(), GSN_CONTINUEB, signal, 6, JBB);
4296 restartCreateObj_getTabInfoConf(signal);
4303 Dbdict::restartCreateObj(
Signal* signal,
4310 #ifdef PRINT_SCHEMA_RESTART
4311 ndbout_c(
"restartCreateObj table: %u file: %u", tableId, Uint32(file));
4314 c_restartRecord.m_entry = *new_entry;
4317 c_readTableRecord.no_of_words = new_entry->m_info_words;
4318 c_readTableRecord.pageId = 0;
4319 c_readTableRecord.m_callback.m_callbackData = tableId;
4320 c_readTableRecord.m_callback.m_callbackFunction =
4321 safe_cast(&Dbdict::restartCreateObj_readConf);
4323 ndbout_c(
"restartCreateObj(%u) file: %u", tableId, file);
4324 startReadTableFile(signal, tableId);
4332 req->senderRef = reference();
4333 req->senderData = tableId;
4334 req->requestType = GetTabInfoReq::RequestById |
4335 GetTabInfoReq::LongSignalConf;
4336 req->tableId = tableId;
4337 sendSignal(calcDictBlockRef(c_masterNodeId), GSN_GET_TABINFOREQ, signal,
4338 GetTabInfoReq::SignalLength, JBB);
4343 Dbdict::restartCreateObj_getTabInfoConf(
Signal* signal)
4349 handle.getSection(objInfoPtr, GetTabInfoConf::DICT_TAB_INFO);
4352 restartCreateObj_parse(signal, objInfoPtr,
false);
4356 Dbdict::restartCreateObj_readConf(
Signal* signal,
4357 Uint32 callbackData,
4361 ndbrequire(returnCode == 0);
4363 PageRecordPtr pageRecPtr;
4364 c_pageRecordArray.
getPtr(pageRecPtr, c_readTableRecord.pageId);
4366 Uint32 sz = c_readTableRecord.no_of_words;
4369 ndbrequire(
import(ptr, pageRecPtr.p->word+ZPAGE_HEADER_SIZE, sz));
4371 restartCreateObj_parse(signal, tmp,
true);
4375 Dbdict::restartCreateObj_parse(
Signal* signal,
4382 switch(c_restartRecord.m_entry.m_tableType){
4383 case DictTabInfo::SystemTable:
4384 case DictTabInfo::UserTable:
4385 case DictTabInfo::UniqueHashIndex:
4386 case DictTabInfo::HashIndex:
4387 case DictTabInfo::UniqueOrderedIndex:
4388 case DictTabInfo::OrderedIndex:
4391 seizeSchemaOp(op_ptr, opRecPtr);
4398 seizeSchemaOp(op_ptr, opRecPtr);
4405 seizeSchemaOp(op_ptr, opRecPtr);
4408 case DictTabInfo::HashMap:
4411 seizeSchemaOp(op_ptr, opRecPtr);
4417 c_txHandleHash.
getPtr(tx_ptr, c_restartRecord.m_tx_ptr_i);
4420 findSchemaTrans(trans_ptr, tx_ptr.p->m_transKey);
4421 addSchemaOp(trans_ptr, op_ptr);
4422 op_ptr.p->m_restart = file ? 1 : 2;
4423 op_ptr.p->m_state = SchemaOp::OS_PARSE_MASTER;
4427 const OpInfo& info = getOpInfo(op_ptr);
4428 (this->*(info.m_parse))(signal,
false, op_ptr, handle, error);
4429 releaseSections(handle);
4430 if (unlikely(hasError(error)))
4437 ndbout <<
"error: " << error << endl;
4441 "Failed to recreate object %u during restart,"
4443 ,c_restartRecord.activeTable
4445 progError(__LINE__, NDBD_EXIT_RESTORE_SCHEMA, msg);
4447 ndbrequire(!hasError(error));
4449 restart_nextOp(signal);
4456 Dbdict::restartDropObj(
Signal* signal,
4461 c_restartRecord.m_entry = *
entry;
4466 switch(c_restartRecord.m_entry.m_tableType){
4467 case DictTabInfo::SystemTable:
4468 case DictTabInfo::UserTable:
4469 case DictTabInfo::UniqueHashIndex:
4470 case DictTabInfo::HashIndex:
4471 case DictTabInfo::UniqueOrderedIndex:
4472 case DictTabInfo::OrderedIndex:
4474 seizeSchemaOp(op_ptr, opRecPtr);
4481 seizeSchemaOp(op_ptr, opRecPtr);
4482 opRecPtr.p->m_request.file_id = tableId;
4483 opRecPtr.p->m_request.file_version = entry->m_tableVersion;
4490 seizeSchemaOp(op_ptr, opRecPtr);
4491 opRecPtr.p->m_request.filegroup_id = tableId;
4492 opRecPtr.p->m_request.filegroup_version = entry->m_tableVersion;
4497 ndbout_c(
"restartDropObj(%u)", tableId);
4500 c_txHandleHash.
getPtr(tx_ptr, c_restartRecord.m_tx_ptr_i);
4503 findSchemaTrans(trans_ptr, tx_ptr.p->m_transKey);
4504 addSchemaOp(trans_ptr, op_ptr);
4505 op_ptr.p->m_restart = 1;
4506 op_ptr.p->m_state = SchemaOp::OS_PARSE_MASTER;
4510 const OpInfo& info = getOpInfo(op_ptr);
4511 (this->*(info.m_parse))(signal,
false, op_ptr, handle, error);
4512 releaseSections(handle);
4513 if (unlikely(hasError(error)))
4520 ndbout <<
"error: " << error << endl;
4524 "Failed to drop object %u during restart, error %u"
4525 ,c_restartRecord.activeTable
4527 progError(__LINE__, NDBD_EXIT_RESTORE_SCHEMA, msg);
4529 ndbrequire(!hasError(error));
4531 restart_nextOp(signal);
4544 void Dbdict::handleApiFailureCallback(
Signal* signal,
4545 Uint32 failedNodeId,
4550 signal->theData[0] = failedNodeId;
4551 signal->theData[1] = reference();
4552 sendSignal(QMGR_REF, GSN_API_FAILCONF, signal, 2, JBB);
4558 void Dbdict::execAPI_FAILREQ(
Signal* signal)
4561 Uint32 failedApiNode = signal->theData[0];
4562 BlockReference retRef = signal->theData[1];
4564 ndbrequire(retRef == QMGR_REF);
4566 Uint32 userNode = refToNode(c_connRecord.userBlockRef);
4567 if (userNode == failedApiNode) {
4569 c_connRecord.userBlockRef = (Uint32)-1;
4574 handleApiFail(signal, failedApiNode);
4577 void Dbdict::handleNdbdFailureCallback(
Signal* signal,
4578 Uint32 failedNodeId,
4586 nfCompRep->
nodeId = getOwnNodeId();
4588 sendSignal(DBDIH_REF, GSN_NF_COMPLETEREP, signal,
4589 NFCompleteRep::SignalLength, JBB);
4595 void Dbdict::execNODE_FAILREP(
Signal* signal)
4600 NodeRecordPtr ownNodePtr;
4602 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
4603 c_failureNr = nodeFail->failNo;
4604 const Uint32 numberOfFailedNodes = nodeFail->noOfNodes;
4605 const bool masterFailed = (c_masterNodeId != nodeFail->masterNodeId);
4606 c_masterNodeId = nodeFail->masterNodeId;
4608 c_noNodesFailed += numberOfFailedNodes;
4609 Uint32 theFailedNodes[NdbNodeBitmask::Size];
4610 memcpy(theFailedNodes, nodeFail->theNodes,
sizeof(theFailedNodes));
4611 c_counterMgr.execNODE_FAILREP(signal);
4614 failedNodes.
assign(NdbNodeBitmask::Size, theFailedNodes);
4615 c_aliveNodes.
bitANDC(failedNodes);
4616 if (masterFailed && c_masterNodeId == getOwnNodeId())
4624 ownNodePtr.p->nodeState = NodeRecord::NDB_MASTER_TAKEOVER;
4625 ownNodePtr.p->nodeFailRep = nodeFailRep;
4626 infoEvent(
"Node %u taking over as DICT master", c_masterNodeId);
4627 handle_master_takeover(signal);
4631 send_nf_complete_rep(signal, &nodeFailRep);
4638 Uint32 theFailedNodes[NdbNodeBitmask::Size];
4639 memcpy(theFailedNodes, nodeFail->theNodes,
sizeof(theFailedNodes));
4641 tmp.
assign(NdbNodeBitmask::Size, theFailedNodes);
4643 NodeRecordPtr ownNodePtr;
4644 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
4645 ownNodePtr.p->nodeState = NodeRecord::NDB_NODE_ALIVE;
4647 for(
unsigned i = 1; i < MAX_NDB_NODES; i++) {
4651 NodeRecordPtr nodePtr;
4652 c_nodes.
getPtr(nodePtr, i);
4654 ndbout_c(
"Sending NF_COMPLETEREP for node %u", i);
4656 nodePtr.p->nodeState = NodeRecord::NDB_NODE_DEAD;
4658 Callback cb = {safe_cast(&Dbdict::handleNdbdFailureCallback),
4672 removeStaleDictLocks(signal, theFailedNodes);
4674 c_sub_startstop_lock.
bitANDC(tmp);
4677 void Dbdict::handle_master_takeover(
Signal* signal)
4686 NodeRecordPtr masterNodePtr;
4687 c_nodes.
getPtr(masterNodePtr, c_masterNodeId);
4689 masterNodePtr.p->m_nodes = c_aliveNodes;
4692 SafeCounter sc(c_counterMgr, masterNodePtr.p->m_counter);
4697 req->senderRef = reference();
4698 sendSignal(rg, GSN_DICT_TAKEOVER_REQ, signal,
4699 DictTakeoverReq::SignalLength, JBB);
4717 void Dbdict::execINCL_NODEREQ(
Signal* signal)
4720 NodeRecordPtr nodePtr;
4721 BlockReference retRef = signal->theData[0];
4722 nodePtr.i = signal->theData[1];
4724 ndbrequire(c_noNodesFailed > 0);
4728 ndbrequire(nodePtr.p->nodeState == NodeRecord::NDB_NODE_DEAD);
4729 nodePtr.p->nodeState = NodeRecord::NDB_NODE_ALIVE;
4730 signal->theData[0] = nodePtr.i;
4731 signal->theData[1] = reference();
4732 sendSignal(retRef, GSN_INCL_NODECONF, signal, 2, JBB);
4734 c_aliveNodes.
set(nodePtr.i);
4747 void Dbdict::printTables()
4750 bool moreTables = c_obj_hash.
first(iter);
4751 printf(
"OBJECTS IN DICT:\n");
4752 char name[PATH_MAX];
4753 while (moreTables) {
4755 ConstRope r(c_rope_pool, tablePtr.p->m_name);
4757 printf(
"%s ", name);
4758 moreTables = c_obj_hash.
next(iter);
4763 #define tabRequire(cond, error) \
4766 parseP->errorCode = error; parseP->errorLine = __LINE__; \
4767 parseP->errorKey = it.getKey(); \
4774 Dbdict::get_object(
const char * name, Uint32 len, Uint32 hash){
4776 if (get_object(old_ptr, name, len, hash))
4784 Dbdict::get_object(DictObjectPtr& obj_ptr,
const char* name, Uint32 len, Uint32 hash)
4787 key.m_key.m_name_ptr =
name;
4788 key.m_key.m_name_len = len;
4789 key.m_key.m_pool = &c_rope_pool;
4790 key.m_name.m_hash = hash;
4791 return c_obj_hash.
find(obj_ptr, key);
4795 Dbdict::release_object(Uint32 obj_ptr_i,
DictObject* obj_ptr_p){
4796 Rope name(c_rope_pool, obj_ptr_p->m_name);
4804 Dbdict::increase_ref_count(Uint32 obj_ptr_i)
4811 Dbdict::decrease_ref_count(Uint32 obj_ptr_i)
4814 ndbrequire(ptr->m_ref_count);
4818 void Dbdict::handleTabInfoInit(
Signal * signal, SchemaTransPtr & trans_ptr,
4820 ParseDictTabInfoRecord * parseP,
4833 status = SimpleProperties::unpack(it, &c_tableDesc,
4834 DictTabInfo::TableMapping,
4835 DictTabInfo::TableMappingSize,
4838 if(status != SimpleProperties::Break){
4839 parseP->errorCode = CreateTableRef::InvalidFormat;
4840 parseP->status = status;
4841 parseP->errorKey = it.
getKey();
4842 parseP->errorLine = __LINE__;
4846 if(parseP->requestType == DictTabInfo::AlterTableFromAPI)
4848 ndbrequire(!checkExist);
4852 ndbrequire(parseP->requestType == DictTabInfo::AlterTableFromAPI);
4859 const Uint32 tableNameLength = Uint32(strlen(c_tableDesc.TableName) + 1);
4860 const Uint32 name_hash = Rope::hash(c_tableDesc.TableName, tableNameLength);
4864 tabRequire(get_object(c_tableDesc.TableName, tableNameLength) == 0,
4865 CreateTableRef::TableAlreadyExist);
4868 if (DictTabInfo::isIndex(c_tableDesc.TableType))
4871 parseP->requestType = DictTabInfo::AddTableFromDict;
4874 TableRecordPtr tablePtr;
4875 switch (parseP->requestType) {
4876 case DictTabInfo::CreateTableFromAPI: {
4879 case DictTabInfo::AlterTableFromAPI:{
4881 tablePtr.i = getFreeTableRecord(c_tableDesc.PrimaryTableId);
4885 tabRequire(tablePtr.i != RNIL, CreateTableRef::NoMoreTableRecords);
4887 c_tableRecordPool.
getPtr(tablePtr);
4890 case DictTabInfo::AddTableFromDict:
4891 case DictTabInfo::ReadTableFromDiskSR:
4892 case DictTabInfo::GetTabInfoConf:
4897 tablePtr.i = c_tableDesc.TableId;
4899 if (parseP->requestType == DictTabInfo::ReadTableFromDiskSR) {
4900 ndbrequire(tablePtr.i == c_restartRecord.activeTable);
4902 if (parseP->requestType == DictTabInfo::GetTabInfoConf) {
4903 ndbrequire(tablePtr.i == c_restartRecord.activeTable);
4906 c_tableRecordPool.
getPtr(tablePtr);
4909 initialiseTableRecord(tablePtr);
4914 Uint32 tableVersion = c_tableDesc.TableVersion;
4915 tablePtr.p->tableVersion = tableVersion;
4925 Rope name(c_rope_pool, tablePtr.p->tableName);
4926 tabRequire(name.assign(c_tableDesc.TableName, tableNameLength, name_hash),
4927 CreateTableRef::OutOfStringBuffer);
4931 if (parseP->requestType != DictTabInfo::AlterTableFromAPI) {
4933 ndbrequire(c_obj_hash.
seize(obj_ptr));
4935 obj_ptr.p->m_id = tablePtr.i;
4936 obj_ptr.p->m_type = c_tableDesc.TableType;
4937 obj_ptr.p->m_name = tablePtr.p->tableName;
4938 obj_ptr.p->m_ref_count = 0;
4939 c_obj_hash.
add(obj_ptr);
4940 tablePtr.p->m_obj_ptr_i = obj_ptr.i;
4944 g_eventLogger->
info(
"Dbdict: create name=%s,id=%u,obj_ptr_i=%d",
4945 c_tableDesc.TableName,
4946 tablePtr.i, tablePtr.p->m_obj_ptr_i);
4948 send_event(signal, trans_ptr,
4949 NDB_LE_CreateSchemaObject,
4951 tablePtr.p->tableVersion,
4952 c_tableDesc.TableType);
4954 parseP->tablePtr = tablePtr;
4957 tabRequire(!(c_tableDesc.TableTemporaryFlag && c_tableDesc.TableLoggedFlag),
4958 CreateTableRef::NoLoggingTemporaryTable);
4960 tablePtr.p->noOfAttributes = c_tableDesc.NoOfAttributes;
4961 tablePtr.p->m_bits |=
4962 (c_tableDesc.TableLoggedFlag ? TableRecord::TR_Logged : 0);
4963 tablePtr.p->m_bits |=
4964 (c_tableDesc.RowChecksumFlag ? TableRecord::TR_RowChecksum : 0);
4965 tablePtr.p->m_bits |=
4966 (c_tableDesc.RowGCIFlag ? TableRecord::TR_RowGCI : 0);
4967 #if DOES_NOT_WORK_CURRENTLY
4968 tablePtr.p->m_bits |=
4969 (c_tableDesc.TableTemporaryFlag ? TableRecord::TR_Temporary : 0);
4971 tablePtr.p->m_bits |=
4972 (c_tableDesc.ForceVarPartFlag ? TableRecord::TR_ForceVarPart : 0);
4973 tablePtr.p->minLoadFactor = c_tableDesc.MinLoadFactor;
4974 tablePtr.p->maxLoadFactor = c_tableDesc.MaxLoadFactor;
4975 tablePtr.p->fragmentType = (DictTabInfo::FragmentType)c_tableDesc.FragmentType;
4977 tablePtr.p->kValue = c_tableDesc.TableKValue;
4978 tablePtr.p->fragmentCount = c_tableDesc.FragmentCount;
4979 tablePtr.p->m_tablespace_id = c_tableDesc.TablespaceId;
4980 tablePtr.p->maxRowsLow = c_tableDesc.MaxRowsLow;
4981 tablePtr.p->maxRowsHigh = c_tableDesc.MaxRowsHigh;
4982 tablePtr.p->minRowsLow = c_tableDesc.MinRowsLow;
4983 tablePtr.p->minRowsHigh = c_tableDesc.MinRowsHigh;
4984 tablePtr.p->defaultNoPartFlag = c_tableDesc.DefaultNoPartFlag;
4985 tablePtr.p->linearHashFlag = c_tableDesc.LinearHashFlag;
4986 tablePtr.p->singleUserMode = c_tableDesc.SingleUserMode;
4987 tablePtr.p->hashMapObjectId = c_tableDesc.HashMapObjectId;
4988 tablePtr.p->hashMapVersion = c_tableDesc.HashMapVersion;
4989 tablePtr.p->storageType = c_tableDesc.TableStorageType;
4990 tablePtr.p->m_extra_row_gci_bits = c_tableDesc.ExtraRowGCIBits;
4991 tablePtr.p->m_extra_row_author_bits = c_tableDesc.ExtraRowAuthorBits;
4993 tabRequire(tablePtr.p->noOfAttributes <= MAX_ATTRIBUTES_IN_TABLE,
4994 CreateTableRef::NoMoreAttributeRecords);
4996 if (tablePtr.p->fragmentType == DictTabInfo::HashMapPartition &&
4997 tablePtr.p->hashMapObjectId == RNIL)
4999 Uint32 fragments = tablePtr.p->fragmentCount;
5003 tablePtr.p->fragmentCount = fragments = get_default_fragments(signal);
5006 char buf[MAX_TAB_NAME_SIZE+1];
5008 NDB_DEFAULT_HASHMAP_BUCKTETS,
5011 if (dictObj && dictObj->m_type == DictTabInfo::HashMap)
5015 ndbrequire(c_hash_map_hash.
find(hm_ptr, dictObj->m_id));
5016 tablePtr.p->hashMapObjectId = hm_ptr.p->m_object_id;
5017 tablePtr.p->hashMapVersion = hm_ptr.p->m_object_version;
5021 if (tablePtr.p->fragmentType == DictTabInfo::HashMapPartition)
5025 tabRequire(c_hash_map_hash.
find(hm_ptr, tablePtr.p->hashMapObjectId),
5026 CreateTableRef::InvalidHashMap);
5028 tabRequire(hm_ptr.p->m_object_version == tablePtr.p->hashMapVersion,
5029 CreateTableRef::InvalidHashMap);
5032 g_hash_map.getPtr(mapptr, hm_ptr.p->m_map_ptr_i);
5034 if (tablePtr.p->fragmentCount == 0)
5037 tablePtr.p->fragmentCount = mapptr.p->m_fragments;
5041 tabRequire(mapptr.p->m_fragments == tablePtr.p->fragmentCount,
5042 CreateTableRef::InvalidHashMap);
5047 Rope frm(c_rope_pool, tablePtr.p->frmData);
5048 tabRequire(frm.assign(c_tableDesc.FrmData, c_tableDesc.FrmLen),
5049 CreateTableRef::OutOfStringBuffer);
5050 Rope range(c_rope_pool, tablePtr.p->rangeData);
5051 tabRequire(range.assign((
const char*)c_tableDesc.RangeListData,
5052 c_tableDesc.RangeListDataLen),
5053 CreateTableRef::OutOfStringBuffer);
5054 Rope fd(c_rope_pool, tablePtr.p->ngData);
5055 tabRequire(fd.assign((
const char*)c_tableDesc.FragmentData,
5056 c_tableDesc.FragmentDataLen),
5057 CreateTableRef::OutOfStringBuffer);
5061 memcpy(c_fragData, c_tableDesc.FragmentData,
5062 c_tableDesc.FragmentDataLen);
5064 if(c_tableDesc.PrimaryTableId != RNIL)
5067 tablePtr.p->primaryTableId = c_tableDesc.PrimaryTableId;
5073 tablePtr.p->triggerId = RNIL;
5078 tablePtr.p->triggerId = c_tableDesc.CustomTriggerId;
5080 if (c_tableDesc.InsertTriggerId != RNIL ||
5081 c_tableDesc.UpdateTriggerId != RNIL ||
5082 c_tableDesc.DeleteTriggerId != RNIL)
5088 ndbrequire(tablePtr.p->isUniqueIndex());
5089 ndbrequire(c_tableDesc.CustomTriggerId == RNIL);
5090 ndbrequire(c_tableDesc.InsertTriggerId != RNIL);
5091 ndbrequire(c_tableDesc.UpdateTriggerId != RNIL);
5092 ndbrequire(c_tableDesc.DeleteTriggerId != RNIL);
5093 ndbout_c(
"table: %u UPGRADE saving (%u/%u/%u)",
5095 c_tableDesc.InsertTriggerId,
5096 c_tableDesc.UpdateTriggerId,
5097 c_tableDesc.DeleteTriggerId);
5098 infoEvent(
"table: %u UPGRADE saving (%u/%u/%u)",
5100 c_tableDesc.InsertTriggerId,
5101 c_tableDesc.UpdateTriggerId,
5102 c_tableDesc.DeleteTriggerId);
5103 tablePtr.p->triggerId = c_tableDesc.InsertTriggerId;
5104 tablePtr.p->m_upgrade_trigger_handling.m_upgrade =
true;
5105 tablePtr.p->m_upgrade_trigger_handling.insertTriggerId = c_tableDesc.InsertTriggerId;
5106 tablePtr.p->m_upgrade_trigger_handling.updateTriggerId = c_tableDesc.UpdateTriggerId;
5107 tablePtr.p->m_upgrade_trigger_handling.deleteTriggerId = c_tableDesc.DeleteTriggerId;
5110 c_tableDesc.InsertTriggerId,
5111 c_tableDesc.UpdateTriggerId,
5112 c_tableDesc.DeleteTriggerId);
5119 tablePtr.p->primaryTableId = RNIL;
5120 tablePtr.p->indexState = TableRecord::IS_UNDEFINED;
5121 tablePtr.p->triggerId = RNIL;
5123 tablePtr.p->buildTriggerId = RNIL;
5125 handleTabInfo(it, parseP, c_tableDesc);
5127 if(parseP->errorCode != 0)
5132 releaseTableObject(tablePtr.i, checkExist);
5133 parseP->tablePtr.setNull();
5137 if (checkExist && tablePtr.p->m_tablespace_id != RNIL)
5143 ndbrequire(c_filegroup_hash.
find(ptr, tablePtr.p->m_tablespace_id));
5144 increase_ref_count(ptr.p->m_obj_ptr_i);
5150 Uint32 insertTriggerId,
5151 Uint32 updateTriggerId,
5152 Uint32 deleteTriggerId)
5158 const Uint32 size = c_triggerRecordPool.getSize();
5159 ndbrequire(updateTriggerId == RNIL || updateTriggerId < size);
5160 ndbrequire(deleteTriggerId == RNIL || deleteTriggerId < size);
5163 if (updateTriggerId != RNIL)
5166 c_triggerRecordPool.
getPtr(triggerPtr, updateTriggerId);
5167 if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED)
5170 initialiseTriggerRecord(triggerPtr);
5171 triggerPtr.p->triggerState = TriggerRecord::TS_FAKE_UPGRADE;
5172 triggerPtr.p->triggerId = triggerPtr.i;
5173 triggerPtr.p->tableId = tabPtr.p->primaryTableId;
5174 triggerPtr.p->indexId = tabPtr.i;
5175 TriggerInfo::packTriggerInfo(triggerPtr.p->triggerInfo,
5176 g_hashIndexTriggerTmpl[0].triggerInfo);
5180 "UPG_UPD_NDB$INDEX_%u_UI", tabPtr.i);
5182 Rope name(c_rope_pool, triggerPtr.p->triggerName);
5187 bool ok = c_obj_hash.
seize(obj_ptr);
5191 obj_ptr.p->m_name = triggerPtr.p->triggerName;
5192 c_obj_hash.
add(obj_ptr);
5193 obj_ptr.p->m_ref_count = 0;
5195 triggerPtr.p->m_obj_ptr_i = obj_ptr.i;
5196 obj_ptr.p->m_id = triggerPtr.p->triggerId;
5197 obj_ptr.p->m_type =TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
5201 if (deleteTriggerId != RNIL)
5204 c_triggerRecordPool.
getPtr(triggerPtr, deleteTriggerId);
5205 if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED)
5208 initialiseTriggerRecord(triggerPtr);
5209 triggerPtr.p->triggerState = TriggerRecord::TS_FAKE_UPGRADE;
5210 triggerPtr.p->triggerId = triggerPtr.i;
5211 triggerPtr.p->tableId = tabPtr.p->primaryTableId;
5212 triggerPtr.p->indexId = tabPtr.i;
5213 TriggerInfo::packTriggerInfo(triggerPtr.p->triggerInfo,
5214 g_hashIndexTriggerTmpl[0].triggerInfo);
5217 "UPG_DEL_NDB$INDEX_%u_UI", tabPtr.i);
5220 Rope name(c_rope_pool, triggerPtr.p->triggerName);
5225 bool ok = c_obj_hash.
seize(obj_ptr);
5229 obj_ptr.p->m_name = triggerPtr.p->triggerName;
5230 c_obj_hash.
add(obj_ptr);
5231 obj_ptr.p->m_ref_count = 0;
5233 triggerPtr.p->m_obj_ptr_i = obj_ptr.i;
5234 obj_ptr.p->m_id = triggerPtr.p->triggerId;
5235 obj_ptr.p->m_type =TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
5241 ParseDictTabInfoRecord * parseP,
5244 TableRecordPtr tablePtr = parseP->tablePtr;
5248 Uint32 keyCount = 0;
5249 Uint32 keyLength = 0;
5250 Uint32 attrCount = tablePtr.p->noOfAttributes;
5251 Uint32 nullCount = 0;
5252 Uint32 nullBits = 0;
5253 Uint32 noOfCharsets = 0;
5254 Uint16 charsets[128];
5255 Uint32 recordLength = 0;
5256 AttributeRecordPtr attrPtr;
5260 tablePtr.p->m_attributes);
5262 Uint32 counts[] = {0,0,0,0,0};
5264 for(Uint32 i = 0; i<attrCount; i++){
5269 status = SimpleProperties::unpack(it, &attrDesc,
5270 DictTabInfo::AttributeMapping,
5271 DictTabInfo::AttributeMappingSize,
5274 if(status != SimpleProperties::Break){
5275 parseP->errorCode = CreateTableRef::InvalidFormat;
5276 parseP->status = status;
5277 parseP->errorKey = it.
getKey();
5278 parseP->errorLine = __LINE__;
5285 const Uint32 len = Uint32(strlen(attrDesc.AttributeName)+1);
5286 const Uint32 name_hash = Rope::hash(attrDesc.AttributeName, len);
5288 AttributeRecord key;
5289 key.m_key.m_name_ptr = attrDesc.AttributeName;
5290 key.m_key.m_name_len = len;
5291 key.attributeName.m_hash = name_hash;
5292 key.m_key.m_pool = &c_rope_pool;
5294 c_attributeRecordHash.
find(old_ptr, key);
5296 if(old_ptr.i != RNIL){
5297 parseP->errorCode = CreateTableRef::AttributeNameTwice;
5302 list.seize(attrPtr);
5303 if(attrPtr.i == RNIL){
5305 parseP->errorCode = CreateTableRef::NoMoreAttributeRecords;
5309 new (attrPtr.p) AttributeRecord();
5310 attrPtr.p->attributeDescriptor = 0x00012255;
5311 attrPtr.p->tupleKey = 0;
5317 Rope name(c_rope_pool, attrPtr.p->attributeName);
5318 if (!name.assign(attrDesc.AttributeName, len, name_hash))
5321 parseP->errorCode = CreateTableRef::OutOfStringBuffer;
5322 parseP->errorLine = __LINE__;
5326 attrPtr.p->attributeId =
i;
5328 attrPtr.p->tupleKey = (keyCount + 1) * attrDesc.AttributeKeyFlag;
5330 attrPtr.p->extPrecision = attrDesc.AttributeExtPrecision;
5331 attrPtr.p->extScale = attrDesc.AttributeExtScale;
5332 attrPtr.p->extLength = attrDesc.AttributeExtLength;
5334 unsigned csNumber = (attrPtr.p->extPrecision >> 16);
5335 if (csNumber != 0) {
5342 parseP->errorCode = CreateTableRef::InvalidCharset;
5343 parseP->errorLine = __LINE__;
5347 all_charsets[cs->number] = cs;
5349 while (i < noOfCharsets) {
5350 if (charsets[i] == csNumber)
5354 if (i == noOfCharsets) {
5356 if (noOfCharsets >
sizeof(charsets)/
sizeof(charsets[0])) {
5357 parseP->errorCode = CreateTableRef::InvalidFormat;
5358 parseP->errorLine = __LINE__;
5361 charsets[
i] = csNumber;
5366 bool translateOk = attrDesc.translateExtType();
5367 tabRequire(translateOk, CreateTableRef::Inconsistency);
5369 if(attrDesc.AttributeArraySize > 65535){
5370 parseP->errorCode = CreateTableRef::ArraySizeTooBig;
5371 parseP->status = status;
5372 parseP->errorKey = it.
getKey();
5373 parseP->errorLine = __LINE__;
5378 if(!attrDesc.AttributeKeyFlag &&
5380 !tablePtr.p->isIndex())
5386 AttributeDescriptor::setType(desc, attrDesc.AttributeExtType);
5387 AttributeDescriptor::setSize(desc, attrDesc.AttributeSize);
5388 AttributeDescriptor::setArraySize(desc, attrDesc.AttributeArraySize);
5389 AttributeDescriptor::setArrayType(desc, attrDesc.AttributeArrayType);
5390 AttributeDescriptor::setNullable(desc, attrDesc.AttributeNullableFlag);
5391 AttributeDescriptor::setDKey(desc, attrDesc.AttributeDKey);
5392 AttributeDescriptor::setPrimaryKey(desc, attrDesc.AttributeKeyFlag);
5393 AttributeDescriptor::setDiskBased(desc, attrDesc.AttributeStorageType == NDB_STORAGETYPE_DISK);
5394 AttributeDescriptor::setDynamic(desc, attrDesc.AttributeDynamic);
5395 attrPtr.p->attributeDescriptor = desc;
5396 attrPtr.p->autoIncrement = attrDesc.AttributeAutoIncrement;
5398 char defaultValueBuf [MAX_ATTR_DEFAULT_VALUE_SIZE];
5400 if (attrDesc.AttributeDefaultValueLen)
5402 ndbrequire(attrDesc.AttributeDefaultValueLen >=
sizeof(Uint32));
5404 memcpy(defaultValueBuf, attrDesc.AttributeDefaultValue,
5405 attrDesc.AttributeDefaultValueLen);
5413 memcpy(&a, defaultValueBuf,
sizeof(Uint32));
5415 memcpy(defaultValueBuf, &a,
sizeof(Uint32));
5417 Uint32 remainBytes = attrDesc.AttributeDefaultValueLen -
sizeof(Uint32);
5423 attrDesc.AttributeSize,
5424 attrDesc.AttributeArrayType,
5425 attrDesc.AttributeArraySize,
5426 (uchar*) defaultValueBuf +
sizeof(Uint32),
5431 Rope defaultValue(c_rope_pool, attrPtr.p->defaultValue);
5432 defaultValue.assign(defaultValueBuf,
5433 attrDesc.AttributeDefaultValueLen);
5436 keyCount += attrDesc.AttributeKeyFlag;
5437 nullCount += attrDesc.AttributeNullableFlag;
5439 const Uint32 aSz = (1 << attrDesc.AttributeSize);
5443 sz = ((aSz * attrDesc.AttributeArraySize) + 31) >> 5;
5448 nullBits += attrDesc.AttributeArraySize;
5451 if(attrDesc.AttributeArraySize == 0)
5453 parseP->errorCode = CreateTableRef::InvalidArraySize;
5454 parseP->status = status;
5455 parseP->errorKey = it.
getKey();
5456 parseP->errorLine = __LINE__;
5461 if(attrDesc.AttributeKeyFlag){
5464 if(attrDesc.AttributeNullableFlag){
5465 parseP->errorCode = CreateTableRef::NullablePrimaryKey;
5466 parseP->status = status;
5467 parseP->errorKey = it.
getKey();
5468 parseP->errorLine = __LINE__;
5473 c_attributeRecordHash.
add(attrPtr);
5475 int a= AttributeDescriptor::getDiskBased(desc);
5476 int b= AttributeDescriptor::getArrayType(desc);
5477 Uint32 pos= 2*(a ? 1 : 0) + (b == NDB_ARRAYTYPE_FIXED ? 0 : 1);
5480 if(b != NDB_ARRAYTYPE_FIXED && sz == 0)
5482 parseP->errorCode = CreateTableRef::VarsizeBitfieldNotSupported;
5483 parseP->status = status;
5484 parseP->errorKey = it.
getKey();
5485 parseP->errorLine = __LINE__;
5492 if(it.
getKey() != DictTabInfo::AttributeName)
5496 tablePtr.p->noOfPrimkey = keyCount;
5497 tablePtr.p->noOfNullAttr = nullCount;
5498 tablePtr.p->noOfCharsets = noOfCharsets;
5499 tablePtr.p->tupKeyLength = keyLength;
5500 tablePtr.p->noOfNullBits = nullCount + nullBits;
5502 tabRequire(recordLength<= MAX_TUPLE_SIZE_IN_WORDS,
5503 CreateTableRef::RecordTooBig);
5504 tabRequire(keyLength <= MAX_KEY_SIZE_IN_WORDS,
5505 CreateTableRef::InvalidPrimaryKeySize);
5506 tabRequire(keyLength > 0,
5507 CreateTableRef::InvalidPrimaryKeySize);
5508 tabRequire(CHECK_SUMA_MESSAGE_SIZE(keyCount, keyLength, attrCount, recordLength),
5509 CreateTableRef::RecordTooBig);
5514 for (Uint32 nodeId=1; nodeId < MAX_NODES; nodeId++)
5519 (ni.
m_type == NODE_TYPE_DB))
5522 if (tablePtr.p->m_extra_row_gci_bits ||
5523 tablePtr.p->m_extra_row_author_bits)
5525 tabRequire(ndb_tup_extrabits(ni.
m_version),
5526 CreateTableRef::FeatureRequiresUpgrade);
5532 if(tablePtr.p->m_tablespace_id != RNIL || counts[3] || counts[4])
5534 FilegroupPtr tablespacePtr;
5535 if(!c_filegroup_hash.
find(tablespacePtr, tablePtr.p->m_tablespace_id))
5537 tabRequire(
false, CreateTableRef::InvalidTablespace);
5542 tabRequire(
false, CreateTableRef::NotATablespace);
5545 if(tablespacePtr.p->m_version != tableDesc.TablespaceVersion)
5547 tabRequire(
false, CreateTableRef::InvalidTablespaceVersion);
5554 Dbdict::block_substartstop(
Signal* signal, SchemaOpPtr op_ptr)
5556 ndbrequire(c_sub_startstop_lock.
get(getOwnNodeId()) ==
false);
5557 c_sub_startstop_lock.
set(getOwnNodeId());
5558 signal->theData[0] = ZWAIT_SUBSTARTSTOP;
5559 signal->theData[1] = op_ptr.p->op_key;
5560 sendSignal(reference(), GSN_CONTINUEB, signal, 2, JBB);
5564 Dbdict::unblock_substartstop()
5566 ndbrequire(c_sub_startstop_lock.
get(getOwnNodeId()));
5567 c_sub_startstop_lock.
clear(getOwnNodeId());
5571 Dbdict::wait_substartstop(
Signal* signal, Uint32 opkey)
5573 if (c_outstanding_sub_startstop == 0)
5577 bool ok = findCallback(callback, opkey);
5579 execute(signal, callback, 0);
5583 signal->theData[0] = ZWAIT_SUBSTARTSTOP;
5584 signal->theData[1] = opkey;
5585 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 100,
5593 Dbdict::wait_gcp(
Signal* signal, SchemaOpPtr op_ptr, Uint32 flags)
5597 req->senderRef = reference();
5598 req->senderData = op_ptr.p->op_key;
5599 req->requestType =
flags;
5601 sendSignal(DBDIH_REF, GSN_WAIT_GCP_REQ, signal,
5602 WaitGCPReq::SignalLength, JBB);
5605 void Dbdict::execWAIT_GCP_CONF(
Signal* signal)
5608 handleDictConf(signal, conf);
5614 void Dbdict::execWAIT_GCP_REF(
Signal* signal)
5618 handleDictRef(signal, ref);
5623 const Dbdict::OpInfo
5624 Dbdict::CreateTableRec::g_opInfo = {
5625 {
'C',
'T',
'a', 0 },
5627 CreateTabReq::SignalLength,
5629 &Dbdict::createTable_seize,
5630 &Dbdict::createTable_release,
5632 &Dbdict::createTable_parse,
5633 &Dbdict::createTable_subOps,
5634 &Dbdict::createTable_reply,
5636 &Dbdict::createTable_prepare,
5637 &Dbdict::createTable_commit,
5638 &Dbdict::createTable_complete,
5640 &Dbdict::createTable_abortParse,
5641 &Dbdict::createTable_abortPrepare
5645 Dbdict::createTable_seize(SchemaOpPtr op_ptr)
5647 return seizeOpRec<CreateTableRec>(op_ptr);
5651 Dbdict::createTable_release(SchemaOpPtr op_ptr)
5653 CreateTableRecPtr createTabPtr;
5654 getOpRec(op_ptr, createTabPtr);
5655 if (createTabPtr.p->m_tabInfoPtrI != RNIL) {
5658 getSection(ss_ptr, createTabPtr.p->m_tabInfoPtrI);
5659 SimulatedBlock::release(ss_ptr);
5660 createTabPtr.p->m_tabInfoPtrI = RNIL;
5662 if (createTabPtr.p->m_fragmentsPtrI != RNIL) {
5665 getSection(ss_ptr, createTabPtr.p->m_fragmentsPtrI);
5666 SimulatedBlock::release(ss_ptr);
5667 createTabPtr.p->m_fragmentsPtrI = RNIL;
5669 releaseOpRec<CreateTableRec>(op_ptr);
5673 Dbdict::execCREATE_TABLE_REQ(
Signal* signal)
5682 if (check_sender_version(signal, MAKE_VERSION(6,4,0)) < 0)
5690 do_swap(tmp->senderRef, tmp->senderData);
5700 CreateTableRecPtr createTabPtr;
5703 startClientReq(op_ptr, createTabPtr, req, impl_req, error);
5704 if (hasError(error)) {
5709 impl_req->tableId = RNIL;
5710 impl_req->tableVersion = 0;
5713 handleClientReq(signal, op_ptr, handle);
5717 releaseSections(handle);
5720 ref->senderRef = reference();
5721 ref->transId = req->transId;
5722 ref->clientData = req->clientData;
5723 getError(error, ref);
5724 ref->errorStatus = error.errorStatus;
5725 ref->errorKey = error.errorKey;
5727 sendSignal(req->clientRef, GSN_CREATE_TABLE_REF, signal,
5728 CreateTableRef::SignalLength, JBB);
5734 Dbdict::get_fragmentation(
Signal* signal, Uint32 tableId)
5739 req->senderData = RNIL;
5740 req->fragmentationType = 0;
5741 req->noOfFragments = 0;
5742 req->primaryTableId = tableId;
5743 req->requestInfo = CreateFragmentationReq::RI_GET_FRAGMENTATION;
5745 CreateFragmentationReq::SignalLength);
5747 return signal->theData[0];
5751 Dbdict::create_fragmentation(
Signal* signal,
5752 TableRecordPtr tabPtr,
5759 frag_req->senderRef = 0;
5760 frag_req->senderData = RNIL;
5761 frag_req->primaryTableId = tabPtr.p->primaryTableId;
5762 frag_req->noOfFragments = tabPtr.p->fragmentCount;
5763 frag_req->fragmentationType = tabPtr.p->fragmentType;
5764 frag_req->requestInfo =
flags;
5766 if (tabPtr.p->hashMapObjectId != RNIL)
5770 ndbrequire(c_hash_map_hash.
find(hm_ptr, tabPtr.p->hashMapObjectId));
5771 frag_req->map_ptr_i = hm_ptr.p->m_map_ptr_i;
5776 frag_req->map_ptr_i = RNIL;
5779 memcpy(signal->theData+25, src, 2*cnt);
5781 if (cnt != 0 && cnt != tabPtr.p->fragmentCount)
5787 return CreateTableRef::InvalidFormat;
5790 if (tabPtr.p->isOrderedIndex()) {
5793 frag_req->primaryTableId = tabPtr.p->primaryTableId;
5794 frag_req->fragmentationType = DictTabInfo::DistrKeyOrderedIndex;
5796 else if (tabPtr.p->isHashIndex())
5804 frag_req->primaryTableId = RNIL;
5814 tabPtr.p->primaryTableId = RNIL;
5818 CreateFragmentationReq::SignalLength);
5821 return signal->theData[0];
5825 Dbdict::createTable_parse(
Signal* signal,
bool master,
5829 D(
"createTable_parse");
5831 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
5832 CreateTableRecPtr createTabPtr;
5833 getOpRec(op_ptr, createTabPtr);
5849 ParseDictTabInfoRecord parseRecord;
5850 parseRecord.requestType = DictTabInfo::CreateTableFromAPI;
5851 parseRecord.errorCode = 0;
5854 if (!handle.getSection(ss_ptr, CreateTableReq::DICT_TAB_INFO)) {
5856 setError(error, CreateTableRef::InvalidFormat, __LINE__);
5861 handleTabInfoInit(signal, trans_ptr, r, &parseRecord);
5862 releaseSections(handle);
5864 if (parseRecord.errorCode == 0)
5866 if (ERROR_INSERTED(6200) ||
5867 (ERROR_INSERTED(6201) &&
5868 DictTabInfo::isIndex(parseRecord.tablePtr.p->tableType)))
5871 CLEAR_ERROR_INSERT_VALUE;
5872 parseRecord.errorCode = 1;
5876 if (parseRecord.errorCode != 0)
5879 if (!parseRecord.tablePtr.isNull())
5882 releaseTableObject(parseRecord.tablePtr.i,
true);
5884 setError(error, parseRecord);
5886 "%s", c_tableDesc.TableName);
5890 TableRecordPtr tabPtr = parseRecord.tablePtr;
5894 DictObjectPtr obj_ptr;
5895 Uint32 obj_ptr_i = tabPtr.p->m_obj_ptr_i;
5896 bool ok = findDictObject(op_ptr, obj_ptr, obj_ptr_i);
5901 Uint32 version = getTableEntry(tabPtr.i)->m_tableVersion;
5902 tabPtr.p->tableVersion = create_obj_inc_schema_version(version);
5906 impl_req->tableId = tabPtr.i;
5907 impl_req->tableVersion = tabPtr.p->tableVersion;
5909 if (ERROR_INSERTED(6202) ||
5910 (ERROR_INSERTED(6203) &&
5911 DictTabInfo::isIndex(parseRecord.tablePtr.p->tableType)))
5914 CLEAR_ERROR_INSERT_VALUE;
5915 setError(error, 1, __LINE__);
5920 Uint16* frag_data = (Uint16*)(signal->getDataPtr()+25);
5921 Uint32 err = create_fragmentation(signal, tabPtr,
5926 setError(error, err, __LINE__);
5933 Uint32 count = 2 + (1 + frag_data[0]) * frag_data[1];
5936 bool ok =
import(frag_ptr, (Uint32*)frag_data, (count + 1) / 2);
5938 createTabPtr.p->m_fragmentsPtrI = frag_ptr.i;
5941 tabPtr.p->fragmentCount = frag_data[1];
5947 packTableIntoPages(w, tabPtr);
5951 createTabPtr.p->m_tabInfoPtrI = ss_ptr.i;
5959 getSection(ss0_ptr, createTabPtr.p->m_tabInfoPtrI);
5960 getSection(ss1_ptr, createTabPtr.p->m_fragmentsPtrI);
5962 ndbrequire(handle.m_cnt == 0);
5963 handle.m_ptr[CreateTabReq::DICT_TAB_INFO] = ss0_ptr;
5964 handle.m_ptr[CreateTabReq::FRAGMENTATION] = ss1_ptr;
5968 createTabPtr.p->m_tabInfoPtrI = RNIL;
5969 createTabPtr.p->m_fragmentsPtrI = RNIL;
5972 else if (op_ptr.p->m_restart)
5975 impl_req->tableId = c_restartRecord.activeTable;
5976 impl_req->tableVersion = c_restartRecord.m_entry.m_tableVersion;
5977 impl_req->gci = c_restartRecord.m_entry.m_gcp;
5980 const Uint32 gci = impl_req->gci;
5981 const Uint32 tableId = impl_req->tableId;
5982 const Uint32 tableVersion = impl_req->tableVersion;
5986 bool ok = handle.getSection(tabInfoPtr, CreateTabReq::DICT_TAB_INFO);
5994 createTabPtr.p->m_request.tableId = tableId;
5996 ParseDictTabInfoRecord parseRecord;
5997 parseRecord.requestType = DictTabInfo::AddTableFromDict;
5998 parseRecord.errorCode = 0;
6002 bool checkExist =
true;
6003 handleTabInfoInit(signal, trans_ptr, r, &parseRecord, checkExist);
6005 if (parseRecord.errorCode != 0)
6008 setError(error, parseRecord);
6010 "%s", c_tableDesc.TableName);
6014 TableRecordPtr tabPtr = parseRecord.tablePtr;
6018 DictObjectPtr obj_ptr;
6019 Uint32 obj_ptr_i = tabPtr.p->m_obj_ptr_i;
6020 bool ok = findDictObject(op_ptr, obj_ptr, obj_ptr_i);
6027 handle.getSection(ptr, CreateTabReq::DICT_TAB_INFO);
6028 if (ptr.sz > MAX_WORDS_META_FILE)
6031 setError(error, CreateTableRef::TableDefinitionTooBig, __LINE__);
6037 saveOpSection(op_ptr, handle, CreateTabReq::DICT_TAB_INFO);
6038 if (op_ptr.p->m_restart == 0)
6041 saveOpSection(op_ptr, handle, CreateTabReq::FRAGMENTATION);
6044 TableRecordPtr tabPtr;
6045 c_tableRecordPool.
getPtr(tabPtr, tableId);
6046 tabPtr.p->packedSize = tabInfoPtr.sz;
6048 tabPtr.p->tableVersion = tableVersion;
6049 tabPtr.p->gciTableCreated = gci;
6051 if (ERROR_INSERTED(6121)) {
6053 CLEAR_ERROR_INSERT_VALUE;
6054 setError(error, 9121, __LINE__);
6059 te.m_tableState = SchemaFile::SF_CREATE;
6060 te.m_tableVersion = tableVersion;
6061 te.m_tableType = tabPtr.p->tableType;
6062 te.m_info_words = tabInfoPtr.sz;
6064 te.m_transId = trans_ptr.p->m_transId;
6066 Uint32 err = trans_log_schema_op(op_ptr, tableId, &te);
6070 setError(error, err, __LINE__);
6073 D(
"createTable_parse: "
6074 << copyRope<MAX_TAB_NAME_SIZE>(tabPtr.p->tableName)
6075 << V(tabPtr.p->tableVersion));
6079 Dbdict::createTable_subOps(
Signal* signal, SchemaOpPtr op_ptr)
6081 D(
"createTable_subOps" << V(op_ptr.i) << *op_ptr.p);
6087 Dbdict::createTable_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
6090 D(
"createTable_reply" << V(op_ptr.i) << *op_ptr.p);
6092 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
6094 CreateTableRecPtr createTabPtr;
6095 getOpRec(op_ptr, createTabPtr);
6097 if (!hasError(error)) {
6099 conf->senderRef = reference();
6100 conf->clientData = op_ptr.p->m_clientData;
6101 conf->transId = trans_ptr.p->m_transId;
6102 conf->tableId = createTabPtr.p->m_request.tableId;
6103 conf->tableVersion = createTabPtr.p->m_request.tableVersion;
6105 D(V(conf->tableId) << V(conf->tableVersion));
6107 Uint32 clientRef = op_ptr.p->m_clientRef;
6108 sendSignal(clientRef, GSN_CREATE_TABLE_CONF, signal,
6109 CreateTableConf::SignalLength, JBB);
6113 ref->senderRef = reference();
6114 ref->clientData = op_ptr.p->m_clientData;
6115 ref->transId = trans_ptr.p->m_transId;
6116 getError(error, ref);
6117 ref->errorStatus = error.errorStatus;
6118 ref->errorKey = error.errorKey;
6120 Uint32 clientRef = op_ptr.p->m_clientRef;
6121 sendSignal(clientRef, GSN_CREATE_TABLE_REF, signal,
6122 CreateTableRef::SignalLength, JBB);
6129 Dbdict::createTable_prepare(
Signal* signal, SchemaOpPtr op_ptr)
6132 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
6133 CreateTableRecPtr createTabPtr;
6134 getOpRec(op_ptr, createTabPtr);
6136 Uint32 tableId = createTabPtr.p->m_request.tableId;
6137 TableRecordPtr tabPtr;
6138 c_tableRecordPool.
getPtr(tabPtr, tableId);
6141 cb.m_callbackData = op_ptr.p->op_key;
6142 cb.m_callbackFunction = safe_cast(&Dbdict::createTab_writeTableConf);
6144 if (ZRESTART_NO_WRITE_AFTER_READ && op_ptr.p->m_restart == 1)
6150 execute(signal, cb, 0);
6154 bool savetodisk = !(tabPtr.p->m_bits & TableRecord::TR_Temporary);
6158 const OpSection& tabInfoSec =
6159 getOpSection(op_ptr, CreateTabReq::DICT_TAB_INFO);
6160 writeTableFile(signal, createTabPtr.p->m_request.tableId,
6166 execute(signal, cb, 0);
6171 Dbdict::createTab_writeTableConf(
Signal* signal,
6178 CreateTableRecPtr createTabPtr;
6179 findSchemaOp(op_ptr, createTabPtr, op_key);
6180 ndbrequire(!op_ptr.isNull());
6182 OpSection& fragSec = op_ptr.p->m_section[CreateTabReq::FRAGMENTATION];
6183 if (op_ptr.p->m_restart)
6186 new (&fragSec) OpSection();
6190 const OpSection& fragSec =
6191 getOpSection(op_ptr, CreateTabReq::FRAGMENTATION);
6192 ndbrequire(fragSec.getSize() > 0);
6196 callback.m_callbackData = op_ptr.p->op_key;
6197 callback.m_callbackFunction =
6198 safe_cast(&Dbdict::createTab_localComplete);
6200 createTab_local(signal, op_ptr, fragSec, &callback);
6204 Dbdict::createTab_local(
Signal* signal,
6210 CreateTableRecPtr createTabPtr;
6211 getOpRec(op_ptr, createTabPtr);
6212 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
6214 createTabPtr.p->m_callback = * c;
6216 TableRecordPtr tabPtr;
6217 c_tableRecordPool.
getPtr(tabPtr, createTabPtr.p->m_request.tableId);
6223 req->senderRef = reference();
6224 req->senderData = op_ptr.p->op_key;
6225 req->tableId = createTabPtr.p->m_request.tableId;
6226 req->tableVersion = tabPtr.p->tableVersion;
6227 req->requestType = 0;
6230 req->tableType = tabPtr.p->tableType;
6231 req->primaryTableId = tabPtr.p->primaryTableId;
6232 req->forceVarPartFlag = !!(tabPtr.p->m_bits& TableRecord::TR_ForceVarPart);
6233 req->noOfNullAttributes = tabPtr.p->noOfNullBits;
6234 req->noOfKeyAttr = tabPtr.p->noOfPrimkey;
6235 req->checksumIndicator = 1;
6236 req->GCPIndicator = 1 + tabPtr.p->m_extra_row_gci_bits;
6237 req->noOfAttributes = tabPtr.p->noOfAttributes;
6238 req->extraRowAuthorBits = tabPtr.p->m_extra_row_author_bits;
6239 sendSignal(DBLQH_REF, GSN_CREATE_TAB_REQ, signal,
6240 CreateTabReq::SignalLengthLDM, JBB);
6247 KeyDescriptor* desc= g_key_descriptor_pool.getPtr(tabPtr.i);
6250 if (tabPtr.p->primaryTableId == RNIL)
6253 desc->primaryTableId = createTabPtr.p->m_request.tableId;
6258 desc->primaryTableId = tabPtr.p->primaryTableId;
6264 tabPtr.p->m_attributes);
6265 for(list.first(attrPtr); !attrPtr.isNull(); list.next(attrPtr))
6267 AttributeRecord* aRec = attrPtr.p;
6270 Uint32 attr = aRec->attributeDescriptor;
6272 desc->noOfKeyAttr ++;
6273 desc->keyAttr[key].attributeDescriptor = attr;
6274 Uint32 csNumber = (aRec->extPrecision >> 16);
6277 desc->keyAttr[key].charsetInfo = all_charsets[csNumber];
6278 ndbrequire(all_charsets[csNumber] != 0);
6279 desc->hasCharAttr = 1;
6283 desc->keyAttr[key].charsetInfo = 0;
6285 if (AttributeDescriptor::getDKey(attr))
6287 desc->noOfDistrKeys ++;
6289 if (AttributeDescriptor::getArrayType(attr) != NDB_ARRAYTYPE_FIXED)
6291 desc->noOfVarKeys ++;
6296 ndbrequire(key == tabPtr.p->noOfPrimkey);
6301 Dbdict::execCREATE_TAB_REF(
Signal* signal)
6308 CreateTableRecPtr createTabPtr;
6309 findSchemaOp(op_ptr, createTabPtr, ref->senderData);
6310 ndbrequire(!op_ptr.isNull());
6312 setError(op_ptr, ref->errorCode, __LINE__);
6313 execute(signal, createTabPtr.p->m_callback, 0);
6317 Dbdict::execCREATE_TAB_CONF(
Signal* signal)
6324 CreateTableRecPtr createTabPtr;
6325 findSchemaOp(op_ptr, createTabPtr, conf->senderData);
6326 ndbrequire(!op_ptr.isNull());
6328 createTabPtr.p->m_lqhFragPtr = conf->lqhConnectPtr;
6330 TableRecordPtr tabPtr;
6331 c_tableRecordPool.
getPtr(tabPtr, createTabPtr.p->m_request.tableId);
6332 sendLQHADDATTRREQ(signal, op_ptr, tabPtr.p->m_attributes.firstItem);
6337 Dbdict::sendLQHADDATTRREQ(
Signal* signal,
6339 Uint32 attributePtrI)
6342 CreateTableRecPtr createTabPtr;
6343 getOpRec(op_ptr, createTabPtr);
6345 TableRecordPtr tabPtr;
6346 c_tableRecordPool.
getPtr(tabPtr, createTabPtr.p->m_request.tableId);
6348 const bool isHashIndex = tabPtr.p->isHashIndex();
6352 Uint32 startIndex = 25;
6353 Uint32 *defVal_dst = &signal->theData[startIndex];
6354 Uint32 defVal_length = 0;
6355 for(i = 0; i<LqhAddAttrReq::MAX_ATTRIBUTES && attributePtrI != RNIL; i++){
6357 AttributeRecordPtr attrPtr;
6358 c_attributeRecordPool.
getPtr(attrPtr, attributePtrI);
6360 entry.attrId = attrPtr.p->attributeId;
6361 entry.attrDescriptor = attrPtr.p->attributeDescriptor;
6362 entry.extTypeInfo = 0;
6364 entry.extTypeInfo |= (attrPtr.p->extPrecision & ~0xFFFF);
6366 ConstRope def(c_rope_pool, attrPtr.p->defaultValue);
6367 def.copy((
char*)defVal_dst);
6369 Uint32 defValueLen = def.size();
6370 defVal_length += (defValueLen + 3)/4;
6371 defVal_dst += (defValueLen + 3)/4;
6373 if (tabPtr.p->isIndex()) {
6374 Uint32 primaryAttrId;
6375 if (attrPtr.p->nextList != RNIL) {
6376 getIndexAttr(tabPtr, attributePtrI, &primaryAttrId);
6378 primaryAttrId = ZNIL;
6379 if (tabPtr.p->isOrderedIndex())
6382 entry.attrId |= (primaryAttrId << 16);
6385 if (attrPtr.p->nextList == RNIL && isHashIndex)
6392 char tmp[MAX_TAB_NAME_SIZE];
6395 ndbrequire(memcmp(tmp,
"NDB$PK",
sizeof(
"NDB$PK")) == 0);
6396 Uint32 at = AttributeDescriptor::getArrayType(entry.attrDescriptor);
6397 if (at == NDB_ARRAYTYPE_MEDIUM_VAR)
6400 AttributeDescriptor::clearArrayType(entry.attrDescriptor);
6401 AttributeDescriptor::setArrayType(entry.attrDescriptor,
6402 NDB_ARRAYTYPE_NONE_VAR);
6406 attributePtrI = attrPtr.p->nextList;
6408 req->lqhFragPtr = createTabPtr.p->m_lqhFragPtr;
6409 req->senderData = op_ptr.p->op_key;
6410 req->senderAttrPtr = attributePtrI;
6411 req->noOfAttributes =
i;
6413 if (defVal_length != 0)
6416 ptr[0].p= &signal->theData[startIndex];
6417 ptr[0].sz= defVal_length;
6419 sendSignal(DBLQH_REF, GSN_LQHADDATTREQ, signal,
6420 LqhAddAttrReq::HeaderLength + LqhAddAttrReq::EntryLength * i, JBB, ptr, 1);
6423 sendSignal(DBLQH_REF, GSN_LQHADDATTREQ, signal,
6424 LqhAddAttrReq::HeaderLength + LqhAddAttrReq::EntryLength * i, JBB);
6428 Dbdict::execLQHADDATTCONF(
Signal * signal)
6434 CreateTableRecPtr createTabPtr;
6435 findSchemaOp(op_ptr, createTabPtr, conf->senderData);
6436 ndbrequire(!op_ptr.isNull());
6438 const Uint32 nextAttrPtr = conf->senderAttrPtr;
6439 if(nextAttrPtr != RNIL){
6441 sendLQHADDATTRREQ(signal, op_ptr, nextAttrPtr);
6445 createTab_dih(signal, op_ptr);
6449 Dbdict::execLQHADDATTREF(
Signal * signal)
6455 CreateTableRecPtr createTabPtr;
6456 findSchemaOp(op_ptr, createTabPtr, ref->senderData);
6457 ndbrequire(!op_ptr.isNull());
6459 setError(op_ptr, ref->errorCode, __LINE__);
6461 sendTransConf(signal, op_ptr);
6465 Dbdict::createTab_dih(
Signal* signal, SchemaOpPtr op_ptr)
6467 CreateTableRecPtr createTabPtr;
6468 getOpRec(op_ptr, createTabPtr);
6469 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
6471 D(
"createTab_dih" << *op_ptr.p);
6473 TableRecordPtr tabPtr;
6474 c_tableRecordPool.
getPtr(tabPtr, createTabPtr.p->m_request.tableId);
6482 const OpSection& fragSec = op_ptr.p->m_section[CreateTabReq::FRAGMENTATION];
6485 req->connectPtr = op_ptr.p->op_key;
6486 req->tableId = tabPtr.i;
6487 req->fragType = tabPtr.p->fragmentType;
6488 req->kValue = tabPtr.p->kValue;
6489 req->noOfReplicas = 0;
6490 req->loggedTable = !!(tabPtr.p->m_bits & TableRecord::TR_Logged);
6491 req->tableType = tabPtr.p->tableType;
6492 req->schemaVersion = tabPtr.p->tableVersion;
6493 req->primaryTableId = tabPtr.p->primaryTableId;
6494 req->temporaryTable = !!(tabPtr.p->m_bits & TableRecord::TR_Temporary);
6496 req->schemaTransId = !trans_ptr.isNull() ? trans_ptr.p->m_transId : 0;
6498 if (tabPtr.p->hashMapObjectId != RNIL)
6501 ndbrequire(c_hash_map_hash.
find(hm_ptr, tabPtr.p->hashMapObjectId));
6502 req->hashMapPtrI = hm_ptr.p->m_map_ptr_i;
6506 req->hashMapPtrI = RNIL;
6513 Uint32 noOfSections = 0;
6515 const Uint32 size = fragSec.getSize();
6520 bool ok = copyOut(fragSec, page, 1024);
6522 ptr[noOfSections].sz =
size;
6523 ptr[noOfSections].p =
page;
6527 sendSignal(DBDIH_REF, GSN_DIADDTABREQ, signal,
6528 DiAddTabReq::SignalLength, JBB,
6535 calcLHbits(Uint32 * lhPageBits, Uint32 * lhDistrBits,
6536 Uint32 fid, Uint32 totalFragments,
Dbdict * dict)
6538 Uint32 distrBits = 0;
6539 Uint32 pageBits = 0;
6542 while (tmp < totalFragments) {
6547 #ifdef ndb_classical_lhdistrbits
6548 if (tmp != totalFragments) {
6550 if ((fid >= (totalFragments - tmp)) && (fid < (tmp - 1))) {
6555 * lhPageBits = pageBits;
6556 * lhDistrBits = distrBits;
6561 Dbdict::execADD_FRAGREQ(
Signal* signal)
6567 Uint32 dihPtr = req->dihPtr;
6568 Uint32 senderData = req->senderData;
6569 Uint32 tableId = req->tableId;
6570 Uint32 fragId = req->fragmentId;
6571 Uint32 node = req->nodeId;
6572 Uint32 lcpNo = req->nextLCP;
6573 Uint32 fragCount = req->totalFragments;
6574 Uint32 requestInfo = req->requestInfo;
6575 Uint32 startGci = req->startGci;
6576 Uint32 logPart = req->logPartId;
6577 Uint32 changeMask = req->changeMask;
6579 ndbrequire(node == getOwnNodeId());
6582 TableRecordPtr tabPtr;
6583 if (AlterTableReq::getAddFragFlag(changeMask))
6585 c_tableRecordPool.
getPtr(tabPtr, tableId);
6586 if (DictTabInfo::isTable(tabPtr.p->tableType))
6589 AlterTableRecPtr alterTabPtr;
6590 findSchemaOp(op_ptr, alterTabPtr, senderData);
6591 ndbrequire(!op_ptr.isNull());
6592 alterTabPtr.p->m_dihAddFragPtr = dihPtr;
6593 tabPtr = alterTabPtr.p->m_newTablePtr;
6598 ndbrequire(DictTabInfo::isOrderedIndex(tabPtr.p->tableType));
6599 AlterIndexRecPtr alterIndexPtr;
6600 findSchemaOp(op_ptr, alterIndexPtr, senderData);
6601 ndbrequire(!op_ptr.isNull());
6602 alterIndexPtr.p->m_dihAddFragPtr = dihPtr;
6608 CreateTableRecPtr createTabPtr;
6609 findSchemaOp(op_ptr, createTabPtr, senderData);
6610 ndbrequire(!op_ptr.isNull());
6611 createTabPtr.p->m_dihAddFragPtr = dihPtr;
6612 c_tableRecordPool.
getPtr(tabPtr, tableId);
6616 tabPtr.p->gciTableCreated = (startGci > tabPtr.p->gciTableCreated ? startGci:
6617 startGci > tabPtr.p->gciTableCreated);
6623 Uint32 lhDistrBits = 0;
6624 Uint32 lhPageBits = 0;
6625 ::calcLHbits(&lhPageBits, &lhDistrBits, fragId, fragCount,
this);
6627 Uint64 maxRows = tabPtr.p->maxRowsLow +
6628 (((Uint64)tabPtr.p->maxRowsHigh) << 32);
6629 Uint64 minRows = tabPtr.p->minRowsLow +
6630 (((Uint64)tabPtr.p->minRowsHigh) << 32);
6631 maxRows = (maxRows + fragCount - 1) / fragCount;
6632 minRows = (minRows + fragCount - 1) / fragCount;
6636 req->senderData = senderData;
6637 req->senderRef = reference();
6638 req->fragmentId = fragId;
6639 req->requestInfo = requestInfo;
6640 req->tableId = tableId;
6641 req->localKeyLength = tabPtr.p->localKeyLen;
6642 req->maxLoadFactor = tabPtr.p->maxLoadFactor;
6643 req->minLoadFactor = tabPtr.p->minLoadFactor;
6644 req->kValue = tabPtr.p->kValue;
6645 req->lh3DistrBits = 0;
6646 req->lh3PageBits = 0;
6647 req->maxRowsLow = (Uint32)(maxRows & 0xFFFFFFFF);
6648 req->maxRowsHigh = (Uint32)(maxRows >> 32);
6649 req->minRowsLow = (Uint32)(minRows & 0xFFFFFFFF);
6650 req->minRowsHigh = (Uint32)(minRows >> 32);
6651 Uint32 keyLen = tabPtr.p->tupKeyLength;
6652 req->keyLength = keyLen;
6653 req->nextLCP = lcpNo;
6655 req->startGci = startGci;
6656 req->tablespace_id= tabPtr.p->m_tablespace_id;
6657 req->tablespace_id = tabPtr.p->m_tablespace_id;
6658 req->logPartId = logPart;
6659 req->changeMask = changeMask;
6660 sendSignal(DBLQH_REF, GSN_LQHFRAGREQ, signal,
6661 LqhFragReq::SignalLength, JBB);
6666 Dbdict::execLQHFRAGCONF(
Signal * signal)
6672 Uint32 fragId = conf->fragId;
6673 Uint32 tableId = conf->tableId;
6675 if (AlterTableReq::getAddFragFlag(conf->changeMask))
6680 c_tableRecordPool.
getPtr(tabPtr, tableId);
6681 if (DictTabInfo::isTable(tabPtr.p->tableType))
6683 AlterTableRecPtr alterTabPtr;
6684 findSchemaOp(op_ptr, alterTabPtr, conf->senderData);
6685 ndbrequire(!op_ptr.isNull());
6686 dihPtr = alterTabPtr.p->m_dihAddFragPtr;
6691 ndbrequire(DictTabInfo::isOrderedIndex(tabPtr.p->tableType));
6692 AlterIndexRecPtr alterIndexPtr;
6693 findSchemaOp(op_ptr, alterIndexPtr, conf->senderData);
6694 ndbrequire(!op_ptr.isNull());
6695 dihPtr = alterIndexPtr.p->m_dihAddFragPtr;
6702 CreateTableRecPtr createTabPtr;
6703 findSchemaOp(op_ptr, createTabPtr, conf->senderData);
6704 ndbrequire(!op_ptr.isNull());
6706 createTabPtr.p->m_lqhFragPtr = conf->lqhFragPtr;
6707 dihPtr = createTabPtr.p->m_dihAddFragPtr;
6712 conf->dihPtr = dihPtr;
6713 conf->fragId = fragId;
6714 sendSignal(DBDIH_REF, GSN_ADD_FRAGCONF, signal,
6715 AddFragConf::SignalLength, JBB);
6720 Dbdict::execLQHFRAGREF(
Signal * signal)
6726 Uint32 tableId = ref->tableId;
6727 Uint32 fragId = ref->fragId;
6728 if (AlterTableReq::getAddFragFlag(ref->changeMask))
6733 c_tableRecordPool.
getPtr(tabPtr, tableId);
6734 if (DictTabInfo::isTable(tabPtr.p->tableType))
6737 AlterTableRecPtr alterTabPtr;
6738 findSchemaOp(op_ptr, alterTabPtr, ref->senderData);
6739 ndbrequire(!op_ptr.isNull());
6740 setError(op_ptr, ref->errorCode, __LINE__);
6741 dihPtr = alterTabPtr.p->m_dihAddFragPtr;
6746 AlterIndexRecPtr alterIndexPtr;
6747 findSchemaOp(op_ptr, alterIndexPtr, ref->senderData);
6748 ndbrequire(!op_ptr.isNull());
6749 setError(op_ptr, ref->errorCode, __LINE__);
6750 dihPtr = alterIndexPtr.p->m_dihAddFragPtr;
6757 CreateTableRecPtr createTabPtr;
6758 findSchemaOp(op_ptr, createTabPtr, ref->senderData);
6759 ndbrequire(!op_ptr.isNull());
6760 setError(op_ptr, ref->errorCode, __LINE__);
6761 dihPtr = createTabPtr.p->m_dihAddFragPtr;
6766 ref->dihPtr = dihPtr;
6767 ref->fragId = fragId;
6768 sendSignal(DBDIH_REF, GSN_ADD_FRAGREF, signal,
6769 AddFragRef::SignalLength, JBB);
6774 Dbdict::execDIADDTABCONF(
Signal* signal)
6781 CreateTableRecPtr createTabPtr;
6782 findSchemaOp(op_ptr, createTabPtr, conf->senderData);
6783 ndbrequire(!op_ptr.isNull());
6785 signal->theData[0] = op_ptr.p->op_key;
6786 signal->theData[1] = reference();
6787 signal->theData[2] = createTabPtr.p->m_request.tableId;
6789 sendSignal(DBLQH_REF, GSN_TAB_COMMITREQ, signal, 3, JBB);
6793 Dbdict::execDIADDTABREF(
Signal* signal)
6800 CreateTableRecPtr createTabPtr;
6801 findSchemaOp(op_ptr, createTabPtr, ref->senderData);
6802 ndbrequire(!op_ptr.isNull());
6804 setError(op_ptr, ref->errorCode, __LINE__);
6805 execute(signal, createTabPtr.p->m_callback, 0);
6810 Dbdict::execTAB_COMMITCONF(
Signal* signal)
6815 CreateTableRecPtr createTabPtr;
6816 findSchemaOp(op_ptr, createTabPtr, signal->theData[0]);
6817 ndbrequire(!op_ptr.isNull());
6820 TableRecordPtr tabPtr;
6821 c_tableRecordPool.
getPtr(tabPtr, createTabPtr.p->m_request.tableId);
6823 if (refToBlock(signal->getSendersBlockRef()) == DBLQH) {
6827 req->tableId = tabPtr.i;
6828 req->tableVersion = tabPtr.p->tableVersion;
6829 req->tableLogged = (Uint32)!!(tabPtr.p->m_bits & TableRecord::TR_Logged);
6830 req->senderRef = reference();
6831 req->tableType = (Uint32)tabPtr.p->tableType;
6832 req->senderData = op_ptr.p->op_key;
6833 req->noOfPrimaryKeys = (Uint32)tabPtr.p->noOfPrimkey;
6834 req->singleUserMode = (Uint32)tabPtr.p->singleUserMode;
6835 req->userDefinedPartition = (tabPtr.p->fragmentType == DictTabInfo::UserDefined);
6837 if (DictTabInfo::isOrderedIndex(tabPtr.p->tableType))
6840 TableRecordPtr basePtr;
6841 c_tableRecordPool.
getPtr(basePtr, tabPtr.p->primaryTableId);
6842 req->userDefinedPartition = (basePtr.p->fragmentType == DictTabInfo::UserDefined);
6845 sendSignal(DBTC_REF, GSN_TC_SCHVERREQ, signal,
6846 TcSchVerReq::SignalLength, JBB);
6850 if (refToBlock(signal->getSendersBlockRef()) == DBDIH) {
6853 signal->theData[0] = op_ptr.p->op_key;
6854 signal->theData[1] = reference();
6855 signal->theData[2] = tabPtr.i;
6857 sendSignal(DBTC_REF, GSN_TAB_COMMITREQ, signal, 3, JBB);
6861 if (refToBlock(signal->getSendersBlockRef()) == DBTC) {
6863 execute(signal, createTabPtr.p->m_callback, 0);
6871 Dbdict::execTAB_COMMITREF(
Signal* signal) {
6877 Dbdict::createTab_localComplete(
Signal* signal,
6884 CreateTableRecPtr createTabPtr;
6885 findSchemaOp(op_ptr, createTabPtr, op_key);
6886 ndbrequire(!op_ptr.isNull());
6891 if (ERROR_INSERTED(6131)) {
6893 CLEAR_ERROR_INSERT_VALUE;
6894 setError(op_ptr.p->m_error, 9131, __LINE__);
6897 if (!hasError(op_ptr.p->m_error)) {
6900 sendTransConf(signal, op_ptr);
6903 sendTransRef(signal, op_ptr);
6910 Dbdict::createTable_commit(
Signal* signal, SchemaOpPtr op_ptr)
6913 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
6915 CreateTableRecPtr createTabPtr;
6916 getOpRec(op_ptr, createTabPtr);
6918 Uint32 tableId = createTabPtr.p->m_request.tableId;
6919 TableRecordPtr tabPtr;
6920 c_tableRecordPool.
getPtr(tabPtr, tableId);
6922 D(
"createTable_commit" << *op_ptr.p);
6925 c.m_callbackData = op_ptr.p->op_key;
6926 c.m_callbackFunction = safe_cast(&Dbdict::createTab_alterComplete);
6927 createTab_activate(signal, op_ptr, &c);
6929 if (DictTabInfo::isIndex(tabPtr.p->tableType))
6932 c_tableRecordPool.
getPtr(basePtr, tabPtr.p->primaryTableId);
6940 Dbdict::createTab_activate(
Signal* signal, SchemaOpPtr op_ptr,
6943 CreateTableRecPtr createTabPtr;
6944 getOpRec(op_ptr, createTabPtr);
6945 createTabPtr.p->m_callback = * c;
6947 signal->theData[0] = op_ptr.p->op_key;
6948 signal->theData[1] = reference();
6949 signal->theData[2] = createTabPtr.p->m_request.tableId;
6950 sendSignal(DBDIH_REF, GSN_TAB_COMMITREQ, signal, 3, JBB);
6954 Dbdict::execTC_SCHVERCONF(
Signal* signal)
6959 CreateTableRecPtr createTabPtr;
6960 findSchemaOp(op_ptr, createTabPtr, signal->theData[1]);
6961 ndbrequire(!op_ptr.isNull());
6963 execute(signal, createTabPtr.p->m_callback, 0);
6967 Dbdict::createTab_alterComplete(
Signal* signal,
6974 CreateTableRecPtr createTabPtr;
6975 findSchemaOp(op_ptr, createTabPtr, op_key);
6976 ndbrequire(!op_ptr.isNull());
6977 const CreateTabReq* impl_req = &createTabPtr.p->m_request;
6979 TableRecordPtr tabPtr;
6980 c_tableRecordPool.
getPtr(tabPtr, impl_req->tableId);
6982 D(
"createTab_alterComplete" << *op_ptr.p);
6990 conf->senderRef = reference();
6991 conf->senderData = impl_req->tableId;
6993 signal->header.m_noOfSections = 1;
6995 getSection(tabInfoPtr, createTabPtr.p->m_tabInfoPtrI);
6996 signal->setSection(tabInfoPtr, 0);
6998 sendSignal(SUMA_REF, GSN_CREATE_TAB_CONF, signal,
6999 CreateTabConf::SignalLength, JBB);
7001 signal->header.m_noOfSections = 0;
7005 sendTransConf(signal, op_ptr);
7011 Dbdict::createTable_complete(
Signal* signal, SchemaOpPtr op_ptr)
7014 sendTransConf(signal, op_ptr);
7018 Dbdict::createTable_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
7020 CreateTableRecPtr createTabPtr;
7021 getOpRec(op_ptr, createTabPtr);
7022 const CreateTabReq* impl_req = &createTabPtr.p->m_request;
7023 const Uint32 tableId = impl_req->tableId;
7025 D(
"createTable_abortParse" << V(tableId) << *op_ptr.p);
7028 if (createTabPtr.p->m_abortPrepareDone)
7031 D(
"done by abort prepare");
7035 if (tableId == RNIL) {
7037 D(
"no table allocated");
7041 TableRecordPtr tabPtr;
7042 c_tableRecordPool.
getPtr(tabPtr, tableId);
7045 if (hasDictObject(op_ptr)) {
7047 unlinkDictObject(op_ptr);
7048 releaseTableObject(tableId,
true);
7052 sendTransConf(signal, op_ptr);
7056 Dbdict::createTable_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
7058 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7059 CreateTableRecPtr createTabPtr;
7060 getOpRec(op_ptr, createTabPtr);
7061 const CreateTabReq* impl_req = &createTabPtr.p->m_request;
7064 D(
"createTable_abortPrepare" << *op_ptr.p);
7066 TableRecordPtr tabPtr;
7067 c_tableRecordPool.
getPtr(tabPtr, impl_req->tableId);
7071 SchemaOpPtr& oplnk_ptr = op_ptr.p->m_oplnk_ptr;
7072 ndbrequire(oplnk_ptr.isNull());
7073 DropTableRecPtr dropTabPtr;
7074 seizeSchemaOp(oplnk_ptr, dropTabPtr);
7075 ndbrequire(!oplnk_ptr.isNull());
7076 DropTabReq* aux_impl_req = &dropTabPtr.p->m_request;
7078 aux_impl_req->senderRef = impl_req->senderRef;
7079 aux_impl_req->senderData = impl_req->senderData;
7080 aux_impl_req->requestType = DropTabReq::CreateTabDrop;
7081 aux_impl_req->tableId = impl_req->tableId;
7082 aux_impl_req->tableVersion = impl_req->tableVersion;
7085 oplnk_ptr.p->m_opbck_ptr = op_ptr;
7088 unlinkDictObject(op_ptr);
7090 dropTabPtr.p->m_block = 0;
7091 dropTabPtr.p->m_blockNo[0] = DBTC;
7092 dropTabPtr.p->m_blockNo[1] = DBLQH;
7093 dropTabPtr.p->m_blockNo[2] = DBDIH;
7094 dropTabPtr.p->m_blockNo[3] = DBLQH;
7095 dropTabPtr.p->m_blockNo[4] = 0;
7097 dropTabPtr.p->m_callback.m_callbackData =
7098 oplnk_ptr.p->op_key;
7099 dropTabPtr.p->m_callback.m_callbackFunction =
7100 safe_cast(&Dbdict::createTable_abortLocalConf);
7103 dropTable_complete_nextStep(signal, oplnk_ptr);
7105 if (tabPtr.p->m_tablespace_id != RNIL) {
7107 ndbrequire(c_filegroup_hash.
find(ptr, tabPtr.p->m_tablespace_id));
7108 decrease_ref_count(ptr.p->m_obj_ptr_i);
7113 Dbdict::createTable_abortLocalConf(
Signal* signal,
7118 D(
"createTable_abortLocalConf" << V(oplnk_key));
7120 SchemaOpPtr oplnk_ptr;
7121 DropTableRecPtr dropTabPtr;
7122 findSchemaOp(oplnk_ptr, dropTabPtr, oplnk_key);
7123 ndbrequire(!oplnk_ptr.isNull());
7125 SchemaOpPtr op_ptr = oplnk_ptr.p->m_opbck_ptr;
7126 CreateTableRecPtr createTabPtr;
7127 getOpRec(op_ptr, createTabPtr);
7128 const CreateTabReq* impl_req = &createTabPtr.p->m_request;
7129 Uint32 tableId = impl_req->tableId;
7131 TableRecordPtr tablePtr;
7132 c_tableRecordPool.
getPtr(tablePtr, tableId);
7134 releaseTableObject(tableId);
7136 createTabPtr.p->m_abortPrepareDone =
true;
7137 sendTransConf(signal, op_ptr);
7143 Dbdict::execCREATE_FRAGMENTATION_REF(
Signal * signal)
7150 Dbdict::execCREATE_FRAGMENTATION_CONF(
Signal* signal)
7157 Dbdict::execCREATE_TAB_REQ(
Signal* signal)
7163 void Dbdict::execCREATE_TABLE_CONF(
Signal* signal)
7167 handleDictConf(signal, conf);
7170 void Dbdict::execCREATE_TABLE_REF(
Signal* signal)
7174 handleDictRef(signal, ref);
7177 void Dbdict::releaseTableObject(Uint32 tableId,
bool removeFromHash)
7179 TableRecordPtr tablePtr;
7180 c_tableRecordPool.
getPtr(tablePtr, tableId);
7184 release_object(tablePtr.p->m_obj_ptr_i);
7185 tablePtr.p->m_obj_ptr_i = RNIL;
7189 Rope tmp(c_rope_pool, tablePtr.p->tableName);
7194 Rope tmp(c_rope_pool, tablePtr.p->frmData);
7199 Rope tmp(c_rope_pool, tablePtr.p->ngData);
7204 Rope tmp(c_rope_pool, tablePtr.p->rangeData);
7209 tablePtr.p->m_attributes);
7210 AttributeRecordPtr attrPtr;
7211 for(list.first(attrPtr); !attrPtr.isNull(); list.next(attrPtr)){
7212 Rope name(c_rope_pool, attrPtr.p->attributeName);
7213 Rope def(c_rope_pool, attrPtr.p->defaultValue);
7220 if (tablePtr.p->m_upgrade_trigger_handling.m_upgrade)
7225 triggerId = tablePtr.p->m_upgrade_trigger_handling.updateTriggerId;
7226 if (triggerId != RNIL)
7229 TriggerRecordPtr triggerPtr;
7230 c_triggerRecordPool.
getPtr(triggerPtr, triggerId);
7231 triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
7232 release_object(triggerPtr.p->m_obj_ptr_i);
7235 triggerId = tablePtr.p->m_upgrade_trigger_handling.deleteTriggerId;
7236 if (triggerId != RNIL)
7239 TriggerRecordPtr triggerPtr;
7240 c_triggerRecordPool.
getPtr(triggerPtr, triggerId);
7241 triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
7242 release_object(triggerPtr.p->m_obj_ptr_i);
7253 const Dbdict::OpInfo
7254 Dbdict::DropTableRec::g_opInfo = {
7255 {
'D',
'T',
'a', 0 },
7257 DropTabReq::SignalLength,
7259 &Dbdict::dropTable_seize,
7260 &Dbdict::dropTable_release,
7262 &Dbdict::dropTable_parse,
7263 &Dbdict::dropTable_subOps,
7264 &Dbdict::dropTable_reply,
7266 &Dbdict::dropTable_prepare,
7267 &Dbdict::dropTable_commit,
7268 &Dbdict::dropTable_complete,
7270 &Dbdict::dropTable_abortParse,
7271 &Dbdict::dropTable_abortPrepare
7275 Dbdict::dropTable_seize(SchemaOpPtr op_ptr)
7277 return seizeOpRec<DropTableRec>(op_ptr);
7281 Dbdict::dropTable_release(SchemaOpPtr op_ptr)
7283 releaseOpRec<DropTableRec>(op_ptr);
7287 Dbdict::execDROP_TABLE_REQ(
Signal* signal)
7296 if (check_sender_version(signal, MAKE_VERSION(6,4,0)) < 0)
7304 do_swap(tmp->senderRef, tmp->senderData);
7314 DropTableRecPtr dropTabPtr;
7317 startClientReq(op_ptr, dropTabPtr, req, impl_req, error);
7318 if (hasError(error)) {
7323 impl_req->tableId = req->tableId;
7324 impl_req->tableVersion = req->tableVersion;
7326 handleClientReq(signal, op_ptr, handle);
7330 releaseSections(handle);
7333 ref->senderRef = reference();
7334 ref->clientData = req->clientData;
7335 ref->transId = req->transId;
7336 ref->tableId = req->tableId;
7337 ref->tableVersion = req->tableVersion;
7338 getError(error, ref);
7339 sendSignal(req->clientRef, GSN_DROP_TABLE_REF, signal,
7340 DropTableRef::SignalLength, JBB);
7346 Dbdict::dropTable_parse(
Signal* signal,
bool master,
7350 D(
"dropTable_parse" << V(op_ptr.i) << *op_ptr.p);
7352 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7353 DropTableRecPtr dropTabPtr;
7354 getOpRec(op_ptr, dropTabPtr);
7355 DropTabReq* impl_req = &dropTabPtr.p->m_request;
7356 Uint32 tableId = impl_req->tableId;
7358 TableRecordPtr tablePtr;
7359 if (!(tableId < c_tableRecordPool.getSize())) {
7361 setError(error, DropTableRef::NoSuchTable, __LINE__);
7364 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
7367 if (tablePtr.p->tableVersion != impl_req->tableVersion) {
7369 setError(error, DropTableRef::InvalidTableVersion, __LINE__);
7373 if (tablePtr.p->m_read_locked)
7376 setError(error, DropTableRef::BackupInProgress, __LINE__);
7380 if (check_write_obj(tablePtr.i,
7381 trans_ptr.p->m_transId,
7382 SchemaFile::SF_DROP, error))
7390 DictObjectPtr obj_ptr;
7391 Uint32 obj_ptr_i = tablePtr.p->m_obj_ptr_i;
7392 bool ok = findDictObject(op_ptr, obj_ptr, obj_ptr_i);
7396 if (ERROR_INSERTED(6121)) {
7398 CLEAR_ERROR_INSERT_VALUE;
7399 setError(error, 9121, __LINE__);
7404 te.m_tableState = SchemaFile::SF_DROP;
7405 te.m_transId = trans_ptr.p->m_transId;
7406 Uint32 err = trans_log_schema_op(op_ptr, tableId, &te);
7410 setError(error, err, __LINE__);
7416 Dbdict::dropTable_subOps(
Signal* signal, SchemaOpPtr op_ptr)
7418 D(
"dropTable_subOps" << V(op_ptr.i) << *op_ptr.p);
7424 Dbdict::dropTable_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
7427 D(
"dropTable_reply" << V(op_ptr.i) << *op_ptr.p);
7429 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7431 DropTableRecPtr dropTabPtr;
7432 getOpRec(op_ptr, dropTabPtr);
7434 if (!hasError(error)) {
7436 conf->senderRef = reference();
7437 conf->clientData = op_ptr.p->m_clientData;
7438 conf->transId = trans_ptr.p->m_transId;
7439 conf->tableId = dropTabPtr.p->m_request.tableId;
7440 conf->tableVersion = dropTabPtr.p->m_request.tableVersion;
7442 D(V(conf->tableId) << V(conf->tableVersion));
7444 Uint32 clientRef = op_ptr.p->m_clientRef;
7445 sendSignal(clientRef, GSN_DROP_TABLE_CONF, signal,
7446 DropTableConf::SignalLength, JBB);
7450 ref->senderRef = reference();
7451 ref->clientData = op_ptr.p->m_clientData;
7452 ref->transId = trans_ptr.p->m_transId;
7453 ref->tableId = dropTabPtr.p->m_request.tableId;
7454 ref->tableVersion = dropTabPtr.p->m_request.tableVersion;
7455 getError(error, ref);
7457 Uint32 clientRef = op_ptr.p->m_clientRef;
7458 sendSignal(clientRef, GSN_DROP_TABLE_REF, signal,
7459 DropTableRef::SignalLength, JBB);
7466 Dbdict::dropTable_prepare(
Signal* signal, SchemaOpPtr op_ptr)
7468 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7470 DropTableRecPtr dropTabPtr;
7471 getOpRec(op_ptr, dropTabPtr);
7473 D(
"dropTable_prepare" << *op_ptr.p);
7475 Mutex mutex(signal, c_mutexMgr, dropTabPtr.p->m_define_backup_mutex);
7477 safe_cast(&Dbdict::dropTable_backup_mutex_locked),
7480 bool ok = mutex.lock(c);
7486 Dbdict::dropTable_backup_mutex_locked(
Signal* signal,
7491 D(
"dropTable_backup_mutex_locked");
7493 ndbrequire(ret == 0);
7496 DropTableRecPtr dropTabPtr;
7497 findSchemaOp(op_ptr, dropTabPtr, op_key);
7498 ndbrequire(!op_ptr.isNull());
7499 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7500 const DropTabReq* impl_req = &dropTabPtr.p->m_request;
7502 TableRecordPtr tablePtr;
7503 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
7505 Mutex mutex(signal, c_mutexMgr, dropTabPtr.p->m_define_backup_mutex);
7508 if (tablePtr.p->m_read_locked)
7511 setError(op_ptr, AlterTableRef::BackupInProgress, __LINE__);
7512 sendTransRef(signal, op_ptr);
7516 sendTransConf(signal, op_ptr);
7521 Dbdict::dropTable_commit(
Signal* signal, SchemaOpPtr op_ptr)
7523 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7525 DropTableRecPtr dropTabPtr;
7526 getOpRec(op_ptr, dropTabPtr);
7528 D(
"dropTable_commit" << *op_ptr.p);
7530 TableRecordPtr tablePtr;
7531 c_tableRecordPool.
getPtr(tablePtr, dropTabPtr.p->m_request.tableId);
7533 if (tablePtr.p->m_tablespace_id != RNIL)
7536 ndbrequire(c_filegroup_hash.
find(ptr, tablePtr.p->m_tablespace_id));
7537 decrease_ref_count(ptr.p->m_obj_ptr_i);
7544 Rope name(c_rope_pool, tablePtr.p->tableName);
7546 g_eventLogger->
info(
"Dbdict: drop name=%s,id=%u,obj_id=%u", buf, tablePtr.i,
7547 tablePtr.p->m_obj_ptr_i);
7550 send_event(signal, trans_ptr,
7551 NDB_LE_DropSchemaObject,
7553 tablePtr.p->tableVersion,
7554 tablePtr.p->tableType);
7556 if (DictTabInfo::isIndex(tablePtr.p->tableType))
7559 c_tableRecordPool.
getPtr(basePtr, tablePtr.p->primaryTableId);
7562 list.remove(tablePtr);
7564 dropTabPtr.p->m_block = 0;
7565 dropTabPtr.p->m_blockNo[0] = DBLQH;
7566 dropTabPtr.p->m_blockNo[1] = DBTC;
7567 dropTabPtr.p->m_blockNo[2] = DBDIH;
7568 dropTabPtr.p->m_blockNo[3] = 0;
7569 dropTable_commit_nextStep(signal, op_ptr);
7574 Dbdict::dropTable_commit_nextStep(
Signal* signal, SchemaOpPtr op_ptr)
7576 DropTableRecPtr dropTabPtr;
7577 getOpRec(op_ptr, dropTabPtr);
7578 const DropTabReq* impl_req = &dropTabPtr.p->m_request;
7583 ndbrequire(!hasError(op_ptr.p->m_error));
7585 Uint32
block = dropTabPtr.p->m_block;
7586 Uint32 blockNo = dropTabPtr.p->m_blockNo[
block];
7587 D(
"dropTable_commit_nextStep" << hex << V(blockNo) << *op_ptr.p);
7592 dropTable_commit_done(signal, op_ptr);
7596 if (ERROR_INSERTED(6131) &&
7599 CLEAR_ERROR_INSERT_VALUE;
7602 ref->senderRef = numberToRef(block, getOwnNodeId());
7603 ref->senderData = op_ptr.p->op_key;
7604 ref->tableId = impl_req->tableId;
7605 ref->errorCode = 9131;
7606 sendSignal(reference(), GSN_PREP_DROP_TAB_REF, signal,
7607 PrepDropTabRef::SignalLength, JBB);
7613 prep->senderRef = reference();
7614 prep->senderData = op_ptr.p->op_key;
7615 prep->tableId = impl_req->tableId;
7616 prep->requestType = impl_req->requestType;
7618 BlockReference ref = numberToRef(blockNo, getOwnNodeId());
7619 sendSignal(ref, GSN_PREP_DROP_TAB_REQ, signal,
7620 PrepDropTabReq::SignalLength, JBB);
7624 Dbdict::execPREP_DROP_TAB_REQ(
Signal* signal)
7631 Dbdict::execPREP_DROP_TAB_CONF(
Signal * signal)
7636 Uint32 nodeId = refToNode(conf->senderRef);
7637 Uint32 block = refToBlock(conf->senderRef);
7638 ndbrequire(nodeId == getOwnNodeId() && block != DBDICT);
7640 dropTable_commit_fromLocal(signal, conf->senderData, 0);
7644 Dbdict::execPREP_DROP_TAB_REF(
Signal* signal)
7649 Uint32 nodeId = refToNode(ref->senderRef);
7650 Uint32 block = refToBlock(ref->senderRef);
7651 ndbrequire(nodeId == getOwnNodeId() && block != DBDICT);
7653 Uint32 errorCode = ref->errorCode;
7654 ndbrequire(errorCode != 0);
7656 if (errorCode == PrepDropTabRef::NoSuchTable && block == DBLQH)
7665 dropTable_commit_fromLocal(signal, ref->senderData, errorCode);
7669 Dbdict::dropTable_commit_fromLocal(
Signal* signal, Uint32 op_key, Uint32 errorCode)
7672 DropTableRecPtr dropTabPtr;
7673 findSchemaOp(op_ptr, dropTabPtr, op_key);
7674 ndbrequire(!op_ptr.isNull());
7679 setError(op_ptr, errorCode, __LINE__);
7682 dropTabPtr.p->m_block++;
7683 dropTable_commit_nextStep(signal, op_ptr);
7687 Dbdict::dropTable_commit_done(
Signal* signal, SchemaOpPtr op_ptr)
7690 D(
"dropTable_commit_done");
7692 sendTransConf(signal, op_ptr);
7698 Dbdict::dropTable_complete(
Signal* signal, SchemaOpPtr op_ptr)
7702 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7704 DropTableRecPtr dropTabPtr;
7705 getOpRec(op_ptr, dropTabPtr);
7707 TableRecordPtr tablePtr;
7708 c_tableRecordPool.
getPtr(tablePtr, dropTabPtr.p->m_request.tableId);
7710 dropTabPtr.p->m_block = 0;
7711 dropTabPtr.p->m_blockNo[0] = DBTC;
7712 dropTabPtr.p->m_blockNo[1] = DBLQH;
7713 dropTabPtr.p->m_blockNo[2] = DBDIH;
7714 dropTabPtr.p->m_blockNo[3] = DBLQH;
7715 dropTabPtr.p->m_blockNo[4] = 0;
7716 dropTabPtr.p->m_callback.m_callbackData =
7718 dropTabPtr.p->m_callback.m_callbackFunction =
7719 safe_cast(&Dbdict::dropTable_complete_done);
7721 dropTable_complete_nextStep(signal, op_ptr);
7725 Dbdict::dropTable_complete_nextStep(
Signal* signal, SchemaOpPtr op_ptr)
7727 DropTableRecPtr dropTabPtr;
7728 getOpRec(op_ptr, dropTabPtr);
7729 const DropTabReq* impl_req = &dropTabPtr.p->m_request;
7734 ndbrequire(!hasError(op_ptr.p->m_error));
7736 TableRecordPtr tablePtr;
7737 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
7739 Uint32 block = dropTabPtr.p->m_block;
7740 Uint32 blockNo = dropTabPtr.p->m_blockNo[
block];
7741 D(
"dropTable_complete_nextStep" << hex << V(blockNo) << *op_ptr.p);
7746 execute(signal, dropTabPtr.p->m_callback, 0);
7751 req->senderRef = reference();
7752 req->senderData = op_ptr.p->op_key;
7753 req->tableId = impl_req->tableId;
7754 req->requestType = impl_req->requestType;
7756 BlockReference ref = numberToRef(blockNo, getOwnNodeId());
7757 sendSignal(ref, GSN_DROP_TAB_REQ, signal,
7758 DropTabReq::SignalLength, JBB);
7762 Dbdict::execDROP_TAB_CONF(
Signal* signal)
7767 Uint32 nodeId = refToNode(conf->senderRef);
7768 Uint32 block = refToBlock(conf->senderRef);
7769 ndbrequire(nodeId == getOwnNodeId() && block != DBDICT);
7771 dropTable_complete_fromLocal(signal, conf->senderData);
7775 Dbdict::execDROP_TAB_REF(
Signal* signal)
7780 Uint32 nodeId = refToNode(ref->senderRef);
7781 Uint32 block = refToBlock(ref->senderRef);
7782 ndbrequire(nodeId == getOwnNodeId() && block != DBDICT);
7783 ndbrequire(ref->errorCode == DropTabRef::NoSuchTable);
7785 dropTable_complete_fromLocal(signal, ref->senderData);
7789 Dbdict::dropTable_complete_fromLocal(
Signal* signal, Uint32 op_key)
7794 DropTableRecPtr dropTabPtr;
7795 findSchemaOp(op_ptr, dropTabPtr, op_key);
7796 ndbrequire(!op_ptr.isNull());
7799 D(
"dropTable_complete_fromLocal" << *op_ptr.p);
7801 dropTabPtr.p->m_block++;
7802 dropTable_complete_nextStep(signal, op_ptr);
7806 Dbdict::dropTable_complete_done(
Signal* signal,
7813 DropTableRecPtr dropTabPtr;
7814 findSchemaOp(op_ptr, dropTabPtr, op_key);
7815 ndbrequire(!op_ptr.isNull());
7816 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
7818 Uint32 tableId = dropTabPtr.p->m_request.tableId;
7820 unlinkDictObject(op_ptr);
7821 releaseTableObject(tableId);
7828 if (trans_ptr.p->m_isMaster) {
7830 conf->senderRef = trans_ptr.p->m_clientRef;
7833 conf->senderRef = 0;
7835 conf->senderData = op_key;
7836 conf->tableId = tableId;
7837 sendSignal(SUMA_REF, GSN_DROP_TAB_CONF, signal,
7838 DropTabConf::SignalLength, JBB);
7841 sendTransConf(signal, trans_ptr);
7847 Dbdict::dropTable_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
7849 D(
"dropTable_abortParse" << *op_ptr.p);
7851 sendTransConf(signal, op_ptr);
7855 Dbdict::dropTable_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
7857 D(
"dropTable_abortPrepare" << *op_ptr.p);
7859 sendTransConf(signal, op_ptr);
7864 void Dbdict::execDROP_TABLE_CONF(
Signal* signal)
7868 handleDictConf(signal, conf);
7871 void Dbdict::execDROP_TABLE_REF(
Signal* signal)
7875 handleDictRef(signal, ref);
7882 const Dbdict::OpInfo
7883 Dbdict::AlterTableRec::g_opInfo = {
7884 {
'A',
'T',
'a', 0 },
7886 AlterTabReq::SignalLength,
7888 &Dbdict::alterTable_seize,
7889 &Dbdict::alterTable_release,
7891 &Dbdict::alterTable_parse,
7892 &Dbdict::alterTable_subOps,
7893 &Dbdict::alterTable_reply,
7895 &Dbdict::alterTable_prepare,
7896 &Dbdict::alterTable_commit,
7897 &Dbdict::alterTable_complete,
7899 &Dbdict::alterTable_abortParse,
7900 &Dbdict::alterTable_abortPrepare
7904 Dbdict::alterTable_seize(SchemaOpPtr op_ptr)
7906 return seizeOpRec<AlterTableRec>(op_ptr);
7910 Dbdict::alterTable_release(SchemaOpPtr op_ptr)
7912 AlterTableRecPtr alterTabPtr;
7913 getOpRec(op_ptr, alterTabPtr);
7915 Rope r(c_rope_pool, alterTabPtr.p->m_oldTableName);
7919 Rope r(c_rope_pool, alterTabPtr.p->m_oldFrmData);
7922 releaseOpRec<AlterTableRec>(op_ptr);
7926 Dbdict::check_ndb_versions()
const
7930 while((node = c_aliveNodes.
find(node + 1)) != BitmaskImpl::NotFound)
7941 Dbdict::check_sender_version(
const Signal* signal, Uint32 version)
const
7946 else if (ver > version)
7952 Dbdict::execALTER_TABLE_REQ(
Signal* signal)
7962 if (check_sender_version(signal, MAKE_VERSION(6,4,0)) < 0)
7970 do_swap(tmp->clientRef, tmp->clientData);
7980 AlterTableRecPtr alterTabPtr;
7983 startClientReq(op_ptr, alterTabPtr, req, impl_req, error);
7984 if (hasError(error)) {
7989 impl_req->tableId = req->tableId;
7990 impl_req->tableVersion = req->tableVersion;
7991 impl_req->newTableVersion = 0;
7993 impl_req->changeMask = req->changeMask;
7994 impl_req->connectPtr = RNIL;
7995 impl_req->noOfNewAttr = 0;
7996 impl_req->newNoOfCharsets = 0;
7997 impl_req->newNoOfKeyAttrs = 0;
7999 handleClientReq(signal, op_ptr, handle);
8003 releaseSections(handle);
8006 ref->senderRef = reference();
8007 ref->clientData = req->clientData;
8008 ref->transId = req->transId;
8009 getError(error, ref);
8010 sendSignal(req->clientRef, GSN_ALTER_TABLE_REF, signal,
8011 AlterTableRef::SignalLength, JBB);
8017 Dbdict::alterTable_parse(
Signal* signal,
bool master,
8021 D(
"alterTable_parse");
8023 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8024 AlterTableRecPtr alterTabPtr;
8025 getOpRec(op_ptr, alterTabPtr);
8026 AlterTabReq* impl_req = &alterTabPtr.p->m_request;
8028 if (AlterTableReq::getReorgSubOp(impl_req->changeMask))
8033 if (master && op_ptr.p->m_base_op_ptr_i == RNIL)
8036 setError(error, AlterTableRef::Inconsistency, __LINE__);
8044 TableRecordPtr tablePtr;
8045 if (!(impl_req->tableId < c_tableRecordPool.getSize())) {
8047 setError(error, AlterTableRef::NoSuchTable, __LINE__);
8050 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
8052 if (tablePtr.p->m_read_locked)
8055 setError(error, tablePtr.p->m_read_locked, __LINE__);
8059 if (check_write_obj(tablePtr.i, trans_ptr.p->m_transId,
8060 SchemaFile::SF_ALTER, error))
8067 alterTabPtr.p->m_tablePtr = tablePtr;
8069 if (tablePtr.p->tableVersion != impl_req->tableVersion) {
8071 setError(error, AlterTableRef::InvalidTableVersion, __LINE__);
8076 TableRecordPtr& newTablePtr = alterTabPtr.p->m_newTablePtr;
8078 ParseDictTabInfoRecord parseRecord;
8079 parseRecord.requestType = DictTabInfo::AlterTableFromAPI;
8080 parseRecord.errorCode = 0;
8083 bool ok = handle.getSection(ptr, AlterTableReq::DICT_TAB_INFO);
8087 handleTabInfoInit(signal,
8088 trans_ptr, r, &parseRecord,
false);
8090 if (parseRecord.errorCode != 0) {
8092 setError(error, parseRecord);
8097 newTablePtr = parseRecord.tablePtr;
8098 alterTabPtr.p->m_newTable_realObjectId = newTablePtr.p->tableId;
8099 newTablePtr.p->tableId = impl_req->tableId;
8109 objEntry = getTableEntry(alterTabPtr.p->m_newTable_realObjectId);
8110 objEntry->m_tableType = DictTabInfo::SchemaTransaction;
8111 objEntry->m_tableState = SchemaFile::SF_STARTED;
8112 objEntry->m_transId = trans_ptr.p->m_transId + 1;
8116 impl_req->newTableVersion =
8117 newTablePtr.p->tableVersion =
8118 alter_obj_inc_schema_version(tablePtr.p->tableVersion);
8122 ConstRope r1(c_rope_pool, tablePtr.p->tableName);
8123 ConstRope r2(c_rope_pool, newTablePtr.p->tableName);
8125 char name[MAX_TAB_NAME_SIZE];
8128 if (r1.compare(name) != 0)
8131 if (get_object(name) != 0)
8134 setError(error, CreateTableRef::TableAlreadyExist, __LINE__);
8141 AlterTableReq::setNameFlag(impl_req->changeMask, 1);
8146 setError(error, AlterTableRef::Inconsistency, __LINE__);
8153 setError(error, AlterTableRef::Inconsistency, __LINE__);
8160 ConstRope r1(c_rope_pool, tablePtr.p->frmData);
8161 ConstRope r2(c_rope_pool, newTablePtr.p->frmData);
8167 AlterTableReq::setFrmFlag(impl_req->changeMask, 1);
8169 else if (!AlterTableReq::getFrmFlag(impl_req->changeMask))
8172 setError(error, AlterTableRef::Inconsistency, __LINE__);
8176 else if (AlterTableReq::getFrmFlag(impl_req->changeMask))
8179 setError(error, AlterTableRef::Inconsistency, __LINE__);
8186 const Uint32 noOfNewAttr =
8187 newTablePtr.p->noOfAttributes - tablePtr.p->noOfAttributes;
8189 if (newTablePtr.p->noOfAttributes > tablePtr.p->noOfAttributes)
8194 AlterTableReq::setAddAttrFlag(impl_req->changeMask, 1);
8196 else if (!AlterTableReq::getAddAttrFlag(impl_req->changeMask))
8199 setError(error, AlterTableRef::Inconsistency, __LINE__);
8203 else if (AlterTableReq::getAddAttrFlag(impl_req->changeMask))
8206 setError(error, AlterTableRef::Inconsistency, __LINE__);
8209 else if (newTablePtr.p->noOfAttributes < tablePtr.p->noOfAttributes)
8212 setError(error, AlterTableRef::UnsupportedChange, __LINE__);
8219 impl_req->noOfNewAttr = noOfNewAttr;
8220 impl_req->newNoOfCharsets = newTablePtr.p->noOfCharsets;
8221 impl_req->newNoOfKeyAttrs = newTablePtr.p->noOfPrimkey;
8223 else if (impl_req->noOfNewAttr != noOfNewAttr)
8226 setError(error, AlterTableRef::Inconsistency, __LINE__);
8231 list(c_attributeRecordPool, newTablePtr.p->m_attributes);
8232 AttributeRecordPtr attrPtr;
8233 list.first(attrPtr);
8235 for (i = 0; i < newTablePtr.p->noOfAttributes; i++) {
8236 if (i >= tablePtr.p->noOfAttributes) {
8238 Uint32 j = 2 * (i - tablePtr.p->noOfAttributes);
8239 alterTabPtr.p->m_newAttrData[j + 0] = attrPtr.p->attributeDescriptor;
8240 alterTabPtr.p->m_newAttrData[j + 1] = attrPtr.p->extPrecision & ~0xFFFF;
8246 if (AlterTableReq::getAddFragFlag(impl_req->changeMask))
8248 if (newTablePtr.p->fragmentType != DictTabInfo::HashMapPartition)
8251 setError(error, AlterTableRef::UnsupportedChange, __LINE__);
8258 if (ERROR_INSERTED(6212))
8260 CLEAR_ERROR_INSERT_VALUE;
8261 setError(error, 1, __LINE__);
8266 if ((err = check_supported_reorg(tablePtr.p->hashMapObjectId,
8267 newTablePtr.p->hashMapObjectId)))
8270 setError(error, AlterTableRef::UnsupportedChange, __LINE__);
8274 if (tablePtr.p->hashMapObjectId != newTablePtr.p->hashMapObjectId)
8277 AlterTableReq::setReorgFragFlag(impl_req->changeMask, 1);
8289 Uint32 save0 = newTablePtr.p->fragmentType;
8290 newTablePtr.p->fragmentType = DictTabInfo::DistrKeyHash;
8298 for (Uint32 i = cnt; i<newTablePtr.p->fragmentCount; i++)
8301 c_fragData[
i] = NDB_UNDEF_NODEGROUP;
8304 Uint32 save1 = newTablePtr.p->primaryTableId;
8313 flags = CreateFragmentationReq::RI_ADD_PARTITION;
8314 newTablePtr.p->primaryTableId = tablePtr.p->tableId;
8316 err = create_fragmentation(signal, newTablePtr,
8319 newTablePtr.p->fragmentType = (DictTabInfo::FragmentType)save0;
8320 newTablePtr.p->primaryTableId = save1;
8325 setError(error, err, __LINE__);
8329 Uint16* data = (Uint16*)(signal->theData+25);
8330 Uint32 count = 2 + (1 + data[0]) * data[1];
8331 memcpy(c_fragData, data, 2*count);
8333 err = get_fragmentation(signal, tablePtr.p->tableId);
8337 setError(error, err, __LINE__);
8341 err = check_supported_add_fragment(c_fragData,
8342 (Uint16*)(signal->theData+25));
8346 setError(error, err, __LINE__);
8350 count = 2 + (1 + c_fragData[0]) * c_fragData[1];
8355 D(
"alterTable_parse " << V(newTablePtr.i) << hex << V(newTablePtr.p->tableVersion));
8357 if (ERROR_INSERTED(6121)) {
8359 CLEAR_ERROR_INSERT_VALUE;
8360 setError(error, 9121, __LINE__);
8368 releaseSections(handle);
8370 packTableIntoPages(w, alterTabPtr.p->m_newTablePtr);
8373 w.getPtr(tabInfoPtr);
8374 handle.m_ptr[AlterTabReq::DICT_TAB_INFO] = tabInfoPtr;
8377 if (AlterTableReq::getAddFragFlag(impl_req->changeMask))
8381 ndbrequire(
import(ss_ptr, c_fragData_align32, (
c_fragDataLen+1)/2));
8382 handle.m_ptr[AlterTabReq::FRAGMENTATION] = ss_ptr;
8390 handle.getSection(ptr, AlterTabReq::DICT_TAB_INFO);
8391 if (ptr.sz > MAX_WORDS_META_FILE)
8394 setError(error, AlterTableRef::TableDefinitionTooBig, __LINE__);
8400 saveOpSection(op_ptr, handle, AlterTabReq::DICT_TAB_INFO);
8401 if (AlterTableReq::getAddFragFlag(impl_req->changeMask))
8404 saveOpSection(op_ptr, handle, AlterTabReq::FRAGMENTATION);
8408 te.m_tableState = SchemaFile::SF_ALTER;
8409 te.m_tableVersion = newTablePtr.p->tableVersion;
8410 te.m_info_words = getOpSection(op_ptr, AlterTabReq::DICT_TAB_INFO).getSize();
8412 te.m_transId = trans_ptr.p->m_transId;
8414 Uint32 err = trans_log_schema_op(op_ptr, impl_req->tableId, &te);
8418 setError(error, err, __LINE__);
8424 Dbdict::check_supported_reorg(Uint32 org_map_id, Uint32 new_map_id)
8426 if (org_map_id == new_map_id)
8432 HashMapPtr orgmap_ptr;
8433 ndbrequire(c_hash_map_hash.
find(orgmap_ptr, org_map_id));
8435 HashMapPtr newmap_ptr;
8436 ndbrequire(c_hash_map_hash.
find(newmap_ptr, new_map_id));
8439 g_hash_map.getPtr(orgptr, orgmap_ptr.p->m_map_ptr_i);
8442 g_hash_map.getPtr(newptr, newmap_ptr.p->m_map_ptr_i);
8444 if (newptr.p->m_cnt < orgptr.p->m_cnt)
8447 return AlterTableRef::UnsupportedChange;
8450 for (Uint32 i = 0; i<orgptr.p->m_cnt; i++)
8453 if (orgptr.p->m_map[i] == newptr.p->m_map[i])
8456 if (newptr.p->m_map[i] < orgptr.p->m_fragments)
8463 return AlterTableRef::UnsupportedChange;
8470 Dbdict::check_supported_add_fragment(Uint16* newdata,
const Uint16* olddata)
8472 Uint32 replicas = newdata[0];
8473 if (replicas != olddata[0])
8476 return AlterTableRef::UnsupportedChange;
8479 Uint32 fragments = newdata[1];
8480 if (fragments < olddata[1])
8483 return AlterTableRef::UnsupportedChange;
8486 Uint32 oldFragments = olddata[1];
8496 for (Uint32 i = 0; i<oldFragments; i++)
8498 Uint32 idx = 2 + (1 + replicas) * i + 1;
8499 if (newdata[idx] != olddata[idx])
8502 return AlterTableRef::UnsupportedChange;
8507 memmove(newdata + 2,
8508 newdata + 2 + (1 + replicas) * oldFragments,
8509 sizeof(
short) * (1 + replicas) * (fragments - oldFragments));
8511 newdata[1] = (fragments - oldFragments);
8517 Dbdict::alterTable_subOps(
Signal* signal, SchemaOpPtr op_ptr)
8519 D(
"alterTable_subOps" << V(op_ptr.i) << *op_ptr.p);
8521 AlterTableRecPtr alterTabPtr;
8522 getOpRec(op_ptr, alterTabPtr);
8523 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
8525 if (AlterTableReq::getAddFragFlag(impl_req->changeMask))
8528 if (alterTabPtr.p->m_sub_add_frag ==
false)
8531 TableRecordPtr tabPtr;
8532 TableRecordPtr indexPtr;
8533 c_tableRecordPool.
getPtr(tabPtr, impl_req->tableId);
8535 Uint32 ptrI = alterTabPtr.p->m_sub_add_frag_index_ptr;
8540 list.first(indexPtr);
8545 list.getPtr(indexPtr, ptrI);
8546 list.next(indexPtr);
8549 for (; !indexPtr.isNull(); list.next(indexPtr))
8551 if (DictTabInfo::isOrderedIndex(indexPtr.p->tableType))
8557 if (indexPtr.isNull())
8560 alterTabPtr.p->m_sub_add_frag =
true;
8566 safe_cast(&Dbdict::alterTable_fromAlterIndex),
8569 op_ptr.p->m_callback = c;
8571 alterTabPtr.p->m_sub_add_frag_index_ptr = indexPtr.i;
8572 alterTable_toAlterIndex(signal, op_ptr);
8578 if (AlterTableReq::getReorgFragFlag(impl_req->changeMask))
8580 if (alterTabPtr.p->m_sub_reorg_commit ==
false)
8584 safe_cast(&Dbdict::alterTable_fromReorgTable),
8587 op_ptr.p->m_callback = c;
8589 alterTabPtr.p->m_sub_reorg_commit =
true;
8590 alterTable_toReorgTable(signal, op_ptr, 0);
8594 if (alterTabPtr.p->m_sub_suma_enable ==
false)
8598 safe_cast(&Dbdict::alterTable_fromReorgTable),
8601 op_ptr.p->m_callback = c;
8603 alterTabPtr.p->m_sub_suma_enable =
true;
8604 alterTable_toSumaSync(signal, op_ptr, 0);
8609 if (alterTabPtr.p->m_sub_suma_filter ==
false)
8613 safe_cast(&Dbdict::alterTable_fromReorgTable),
8616 op_ptr.p->m_callback = c;
8618 alterTabPtr.p->m_sub_suma_filter =
true;
8619 alterTable_toSumaSync(signal, op_ptr, 1);
8623 if (alterTabPtr.p->m_sub_trigger ==
false)
8627 safe_cast(&Dbdict::alterTable_fromCreateTrigger),
8630 op_ptr.p->m_callback = c;
8632 alterTable_toCreateTrigger(signal, op_ptr);
8634 alterTabPtr.p->m_sub_trigger =
true;
8638 if (alterTabPtr.p->m_sub_copy_data ==
false)
8642 safe_cast(&Dbdict::alterTable_fromCopyData),
8645 op_ptr.p->m_callback = c;
8647 alterTable_toCopyData(signal, op_ptr);
8649 alterTabPtr.p->m_sub_copy_data =
true;
8653 if (alterTabPtr.p->m_sub_reorg_complete ==
false)
8657 safe_cast(&Dbdict::alterTable_fromReorgTable),
8660 op_ptr.p->m_callback = c;
8662 alterTabPtr.p->m_sub_reorg_complete =
true;
8663 alterTable_toReorgTable(signal, op_ptr, 1);
8672 Dbdict::alterTable_toAlterIndex(
Signal* signal,
8676 AlterTableRecPtr alterTabPtr;
8677 getOpRec(op_ptr, alterTabPtr);
8678 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8680 TableRecordPtr indexPtr;
8681 c_tableRecordPool.
getPtr(indexPtr, alterTabPtr.p->m_sub_add_frag_index_ptr);
8684 req->clientRef = reference();
8685 req->clientData = op_ptr.p->op_key;
8686 req->transId = trans_ptr.p->m_transId;
8687 req->transKey = trans_ptr.p->trans_key;
8688 req->requestInfo = 0;
8689 req->indexId = indexPtr.p->tableId;
8690 req->indexVersion = indexPtr.p->tableVersion;
8691 DictSignal::setRequestType(req->requestInfo,
8692 AlterIndxImplReq::AlterIndexAddPartition);
8693 sendSignal(reference(), GSN_ALTER_INDX_REQ, signal,
8694 AlterIndxReq::SignalLength, JBB);
8698 Dbdict::alterTable_fromAlterIndex(
Signal* signal,
8705 AlterTableRecPtr alterTablePtr;
8707 findSchemaOp(op_ptr, alterTablePtr, op_key);
8708 ndbrequire(!op_ptr.isNull());
8709 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8715 ndbrequire(conf->transId == trans_ptr.p->m_transId);
8716 createSubOps(signal, op_ptr);
8722 setError(error, ref);
8723 abortSubOps(signal, op_ptr, error);
8728 Dbdict::alterTable_toReorgTable(
Signal* signal,
8733 AlterTableRecPtr alterTabPtr;
8734 getOpRec(op_ptr, alterTabPtr);
8735 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8736 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
8739 req->clientRef = reference();
8740 req->clientData = op_ptr.p->op_key;
8741 req->transId = trans_ptr.p->m_transId;
8742 req->transKey = trans_ptr.p->trans_key;
8743 req->requestInfo = 0;
8744 req->tableId = impl_req->tableId;
8745 req->tableVersion = impl_req->tableVersion;
8746 req->changeMask = 0;
8750 AlterTableReq::setReorgCommitFlag(req->changeMask, 1);
8755 AlterTableReq::setReorgCompleteFlag(req->changeMask, 1);
8762 sendSignal(reference(), GSN_ALTER_TABLE_REQ, signal,
8763 AlterTableReq::SignalLength, JBB);
8767 Dbdict::alterTable_fromReorgTable(
Signal* signal,
8774 AlterTableRecPtr alterTablePtr;
8776 findSchemaOp(op_ptr, alterTablePtr, op_key);
8777 ndbrequire(!op_ptr.isNull());
8778 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8786 ndbrequire(conf->transId == trans_ptr.p->m_transId);
8787 createSubOps(signal, op_ptr);
8793 setError(error, ref);
8794 abortSubOps(signal, op_ptr, error);
8799 Dbdict::alterTable_toCreateTrigger(
Signal* signal,
8804 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8805 AlterTableRecPtr alterTablePtr;
8806 getOpRec(op_ptr, alterTablePtr);
8807 const AlterTabReq* impl_req = &alterTablePtr.p->m_request;
8808 TableRecordPtr tablePtr;
8809 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
8811 const TriggerTmpl& triggerTmpl = g_reorgTriggerTmpl[0];
8815 Uint32 requestInfo = 0;
8816 DictSignal::setRequestType(requestInfo, CreateTrigReq::CreateTriggerOnline);
8818 req->clientRef = reference();
8819 req->clientData = op_ptr.p->op_key;
8820 req->transId = trans_ptr.p->m_transId;
8821 req->transKey = trans_ptr.p->trans_key;
8822 req->requestInfo = requestInfo;
8823 req->tableId = impl_req->tableId;
8824 req->tableVersion = impl_req->tableVersion;
8825 req->indexId = RNIL;
8826 req->indexVersion = RNIL;
8828 req->forceTriggerId = RNIL;
8830 TriggerInfo::packTriggerInfo(req->triggerInfo, triggerTmpl.triggerInfo);
8832 req->receiverRef = 0;
8834 char triggerName[MAX_TAB_NAME_SIZE];
8835 sprintf(triggerName, triggerTmpl.nameFormat, impl_req->tableId);
8838 Uint32 buffer[2 + ((MAX_TAB_NAME_SIZE + 3) >> 2)];
8841 w.add(DictTabInfo::TableName, triggerName);
8843 lsPtr[0].p = buffer;
8844 lsPtr[0].sz = w.getWordsUsed();
8848 lsPtr[1].p = mask.rep.data;
8849 lsPtr[1].sz = mask.getSizeInWords();
8851 sendSignal(reference(), GSN_CREATE_TRIG_REQ, signal,
8852 CreateTrigReq::SignalLength, JBB, lsPtr, 2);
8856 Dbdict::alterTable_fromCreateTrigger(
Signal* signal, Uint32 op_key, Uint32 ret)
8858 alterTable_fromAlterIndex(signal, op_key, ret);
8862 Dbdict::alterTable_toCopyData(
Signal* signal, SchemaOpPtr op_ptr)
8866 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8867 AlterTableRecPtr alterTablePtr;
8868 getOpRec(op_ptr, alterTablePtr);
8869 const AlterTabReq* impl_req = &alterTablePtr.p->m_request;
8870 TableRecordPtr tablePtr;
8871 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
8875 req->clientRef = reference();
8876 req->clientData = op_ptr.p->op_key;
8877 req->transId = trans_ptr.p->m_transId;
8878 req->transKey = trans_ptr.p->trans_key;
8879 req->requestInfo = 0;
8880 req->requestType = 0;
8881 req->srcTableId = impl_req->tableId;
8882 req->dstTableId = impl_req->tableId;
8883 req->srcFragments = tablePtr.p->fragmentCount;
8885 sendSignal(reference(), GSN_COPY_DATA_REQ, signal,
8886 CopyDataReq::SignalLength, JBB);
8890 Dbdict::alterTable_fromCopyData(
Signal* signal, Uint32 op_key, Uint32 ret)
8892 alterTable_fromAlterIndex(signal, op_key, ret);
8896 Dbdict::alterTable_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
8899 D(
"alterTable_reply" << V(op_ptr.i) << *op_ptr.p);
8901 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8903 AlterTableRecPtr alterTabPtr;
8904 getOpRec(op_ptr, alterTabPtr);
8905 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
8907 if (!hasError(error)) {
8909 conf->senderRef = reference();
8910 conf->clientData = op_ptr.p->m_clientData;
8911 conf->transId = trans_ptr.p->m_transId;
8912 conf->tableId = impl_req->tableId;
8913 conf->tableVersion = impl_req->tableVersion;
8914 conf->newTableVersion = impl_req->newTableVersion;
8916 Uint32 clientRef = op_ptr.p->m_clientRef;
8917 sendSignal(clientRef, GSN_ALTER_TABLE_CONF, signal,
8918 AlterTableConf::SignalLength, JBB);
8922 ref->senderRef = reference();
8923 ref->clientData = op_ptr.p->m_clientData;
8924 ref->transId = trans_ptr.p->m_transId;
8925 getError(error, ref);
8926 ref->errorStatus = error.errorStatus;
8927 ref->errorKey = error.errorKey;
8929 Uint32 clientRef = op_ptr.p->m_clientRef;
8930 sendSignal(clientRef, GSN_ALTER_TABLE_REF, signal,
8931 AlterTableRef::SignalLength, JBB);
8936 Dbdict::alterTable_toSumaSync(
Signal* signal,
8941 AlterTableRecPtr alterTabPtr;
8942 getOpRec(op_ptr, alterTabPtr);
8943 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8944 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
8947 req->clientRef = reference();
8948 req->clientData = op_ptr.p->op_key;
8949 req->transId = trans_ptr.p->m_transId;
8950 req->transKey = trans_ptr.p->trans_key;
8951 req->requestInfo = 0;
8952 req->tableId = impl_req->tableId;
8953 req->tableVersion = impl_req->tableVersion;
8954 req->changeMask = 0;
8958 AlterTableReq::setReorgSumaEnableFlag(req->changeMask, 1);
8962 AlterTableReq::setReorgSumaFilterFlag(req->changeMask, 1);
8969 sendSignal(reference(), GSN_ALTER_TABLE_REQ, signal,
8970 AlterTableReq::SignalLength, JBB);
8977 Dbdict::alterTable_prepare(
Signal* signal, SchemaOpPtr op_ptr)
8980 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
8982 AlterTableRecPtr alterTabPtr;
8983 getOpRec(op_ptr, alterTabPtr);
8984 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
8986 D(
"alterTable_prepare" << *op_ptr.p);
8988 if (AlterTableReq::getReorgSubOp(impl_req->changeMask))
8998 for (list.prev(tmp); !tmp.isNull(); list.prev(tmp))
9001 if (&tmp.p->m_oprec_ptr.p->m_opInfo== &Dbdict::AlterTableRec::g_opInfo)
9007 ndbrequire(!tmp.isNull());
9008 alterTabPtr.p->m_dihAddFragPtr =
9009 ((AlterTableRec*)tmp.p->m_oprec_ptr.p)->m_dihAddFragPtr;
9010 alterTabPtr.p->m_lqhFragPtr =
9011 ((AlterTableRec*)tmp.p->m_oprec_ptr.p)->m_lqhFragPtr;
9014 sendTransConf(signal, op_ptr);
9018 Mutex mutex(signal, c_mutexMgr, alterTabPtr.p->m_define_backup_mutex);
9020 safe_cast(&Dbdict::alterTable_backup_mutex_locked),
9023 bool ok = mutex.lock(c);
9029 Dbdict::alterTable_backup_mutex_locked(
Signal* signal,
9034 D(
"alterTable_backup_mutex_locked");
9036 ndbrequire(ret == 0);
9039 AlterTableRecPtr alterTabPtr;
9040 findSchemaOp(op_ptr, alterTabPtr, op_key);
9041 ndbrequire(!op_ptr.isNull());
9042 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
9043 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9045 TableRecordPtr tablePtr;
9046 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
9048 Mutex mutex(signal, c_mutexMgr, alterTabPtr.p->m_define_backup_mutex);
9051 if (tablePtr.p->m_read_locked)
9054 setError(op_ptr, tablePtr.p->m_read_locked, __LINE__);
9055 sendTransRef(signal, op_ptr);
9062 Callback callback = {
9063 safe_cast(&Dbdict::alterTab_writeTableConf),
9064 callback.m_callbackData = op_ptr.p->op_key
9067 const OpSection& tabInfoSec =
9068 getOpSection(op_ptr, CreateTabReq::DICT_TAB_INFO);
9070 bool savetodisk = !(tablePtr.p->m_bits & TableRecord::TR_Temporary);
9072 writeTableFile(signal, impl_req->tableId, tabInfoSec, &callback);
9074 execute(signal, callback, 0);
9079 Dbdict::alterTab_writeTableConf(
Signal* signal, Uint32 op_key, Uint32 ret)
9082 ndbrequire(ret == 0);
9085 AlterTableRecPtr alterTabPtr;
9086 findSchemaOp(op_ptr, alterTabPtr, op_key);
9088 alterTable_toLocal(signal, op_ptr);
9092 Dbdict::alterTable_toLocal(
Signal* signal, SchemaOpPtr op_ptr)
9094 AlterTableRecPtr alterTabPtr;
9095 getOpRec(op_ptr, alterTabPtr);
9096 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9098 const Uint32 blockIndex = alterTabPtr.p->m_blockIndex;
9099 if (blockIndex == AlterTableRec::BlockCount)
9102 sendTransConf(signal, op_ptr);
9106 ndbrequire(blockIndex < AlterTableRec::BlockCount);
9107 const Uint32 blockNo = alterTabPtr.p->m_blockNo[blockIndex];
9109 D(
"alterTable_toLocal" << V(blockIndex) << V(getBlockName(blockNo)));
9112 req->senderRef = reference();
9113 req->senderData = op_ptr.p->op_key;
9114 req->requestType = AlterTabReq::AlterTablePrepare;
9115 req->tableId = impl_req->tableId;
9116 req->tableVersion = impl_req->tableVersion;
9117 req->newTableVersion = impl_req->newTableVersion;
9118 req->gci = impl_req->gci;
9119 req->changeMask = impl_req->changeMask;
9120 req->connectPtr = RNIL;
9121 req->noOfNewAttr = impl_req->noOfNewAttr;
9122 req->newNoOfCharsets = impl_req->newNoOfCharsets;
9123 req->newNoOfKeyAttrs = impl_req->newNoOfKeyAttrs;
9126 safe_cast(&Dbdict::alterTable_fromLocal),
9129 op_ptr.p->m_callback = c;
9131 if (ERROR_INSERTED(6131) &&
9132 blockIndex + 1 == AlterTableRec::BlockCount) {
9134 CLEAR_ERROR_INSERT_VALUE;
9136 ref->senderRef = reference();
9137 ref->senderData = op_ptr.p->op_key;
9138 ref->errorCode = 9131;
9139 sendSignal(reference(), GSN_ALTER_TAB_REF, signal,
9140 AlterTabRef::SignalLength, JBB);
9144 BlockReference blockRef = numberToRef(blockNo, getOwnNodeId());
9146 if (blockNo == DBLQH && req->noOfNewAttr > 0)
9150 ptr[0].p = alterTabPtr.p->m_newAttrData;
9151 ptr[0].sz = 2 * impl_req->noOfNewAttr;
9152 sendSignal(blockRef, GSN_ALTER_TAB_REQ, signal,
9153 AlterTabReq::SignalLength, JBB, ptr, 1);
9155 else if (blockNo == DBDIH && AlterTableReq::getAddFragFlag(req->changeMask))
9158 const OpSection& fragInfoSec =
9159 getOpSection(op_ptr, AlterTabReq::FRAGMENTATION);
9161 bool ok = copyOut(fragInfoSec, fragInfoPtr);
9164 if (AlterTableReq::getReorgFragFlag(req->changeMask))
9168 ndbrequire(c_hash_map_hash.
find(hm_ptr,
9169 alterTabPtr.p->m_newTablePtr.p->hashMapObjectId));
9170 req->new_map_ptr_i = hm_ptr.p->m_map_ptr_i;
9174 sendSignal(blockRef, GSN_ALTER_TAB_REQ, signal,
9175 AlterTabReq::SignalLength, JBB, &handle);
9180 sendSignal(blockRef, GSN_ALTER_TAB_REQ, signal,
9181 AlterTabReq::SignalLength, JBB);
9186 Dbdict::alterTable_fromLocal(
Signal* signal,
9190 D(
"alterTable_fromLocal");
9193 AlterTableRecPtr alterTabPtr;
9194 findSchemaOp(op_ptr, alterTabPtr, op_key);
9195 ndbrequire(!op_ptr.isNull());
9197 Uint32& blockIndex = alterTabPtr.p->m_blockIndex;
9198 ndbrequire(blockIndex < AlterTableRec::BlockCount);
9199 const Uint32 blockNo = alterTabPtr.p->m_blockNo[blockIndex];
9204 setError(op_ptr, ret, __LINE__);
9205 sendTransRef(signal, op_ptr);
9215 alterTabPtr.p->m_lqhFragPtr = conf->connectPtr;
9219 alterTabPtr.p->m_dihAddFragPtr = conf->connectPtr;
9224 alterTable_toLocal(signal, op_ptr);
9230 Dbdict::alterTable_commit(
Signal* signal, SchemaOpPtr op_ptr)
9232 AlterTableRecPtr alterTabPtr;
9233 getOpRec(op_ptr, alterTabPtr);
9234 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9236 D(
"alterTable_commit" << *op_ptr.p);
9238 TableRecordPtr tablePtr;
9239 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
9241 if (op_ptr.p->m_sections)
9245 ndbrequire(AlterTableReq::getReorgSubOp(impl_req->changeMask) ==
false);
9247 const OpSection& tabInfoSec =
9248 getOpSection(op_ptr, CreateTabReq::DICT_TAB_INFO);
9249 const Uint32 size = tabInfoSec.getSize();
9252 tablePtr.p->packedSize =
size;
9253 tablePtr.p->tableVersion = impl_req->newTableVersion;
9254 tablePtr.p->gciTableCreated = impl_req->gci;
9256 TableRecordPtr newTablePtr = alterTabPtr.p->m_newTablePtr;
9258 const Uint32 changeMask = impl_req->changeMask;
9264 const Uint32 sz = MAX_TAB_NAME_SIZE;
9266 <<
" old=" << copyRope<sz>(tablePtr.p->tableName)
9267 <<
" new=" << copyRope<sz>(newTablePtr.p->tableName));
9270 c_obj_pool.
getPtr(obj_ptr, tablePtr.p->m_obj_ptr_i);
9273 c_obj_hash.
remove(obj_ptr);
9277 copyRope<sz>(alterTabPtr.p->m_oldTableName, tablePtr.p->tableName) &&
9278 copyRope<sz>(tablePtr.p->tableName, newTablePtr.p->tableName);
9282 obj_ptr.p->m_name = tablePtr.p->tableName;
9283 c_obj_hash.
add(obj_ptr);
9286 if (AlterTableReq::getFrmFlag(changeMask))
9290 const Uint32 sz = MAX_FRM_DATA_SIZE;
9292 copyRope<sz>(alterTabPtr.p->m_oldFrmData, tablePtr.p->frmData) &&
9293 copyRope<sz>(tablePtr.p->frmData, newTablePtr.p->frmData);
9297 if (AlterTableReq::getAddAttrFlag(changeMask))
9303 list(c_attributeRecordPool, tablePtr.p->m_attributes);
9305 newlist(c_attributeRecordPool, newTablePtr.p->m_attributes);
9307 const Uint32 noOfNewAttr = impl_req->noOfNewAttr;
9308 ndbrequire(noOfNewAttr > 0);
9312 AttributeRecordPtr pPtr;
9313 ndbrequire(newlist.last(pPtr));
9314 for (i = 1; i < noOfNewAttr; i++) {
9316 ndbrequire(newlist.prev(pPtr));
9320 for (i = 0; i < noOfNewAttr; i++) {
9321 AttributeRecordPtr qPtr = pPtr;
9323 newlist.remove(qPtr);
9326 tablePtr.p->noOfAttributes += noOfNewAttr;
9329 if (AlterTableReq::getAddFragFlag(changeMask))
9332 Uint32 save = tablePtr.p->fragmentCount;
9333 tablePtr.p->fragmentCount = newTablePtr.p->fragmentCount;
9334 newTablePtr.p->fragmentCount = save;
9338 alterTabPtr.p->m_blockIndex = 0;
9339 alterTabPtr.p->m_blockNo[0] = DBLQH;
9340 alterTabPtr.p->m_blockNo[1] = DBDIH;
9341 alterTabPtr.p->m_blockNo[2] = DBTC;
9343 if (AlterTableReq::getReorgFragFlag(impl_req->changeMask))
9348 TableRecordPtr newTablePtr = alterTabPtr.p->m_newTablePtr;
9349 tablePtr.p->hashMapObjectId = newTablePtr.p->hashMapObjectId;
9350 tablePtr.p->hashMapVersion = newTablePtr.p->hashMapVersion;
9351 alterTabPtr.p->m_blockNo[1] = RNIL;
9353 else if (AlterTableReq::getReorgCommitFlag(impl_req->changeMask))
9359 alterTabPtr.p->m_blockNo[0] = RNIL;
9360 alterTabPtr.p->m_blockNo[2] = RNIL;
9362 else if (AlterTableReq::getReorgCompleteFlag(impl_req->changeMask) ||
9363 AlterTableReq::getReorgSumaEnableFlag(impl_req->changeMask) ||
9364 AlterTableReq::getReorgSumaFilterFlag(impl_req->changeMask))
9367 sendTransConf(signal, op_ptr);
9371 alterTable_toCommitComplete(signal, op_ptr);
9375 Dbdict::alterTable_toCommitComplete(
Signal* signal,
9379 D(
"alterTable_toTupCommit");
9381 AlterTableRecPtr alterTabPtr;
9382 getOpRec(op_ptr, alterTabPtr);
9383 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9386 req->senderRef = reference();
9387 req->senderData = op_ptr.p->op_key;
9388 if (type == ~Uint32(0))
9391 switch(op_ptr.p->m_state){
9392 case SchemaOp::OS_COMMITTING:
9394 req->requestType = AlterTabReq::AlterTableCommit;
9396 case SchemaOp::OS_COMPLETING:
9398 req->requestType = AlterTabReq::AlterTableComplete;
9401 jamLine(op_ptr.p->m_state);
9409 req->requestType =
type;
9412 req->tableId = impl_req->tableId;
9413 req->tableVersion = impl_req->tableVersion;
9414 req->newTableVersion = impl_req->newTableVersion;
9415 req->gci = impl_req->gci;
9416 req->changeMask = impl_req->changeMask;
9417 req->noOfNewAttr = impl_req->noOfNewAttr;
9418 req->newNoOfCharsets = impl_req->newNoOfCharsets;
9419 req->newNoOfKeyAttrs = impl_req->newNoOfKeyAttrs;
9420 req->connectPtr = RNIL;
9422 Uint32 blockIndex = alterTabPtr.p->m_blockIndex;
9423 const Uint32 blockNo = alterTabPtr.p->m_blockNo[blockIndex];
9427 req->connectPtr = alterTabPtr.p->m_dihAddFragPtr;
9430 req->connectPtr = alterTabPtr.p->m_lqhFragPtr;
9433 alterTable_fromCommitComplete(signal, op_ptr.p->op_key, 0);
9438 safe_cast(&Dbdict::alterTable_fromCommitComplete),
9441 op_ptr.p->m_callback = c;
9443 sendSignal(numberToRef(blockNo, getOwnNodeId()),
9444 GSN_ALTER_TAB_REQ, signal,
9445 AlterTabReq::SignalLength, JBB);
9449 Dbdict::alterTable_fromCommitComplete(
Signal* signal,
9453 D(
"alterTable_fromCommit");
9456 AlterTableRecPtr alterTabPtr;
9457 findSchemaOp(op_ptr, alterTabPtr, op_key);
9458 ndbrequire(!op_ptr.isNull());
9459 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9461 ndbrequire(ret == 0);
9462 if (++ alterTabPtr.p->m_blockIndex < AlterTableRec::BlockCount)
9465 alterTable_toCommitComplete(signal, op_ptr);
9469 if (AlterTableReq::getReorgSubOp(impl_req->changeMask))
9472 sendTransConf(signal, op_ptr);
9476 if (op_ptr.p->m_state == SchemaOp::OS_COMPLETING)
9479 sendTransConf(signal, op_ptr);
9483 const Uint32 tableId = impl_req->tableId;
9484 TableRecordPtr tablePtr;
9485 c_tableRecordPool.
getPtr(tablePtr, tableId);
9491 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
9494 if (trans_ptr.p->m_isMaster)
9495 req->senderRef = trans_ptr.p->m_clientRef;
9498 req->senderData = op_key;
9499 req->tableId = impl_req->tableId;
9500 req->tableVersion = impl_req->tableVersion;
9501 req->newTableVersion = impl_req->newTableVersion;
9502 req->gci = tablePtr.p->gciTableCreated;
9503 req->requestType = 0;
9504 req->changeMask = impl_req->changeMask;
9505 req->connectPtr = RNIL;
9506 req->noOfNewAttr = impl_req->noOfNewAttr;
9507 req->newNoOfCharsets = impl_req->newNoOfCharsets;
9508 req->newNoOfKeyAttrs = impl_req->newNoOfKeyAttrs;
9510 const OpSection& tabInfoSec =
9511 getOpSection(op_ptr, AlterTabReq::DICT_TAB_INFO);
9513 bool ok = copyOut(tabInfoSec, tabInfoPtr);
9517 sendSignal(SUMA_REF, GSN_ALTER_TAB_REQ, signal,
9518 AlterTabReq::SignalLength, JBB, &handle);
9524 api->gsn = GSN_ALTER_TABLE_REP;
9525 api->minVersion = MAKE_VERSION(4,1,15);
9528 rep->tableId = tablePtr.p->tableId;
9530 rep->tableVersion = impl_req->tableVersion;
9531 rep->changeType = AlterTableRep::CT_ALTERED;
9533 char oldTableName[MAX_TAB_NAME_SIZE];
9534 memset(oldTableName, 0,
sizeof(oldTableName));
9538 ? alterTabPtr.p->m_oldTableName
9539 : tablePtr.p->tableName;
9541 r.copy(oldTableName);
9545 ptr[0].p = (Uint32*)oldTableName;
9546 ptr[0].sz = (
sizeof(oldTableName) + 3) >> 2;
9548 sendSignal(QMGR_REF, GSN_API_BROADCAST_REP, signal,
9549 ApiBroadcastRep::SignalLength + AlterTableRep::SignalLength,
9556 objEntry = getTableEntry(alterTabPtr.p->m_newTable_realObjectId);
9557 objEntry->m_tableType = DictTabInfo::UndefTableType;
9558 objEntry->m_tableState = SchemaFile::SF_UNUSED;
9559 objEntry->m_transId = 0;
9562 releaseTableObject(alterTabPtr.p->m_newTablePtr.i,
false);
9563 sendTransConf(signal, op_ptr);
9569 Dbdict::alterTable_complete(
Signal* signal, SchemaOpPtr op_ptr)
9572 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
9574 AlterTableRecPtr alterTabPtr;
9575 getOpRec(op_ptr, alterTabPtr);
9576 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9578 alterTabPtr.p->m_blockIndex = 0;
9579 alterTabPtr.p->m_blockNo[0] = RNIL;
9580 alterTabPtr.p->m_blockNo[1] = RNIL;
9581 alterTabPtr.p->m_blockNo[2] = RNIL;
9583 if (AlterTableReq::getReorgCommitFlag(impl_req->changeMask))
9586 alterTabPtr.p->m_blockNo[0] = DBDIH;
9587 alterTable_toCommitComplete(signal, op_ptr,
9588 AlterTabReq::AlterTableWaitScan);
9591 else if (AlterTableReq::getReorgCompleteFlag(impl_req->changeMask))
9598 alterTabPtr.p->m_blockNo[0] = DBDIH;
9599 alterTabPtr.p->m_blockNo[1] = DBLQH;
9600 alterTable_toCommitComplete(signal, op_ptr);
9603 else if (AlterTableReq::getReorgSumaEnableFlag(impl_req->changeMask))
9606 alterTabPtr.p->m_blockNo[0] = DBLQH;
9607 alterTable_toCommitComplete(signal, op_ptr,
9608 AlterTabReq::AlterTableSumaEnable);
9611 else if (AlterTableReq::getReorgSumaFilterFlag(impl_req->changeMask))
9614 alterTabPtr.p->m_blockNo[0] = DBLQH;
9615 alterTable_toCommitComplete(signal, op_ptr,
9616 AlterTabReq::AlterTableSumaFilter);
9619 sendTransConf(signal, op_ptr);
9625 Dbdict::alterTable_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
9627 D(
"alterTable_abortParse" << *op_ptr.p);
9629 AlterTableRecPtr alterTabPtr;
9630 getOpRec(op_ptr, alterTabPtr);
9631 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9633 if (AlterTableReq::getReorgSubOp(impl_req->changeMask))
9636 sendTransConf(signal, op_ptr);
9640 TableRecordPtr& newTablePtr = alterTabPtr.p->m_newTablePtr;
9641 if (!newTablePtr.isNull()) {
9648 objEntry = getTableEntry(alterTabPtr.p->m_newTable_realObjectId);
9649 objEntry->m_tableType = DictTabInfo::UndefTableType;
9650 objEntry->m_tableState = SchemaFile::SF_UNUSED;
9651 objEntry->m_transId = 0;
9654 releaseTableObject(newTablePtr.i,
false);
9655 newTablePtr.setNull();
9658 TableRecordPtr& tablePtr = alterTabPtr.p->m_tablePtr;
9659 if (!tablePtr.isNull()) {
9664 sendTransConf(signal, op_ptr);
9668 Dbdict::alterTable_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
9670 D(
"alterTable_abortPrepare" << *op_ptr.p);
9672 AlterTableRecPtr alterTabPtr;
9673 getOpRec(op_ptr, alterTabPtr);
9674 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9676 if (AlterTableReq::getReorgSubOp(impl_req->changeMask))
9683 sendTransConf(signal, op_ptr);
9687 if (alterTabPtr.p->m_blockIndex > 0)
9694 alterTable_abortToLocal(signal, op_ptr);
9700 sendTransConf(signal, op_ptr);
9706 Dbdict::alterTable_abortToLocal(
Signal* signal, SchemaOpPtr op_ptr)
9708 AlterTableRecPtr alterTabPtr;
9709 getOpRec(op_ptr, alterTabPtr);
9710 const AlterTabReq* impl_req = &alterTabPtr.p->m_request;
9712 const Uint32 blockCount = alterTabPtr.p->m_blockIndex;
9713 ndbrequire(blockCount != 0 && blockCount <= AlterTableRec::BlockCount);
9714 const Uint32 blockIndex = blockCount - 1;
9715 const Uint32 blockNo = alterTabPtr.p->m_blockNo[blockIndex];
9717 D(
"alterTable_abortToLocal" << V(blockIndex) << V(getBlockName(blockNo)));
9719 Uint32 connectPtr = RNIL;
9723 connectPtr = alterTabPtr.p->m_lqhFragPtr;
9727 connectPtr = alterTabPtr.p->m_dihAddFragPtr;
9732 req->senderRef = reference();
9733 req->senderData = op_ptr.p->op_key;
9734 req->requestType = AlterTabReq::AlterTableRevert;
9735 req->tableId = impl_req->tableId;
9736 req->tableVersion = impl_req->tableVersion;
9737 req->newTableVersion = impl_req->newTableVersion;
9738 req->gci = impl_req->gci;
9739 req->changeMask = impl_req->changeMask;
9740 req->connectPtr = connectPtr;
9741 req->noOfNewAttr = impl_req->noOfNewAttr;
9742 req->newNoOfCharsets = impl_req->newNoOfCharsets;
9743 req->newNoOfKeyAttrs = impl_req->newNoOfKeyAttrs;
9746 safe_cast(&Dbdict::alterTable_abortFromLocal),
9749 op_ptr.p->m_callback = c;
9751 BlockReference blockRef = numberToRef(blockNo, getOwnNodeId());
9752 sendSignal(blockRef, GSN_ALTER_TAB_REQ, signal,
9753 AlterTabReq::SignalLength, JBB);
9757 Dbdict::alterTable_abortFromLocal(
Signal*signal, Uint32 op_key, Uint32 ret)
9760 AlterTableRecPtr alterTabPtr;
9761 findSchemaOp(op_ptr, alterTabPtr, op_key);
9762 ndbrequire(!op_ptr.isNull());
9764 const Uint32 blockCount = alterTabPtr.p->m_blockIndex;
9765 ndbrequire(blockCount != 0 && blockCount <= AlterTableRec::BlockCount);
9766 const Uint32 blockIndex = blockCount - 1;
9767 alterTabPtr.p->m_blockIndex = blockIndex;
9769 ndbrequire(ret == 0);
9774 alterTable_abortToLocal(signal, op_ptr);
9780 sendTransConf(signal, op_ptr);
9787 Dbdict::execALTER_TAB_CONF(
Signal* signal)
9791 ndbrequire(refToNode(conf->senderRef) == getOwnNodeId());
9792 handleDictConf(signal, conf);
9796 Dbdict::execALTER_TAB_REF(
Signal* signal)
9800 ndbrequire(refToNode(ref->senderRef) == getOwnNodeId());
9801 handleDictRef(signal, ref);
9805 Dbdict::execALTER_TABLE_CONF(
Signal* signal)
9809 ndbrequire(refToNode(conf->senderRef) == getOwnNodeId());
9810 handleDictConf(signal, conf);
9814 Dbdict::execALTER_TABLE_REF(
Signal* signal)
9818 ndbrequire(refToNode(ref->senderRef) == getOwnNodeId());
9819 handleDictRef(signal, ref);
9834 void Dbdict::execGET_TABLEDID_REQ(
Signal * signal)
9837 ndbrequire(signal->getNoOfSections() == 1);
9839 Uint32 senderData = req->senderData;
9840 Uint32 senderRef = req->senderRef;
9841 Uint32 len = req->len;
9846 sendGET_TABLEID_REF((
Signal*)signal,
9848 GetTableIdRef::TableNameTooLong);
9852 char tableName[PATH_MAX];
9855 handle.getSection(ssPtr,GetTableIdReq::TABLE_NAME);
9856 copy((Uint32*)tableName, ssPtr);
9857 releaseSections(handle);
9859 DictObject * obj_ptr_p = get_object(tableName, len);
9860 if(obj_ptr_p == 0 || !DictTabInfo::isTable(obj_ptr_p->m_type)){
9862 sendGET_TABLEID_REF(signal,
9864 GetTableIdRef::TableNotDefined);
9868 TableRecordPtr tablePtr;
9869 c_tableRecordPool.
getPtr(tablePtr, obj_ptr_p->m_id);
9872 conf->tableId = tablePtr.p->tableId;
9873 conf->schemaVersion = tablePtr.p->tableVersion;
9874 conf->senderData = senderData;
9875 sendSignal(senderRef, GSN_GET_TABLEID_CONF, signal,
9876 GetTableIdConf::SignalLength, JBB);
9880 void Dbdict::sendGET_TABLEID_REF(
Signal* signal,
9882 GetTableIdRef::ErrorCode errorCode)
9888 BlockReference retRef = req->senderRef;
9889 ref->err = errorCode;
9890 sendSignal(retRef, GSN_GET_TABLEID_REF, signal,
9891 GetTableIdRef::SignalLength, JBB);
9897 void Dbdict::execGET_TABINFOREQ(
Signal* signal)
9912 bool fromTimeQueue = (signal->senderBlockRef() == reference());
9914 if (c_retrieveRecord.busyState && fromTimeQueue ==
true) {
9917 sendSignalWithDelay(reference(), GSN_GET_TABINFOREQ, signal, 30,
9923 const Uint32 MAX_WAITERS = 5;
9925 if(c_retrieveRecord.busyState && fromTimeQueue ==
false)
9928 if(c_retrieveRecord.noOfWaiters < MAX_WAITERS){
9930 c_retrieveRecord.noOfWaiters++;
9932 sendSignalWithDelay(reference(), GSN_GET_TABINFOREQ, signal, 30,
9937 releaseSections(handle);
9938 sendGET_TABINFOREF(signal, req, GetTabInfoRef::Busy, __LINE__);
9944 c_retrieveRecord.noOfWaiters--;
9947 const bool useLongSig = (req->requestType & GetTabInfoReq::LongSignalConf);
9948 const bool byName = (req->requestType & GetTabInfoReq::RequestByName);
9949 const Uint32 transId = req->schemaTransId;
9951 Uint32 obj_id = RNIL;
9954 ndbrequire(handle.m_cnt == 1);
9955 const Uint32 len = req->tableNameLen;
9959 releaseSections(handle);
9960 sendGET_TABINFOREF(signal, req, GetTabInfoRef::TableNameTooLong, __LINE__);
9964 Uint32 tableName[(PATH_MAX + 3) / 4];
9966 handle.getSection(ssPtr,GetTabInfoReq::TABLE_NAME);
9967 copy(tableName, ssPtr);
9969 DictObject * old_ptr_p = get_object((
char*)tableName, len);
9971 obj_id = old_ptr_p->m_id;
9974 obj_id = req->tableId;
9976 releaseSections(handle);
9981 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
9982 objEntry = getTableEntry(xsf, obj_id);
9989 sendGET_TABINFOREF(signal, req, GetTabInfoRef::TableNotDefined, __LINE__);
9995 D(
"execGET_TABINFOREQ" << V(transId) <<
" " << *objEntry);
9997 if (transId != 0 && transId == objEntry->m_transId)
10002 else if (refToBlock(req->senderRef) != DBUTIL &&
10003 refToBlock(req->senderRef) != SUMA)
10007 if ((err = check_read_obj(objEntry)))
10011 sendGET_TABINFOREF(signal, req, (GetTabInfoRef::ErrorCode)err, __LINE__);
10016 c_retrieveRecord.busyState =
true;
10017 c_retrieveRecord.blockRef = req->senderRef;
10018 c_retrieveRecord.m_senderData = req->senderData;
10019 c_retrieveRecord.tableId = obj_id;
10020 c_retrieveRecord.currentSent = 0;
10021 c_retrieveRecord.m_useLongSig = useLongSig;
10022 c_retrieveRecord.m_table_type = objEntry->m_tableType;
10023 c_retrieveRecord.schemaTransId = transId;
10024 c_retrieveRecord.requestType = req->requestType;
10025 c_packTable.m_state = PackTable::PTS_GET_TAB;
10032 if (objEntry->m_tableState != SchemaFile::SF_CREATE)
10037 req->senderData= c_retrieveRecord.retrievePage;
10038 req->senderRef= reference();
10039 req->requestType= GetTabInfoReq::RequestById;
10040 req->tableId= obj_id;
10041 req->schemaTransId = 0;
10043 sendSignal(TSMAN_REF, GSN_GET_TABINFOREQ, signal,
10044 GetTabInfoReq::SignalLength, JBB);
10054 signal->theData[4] = 0;
10060 if (objEntry->m_tableState != SchemaFile::SF_CREATE)
10064 req->senderData= c_retrieveRecord.retrievePage;
10065 req->senderRef= reference();
10066 req->requestType= GetTabInfoReq::RequestById;
10067 req->tableId= obj_id;
10068 req->schemaTransId = 0;
10070 sendSignal(LGMAN_REF, GSN_GET_TABINFOREQ, signal,
10071 GetTabInfoReq::SignalLength, JBB);
10081 signal->theData[4] = 0;
10082 signal->theData[5] = 0;
10087 signal->theData[0] = ZPACK_TABLE_INTO_PAGES;
10088 signal->theData[1] = obj_id;
10089 signal->theData[2] = objEntry->m_tableType;
10090 signal->theData[3] = c_retrieveRecord.retrievePage;
10091 sendSignal(reference(), GSN_CONTINUEB, signal, len, JBB);
10094 void Dbdict::sendGetTabResponse(
Signal* signal)
10096 PageRecordPtr pagePtr;
10098 conf->senderRef = reference();
10099 conf->senderData = c_retrieveRecord.m_senderData;
10100 conf->requestType = DictTabInfo::GetTabInfoConf;
10101 conf->totalLen = c_retrieveRecord.retrievedNoOfWords;
10103 c_pageRecordArray.
getPtr(pagePtr, c_retrieveRecord.retrievePage);
10104 Uint32* pagePointer = (Uint32*)&pagePtr.p->word[0] + ZPAGE_HEADER_SIZE;
10106 if(c_retrieveRecord.m_useLongSig){
10110 conf->tableId = c_retrieveRecord.tableId;
10111 conf->senderData = c_retrieveRecord.m_senderData;
10112 conf->totalLen = c_retrieveRecord.retrievedNoOfWords;
10113 conf->tableType = c_retrieveRecord.m_table_type;
10115 Callback c = { safe_cast(&Dbdict::initRetrieveRecord), 0 };
10117 ptr[0].p = pagePointer;
10118 ptr[0].sz = c_retrieveRecord.retrievedNoOfWords;
10119 sendFragmentedSignal(c_retrieveRecord.blockRef,
10120 GSN_GET_TABINFO_CONF,
10122 GetTabInfoConf::SignalLength,
10133 void Dbdict::sendGET_TABINFOREF(
Signal* signal,
10135 GetTabInfoRef::ErrorCode errorCode,
10142 ref->senderData = req_copy.senderData;
10143 ref->senderRef = reference();
10144 ref->requestType = req_copy.requestType;
10145 ref->tableId = req_copy.tableId;
10146 ref->schemaTransId = req_copy.schemaTransId;
10147 ref->errorCode = (Uint32)errorCode;
10148 ref->errorLine = errorLine;
10150 BlockReference retRef = req_copy.senderRef;
10151 sendSignal(retRef, GSN_GET_TABINFOREF, signal,
10152 GetTabInfoRef::SignalLength, JBB);
10156 Dbdict::execLIST_TABLES_REQ(
Signal* signal)
10161 Uint32 senderRef = req->senderRef;
10164 if (ndbd_LIST_TABLES_CONF_long_signal(receiverVersion))
10167 sendOLD_LIST_TABLES_CONF(signal, req);
10172 Uint32 senderRef = req->senderRef;
10173 Uint32 senderData = req->senderData;
10175 const Uint32 reqTableId = req->oldGetTableId();
10176 const Uint32 reqTableType = req->oldGetTableType();
10177 const bool reqListNames = req->getListNames();
10178 const bool reqListIndexes = req->getListIndexes();
10179 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
10182 conf->senderData = senderData;
10187 bool ok = c_obj_hash.
first(iter);
10188 for(;
ok; ok = c_obj_hash.
next(iter)){
10189 Uint32 type = iter.curr.p->m_type;
10190 if ((reqTableType != (Uint32)0) && (reqTableType !=
type))
10193 if (reqListIndexes && !DictTabInfo::isIndex(type))
10196 TableRecordPtr tablePtr;
10197 if (DictTabInfo::isTable(type) || DictTabInfo::isIndex(type)){
10198 c_tableRecordPool.
getPtr(tablePtr, iter.curr.p->m_id);
10200 if(reqListIndexes && (reqTableId != tablePtr.p->primaryTableId))
10203 conf->tableData[pos] = 0;
10204 conf->setTableId(pos, tablePtr.i);
10205 conf->setTableType(pos, type);
10208 if(DictTabInfo::isTable(type))
10211 switch(te->m_tableState){
10212 case SchemaFile::SF_CREATE:
10214 conf->setTableState(pos, DictTabInfo::StateBuilding);
10216 case SchemaFile::SF_ALTER:
10218 conf->setTableState(pos, DictTabInfo::StateOnline);
10220 case SchemaFile::SF_DROP:
10222 conf->setTableState(pos, DictTabInfo::StateDropping);
10224 case SchemaFile::SF_IN_USE:
10226 if (tablePtr.p->m_read_locked)
10229 conf->setTableState(pos, DictTabInfo::StateBackup);
10234 conf->setTableState(pos, DictTabInfo::StateOnline);
10239 conf->setTableState(pos, DictTabInfo::StateBroken);
10243 if (tablePtr.p->isIndex()) {
10244 switch (tablePtr.p->indexState) {
10245 case TableRecord::IS_OFFLINE:
10246 conf->setTableState(pos, DictTabInfo::StateOffline);
10248 case TableRecord::IS_BUILDING:
10249 conf->setTableState(pos, DictTabInfo::StateBuilding);
10251 case TableRecord::IS_DROPPING:
10252 conf->setTableState(pos, DictTabInfo::StateDropping);
10254 case TableRecord::IS_ONLINE:
10255 conf->setTableState(pos, DictTabInfo::StateOnline);
10258 conf->setTableState(pos, DictTabInfo::StateBroken);
10263 if (! (tablePtr.p->m_bits & TableRecord::TR_Logged)) {
10264 conf->setTableStore(pos, DictTabInfo::StoreNotLogged);
10266 conf->setTableStore(pos, DictTabInfo::StorePermanent);
10269 if (tablePtr.p->m_bits & TableRecord::TR_Temporary) {
10270 conf->setTableTemp(pos, NDB_TEMP_TAB_TEMPORARY);
10272 conf->setTableTemp(pos, NDB_TEMP_TAB_PERMANENT);
10276 if(DictTabInfo::isTrigger(type)){
10277 TriggerRecordPtr triggerPtr;
10278 c_triggerRecordPool.
getPtr(triggerPtr, iter.curr.p->m_id);
10280 conf->tableData[pos] = 0;
10281 conf->setTableId(pos, triggerPtr.i);
10282 conf->setTableType(pos, type);
10283 switch (triggerPtr.p->triggerState) {
10284 case TriggerRecord::TS_DEFINING:
10285 conf->setTableState(pos, DictTabInfo::StateBuilding);
10287 case TriggerRecord::TS_OFFLINE:
10288 conf->setTableState(pos, DictTabInfo::StateOffline);
10290 case TriggerRecord::TS_ONLINE:
10291 conf->setTableState(pos, DictTabInfo::StateOnline);
10294 conf->setTableState(pos, DictTabInfo::StateBroken);
10297 conf->setTableStore(pos, DictTabInfo::StoreNotLogged);
10300 if (DictTabInfo::isFilegroup(type)){
10302 conf->tableData[pos] = 0;
10303 conf->setTableId(pos, iter.curr.p->m_id);
10304 conf->setTableType(pos, type);
10305 conf->setTableState(pos, DictTabInfo::StateOnline);
10308 if (DictTabInfo::isFile(type)){
10310 conf->tableData[pos] = 0;
10311 conf->setTableId(pos, iter.curr.p->m_id);
10312 conf->setTableType(pos, type);
10313 conf->setTableState(pos, DictTabInfo::StateOnline);
10317 if (pos >= OldListTablesConf::DataLength) {
10318 sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
10319 OldListTablesConf::SignalLength, JBB);
10324 if (! reqListNames)
10327 Rope name(c_rope_pool, iter.curr.p->m_name);
10328 const Uint32 size = name.size();
10329 conf->tableData[pos] =
size;
10331 if (pos >= OldListTablesConf::DataLength) {
10332 sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
10333 OldListTablesConf::SignalLength, JBB);
10338 char tmp[PATH_MAX];
10341 char* p = (
char*)&conf->tableData[pos];
10342 for (Uint32 j = 0; j < 4; j++) {
10349 if (pos >= OldListTablesConf::DataLength) {
10350 sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
10351 OldListTablesConf::SignalLength, JBB);
10358 sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
10359 OldListTablesConf::HeaderLength + pos, JBB);
10364 Uint32 senderRef = req->senderRef;
10365 Uint32 senderData = req->senderData;
10367 const Uint32 reqTableId = req->getTableId();
10368 const Uint32 reqTableType = req->getTableType();
10369 const bool reqListNames = req->getListNames();
10370 const bool reqListIndexes = req->getListIndexes();
10371 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
10375 bool done = !c_obj_hash.
first(iter);
10384 conf->senderData = senderData;
10385 conf->noOfTables = 0;
10386 sendSignal(rg, GSN_LIST_TABLES_CONF, signal,
10387 ListTablesConf::SignalLength, JBB);
10397 const Uint32 listTablesDataSizeInWords = (
sizeof(
ListTablesData) + 3) / 4;
10398 char tname[PATH_MAX];
10403 Uint32 fragId = rand();
10404 Uint32 fragInfo = 0;
10405 const Uint32 fragSize = 240;
10407 tableDataWriter.first();
10408 tableNamesWriter.first();
10411 Uint32 type = iter.curr.p->m_type;
10413 if ((reqTableType != (Uint32)0) && (reqTableType != type))
10416 if (reqListIndexes && !DictTabInfo::isIndex(type))
10420 if (DictTabInfo::isTable(type) || DictTabInfo::isIndex(type)){
10421 c_tableRecordPool.
getPtr(tablePtr, iter.curr.p->m_id);
10423 if(reqListIndexes && (reqTableId != tablePtr.p->primaryTableId))
10426 ltd.requestData = 0;
10427 ltd.setTableId(tablePtr.i);
10428 ltd.setTableType(type);
10431 if(DictTabInfo::isTable(type)){
10433 switch(te->m_tableState){
10434 case SchemaFile::SF_CREATE:
10436 ltd.setTableState(DictTabInfo::StateBuilding);
10438 case SchemaFile::SF_ALTER:
10440 ltd.setTableState(DictTabInfo::StateOnline);
10442 case SchemaFile::SF_DROP:
10444 ltd.setTableState(DictTabInfo::StateDropping);
10446 case SchemaFile::SF_IN_USE:
10448 if (tablePtr.p->m_read_locked)
10451 ltd.setTableState(DictTabInfo::StateBackup);
10456 ltd.setTableState(DictTabInfo::StateOnline);
10461 ltd.setTableState(DictTabInfo::StateBroken);
10465 if (tablePtr.p->isIndex()) {
10466 switch (tablePtr.p->indexState) {
10467 case TableRecord::IS_OFFLINE:
10468 ltd.setTableState(DictTabInfo::StateOffline);
10470 case TableRecord::IS_BUILDING:
10471 ltd.setTableState(DictTabInfo::StateBuilding);
10473 case TableRecord::IS_DROPPING:
10474 ltd.setTableState(DictTabInfo::StateDropping);
10476 case TableRecord::IS_ONLINE:
10477 ltd.setTableState(DictTabInfo::StateOnline);
10480 ltd.setTableState(DictTabInfo::StateBroken);
10485 if (! (tablePtr.p->m_bits & TableRecord::TR_Logged)) {
10486 ltd.setTableStore(DictTabInfo::StoreNotLogged);
10488 ltd.setTableStore(DictTabInfo::StorePermanent);
10491 if (tablePtr.p->m_bits & TableRecord::TR_Temporary) {
10492 ltd.setTableTemp(NDB_TEMP_TAB_TEMPORARY);
10494 ltd.setTableTemp(NDB_TEMP_TAB_PERMANENT);
10497 if(DictTabInfo::isTrigger(type)){
10499 c_triggerRecordPool.
getPtr(triggerPtr, iter.curr.p->m_id);
10501 ltd.requestData = 0;
10502 ltd.setTableId(triggerPtr.i);
10503 ltd.setTableType(type);
10504 switch (triggerPtr.p->triggerState) {
10505 case TriggerRecord::TS_DEFINING:
10506 ltd.setTableState(DictTabInfo::StateBuilding);
10508 case TriggerRecord::TS_OFFLINE:
10509 ltd.setTableState(DictTabInfo::StateOffline);
10511 case TriggerRecord::TS_ONLINE:
10512 ltd.setTableState(DictTabInfo::StateOnline);
10515 ltd.setTableState(DictTabInfo::StateBroken);
10518 ltd.setTableStore(DictTabInfo::StoreNotLogged);
10520 if (DictTabInfo::isFilegroup(type)){
10522 ltd.requestData = 0;
10523 ltd.setTableId(iter.curr.p->m_id);
10524 ltd.setTableType(type);
10525 ltd.setTableState(DictTabInfo::StateOnline);
10527 if (DictTabInfo::isFile(type)){
10529 ltd.requestData = 0;
10530 ltd.setTableId(iter.curr.p->m_id);
10531 ltd.setTableType(type);
10532 ltd.setTableState(DictTabInfo::StateOnline);
10534 if (DictTabInfo::isHashMap(type))
10537 ltd.setTableId(iter.curr.p->m_id);
10538 ltd.setTableType(type);
10539 ltd.setTableState(DictTabInfo::StateOnline);
10541 tableDataWriter.putWords((Uint32 *) <d, listTablesDataSizeInWords);
10547 Rope name(c_rope_pool, iter.curr.p->m_name);
10548 const Uint32 size = name.size();
10549 const Uint32 wsize = (size + 3) / 4;
10550 tableNamesWriter.putWord(size);
10552 tableNamesWriter.putWords((Uint32 *) tname, wsize);
10556 Uint32 tableDataWords = tableDataWriter.getWordsUsed();
10557 Uint32 tableNameWords = tableNamesWriter.getWordsUsed();
10559 done = !c_obj_hash.
next(iter);
10560 if ((tableDataWords + tableNameWords) > fragSize || done)
10567 Uint32 sigLen = ListTablesConf::SignalLength;
10569 if (tableDataWords != 0)
10574 if (tableNameWords != 0)
10579 Uint32 * secNos = &signal->theData[sigLen];
10580 signal->theData[sigLen + secs] = fragId;
10593 if (tableNameWords == 0)
10595 tableDataWriter.
getPtr(segSecPtr);
10596 secNos[0] = ListTablesConf::TABLE_DATA;;
10600 tableNamesWriter.
getPtr(segSecPtr);
10601 secNos[0] = ListTablesConf::TABLE_NAMES;
10603 handle.m_ptr[0] = segSecPtr;
10612 tableDataWriter.
getPtr(tableDataPtr);
10614 tableNamesWriter.
getPtr(tableNamesPtr);
10615 handle.m_ptr[0] = tableDataPtr;
10616 handle.m_ptr[1] = tableNamesPtr;
10618 secNos[0] = ListTablesConf::TABLE_DATA;
10619 secNos[1] = ListTablesConf::TABLE_NAMES;
10647 signal->header.m_fragmentInfo = fragInfo;
10650 conf->senderData = senderData;
10651 conf->noOfTables = count;
10652 sendSignal(rg, GSN_LIST_TABLES_CONF, signal,
10653 sigLen, JBB, &handle);
10655 signal->header.m_noOfSections = 0;
10656 signal->header.m_fragmentInfo = 0;
10669 tableDataWriter.first();
10670 tableNamesWriter.first();
10677 const Dbdict::OpInfo
10678 Dbdict::CreateIndexRec::g_opInfo = {
10679 {
'C',
'I',
'n', 0 },
10680 GSN_CREATE_INDX_IMPL_REQ,
10681 CreateIndxImplReq::SignalLength,
10683 &Dbdict::createIndex_seize,
10684 &Dbdict::createIndex_release,
10686 &Dbdict::createIndex_parse,
10687 &Dbdict::createIndex_subOps,
10688 &Dbdict::createIndex_reply,
10690 &Dbdict::createIndex_prepare,
10691 &Dbdict::createIndex_commit,
10692 &Dbdict::createIndex_complete,
10694 &Dbdict::createIndex_abortParse,
10695 &Dbdict::createIndex_abortPrepare
10699 Dbdict::createIndex_seize(SchemaOpPtr op_ptr)
10701 return seizeOpRec<CreateIndexRec>(op_ptr);
10705 Dbdict::createIndex_release(SchemaOpPtr op_ptr)
10707 releaseOpRec<CreateIndexRec>(op_ptr);
10711 Dbdict::execCREATE_INDX_REQ(
Signal* signal)
10720 if (check_sender_version(signal, MAKE_VERSION(6,4,0)) < 0)
10728 do_swap(tmp->clientRef, tmp->clientData);
10737 SchemaOpPtr op_ptr;
10738 CreateIndexRecPtr createIndexPtr;
10741 startClientReq(op_ptr, createIndexPtr, req, impl_req, error);
10742 if (hasError(error)) {
10747 impl_req->tableId = req->tableId;
10748 impl_req->tableVersion = req->tableVersion;
10749 impl_req->indexType = req->indexType;
10751 impl_req->indexId = RNIL;
10752 impl_req->indexVersion = 0;
10754 handleClientReq(signal, op_ptr, handle);
10758 releaseSections(handle);
10762 ref->senderRef = reference();
10763 ref->clientData = req->clientData;
10764 ref->transId = req->transId;
10765 getError(error, ref);
10767 sendSignal(req->clientRef, GSN_CREATE_INDX_REF, signal,
10768 CreateIndxRef::SignalLength, JBB);
10774 Dbdict::createIndex_parse(
Signal* signal,
bool master,
10775 SchemaOpPtr op_ptr,
10778 D(
"createIndex_parse");
10780 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
10781 CreateIndexRecPtr createIndexPtr;
10782 getOpRec(op_ptr, createIndexPtr);
10789 handle.getSection(ss_ptr, CreateIndxReq::ATTRIBUTE_LIST_SECTION);
10792 if (!r.getWord(&attrList.sz) ||
10793 r.getSize() != 1 + attrList.sz ||
10794 attrList.sz == 0 ||
10795 attrList.sz > MAX_ATTRIBUTES_IN_INDEX ||
10796 !r.getWords(attrList.id, attrList.sz)) {
10798 setError(error, CreateIndxRef::InvalidIndexType, __LINE__);
10804 Uint32& bits = createIndexPtr.p->m_bits;
10805 bits = TableRecord::TR_RowChecksum;
10808 handle.getSection(ss_ptr, CreateIndxReq::INDEX_NAME_SECTION);
10813 SimpleProperties::unpack(
10815 DictTabInfo::TableMapping, DictTabInfo::TableMappingSize,
10817 if (status != SimpleProperties::Eof ||
10818 tableDesc.TableName[0] == 0)
10821 setError(error, CreateIndxRef::InvalidName, __LINE__);
10824 const Uint32 bytesize =
sizeof(createIndexPtr.p->m_indexName);
10825 memcpy(createIndexPtr.p->m_indexName, tableDesc.TableName, bytesize);
10826 if (tableDesc.TableLoggedFlag) {
10828 bits |= TableRecord::TR_Logged;
10830 if (tableDesc.TableTemporaryFlag) {
10832 bits |= TableRecord::TR_Temporary;
10834 D(
"index " << createIndexPtr.p->m_indexName);
10838 TableRecordPtr tablePtr;
10840 if (!(impl_req->tableId < c_tableRecordPool.getSize())) {
10842 setError(error, CreateIndxRef::InvalidPrimaryTable, __LINE__);
10845 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
10847 if (!tablePtr.p->isTable()) {
10849 setError(error, CreateIndxRef::InvalidPrimaryTable, __LINE__);
10854 if ((err = check_read_obj(tablePtr.i, trans_ptr.p->m_transId)))
10857 setError(error, err, __LINE__);
10864 switch (impl_req->indexType) {
10865 case DictTabInfo::UniqueHashIndex:
10867 createIndexPtr.p->m_fragmentType = DictTabInfo::HashMapPartition;
10869 case DictTabInfo::OrderedIndex:
10871 if (bits & TableRecord::TR_Logged) {
10873 setError(error, CreateIndxRef::InvalidIndexType, __LINE__);
10876 createIndexPtr.p->m_fragmentType = DictTabInfo::DistrKeyOrderedIndex;
10878 createIndexPtr.p->m_indexKeyLength = MAX_TTREE_NODE_SIZE;
10881 setError(error, CreateIndxRef::InvalidIndexType, __LINE__);
10888 if (!(bits & TableRecord::TR_Temporary) &&
10889 (tablePtr.p->m_bits & TableRecord::TR_Temporary))
10892 setError(error, CreateIndxRef::TableIsTemporary, __LINE__);
10895 if ((bits & TableRecord::TR_Temporary) &&
10896 !(tablePtr.p->m_bits & TableRecord::TR_Temporary))
10901 setError(error, CreateIndxRef::TableIsNotTemporary, __LINE__);
10904 if ((bits & TableRecord::TR_Temporary) &&
10905 (bits & TableRecord::TR_Logged))
10908 setError(error, CreateIndxRef::NoLoggingTemporaryIndex, __LINE__);
10915 AttributeMap& attrMap = createIndexPtr.p->m_attrMap;
10918 for (k = 0; k < attrList.sz; k++) {
10920 Uint32 current_id = attrList.id[k];
10921 AttributeRecordPtr attrPtr;
10926 list(c_attributeRecordPool, tablePtr.p->m_attributes);
10927 list.first(attrPtr);
10928 while (!attrPtr.isNull()) {
10930 if (attrPtr.p->attributeId == current_id) {
10934 list.next(attrPtr);
10937 if (attrPtr.isNull()) {
10940 setError(error, CreateIndxRef::BadRequestType, __LINE__);
10945 if (attrMask.
get(current_id)) {
10947 setError(error, CreateIndxRef::DuplicateAttributes, __LINE__);
10950 attrMask.
set(current_id);
10953 const Uint32 attrDesc = attrPtr.p->attributeDescriptor;
10954 if (AttributeDescriptor::getDiskBased(attrDesc)) {
10956 setError(error, CreateIndxRef::IndexOnDiskAttributeError, __LINE__);
10961 Uint32 new_index = k;
10962 if (impl_req->indexType == DictTabInfo::UniqueHashIndex) {
10965 while (new_index > 0) {
10967 if (current_id >= attrMap[new_index - 1].attr_id) {
10971 attrMap[new_index] = attrMap[new_index - 1];
10975 attrMap[new_index].old_index = k;
10976 attrMap[new_index].attr_id = current_id;
10977 attrMap[new_index].attr_ptr_i = attrPtr.i;
10980 if (impl_req->indexType == DictTabInfo::UniqueHashIndex) {
10982 const Uint32 s1 = AttributeDescriptor::getSize(attrDesc);
10983 const Uint32 s2 = AttributeDescriptor::getArraySize(attrDesc);
10984 createIndexPtr.p->m_indexKeyLength += ((1 << s1) * s2 + 31) >> 5;
10992 impl_req->indexId = getFreeObjId(0);
10995 if (impl_req->indexId == RNIL)
10998 setError(error, CreateTableRef::NoMoreTableRecords, __LINE__);
11002 if (impl_req->indexId >= c_tableRecordPool.getSize())
11005 setError(error, CreateTableRef::NoMoreTableRecords, __LINE__);
11009 if (ERROR_INSERTED(6122)) {
11011 CLEAR_ERROR_INSERT_VALUE;
11012 setError(error, 9122, __LINE__);
11018 Dbdict::createIndex_subOps(
Signal* signal, SchemaOpPtr op_ptr)
11020 D(
"createIndex_subOps" << V(op_ptr.i) << *op_ptr.p);
11022 CreateIndexRecPtr createIndexPtr;
11023 getOpRec(op_ptr, createIndexPtr);
11026 if (!createIndexPtr.p->m_sub_create_table) {
11029 safe_cast(&Dbdict::createIndex_fromCreateTable),
11032 op_ptr.p->m_callback = c;
11033 createIndex_toCreateTable(signal, op_ptr);
11037 if (!createIndexPtr.p->m_sub_alter_index) {
11040 safe_cast(&Dbdict::createIndex_fromAlterIndex),
11043 op_ptr.p->m_callback = c;
11044 createIndex_toAlterIndex(signal, op_ptr);
11051 Dbdict::createIndex_toCreateTable(
Signal* signal, SchemaOpPtr op_ptr)
11053 D(
"createIndex_toCreateTable");
11055 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11056 CreateIndexRecPtr createIndexPtr;
11057 getOpRec(op_ptr, createIndexPtr);
11059 TableRecordPtr tablePtr;
11060 c_tableRecordPool.
getPtr(tablePtr, createIndexPtr.p->m_request.tableId);
11061 ndbrequire(tablePtr.i == tablePtr.p->tableId);
11073 w.add(DictTabInfo::TableId, createIndexPtr.p->m_request.indexId);
11074 w.add(DictTabInfo::TableName, createIndexPtr.p->m_indexName);
11075 {
bool flag = createIndexPtr.p->m_bits & TableRecord::TR_Logged;
11076 w.add(DictTabInfo::TableLoggedFlag, (Uint32)flag);
11078 {
bool flag = createIndexPtr.p->m_bits & TableRecord::TR_Temporary;
11079 w.add(DictTabInfo::TableTemporaryFlag, (Uint32)flag);
11081 w.add(DictTabInfo::FragmentTypeVal, createIndexPtr.p->m_fragmentType);
11082 w.add(DictTabInfo::TableTypeVal, createIndexPtr.p->m_request.indexType);
11083 {
Rope name(c_rope_pool, tablePtr.p->tableName);
11084 char tableName[MAX_TAB_NAME_SIZE];
11085 name.copy(tableName);
11086 w.add(DictTabInfo::PrimaryTable, tableName);
11088 w.add(DictTabInfo::PrimaryTableId, tablePtr.p->tableId);
11089 w.add(DictTabInfo::NoOfAttributes, createIndexPtr.p->m_attrList.sz + 1);
11090 w.add(DictTabInfo::NoOfKeyAttr, createIndexPtr.p->m_attrList.sz);
11091 w.add(DictTabInfo::NoOfNullable, (Uint32)0);
11092 w.add(DictTabInfo::KeyLength, createIndexPtr.p->m_indexKeyLength);
11093 w.add(DictTabInfo::SingleUserMode, (Uint32)NDB_SUM_READ_WRITE);
11098 const AttributeMap& attrMap = createIndexPtr.p->m_attrMap;
11100 for (k = 0; k < createIndexPtr.p->m_attrList.sz; k++) {
11105 AttributeRecordPtr attrPtr;
11106 c_attributeRecordPool.
getPtr(attrPtr, attrMap[k].attr_ptr_i);
11108 {
Rope attrName(c_rope_pool, attrPtr.p->attributeName);
11109 char attributeName[MAX_ATTR_NAME_SIZE];
11110 attrName.copy(attributeName);
11111 w.add(DictTabInfo::AttributeName, attributeName);
11114 const Uint32 attrDesc = attrPtr.p->attributeDescriptor;
11115 const bool isNullable = AttributeDescriptor::getNullable(attrDesc);
11116 const Uint32 arrayType = AttributeDescriptor::getArrayType(attrDesc);
11119 w.add(DictTabInfo::AttributeId, k);
11120 if (createIndexPtr.p->m_request.indexType == DictTabInfo::UniqueHashIndex) {
11122 w.add(DictTabInfo::AttributeKeyFlag, (Uint32)
true);
11123 w.add(DictTabInfo::AttributeNullableFlag, (Uint32)
false);
11125 if (createIndexPtr.p->m_request.indexType == DictTabInfo::OrderedIndex) {
11127 w.add(DictTabInfo::AttributeKeyFlag, (Uint32)
false);
11128 w.add(DictTabInfo::AttributeNullableFlag, (Uint32)isNullable);
11130 w.add(DictTabInfo::AttributeArrayType, arrayType);
11131 w.add(DictTabInfo::AttributeExtType, attrType);
11132 w.add(DictTabInfo::AttributeExtPrecision, attrPtr.p->extPrecision);
11133 w.add(DictTabInfo::AttributeExtScale, attrPtr.p->extScale);
11134 w.add(DictTabInfo::AttributeExtLength, attrPtr.p->extLength);
11135 w.add(DictTabInfo::AttributeEnd, (Uint32)
true);
11138 if (createIndexPtr.p->m_request.indexType == DictTabInfo::UniqueHashIndex) {
11140 Uint32 key_type = NDB_ARRAYTYPE_FIXED;
11141 AttributeRecordPtr attrPtr;
11143 tablePtr.p->m_attributes);
11145 for (list.first(attrPtr); !attrPtr.isNull(); list.next(attrPtr))
11147 const Uint32 desc = attrPtr.p->attributeDescriptor;
11148 if (AttributeDescriptor::getPrimaryKey(desc) &&
11149 AttributeDescriptor::getArrayType(desc) != NDB_ARRAYTYPE_FIXED)
11151 key_type = NDB_ARRAYTYPE_MEDIUM_VAR;
11152 if (NDB_VERSION_D >= MAKE_VERSION(7,1,0))
11163 key_type = NDB_ARRAYTYPE_NONE_VAR;
11170 w.add(DictTabInfo::AttributeName,
"NDB$PK");
11171 w.add(DictTabInfo::AttributeId, createIndexPtr.p->m_attrList.sz);
11172 w.add(DictTabInfo::AttributeArrayType, key_type);
11173 w.add(DictTabInfo::AttributeKeyFlag, (Uint32)
false);
11174 w.add(DictTabInfo::AttributeNullableFlag, (Uint32)
false);
11175 w.add(DictTabInfo::AttributeExtType, (Uint32)DictTabInfo::ExtUnsigned);
11176 w.add(DictTabInfo::AttributeExtLength, tablePtr.p->tupKeyLength+1);
11177 w.add(DictTabInfo::AttributeEnd, (Uint32)
true);
11179 if (createIndexPtr.p->m_request.indexType == DictTabInfo::OrderedIndex) {
11182 w.add(DictTabInfo::AttributeName,
"NDB$TNODE");
11183 w.add(DictTabInfo::AttributeId, createIndexPtr.p->m_attrList.sz);
11185 w.add(DictTabInfo::AttributeArrayType, (Uint32)NDB_ARRAYTYPE_FIXED);
11186 w.add(DictTabInfo::AttributeKeyFlag, (Uint32)
true);
11187 w.add(DictTabInfo::AttributeNullableFlag, (Uint32)
false);
11188 w.add(DictTabInfo::AttributeExtType, (Uint32)DictTabInfo::ExtUnsigned);
11189 w.add(DictTabInfo::AttributeExtLength, createIndexPtr.p->m_indexKeyLength);
11190 w.add(DictTabInfo::AttributeEnd, (Uint32)
true);
11193 w.add(DictTabInfo::TableEnd, (Uint32)
true);
11197 Uint32 requestInfo = 0;
11198 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
11200 req->clientRef = reference();
11201 req->clientData = op_ptr.p->op_key;
11202 req->transId = trans_ptr.p->m_transId;
11203 req->transKey = trans_ptr.p->trans_key;
11204 req->requestInfo = requestInfo;
11207 lsPtr[0].p = wbuffer;
11208 lsPtr[0].sz = w.getWordsUsed();
11209 sendSignal(reference(), GSN_CREATE_TABLE_REQ, signal,
11210 CreateTableReq::SignalLength, JBB, lsPtr, 1);
11214 Dbdict::createIndex_fromCreateTable(
Signal* signal, Uint32 op_key, Uint32 ret)
11217 D(
"createIndex_fromCreateTable" << dec << V(op_key) << V(ret));
11219 SchemaOpPtr op_ptr;
11220 CreateIndexRecPtr createIndexPtr;
11222 findSchemaOp(op_ptr, createIndexPtr, op_key);
11223 ndbrequire(!op_ptr.isNull());
11224 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11231 ndbrequire(conf->transId == trans_ptr.p->m_transId);
11232 impl_req->indexVersion = conf->tableVersion;
11233 createIndexPtr.p->m_sub_create_table =
true;
11235 createSubOps(signal, op_ptr);
11241 setError(error, ref);
11242 abortSubOps(signal, op_ptr, error);
11247 Dbdict::createIndex_toAlterIndex(
Signal* signal, SchemaOpPtr op_ptr)
11249 D(
"createIndex_toAlterIndex");
11253 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11254 CreateIndexRecPtr createIndexPtr;
11255 getOpRec(op_ptr, createIndexPtr);
11257 Uint32 requestInfo = 0;
11258 DictSignal::setRequestType(requestInfo, AlterIndxImplReq::AlterIndexOnline);
11259 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
11261 if (op_ptr.p->m_requestInfo & CreateIndxReq::RF_BUILD_OFFLINE)
11264 requestInfo |= AlterIndxReq::RF_BUILD_OFFLINE;
11267 req->clientRef = reference();
11268 req->clientData = op_ptr.p->op_key;
11269 req->transId = trans_ptr.p->m_transId;
11270 req->transKey = trans_ptr.p->trans_key;
11271 req->requestInfo = requestInfo;
11272 req->indexId = createIndexPtr.p->m_request.indexId;
11273 req->indexVersion = createIndexPtr.p->m_request.indexVersion;
11275 sendSignal(reference(), GSN_ALTER_INDX_REQ, signal,
11276 AlterIndxReq::SignalLength, JBB);
11280 Dbdict::createIndex_fromAlterIndex(
Signal* signal, Uint32 op_key, Uint32 ret)
11283 D(
"createIndex_fromAlterIndex");
11285 SchemaOpPtr op_ptr;
11286 CreateIndexRecPtr createIndexPtr;
11288 findSchemaOp(op_ptr, createIndexPtr, op_key);
11289 ndbrequire(!op_ptr.isNull());
11290 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11297 ndbrequire(conf->transId == trans_ptr.p->m_transId);
11298 createIndexPtr.p->m_sub_alter_index =
true;
11299 createSubOps(signal, op_ptr);
11306 setError(error, ref);
11307 abortSubOps(signal, op_ptr, error);
11312 Dbdict::createIndex_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
11315 D(
"createIndex_reply");
11317 SchemaTransPtr& trans_ptr = op_ptr.p->m_trans_ptr;
11318 CreateIndexRecPtr createIndexPtr;
11319 getOpRec(op_ptr, createIndexPtr);
11322 if (!hasError(error)) {
11324 conf->senderRef = reference();
11325 conf->clientData = op_ptr.p->m_clientData;
11326 conf->transId = trans_ptr.p->m_transId;
11327 conf->indexId = impl_req->indexId;
11328 conf->indexVersion = impl_req->indexVersion;
11330 D(V(conf->indexId) << V(conf->indexVersion));
11332 Uint32 clientRef = op_ptr.p->m_clientRef;
11333 sendSignal(clientRef, GSN_CREATE_INDX_CONF, signal,
11334 CreateIndxConf::SignalLength, JBB);
11338 ref->senderRef = reference();
11339 ref->clientData = op_ptr.p->m_clientData;
11340 ref->transId = trans_ptr.p->m_transId;
11341 getError(error, ref);
11343 Uint32 clientRef = op_ptr.p->m_clientRef;
11344 sendSignal(clientRef, GSN_CREATE_INDX_REF, signal,
11345 CreateIndxRef::SignalLength, JBB);
11352 Dbdict::createIndex_prepare(
Signal* signal, SchemaOpPtr op_ptr)
11355 D(
"createIndex_prepare");
11357 CreateIndexRecPtr createIndexPtr;
11358 getOpRec(op_ptr, createIndexPtr);
11360 sendTransConf(signal, op_ptr);
11366 Dbdict::createIndex_commit(
Signal* signal, SchemaOpPtr op_ptr)
11369 D(
"createIndex_commit");
11371 sendTransConf(signal, op_ptr);
11377 Dbdict::createIndex_complete(
Signal* signal, SchemaOpPtr op_ptr)
11380 sendTransConf(signal, op_ptr);
11386 Dbdict::createIndex_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
11388 D(
"createIndex_abortParse" << *op_ptr.p);
11392 sendTransConf(signal, op_ptr);
11396 Dbdict::createIndex_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
11398 D(
"createIndex_abortPrepare" << *op_ptr.p);
11401 CreateIndexRecPtr createIndexPtr;
11402 getOpRec(op_ptr, createIndexPtr);
11404 sendTransConf(signal, op_ptr);
11410 Dbdict::execCREATE_INDX_IMPL_CONF(
Signal* signal)
11414 ndbrequire(refToNode(conf->senderRef) == getOwnNodeId());
11415 handleDictConf(signal, conf);
11419 Dbdict::execCREATE_INDX_IMPL_REF(
Signal* signal)
11423 ndbrequire(refToNode(ref->senderRef) == getOwnNodeId());
11424 handleDictRef(signal, ref);
11431 const Dbdict::OpInfo
11432 Dbdict::DropIndexRec::g_opInfo = {
11433 {
'D',
'I',
'n', 0 },
11434 GSN_DROP_INDX_IMPL_REQ,
11435 DropIndxImplReq::SignalLength,
11437 &Dbdict::dropIndex_seize,
11438 &Dbdict::dropIndex_release,
11440 &Dbdict::dropIndex_parse,
11441 &Dbdict::dropIndex_subOps,
11442 &Dbdict::dropIndex_reply,
11444 &Dbdict::dropIndex_prepare,
11445 &Dbdict::dropIndex_commit,
11446 &Dbdict::dropIndex_complete,
11448 &Dbdict::dropIndex_abortParse,
11449 &Dbdict::dropIndex_abortPrepare
11453 Dbdict::dropIndex_seize(SchemaOpPtr op_ptr)
11455 return seizeOpRec<DropIndexRec>(op_ptr);
11459 Dbdict::dropIndex_release(SchemaOpPtr op_ptr)
11461 releaseOpRec<DropIndexRec>(op_ptr);
11465 Dbdict::execDROP_INDX_REQ(
Signal* signal)
11474 if (check_sender_version(signal, MAKE_VERSION(6,4,0)) < 0)
11482 do_swap(tmp->clientRef, tmp->clientData);
11491 SchemaOpPtr op_ptr;
11492 DropIndexRecPtr dropIndexPtr;
11495 startClientReq(op_ptr, dropIndexPtr, req, impl_req, error);
11496 if (hasError(error)) {
11501 impl_req->tableId = RNIL;
11502 impl_req->tableVersion = 0;
11503 impl_req->indexId = req->indexId;
11504 impl_req->indexVersion = req->indexVersion;
11506 handleClientReq(signal, op_ptr, handle);
11510 releaseSections(handle);
11513 ref->senderRef = reference();
11514 ref->clientData = req->clientData;
11515 ref->transId = req->transId;
11516 ref->indexId = req->indexId;
11517 ref->indexVersion = req->indexVersion;
11518 getError(error, ref);
11520 sendSignal(req->clientRef, GSN_DROP_INDX_REF, signal,
11521 DropIndxRef::SignalLength, JBB);
11527 Dbdict::dropIndex_parse(
Signal* signal,
bool master,
11528 SchemaOpPtr op_ptr,
11531 D(
"dropIndex_parse" << V(op_ptr.i) << *op_ptr.p);
11533 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11534 DropIndexRecPtr dropIndexPtr;
11535 getOpRec(op_ptr, dropIndexPtr);
11538 TableRecordPtr indexPtr;
11539 if (!(impl_req->indexId < c_tableRecordPool.getSize())) {
11541 setError(error, DropIndxRef::IndexNotFound, __LINE__);
11544 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
11546 if (!indexPtr.p->isIndex())
11549 setError(error, DropIndxRef::NotAnIndex, __LINE__);
11553 if (indexPtr.p->tableVersion != impl_req->indexVersion)
11556 setError(error, DropIndxRef::InvalidIndexVersion, __LINE__);
11560 if (check_write_obj(indexPtr.i, trans_ptr.p->m_transId,
11561 SchemaFile::SF_DROP, error))
11567 ndbrequire(indexPtr.p->primaryTableId != RNIL);
11568 TableRecordPtr tablePtr;
11569 c_tableRecordPool.
getPtr(tablePtr, indexPtr.p->primaryTableId);
11575 impl_req->tableId = tablePtr.p->tableId;
11576 impl_req->tableVersion = tablePtr.p->tableVersion;
11580 if (impl_req->tableId != tablePtr.p->tableId)
11583 setError(error, DropIndxRef::InvalidIndexVersion, __LINE__);
11586 if (impl_req->tableVersion != tablePtr.p->tableVersion)
11589 setError(error, DropIndxRef::InvalidIndexVersion, __LINE__);
11594 if (ERROR_INSERTED(6122)) {
11596 CLEAR_ERROR_INSERT_VALUE;
11597 setError(error, 9122, __LINE__);
11603 Dbdict::dropIndex_subOps(
Signal* signal, SchemaOpPtr op_ptr)
11605 D(
"dropIndex_subOps" << V(op_ptr.i) << *op_ptr.p);
11607 DropIndexRecPtr dropIndexPtr;
11608 getOpRec(op_ptr, dropIndexPtr);
11611 if (!dropIndexPtr.p->m_sub_alter_index) {
11614 safe_cast(&Dbdict::dropIndex_fromAlterIndex),
11617 op_ptr.p->m_callback = c;
11618 dropIndex_toAlterIndex(signal, op_ptr);
11623 if (!dropIndexPtr.p->m_sub_drop_table) {
11626 safe_cast(&Dbdict::dropIndex_fromDropTable),
11629 op_ptr.p->m_callback = c;
11630 dropIndex_toDropTable(signal, op_ptr);
11638 Dbdict::dropIndex_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
11641 D(
"dropIndex_reply" << V(op_ptr.i) << *op_ptr.p);
11643 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11645 DropIndexRecPtr dropIndexPtr;
11646 getOpRec(op_ptr, dropIndexPtr);
11649 if (!hasError(error)) {
11651 conf->senderRef = reference();
11652 conf->clientData = op_ptr.p->m_clientData;
11653 conf->transId = trans_ptr.p->m_transId;
11655 conf->indexId = impl_req->indexId;
11656 conf->indexVersion = impl_req->indexVersion;
11658 Uint32 clientRef = op_ptr.p->m_clientRef;
11659 sendSignal(clientRef, GSN_DROP_INDX_CONF, signal,
11660 DropIndxConf::SignalLength, JBB);
11664 ref->senderRef = reference();
11665 ref->clientData = op_ptr.p->m_clientData;
11666 ref->transId = trans_ptr.p->m_transId;
11668 ref->indexId = impl_req->indexId;
11669 ref->indexVersion = impl_req->indexVersion;
11670 getError(error, ref);
11672 Uint32 clientRef = op_ptr.p->m_clientRef;
11673 sendSignal(clientRef, GSN_DROP_INDX_REF, signal,
11674 DropIndxRef::SignalLength, JBB);
11681 Dbdict::dropIndex_prepare(
Signal* signal, SchemaOpPtr op_ptr)
11683 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11685 DropIndexRecPtr dropIndexPtr;
11686 getOpRec(op_ptr, dropIndexPtr);
11688 D(
"dropIndex_prepare" << *op_ptr.p);
11690 sendTransConf(signal, op_ptr);
11696 Dbdict::dropIndex_commit(
Signal* signal, SchemaOpPtr op_ptr)
11698 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11700 DropIndexRecPtr dropIndexPtr;
11701 getOpRec(op_ptr, dropIndexPtr);
11703 D(
"dropIndex_commit" << *op_ptr.p);
11705 sendTransConf(signal, op_ptr);
11711 Dbdict::dropIndex_complete(
Signal* signal, SchemaOpPtr op_ptr)
11714 sendTransConf(signal, op_ptr);
11720 Dbdict::dropIndex_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
11722 D(
"dropIndex_abortParse" << *op_ptr.p);
11724 sendTransConf(signal, op_ptr);
11728 Dbdict::dropIndex_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
11730 D(
"dropIndex_abortPrepare" << *op_ptr.p);
11732 sendTransConf(signal, op_ptr);
11736 Dbdict::dropIndex_toAlterIndex(
Signal* signal, SchemaOpPtr op_ptr)
11738 D(
"dropIndex_toAlterIndex");
11742 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11743 DropIndexRecPtr dropIndexPtr;
11744 getOpRec(op_ptr, dropIndexPtr);
11746 Uint32 requestInfo = 0;
11747 DictSignal::setRequestType(requestInfo, AlterIndxImplReq::AlterIndexOffline);
11748 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
11750 req->clientRef = reference();
11751 req->clientData = op_ptr.p->op_key;
11752 req->transId = trans_ptr.p->m_transId;
11753 req->transKey = trans_ptr.p->trans_key;
11754 req->requestInfo = requestInfo;
11755 req->indexId = dropIndexPtr.p->m_request.indexId;
11756 req->indexVersion = dropIndexPtr.p->m_request.indexVersion;
11758 sendSignal(reference(), GSN_ALTER_INDX_REQ, signal,
11759 AlterIndxReq::SignalLength, JBB);
11763 Dbdict::dropIndex_fromAlterIndex(
Signal* signal, Uint32 op_key, Uint32 ret)
11766 D(
"dropIndex_fromAlterIndex");
11768 SchemaOpPtr op_ptr;
11769 DropIndexRecPtr dropIndexPtr;
11771 findSchemaOp(op_ptr, dropIndexPtr, op_key);
11772 ndbrequire(!op_ptr.isNull());
11773 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11779 ndbrequire(conf->transId == trans_ptr.p->m_transId);
11780 dropIndexPtr.p->m_sub_alter_index =
true;
11781 createSubOps(signal, op_ptr);
11788 setError(error, ref);
11789 abortSubOps(signal, op_ptr, error);
11794 Dbdict::dropIndex_toDropTable(
Signal* signal, SchemaOpPtr op_ptr)
11796 D(
"dropIndex_toDropTable");
11798 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11799 DropIndexRecPtr dropIndexPtr;
11800 getOpRec(op_ptr, dropIndexPtr);
11805 Uint32 requestInfo = 0;
11806 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
11808 req->clientRef = reference();
11809 req->clientData = op_ptr.p->op_key;
11810 req->transId = trans_ptr.p->m_transId;
11811 req->transKey = trans_ptr.p->trans_key;
11812 req->requestInfo = requestInfo;
11813 req->tableId = impl_req->indexId;
11814 req->tableVersion = impl_req->indexVersion;
11815 sendSignal(reference(), GSN_DROP_TABLE_REQ, signal,
11816 DropTableReq::SignalLength, JBB);
11820 Dbdict::dropIndex_fromDropTable(
Signal* signal, Uint32 op_key, Uint32 ret)
11823 D(
"dropIndex_fromDropTable" << dec << V(op_key) << V(ret));
11825 SchemaOpPtr op_ptr;
11826 DropIndexRecPtr dropIndexPtr;
11828 findSchemaOp(op_ptr, dropIndexPtr, op_key);
11829 ndbrequire(!op_ptr.isNull());
11830 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
11837 ndbrequire(conf->transId == trans_ptr.p->m_transId);
11838 dropIndexPtr.p->m_sub_drop_table =
true;
11839 createSubOps(signal, op_ptr);
11845 setError(error, ref);
11846 abortSubOps(signal, op_ptr, error);
11853 Dbdict::execDROP_INDX_IMPL_CONF(
Signal* signal)
11857 ndbrequire(refToNode(conf->senderRef) == getOwnNodeId());
11858 handleDictConf(signal, conf);
11862 Dbdict::execDROP_INDX_IMPL_REF(
Signal* signal)
11866 ndbrequire(refToNode(ref->senderRef) == getOwnNodeId());
11867 handleDictRef(signal, ref);
11874 const Dbdict::OpInfo
11875 Dbdict::AlterIndexRec::g_opInfo = {
11876 {
'A',
'I',
'n', 0 },
11877 GSN_ALTER_INDX_IMPL_REQ,
11878 AlterIndxImplReq::SignalLength,
11880 &Dbdict::alterIndex_seize,
11881 &Dbdict::alterIndex_release,
11883 &Dbdict::alterIndex_parse,
11884 &Dbdict::alterIndex_subOps,
11885 &Dbdict::alterIndex_reply,
11887 &Dbdict::alterIndex_prepare,
11888 &Dbdict::alterIndex_commit,
11889 &Dbdict::alterIndex_complete,
11891 &Dbdict::alterIndex_abortParse,
11892 &Dbdict::alterIndex_abortPrepare
11896 Dbdict::alterIndex_seize(SchemaOpPtr op_ptr)
11898 return seizeOpRec<AlterIndexRec>(op_ptr);
11902 Dbdict::alterIndex_release(SchemaOpPtr op_ptr)
11904 releaseOpRec<AlterIndexRec>(op_ptr);
11908 Dbdict::execALTER_INDX_REQ(
Signal* signal)
11923 SchemaOpPtr op_ptr;
11924 AlterIndexRecPtr alterIndexPtr;
11927 startClientReq(op_ptr, alterIndexPtr, req, impl_req, error);
11928 if (hasError(error)) {
11933 impl_req->tableId = RNIL;
11934 impl_req->tableVersion = 0;
11935 impl_req->indexId = req->indexId;
11936 impl_req->indexVersion = req->indexVersion;
11937 impl_req->indexType = 0;
11939 handleClientReq(signal, op_ptr, handle);
11943 releaseSections(handle);
11946 ref->senderRef = reference();
11947 ref->clientData = req->clientData;
11948 ref->transId = req->transId;
11949 ref->indexId = req->indexId;
11950 ref->indexVersion = req->indexVersion;
11951 getError(error, ref);
11953 sendSignal(req->clientRef, GSN_ALTER_INDX_REF, signal,
11954 AlterIndxRef::SignalLength, JBB);
11957 const Dbdict::TriggerTmpl
11958 Dbdict::g_hashIndexTriggerTmpl[1] = {
11959 {
"NDB$INDEX_%u_UI",
11961 TriggerType::SECONDARY_INDEX,
11962 TriggerActionTime::TA_AFTER,
11963 TriggerEvent::TE_CUSTOM,
11969 const Dbdict::TriggerTmpl
11970 Dbdict::g_orderedIndexTriggerTmpl[1] = {
11971 {
"NDB$INDEX_%u_CUSTOM",
11973 TriggerType::ORDERED_INDEX,
11974 TriggerActionTime::TA_CUSTOM,
11975 TriggerEvent::TE_CUSTOM,
11981 const Dbdict::TriggerTmpl
11982 Dbdict::g_buildIndexConstraintTmpl[1] = {
11983 {
"NDB$INDEX_%u_BUILD",
11985 TriggerType::READ_ONLY_CONSTRAINT,
11986 TriggerActionTime::TA_AFTER,
11987 TriggerEvent::TE_UPDATE,
11993 const Dbdict::TriggerTmpl
11994 Dbdict::g_reorgTriggerTmpl[1] = {
11997 TriggerType::REORG_TRIGGER,
11998 TriggerActionTime::TA_AFTER,
11999 TriggerEvent::TE_CUSTOM,
12008 Dbdict::alterIndex_parse(
Signal* signal,
bool master,
12009 SchemaOpPtr op_ptr,
12012 D(
"alterIndex_parse" << V(op_ptr.i) << *op_ptr.p);
12014 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12015 AlterIndexRecPtr alterIndexPtr;
12016 getOpRec(op_ptr, alterIndexPtr);
12019 TableRecordPtr indexPtr;
12020 if (!(impl_req->indexId < c_tableRecordPool.getSize())) {
12022 setError(error, AlterIndxRef::IndexNotFound, __LINE__);
12025 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12028 char indexName[MAX_TAB_NAME_SIZE];
12029 memset(indexName, 0,
sizeof(indexName));
12031 ConstRope r(c_rope_pool, indexPtr.p->tableName);
12034 D(
"index " << indexName);
12036 if (indexPtr.p->tableVersion != impl_req->indexVersion) {
12038 setError(error, AlterIndxRef::InvalidIndexVersion, __LINE__);
12042 if (check_write_obj(indexPtr.i, trans_ptr.p->m_transId,
12043 SchemaFile::SF_ALTER, error))
12050 switch (indexPtr.p->tableType) {
12051 case DictTabInfo::UniqueHashIndex:
12053 alterIndexPtr.p->m_triggerTmpl = g_hashIndexTriggerTmpl;
12055 case DictTabInfo::OrderedIndex:
12057 alterIndexPtr.p->m_triggerTmpl = g_orderedIndexTriggerTmpl;
12061 setError(error, AlterIndxRef::NotAnIndex, __LINE__);
12068 impl_req->indexType = indexPtr.p->tableType;
12073 ndbrequire(impl_req->indexType == (Uint32)indexPtr.p->tableType);
12076 ndbrequire(indexPtr.p->primaryTableId != RNIL);
12077 TableRecordPtr tablePtr;
12078 c_tableRecordPool.
getPtr(tablePtr, indexPtr.p->primaryTableId);
12084 impl_req->tableId = tablePtr.p->tableId;
12085 impl_req->tableVersion = tablePtr.p->tableVersion;
12089 if (impl_req->tableId != tablePtr.p->tableId)
12092 setError(error, AlterIndxRef::InvalidIndexVersion, __LINE__);
12095 if (impl_req->tableVersion != tablePtr.p->tableVersion)
12098 setError(error, AlterIndxRef::InvalidIndexVersion, __LINE__);
12104 Uint32 requestType = impl_req->requestType;
12105 switch (requestType) {
12106 case AlterIndxImplReq::AlterIndexOnline:
12108 indexPtr.p->indexState = TableRecord::IS_BUILDING;
12110 case AlterIndxImplReq::AlterIndexOffline:
12112 indexPtr.p->indexState = TableRecord::IS_DROPPING;
12114 case AlterIndxImplReq::AlterIndexAddPartition:
12116 if (indexPtr.p->tableType == DictTabInfo::OrderedIndex)
12127 ndbrequire(list.prev(baseop));
12128 Uint32 sz =
sizeof(baseop.p->m_oprec_ptr.p->m_opType);
12129 const char * opType = baseop.p->m_oprec_ptr.p->m_opType;
12130 if (memcmp(opType, AlterTableRec::g_opInfo.m_opType, sz) == 0)
12133 op_ptr.p->m_base_op_ptr_i = baseop.i;
12138 ndbrequire(memcmp(opType, AlterIndexRec::g_opInfo.m_opType, sz) == 0);
12139 op_ptr.p->m_base_op_ptr_i = baseop.p->m_base_op_ptr_i;
12146 setError(error, AlterIndxRef::BadRequestType, __LINE__);
12151 getIndexAttrMask(indexPtr, alterIndexPtr.p->m_attrMask);
12154 if (indexPtr.p->tableType == DictTabInfo::OrderedIndex) {
12158 if (requestType == AlterIndxImplReq::AlterIndexOnline) {
12160 set_index_stat_frag(signal, indexPtr);
12164 if (strstr(indexName,
"/" NDB_INDEX_STAT_PREFIX) != 0) {
12166 D(
"skip index stats operations for system index");
12167 alterIndexPtr.p->m_sub_index_stat_dml =
true;
12168 alterIndexPtr.p->m_sub_index_stat_mon =
true;
12173 getNodeState().startLevel != NodeState::SL_SINGLEUSER) {
12175 alterIndexPtr.p->m_sub_index_stat_dml =
true;
12179 if (requestType == AlterIndxImplReq::AlterIndexOnline &&
12180 !c_indexStatAutoCreate) {
12182 alterIndexPtr.p->m_sub_index_stat_dml =
true;
12186 if (requestType == AlterIndxImplReq::AlterIndexOffline) {
12193 if (ERROR_INSERTED(6123)) {
12195 CLEAR_ERROR_INSERT_VALUE;
12196 setError(error, 9123, __LINE__);
12202 Dbdict::set_index_stat_frag(
Signal* signal, TableRecordPtr indexPtr)
12205 const Uint32 indexId = indexPtr.i;
12206 Uint32 err = get_fragmentation(signal, indexId);
12207 ndbrequire(err == 0);
12210 const Uint16* frag_data = (Uint16*)(signal->theData+25);
12211 const Uint32 noOfFragments = frag_data[1];
12212 const Uint32 noOfReplicas = frag_data[0];
12213 ndbrequire(noOfFragments != 0 && noOfReplicas != 0);
12216 const Uint32 value = indexPtr.p->primaryTableId + indexPtr.i;
12217 const Uint32 fragId = value % noOfFragments;
12218 const Uint32 fragIndex = 2 + (1 + noOfReplicas) * fragId;
12219 const Uint32 nodeIndex = value % noOfReplicas;
12220 const Uint32 nodeId = frag_data[fragIndex + 1 + nodeIndex];
12222 D(
"set_index_stat_frag" << V(indexId) << V(fragId) << V(nodeId));
12223 indexPtr.p->indexStatFragId = fragId;
12224 indexPtr.p->indexStatNodeId = nodeId;
12228 Dbdict::alterIndex_subOps(
Signal* signal, SchemaOpPtr op_ptr)
12230 D(
"alterIndex_subOps" << V(op_ptr.i) << *op_ptr.p);
12232 AlterIndexRecPtr alterIndexPtr;
12233 getOpRec(op_ptr, alterIndexPtr);
12235 Uint32 requestType = impl_req->requestType;
12236 TableRecordPtr indexPtr;
12237 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12240 if (alterIndexPtr.p->m_sub_trigger ==
false)
12243 alterIndexPtr.p->m_sub_trigger =
true;
12244 switch (requestType) {
12245 case AlterIndxImplReq::AlterIndexOnline:
12249 safe_cast(&Dbdict::alterIndex_fromCreateTrigger),
12252 op_ptr.p->m_callback = c;
12253 alterIndex_toCreateTrigger(signal, op_ptr);
12256 case AlterIndxImplReq::AlterIndexOffline:
12260 safe_cast(&Dbdict::alterIndex_fromDropTrigger),
12263 op_ptr.p->m_callback = c;
12264 alterIndex_toDropTrigger(signal, op_ptr);
12267 case AlterIndxImplReq::AlterIndexAddPartition:
12277 if (requestType == AlterIndxImplReq::AlterIndexOnline &&
12278 !alterIndexPtr.p->m_sub_build_index) {
12281 safe_cast(&Dbdict::alterIndex_fromBuildIndex),
12284 op_ptr.p->m_callback = c;
12285 alterIndex_toBuildIndex(signal, op_ptr);
12289 if (indexPtr.p->isOrderedIndex() &&
12290 (!alterIndexPtr.p->m_sub_index_stat_dml ||
12291 !alterIndexPtr.p->m_sub_index_stat_mon)) {
12294 safe_cast(&Dbdict::alterIndex_fromIndexStat),
12297 op_ptr.p->m_callback = c;
12298 alterIndex_toIndexStat(signal, op_ptr);
12306 Dbdict::alterIndex_toCreateTrigger(
Signal* signal, SchemaOpPtr op_ptr)
12308 D(
"alterIndex_toCreateTrigger");
12310 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12311 AlterIndexRecPtr alterIndexPtr;
12312 getOpRec(op_ptr, alterIndexPtr);
12314 TableRecordPtr indexPtr;
12315 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12317 const TriggerTmpl& triggerTmpl = alterIndexPtr.p->m_triggerTmpl[0];
12321 Uint32 requestInfo = 0;
12322 DictSignal::setRequestType(requestInfo, CreateTrigReq::CreateTriggerOnline);
12323 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
12325 req->clientRef = reference();
12326 req->clientData = op_ptr.p->op_key;
12327 req->transId = trans_ptr.p->m_transId;
12328 req->transKey = trans_ptr.p->trans_key;
12329 req->requestInfo = requestInfo;
12330 req->tableId = impl_req->tableId;
12331 req->tableVersion = impl_req->tableVersion;
12332 req->indexId = impl_req->indexId;
12333 req->indexVersion = impl_req->indexVersion;
12334 req->triggerNo = 0;
12336 Uint32 forceTriggerId = indexPtr.p->triggerId;
12340 ndbrequire(forceTriggerId == RNIL);
12342 req->forceTriggerId = forceTriggerId;
12344 TriggerInfo::packTriggerInfo(req->triggerInfo, triggerTmpl.triggerInfo);
12346 req->receiverRef = 0;
12348 char triggerName[MAX_TAB_NAME_SIZE];
12349 sprintf(triggerName, triggerTmpl.nameFormat, impl_req->indexId);
12352 Uint32 buffer[2 + ((MAX_TAB_NAME_SIZE + 3) >> 2)];
12355 w.add(DictTabInfo::TableName, triggerName);
12357 lsPtr[0].p = buffer;
12358 lsPtr[0].sz = w.getWordsUsed();
12360 lsPtr[1].p = alterIndexPtr.p->m_attrMask.rep.data;
12361 lsPtr[1].sz = alterIndexPtr.p->m_attrMask.getSizeInWords();
12363 sendSignal(reference(), GSN_CREATE_TRIG_REQ, signal,
12364 CreateTrigReq::SignalLength, JBB, lsPtr, 2);
12368 Dbdict::alterIndex_fromCreateTrigger(
Signal* signal, Uint32 op_key, Uint32 ret)
12372 SchemaOpPtr op_ptr;
12373 AlterIndexRecPtr alterIndexPtr;
12375 findSchemaOp(op_ptr, alterIndexPtr, op_key);
12376 ndbrequire(!op_ptr.isNull());
12377 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12380 D(
"alterIndex_fromCreateTrigger" << dec << V(op_key) << V(ret));
12387 ndbrequire(conf->transId == trans_ptr.p->m_transId);
12388 createSubOps(signal, op_ptr);
12393 setError(error, ref);
12394 abortSubOps(signal, op_ptr, error);
12399 Dbdict::alterIndex_toDropTrigger(
Signal* signal, SchemaOpPtr op_ptr)
12401 D(
"alterIndex_toDropTrigger");
12403 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12404 AlterIndexRecPtr alterIndexPtr;
12405 getOpRec(op_ptr, alterIndexPtr);
12408 TableRecordPtr indexPtr;
12409 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12415 Uint32 requestInfo = 0;
12416 DictSignal::setRequestType(requestInfo, 0);
12417 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
12419 req->clientRef = reference();
12420 req->clientData = op_ptr.p->op_key;
12421 req->transId = trans_ptr.p->m_transId;
12422 req->transKey = trans_ptr.p->trans_key;
12423 req->requestInfo = requestInfo;
12424 req->tableId = impl_req->tableId;
12425 req->tableVersion = impl_req->tableVersion;
12426 req->indexId = impl_req->indexId;
12427 req->indexVersion = impl_req->indexVersion;
12428 req->triggerNo = 0;
12429 req->triggerId = indexPtr.p->triggerId;
12431 sendSignal(reference(), GSN_DROP_TRIG_REQ, signal,
12432 DropTrigReq::SignalLength, JBB);
12436 Dbdict::alterIndex_fromDropTrigger(
Signal* signal, Uint32 op_key, Uint32 ret)
12440 SchemaOpPtr op_ptr;
12441 AlterIndexRecPtr alterIndexPtr;
12443 findSchemaOp(op_ptr, alterIndexPtr, op_key);
12444 ndbrequire(!op_ptr.isNull());
12445 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12448 D(
"alterIndex_fromDropTrigger" << dec << V(op_key) << V(ret));
12454 ndbrequire(conf->transId == trans_ptr.p->m_transId);
12455 createSubOps(signal, op_ptr);
12461 setError(error, ref);
12462 abortSubOps(signal, op_ptr, error);
12467 Dbdict::alterIndex_toBuildIndex(
Signal* signal, SchemaOpPtr op_ptr)
12469 D(
"alterIndex_toBuildIndex");
12473 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12474 AlterIndexRecPtr alterIndexPtr;
12475 getOpRec(op_ptr, alterIndexPtr);
12478 Uint32 requestInfo = 0;
12479 DictSignal::setRequestType(requestInfo, BuildIndxReq::MainOp);
12480 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
12482 if (op_ptr.p->m_requestInfo & AlterIndxReq::RF_BUILD_OFFLINE)
12485 requestInfo |= BuildIndxReq::RF_BUILD_OFFLINE;
12488 req->clientRef = reference();
12489 req->clientData = op_ptr.p->op_key;
12490 req->transId = trans_ptr.p->m_transId;
12491 req->transKey = trans_ptr.p->trans_key;
12492 req->requestInfo = requestInfo;
12495 req->tableId = impl_req->tableId;
12496 req->indexId = impl_req->indexId;
12497 req->indexType = impl_req->indexType;
12498 req->parallelism = 16;
12500 sendSignal(reference(), GSN_BUILDINDXREQ, signal,
12501 BuildIndxReq::SignalLength, JBB);
12505 Dbdict::alterIndex_fromBuildIndex(
Signal* signal, Uint32 op_key, Uint32 ret)
12508 D(
"alterIndex_fromBuildIndex");
12510 SchemaOpPtr op_ptr;
12511 AlterIndexRecPtr alterIndexPtr;
12513 findSchemaOp(op_ptr, alterIndexPtr, op_key);
12514 ndbrequire(!op_ptr.isNull());
12515 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12522 ndbrequire(conf->transId == trans_ptr.p->m_transId);
12523 alterIndexPtr.p->m_sub_build_index =
true;
12524 createSubOps(signal, op_ptr);
12531 setError(error, ref);
12532 abortSubOps(signal, op_ptr, error);
12537 Dbdict::alterIndex_toIndexStat(
Signal* signal, SchemaOpPtr op_ptr)
12539 D(
"alterIndex_toIndexStat");
12541 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12542 AlterIndexRecPtr alterIndexPtr;
12543 getOpRec(op_ptr, alterIndexPtr);
12548 Uint32 requestType = 0;
12549 switch (impl_req->requestType) {
12550 case AlterIndxImplReq::AlterIndexOnline:
12551 if (!alterIndexPtr.p->m_sub_index_stat_dml)
12552 requestType = IndexStatReq::RT_UPDATE_STAT;
12554 requestType = IndexStatReq::RT_START_MON;
12556 case AlterIndxImplReq::AlterIndexOffline:
12557 if (!alterIndexPtr.p->m_sub_index_stat_dml)
12558 requestType = IndexStatReq::RT_DELETE_STAT;
12560 requestType = IndexStatReq::RT_STOP_MON;
12567 Uint32 requestInfo = 0;
12568 DictSignal::setRequestType(requestInfo, requestType);
12569 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
12571 TableRecordPtr indexPtr;
12572 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12574 req->clientRef = reference();
12575 req->clientData = op_ptr.p->op_key;
12576 req->transId = trans_ptr.p->m_transId;
12577 req->transKey = trans_ptr.p->trans_key;
12578 req->requestInfo = requestInfo;
12579 req->requestFlag = 0;
12580 req->indexId = impl_req->indexId;
12581 req->indexVersion = indexPtr.p->tableVersion;
12582 req->tableId = impl_req->tableId;
12584 sendSignal(reference(), GSN_INDEX_STAT_REQ,
12585 signal, IndexStatReq::SignalLength, JBB);
12589 Dbdict::alterIndex_fromIndexStat(
Signal* signal, Uint32 op_key, Uint32 ret)
12592 D(
"alterIndex_fromIndexStat");
12594 SchemaOpPtr op_ptr;
12595 AlterIndexRecPtr alterIndexPtr;
12597 findSchemaOp(op_ptr, alterIndexPtr, op_key);
12598 ndbrequire(!op_ptr.isNull());
12599 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12606 ndbrequire(conf->transId == trans_ptr.p->m_transId);
12607 ndbrequire(!alterIndexPtr.p->m_sub_index_stat_dml ||
12608 !alterIndexPtr.p->m_sub_index_stat_mon);
12609 alterIndexPtr.p->m_sub_index_stat_dml =
true;
12610 alterIndexPtr.p->m_sub_index_stat_mon =
true;
12611 createSubOps(signal, op_ptr);
12618 setError(error, ref);
12619 abortSubOps(signal, op_ptr, error);
12624 Dbdict::alterIndex_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
12626 D(
"alterIndex_reply" << V(op_ptr.i) << *op_ptr.p);
12628 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12630 AlterIndexRecPtr alterIndexPtr;
12631 getOpRec(op_ptr, alterIndexPtr);
12634 if (!hasError(error)) {
12636 conf->senderRef = reference();
12637 conf->clientData = op_ptr.p->m_clientData;
12638 conf->transId = trans_ptr.p->m_transId;
12639 conf->indexId = impl_req->indexId;
12640 conf->indexVersion = impl_req->indexVersion;
12642 Uint32 clientRef = op_ptr.p->m_clientRef;
12643 sendSignal(clientRef, GSN_ALTER_INDX_CONF,
12644 signal, AlterIndxConf::SignalLength, JBB);
12648 ref->senderRef = reference();
12649 ref->clientData = op_ptr.p->m_clientData;
12650 ref->transId = trans_ptr.p->m_transId;
12653 ref->indexId = impl_req->indexId;
12654 ref->indexVersion = impl_req->indexVersion;
12655 getError(error, ref);
12657 Uint32 clientRef = op_ptr.p->m_clientRef;
12658 sendSignal(clientRef, GSN_ALTER_INDX_REF,
12659 signal, AlterIndxRef::SignalLength, JBB);
12666 Dbdict::alterIndex_prepare(
Signal* signal, SchemaOpPtr op_ptr)
12668 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12670 AlterIndexRecPtr alterIndexPtr;
12671 getOpRec(op_ptr, alterIndexPtr);
12673 Uint32 requestType = impl_req->requestType;
12675 TableRecordPtr indexPtr;
12676 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12678 D(
"alterIndex_prepare" << *op_ptr.p);
12686 switch (indexPtr.p->tableType) {
12687 case DictTabInfo::UniqueHashIndex:
12690 safe_cast(&Dbdict::alterIndex_fromLocal),
12693 op_ptr.p->m_callback = c;
12695 switch (requestType) {
12696 case AlterIndxImplReq::AlterIndexOnline:
12697 alterIndex_toCreateLocal(signal, op_ptr);
12699 case AlterIndxImplReq::AlterIndexOffline:
12700 alterIndex_toDropLocal(signal, op_ptr);
12708 case DictTabInfo::OrderedIndex:
12709 if (requestType == AlterIndxImplReq::AlterIndexAddPartition)
12713 safe_cast(&Dbdict::alterIndex_fromAddPartitions),
12716 op_ptr.p->m_callback = c;
12717 alterIndex_toAddPartitions(signal, op_ptr);
12720 sendTransConf(signal, op_ptr);
12729 Dbdict::alterIndex_toCreateLocal(
Signal* signal, SchemaOpPtr op_ptr)
12731 AlterIndexRecPtr alterIndexPtr;
12732 getOpRec(op_ptr, alterIndexPtr);
12735 TableRecordPtr indexPtr;
12736 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12738 D(
"alterIndex_toCreateLocal" << *op_ptr.p);
12742 req->senderRef = reference();
12743 req->senderData = op_ptr.p->op_key;
12744 req->requestType = 0;
12745 req->tableId = impl_req->tableId;
12746 req->tableVersion = 0;
12747 req->indexType = indexPtr.p->tableType;
12748 req->indexId = impl_req->indexId;
12749 req->indexVersion = 0;
12752 getIndexAttrList(indexPtr, alterIndexPtr.p->m_attrList);
12754 ls_ptr[0].p = (Uint32*)&alterIndexPtr.p->m_attrList;
12755 ls_ptr[0].sz = 1 + alterIndexPtr.p->m_attrList.sz;
12757 BlockReference ref = DBTC_REF;
12758 sendSignal(ref, GSN_CREATE_INDX_IMPL_REQ, signal,
12759 CreateIndxImplReq::SignalLength, JBB, ls_ptr, 1);
12763 Dbdict::alterIndex_toDropLocal(
Signal* signal, SchemaOpPtr op_ptr)
12765 AlterIndexRecPtr alterIndexPtr;
12766 getOpRec(op_ptr, alterIndexPtr);
12769 TableRecordPtr indexPtr;
12770 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
12772 D(
"alterIndex_toDropLocal" << *op_ptr.p);
12776 req->senderRef = reference();
12777 req->senderData = op_ptr.p->op_key;
12778 req->tableId = impl_req->tableId;
12779 req->tableVersion = 0;
12780 req->indexId = impl_req->indexId;
12781 req->indexVersion = 0;
12783 BlockReference ref = DBTC_REF;
12784 sendSignal(ref, GSN_DROP_INDX_IMPL_REQ, signal,
12785 DropIndxImplReq::SignalLength, JBB);
12789 Dbdict::alterIndex_fromLocal(
Signal* signal, Uint32 op_key, Uint32 ret)
12791 SchemaOpPtr op_ptr;
12792 AlterIndexRecPtr alterIndexPtr;
12793 findSchemaOp(op_ptr, alterIndexPtr, op_key);
12794 ndbrequire(!op_ptr.isNull());
12796 D(
"alterIndex_fromLocal" << *op_ptr.p << V(ret));
12800 alterIndexPtr.p->m_tc_index_done =
true;
12801 sendTransConf(signal, op_ptr);
12804 setError(op_ptr, ret, __LINE__);
12805 sendTransRef(signal, op_ptr);
12810 Dbdict::alterIndex_toAddPartitions(
Signal* signal, SchemaOpPtr op_ptr)
12812 AlterIndexRecPtr alterIndexPtr;
12813 getOpRec(op_ptr, alterIndexPtr);
12819 SchemaOpPtr base_op;
12820 c_schemaOpPool.
getPtr(base_op, op_ptr.p->m_base_op_ptr_i);
12822 const OpSection& fragInfoSec =
12823 getOpSection(base_op, AlterTabReq::FRAGMENTATION);
12825 bool ok = copyOut(fragInfoSec, fragInfoPtr);
12830 req->senderRef = reference();
12831 req->senderData = op_ptr.p->op_key;
12832 req->requestType = AlterTabReq::AlterTablePrepare;
12833 req->tableId = impl_req->indexId;
12834 req->tableVersion = impl_req->indexVersion;
12835 req->newTableVersion = impl_req->indexVersion;
12837 req->changeMask = 0;
12838 req->connectPtr = RNIL;
12839 req->noOfNewAttr = 0;
12840 req->newNoOfCharsets = 0;
12841 req->newNoOfKeyAttrs = 0;
12842 AlterTableReq::setAddFragFlag(req->changeMask, 1);
12844 sendSignal(DBDIH_REF, GSN_ALTER_TAB_REQ, signal,
12845 AlterTabReq::SignalLength, JBB, &handle);
12849 Dbdict::alterIndex_fromAddPartitions(
Signal* signal, Uint32 op_key, Uint32 ret)
12851 SchemaOpPtr op_ptr;
12852 AlterIndexRecPtr alterIndexPtr;
12853 findSchemaOp(op_ptr, alterIndexPtr, op_key);
12854 ndbrequire(!op_ptr.isNull());
12862 alterIndexPtr.p->m_dihAddFragPtr = conf->connectPtr;
12864 sendTransConf(signal, op_ptr);
12867 setError(op_ptr, ret, __LINE__);
12868 sendTransRef(signal, op_ptr);
12875 Dbdict::alterIndex_commit(
Signal* signal, SchemaOpPtr op_ptr)
12878 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12880 AlterIndexRecPtr alterIndexPtr;
12881 getOpRec(op_ptr, alterIndexPtr);
12884 if (impl_req->requestType == AlterIndxImplReq::AlterIndexAddPartition)
12887 req->senderRef = reference();
12888 req->senderData = op_ptr.p->op_key;
12889 req->requestType = AlterTabReq::AlterTableCommit;
12890 req->tableId = impl_req->indexId;
12891 req->tableVersion = impl_req->indexVersion;
12892 req->newTableVersion = impl_req->indexVersion;
12894 req->changeMask = 0;
12895 req->connectPtr = RNIL;
12896 req->noOfNewAttr = 0;
12897 req->newNoOfCharsets = 0;
12898 req->newNoOfKeyAttrs = 0;
12899 req->connectPtr = alterIndexPtr.p->m_dihAddFragPtr;
12902 safe_cast(&Dbdict::alterIndex_fromLocal),
12905 op_ptr.p->m_callback = c;
12907 sendSignal(DBDIH_REF,
12908 GSN_ALTER_TAB_REQ, signal,
12909 AlterTabReq::SignalLength, JBB);
12913 sendTransConf(signal, op_ptr);
12919 Dbdict::alterIndex_complete(
Signal* signal, SchemaOpPtr op_ptr)
12922 sendTransConf(signal, op_ptr);
12928 Dbdict::alterIndex_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
12930 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12931 AlterIndexRecPtr alterIndexPtr;
12932 getOpRec(op_ptr, alterIndexPtr);
12934 Uint32 requestType = impl_req->requestType;
12935 Uint32 indexId = impl_req->indexId;
12937 D(
"alterIndex_abortParse" << *op_ptr.p);
12940 if (!(impl_req->indexId < c_tableRecordPool.getSize())) {
12942 D(
"invalid index id" << V(indexId));
12946 TableRecordPtr indexPtr;
12947 c_tableRecordPool.
getPtr(indexPtr, indexId);
12949 switch (requestType) {
12950 case AlterIndxImplReq::AlterIndexOnline:
12952 indexPtr.p->indexState = TableRecord::IS_OFFLINE;
12954 case AlterIndxImplReq::AlterIndexOffline:
12956 indexPtr.p->indexState = TableRecord::IS_ONLINE;
12963 sendTransConf(signal, op_ptr);
12967 Dbdict::alterIndex_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
12969 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
12970 AlterIndexRecPtr alterIndexPtr;
12971 getOpRec(op_ptr, alterIndexPtr);
12973 Uint32 requestType = impl_req->requestType;
12975 D(
"alterIndex_abortPrepare" << *op_ptr.p);
12977 if (impl_req->requestType == AlterIndxImplReq::AlterIndexAddPartition)
12980 req->senderRef = reference();
12981 req->senderData = op_ptr.p->op_key;
12982 req->requestType = AlterTabReq::AlterTableRevert;
12983 req->tableId = impl_req->indexId;
12984 req->tableVersion = impl_req->indexVersion;
12985 req->newTableVersion = impl_req->indexVersion;
12987 req->changeMask = 0;
12988 req->connectPtr = RNIL;
12989 req->noOfNewAttr = 0;
12990 req->newNoOfCharsets = 0;
12991 req->newNoOfKeyAttrs = 0;
12992 req->connectPtr = alterIndexPtr.p->m_dihAddFragPtr;
12993 AlterTableReq::setAddFragFlag(req->changeMask, 1);
12996 safe_cast(&Dbdict::alterIndex_fromLocal),
12999 op_ptr.p->m_callback = c;
13001 sendSignal(DBDIH_REF,
13002 GSN_ALTER_TAB_REQ, signal,
13003 AlterTabReq::SignalLength, JBB);
13007 if (!alterIndexPtr.p->m_tc_index_done) {
13009 sendTransConf(signal, op_ptr);
13014 safe_cast(&Dbdict::alterIndex_abortFromLocal),
13017 op_ptr.p->m_callback = c;
13019 switch (requestType) {
13020 case AlterIndxImplReq::AlterIndexOnline:
13022 alterIndex_toDropLocal(signal, op_ptr);
13024 case AlterIndxImplReq::AlterIndexOffline:
13026 alterIndex_toCreateLocal(signal, op_ptr);
13035 Dbdict::alterIndex_abortFromLocal(
Signal* signal,
13039 SchemaOpPtr op_ptr;
13040 AlterIndexRecPtr alterIndexPtr;
13041 findSchemaOp(op_ptr, alterIndexPtr, op_key);
13042 ndbrequire(!op_ptr.isNull());
13044 D(
"alterIndex_abortFromLocal" << V(ret) << *op_ptr.p);
13048 alterIndexPtr.p->m_tc_index_done =
false;
13049 sendTransConf(signal, op_ptr);
13059 Dbdict::execALTER_INDX_CONF(
Signal* signal)
13063 handleDictConf(signal, conf);
13067 Dbdict::execALTER_INDX_REF(
Signal* signal)
13071 handleDictRef(signal, ref);
13075 Dbdict::execALTER_INDX_IMPL_CONF(
Signal* signal)
13079 handleDictConf(signal, conf);
13083 Dbdict::execALTER_INDX_IMPL_REF(
Signal* signal)
13087 handleDictRef(signal, ref);
13094 const Dbdict::OpInfo
13095 Dbdict::BuildIndexRec::g_opInfo = {
13096 {
'B',
'I',
'n', 0 },
13097 GSN_BUILD_INDX_IMPL_REQ,
13098 BuildIndxImplReq::SignalLength,
13100 &Dbdict::buildIndex_seize,
13101 &Dbdict::buildIndex_release,
13103 &Dbdict::buildIndex_parse,
13104 &Dbdict::buildIndex_subOps,
13105 &Dbdict::buildIndex_reply,
13107 &Dbdict::buildIndex_prepare,
13108 &Dbdict::buildIndex_commit,
13109 &Dbdict::buildIndex_complete,
13111 &Dbdict::buildIndex_abortParse,
13112 &Dbdict::buildIndex_abortPrepare
13116 Dbdict::buildIndex_seize(SchemaOpPtr op_ptr)
13118 return seizeOpRec<BuildIndexRec>(op_ptr);
13122 Dbdict::buildIndex_release(SchemaOpPtr op_ptr)
13124 releaseOpRec<BuildIndexRec>(op_ptr);
13128 Dbdict::execBUILDINDXREQ(
Signal* signal)
13143 SchemaOpPtr op_ptr;
13144 BuildIndexRecPtr buildIndexPtr;
13147 startClientReq(op_ptr, buildIndexPtr, req, impl_req, error);
13148 if (hasError(error)) {
13153 impl_req->buildId = req->buildId;
13154 impl_req->buildKey = req->buildKey;
13155 impl_req->tableId = req->tableId;
13156 impl_req->indexId = req->indexId;
13157 impl_req->indexType = req->indexType;
13158 impl_req->parallelism = req->parallelism;
13160 handleClientReq(signal, op_ptr, handle);
13164 releaseSections(handle);
13167 ref->senderRef = reference();
13168 ref->clientData = req->clientData;
13169 ref->transId = req->transId;
13170 ref->tableId = req->tableId;
13171 ref->indexId = req->indexId;
13172 ref->indexType = req->indexType;
13173 getError(error, ref);
13175 sendSignal(req->clientRef, GSN_BUILDINDXREF, signal,
13176 BuildIndxRef::SignalLength, JBB);
13182 Dbdict::buildIndex_parse(
Signal* signal,
bool master,
13183 SchemaOpPtr op_ptr,
13186 D(
"buildIndex_parse");
13188 BuildIndexRecPtr buildIndexPtr;
13189 getOpRec(op_ptr, buildIndexPtr);
13193 TableRecordPtr indexPtr;
13194 if (!(impl_req->indexId < c_tableRecordPool.getSize())) {
13196 setError(error, BuildIndxRef::IndexNotFound, __LINE__);
13199 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
13201 ndbrequire(indexPtr.p->primaryTableId == impl_req->tableId);
13204 TableRecordPtr tablePtr;
13205 if (!(impl_req->tableId < c_tableRecordPool.getSize())) {
13207 setError(error, BuildIndxRef::IndexNotFound, __LINE__);
13210 c_tableRecordPool.
getPtr(tablePtr, impl_req->tableId);
13213 getIndexAttrList(indexPtr, buildIndexPtr.p->m_indexKeyList);
13214 getTableKeyList(tablePtr, buildIndexPtr.p->m_tableKeyList);
13216 Uint32 requestType = impl_req->requestType;
13217 switch (requestType) {
13218 case BuildIndxReq::MainOp:
13219 case BuildIndxReq::SubOp:
13224 setError(error, BuildIndxRef::BadRequestType, __LINE__);
13229 switch (indexPtr.p->tableType) {
13230 case DictTabInfo::UniqueHashIndex:
13232 if (requestType == BuildIndxReq::MainOp) {
13233 buildIndexPtr.p->m_triggerTmpl = g_buildIndexConstraintTmpl;
13234 buildIndexPtr.p->m_subOpCount = 3;
13235 buildIndexPtr.p->m_subOpIndex = 0;
13238 Uint32 attrId = indexPtr.p->noOfAttributes - 1;
13239 buildIndexPtr.p->m_attrMask.clear();
13240 buildIndexPtr.p->m_attrMask.set(attrId);
13247 buildIndexPtr.p->m_triggerTmpl = 0;
13248 buildIndexPtr.p->m_subOpCount = 0;
13249 buildIndexPtr.p->m_doBuild =
true;
13254 if (ERROR_INSERTED(6126)) {
13256 CLEAR_ERROR_INSERT_VALUE;
13257 setError(error, 9126, __LINE__);
13263 Dbdict::buildIndex_subOps(
Signal* signal, SchemaOpPtr op_ptr)
13265 D(
"buildIndex_subOps" << V(op_ptr.i) << *op_ptr.p);
13267 BuildIndexRecPtr buildIndexPtr;
13268 getOpRec(op_ptr, buildIndexPtr);
13271 if (buildIndexPtr.p->m_subOpIndex < buildIndexPtr.p->m_subOpCount) {
13273 switch (buildIndexPtr.p->m_subOpIndex) {
13278 safe_cast(&Dbdict::buildIndex_fromCreateConstraint),
13281 op_ptr.p->m_callback = c;
13282 buildIndex_toCreateConstraint(signal, op_ptr);
13291 safe_cast(&Dbdict::buildIndex_fromBuildIndex),
13294 op_ptr.p->m_callback = c;
13295 buildIndex_toBuildIndex(signal, op_ptr);
13303 safe_cast(&Dbdict::buildIndex_fromDropConstraint),
13306 op_ptr.p->m_callback = c;
13307 buildIndex_toDropConstraint(signal, op_ptr);
13321 Dbdict::buildIndex_toCreateConstraint(
Signal* signal, SchemaOpPtr op_ptr)
13323 D(
"buildIndex_toCreateConstraint");
13325 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
13326 BuildIndexRecPtr buildIndexPtr;
13327 getOpRec(op_ptr, buildIndexPtr);
13330 const TriggerTmpl& triggerTmpl = buildIndexPtr.p->m_triggerTmpl[0];
13334 Uint32 requestInfo = 0;
13335 DictSignal::setRequestType(requestInfo, CreateTrigReq::CreateTriggerOnline);
13336 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
13338 req->clientRef = reference();
13339 req->clientData = op_ptr.p->op_key;
13340 req->transId = trans_ptr.p->m_transId;
13341 req->transKey = trans_ptr.p->trans_key;
13342 req->requestInfo = requestInfo;
13343 req->tableId = impl_req->indexId;
13344 req->tableVersion = 0;
13345 req->indexId = RNIL;
13346 req->indexVersion = 0;
13347 req->triggerNo = 0;
13348 req->forceTriggerId = RNIL;
13350 TriggerInfo::packTriggerInfo(req->triggerInfo, triggerTmpl.triggerInfo);
13352 req->receiverRef = 0;
13354 char triggerName[MAX_TAB_NAME_SIZE];
13355 sprintf(triggerName, triggerTmpl.nameFormat, impl_req->indexId);
13358 Uint32 buffer[2 + ((MAX_TAB_NAME_SIZE + 3) >> 2)];
13361 w.add(DictTabInfo::TableName, triggerName);
13363 ls_ptr[0].p = buffer;
13364 ls_ptr[0].sz = w.getWordsUsed();
13366 ls_ptr[1].p = buildIndexPtr.p->m_attrMask.rep.data;
13367 ls_ptr[1].sz = buildIndexPtr.p->m_attrMask.getSizeInWords();
13369 sendSignal(reference(), GSN_CREATE_TRIG_REQ, signal,
13370 CreateTrigReq::SignalLength, JBB, ls_ptr, 2);
13374 Dbdict::buildIndex_fromCreateConstraint(
Signal* signal, Uint32 op_key, Uint32 ret)
13378 SchemaOpPtr op_ptr;
13379 BuildIndexRecPtr buildIndexPtr;
13381 findSchemaOp(op_ptr, buildIndexPtr, op_key);
13382 ndbrequire(!op_ptr.isNull());
13383 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
13386 D(
"buildIndex_fromCreateConstraint" << dec << V(op_key) << V(ret));
13393 ndbrequire(conf->transId == trans_ptr.p->m_transId);
13394 ndbrequire(buildIndexPtr.p->m_subOpIndex < buildIndexPtr.p->m_subOpCount);
13395 buildIndexPtr.p->m_subOpIndex += 1;
13396 createSubOps(signal, op_ptr);
13402 setError(error, ref);
13403 abortSubOps(signal, op_ptr, error);
13408 Dbdict::buildIndex_toBuildIndex(
Signal* signal, SchemaOpPtr op_ptr)
13410 D(
"buildIndex_toBuildIndex");
13412 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
13413 BuildIndexRecPtr buildIndexPtr;
13414 getOpRec(op_ptr, buildIndexPtr);
13419 Uint32 requestInfo = 0;
13420 DictSignal::setRequestType(requestInfo, BuildIndxReq::SubOp);
13421 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
13423 req->clientRef = reference();
13424 req->clientData = op_ptr.p->op_key;
13425 req->transId = trans_ptr.p->m_transId;
13426 req->transKey = trans_ptr.p->trans_key;
13427 req->requestInfo = requestInfo;
13430 req->tableId = impl_req->tableId;
13431 req->indexId = impl_req->indexId;
13432 req->indexType = impl_req->indexType;
13433 req->parallelism = impl_req->parallelism;
13435 sendSignal(reference(), GSN_BUILDINDXREQ, signal,
13436 BuildIndxReq::SignalLength, JBB);
13440 Dbdict::buildIndex_fromBuildIndex(
Signal* signal, Uint32 op_key, Uint32 ret)
13443 D(
"buildIndex_fromBuildIndex");
13445 SchemaOpPtr op_ptr;
13446 BuildIndexRecPtr buildIndexPtr;
13448 findSchemaOp(op_ptr, buildIndexPtr, op_key);
13449 ndbrequire(!op_ptr.isNull());
13450 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
13457 ndbrequire(conf->transId == trans_ptr.p->m_transId);
13458 ndbrequire(buildIndexPtr.p->m_subOpIndex < buildIndexPtr.p->m_subOpCount);
13459 buildIndexPtr.p->m_subOpIndex += 1;
13460 createSubOps(signal, op_ptr);
13467 setError(error, ref);
13468 abortSubOps(signal, op_ptr, error);
13473 Dbdict::buildIndex_toDropConstraint(
Signal* signal, SchemaOpPtr op_ptr)
13475 D(
"buildIndex_toDropConstraint");
13477 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
13478 BuildIndexRecPtr buildIndexPtr;
13479 getOpRec(op_ptr, buildIndexPtr);
13482 TableRecordPtr indexPtr;
13483 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
13485 const TriggerTmpl& triggerTmpl = buildIndexPtr.p->m_triggerTmpl[0];
13489 Uint32 requestInfo = 0;
13490 DictSignal::setRequestType(requestInfo, 0);
13491 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
13493 req->clientRef = reference();
13494 req->clientData = op_ptr.p->op_key;
13495 req->transId = trans_ptr.p->m_transId;
13496 req->transKey = trans_ptr.p->trans_key;
13497 req->requestInfo = requestInfo;
13498 req->tableId = impl_req->indexId;
13499 req->tableVersion = 0;
13500 req->indexId = RNIL;
13501 req->indexVersion = 0;
13502 req->triggerNo = 0;
13503 req->triggerId = RNIL;
13507 char triggerName[MAX_TAB_NAME_SIZE];
13508 sprintf(triggerName, triggerTmpl.nameFormat, impl_req->indexId);
13511 Uint32 buffer[2 + ((MAX_TAB_NAME_SIZE + 3) >> 2)];
13514 w.add(DictTabInfo::TableName, triggerName);
13516 ls_ptr[0].p = buffer;
13517 ls_ptr[0].sz = w.getWordsUsed();
13519 sendSignal(reference(), GSN_DROP_TRIG_REQ, signal,
13520 DropTrigReq::SignalLength, JBB, ls_ptr, 1);
13524 Dbdict::buildIndex_fromDropConstraint(
Signal* signal, Uint32 op_key, Uint32 ret)
13528 SchemaOpPtr op_ptr;
13529 BuildIndexRecPtr buildIndexPtr;
13531 findSchemaOp(op_ptr, buildIndexPtr, op_key);
13532 ndbrequire(!op_ptr.isNull());
13533 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
13536 D(
"buildIndex_fromDropConstraint" << dec << V(op_key) << V(ret));
13542 ndbrequire(conf->transId == trans_ptr.p->m_transId);
13543 ndbrequire(buildIndexPtr.p->m_subOpIndex < buildIndexPtr.p->m_subOpCount);
13544 buildIndexPtr.p->m_subOpIndex += 1;
13545 createSubOps(signal, op_ptr);
13552 setError(error, ref);
13553 abortSubOps(signal, op_ptr, error);
13558 Dbdict::buildIndex_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
13562 SchemaTransPtr& trans_ptr = op_ptr.p->m_trans_ptr;
13563 BuildIndexRecPtr buildIndexPtr;
13564 getOpRec(op_ptr, buildIndexPtr);
13567 D(
"buildIndex_reply" << V(impl_req->indexId));
13569 TableRecordPtr indexPtr;
13570 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
13572 if (!hasError(error)) {
13574 conf->senderRef = reference();
13575 conf->clientData = op_ptr.p->m_clientData;
13576 conf->transId = trans_ptr.p->m_transId;
13577 conf->tableId = impl_req->tableId;
13578 conf->indexId = impl_req->indexId;
13579 conf->indexType = impl_req->indexType;
13581 Uint32 clientRef = op_ptr.p->m_clientRef;
13582 sendSignal(clientRef, GSN_BUILDINDXCONF, signal,
13583 BuildIndxConf::SignalLength, JBB);
13587 ref->senderRef = reference();
13588 ref->clientData = op_ptr.p->m_clientData;
13589 ref->transId = trans_ptr.p->m_transId;
13590 ref->tableId = impl_req->tableId;
13591 ref->indexId = impl_req->indexId;
13592 ref->indexType = impl_req->indexType;
13593 getError(error, ref);
13595 Uint32 clientRef = op_ptr.p->m_clientRef;
13596 sendSignal(clientRef, GSN_BUILDINDXREF, signal,
13597 BuildIndxRef::SignalLength, JBB);
13604 Dbdict::buildIndex_prepare(
Signal* signal, SchemaOpPtr op_ptr)
13607 BuildIndexRecPtr buildIndexPtr;
13608 getOpRec(op_ptr, buildIndexPtr);
13611 Uint32 requestInfo = op_ptr.p->m_requestInfo;
13612 bool noBuild = (requestInfo & DictSignal::RF_NO_BUILD);
13614 D(
"buildIndex_prepare" << hex << V(requestInfo));
13616 if (noBuild || !buildIndexPtr.p->m_doBuild) {
13618 sendTransConf(signal, op_ptr);
13622 buildIndex_toLocalBuild(signal, op_ptr);
13626 Dbdict:: buildIndex_toLocalBuild(
Signal* signal, SchemaOpPtr op_ptr)
13628 BuildIndexRecPtr buildIndexPtr;
13629 getOpRec(op_ptr, buildIndexPtr);
13631 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
13633 TableRecordPtr indexPtr;
13634 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
13636 D(
"buildIndex_toLocalBuild");
13640 req->senderRef = reference();
13641 req->senderData = op_ptr.p->op_key;
13642 req->requestType = impl_req->requestType;
13643 req->transId = trans_ptr.p->m_transId;
13644 req->buildId = impl_req->buildId;
13645 req->buildKey = impl_req->buildKey;
13646 req->tableId = impl_req->tableId;
13647 req->indexId = impl_req->indexId;
13648 req->indexType = indexPtr.p->tableType;
13649 req->parallelism = impl_req->parallelism;
13652 req->requestType |= BuildIndxImplReq::RF_NO_DISK;
13655 safe_cast(&Dbdict::buildIndex_fromLocalBuild),
13658 op_ptr.p->m_callback = c;
13660 switch (indexPtr.p->tableType) {
13661 case DictTabInfo::UniqueHashIndex:
13665 ls_ptr[0].sz = buildIndexPtr.p->m_indexKeyList.sz;
13666 ls_ptr[0].p = buildIndexPtr.p->m_indexKeyList.id;
13667 ls_ptr[1].sz = buildIndexPtr.p->m_tableKeyList.sz;
13668 ls_ptr[1].p = buildIndexPtr.p->m_tableKeyList.id;
13670 sendSignal(TRIX_REF, GSN_BUILD_INDX_IMPL_REQ, signal,
13671 BuildIndxImplReq::SignalLength, JBB, ls_ptr, 2);
13674 case DictTabInfo::OrderedIndex:
13676 if (op_ptr.p->m_requestInfo & BuildIndxReq::RF_BUILD_OFFLINE)
13679 req->requestType |= BuildIndxImplReq::RF_BUILD_OFFLINE;
13683 sendSignal(DBTUP_REF, GSN_BUILD_INDX_IMPL_REQ, signal,
13684 BuildIndxImplReq::SignalLength, JBB);
13694 Dbdict::buildIndex_fromLocalBuild(
Signal* signal, Uint32 op_key, Uint32 ret)
13696 SchemaOpPtr op_ptr;
13697 BuildIndexRecPtr buildIndexPtr;
13698 findSchemaOp(op_ptr, buildIndexPtr, op_key);
13699 ndbrequire(!op_ptr.isNull());
13701 D(
"buildIndex_fromLocalBuild");
13705 sendTransConf(signal, op_ptr);
13708 setError(op_ptr, ret, __LINE__);
13709 sendTransRef(signal, op_ptr);
13716 Dbdict::buildIndex_commit(
Signal* signal, SchemaOpPtr op_ptr)
13719 BuildIndexRecPtr buildIndexPtr;
13720 getOpRec(op_ptr, buildIndexPtr);
13722 D(
"buildIndex_commit" << *op_ptr.p);
13724 buildIndex_toLocalOnline(signal, op_ptr);
13728 Dbdict::buildIndex_toLocalOnline(
Signal* signal, SchemaOpPtr op_ptr)
13730 BuildIndexRecPtr buildIndexPtr;
13731 getOpRec(op_ptr, buildIndexPtr);
13734 TableRecordPtr indexPtr;
13735 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
13737 D(
"buildIndex_toLocalOnline");
13741 req->senderRef = reference();
13742 req->senderData = op_ptr.p->op_key;
13743 req->requestType = impl_req->requestType;
13744 req->tableId = impl_req->tableId;
13745 req->tableVersion = 0;
13746 req->indexId = impl_req->indexId;
13747 req->indexVersion = 0;
13750 safe_cast(&Dbdict::buildIndex_fromLocalOnline),
13753 op_ptr.p->m_callback = c;
13755 switch (indexPtr.p->tableType) {
13756 case DictTabInfo::UniqueHashIndex:
13759 sendSignal(DBTC_REF, GSN_ALTER_INDX_IMPL_REQ, signal,
13760 AlterIndxImplReq::SignalLength, JBB);
13763 case DictTabInfo::OrderedIndex:
13766 sendSignal(DBTUX_REF, GSN_ALTER_INDX_IMPL_REQ, signal,
13767 AlterIndxImplReq::SignalLength, JBB);
13777 Dbdict::buildIndex_fromLocalOnline(
Signal* signal, Uint32 op_key, Uint32 ret)
13779 SchemaOpPtr op_ptr;
13780 BuildIndexRecPtr buildIndexPtr;
13781 findSchemaOp(op_ptr, buildIndexPtr, op_key);
13782 ndbrequire(!op_ptr.isNull());
13785 TableRecordPtr indexPtr;
13786 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
13788 D(
"buildIndex_fromLocalOnline");
13793 indexPtr.p->indexState = TableRecord::IS_ONLINE;
13794 sendTransConf(signal, op_ptr);
13804 Dbdict::buildIndex_complete(
Signal* signal, SchemaOpPtr op_ptr)
13807 sendTransConf(signal, op_ptr);
13813 Dbdict::buildIndex_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
13815 D(
"buildIndex_abortParse" << *op_ptr.p);
13817 sendTransConf(signal, op_ptr);
13821 Dbdict::buildIndex_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
13823 D(
"buildIndex_abortPrepare" << *op_ptr.p);
13826 sendTransConf(signal, op_ptr);
13832 Dbdict::execBUILDINDXCONF(
Signal* signal)
13836 handleDictConf(signal, conf);
13840 Dbdict::execBUILDINDXREF(
Signal* signal)
13844 handleDictRef(signal, ref);
13848 Dbdict::execBUILD_INDX_IMPL_CONF(
Signal* signal)
13852 handleDictConf(signal, conf);
13856 Dbdict::execBUILD_INDX_IMPL_REF(
Signal* signal)
13860 handleDictRef(signal, ref);
13867 const Dbdict::OpInfo
13868 Dbdict::IndexStatRec::g_opInfo = {
13869 {
'S',
'I',
'n', 0 },
13870 GSN_INDEX_STAT_IMPL_REQ,
13871 IndexStatImplReq::SignalLength,
13873 &Dbdict::indexStat_seize,
13874 &Dbdict::indexStat_release,
13876 &Dbdict::indexStat_parse,
13877 &Dbdict::indexStat_subOps,
13878 &Dbdict::indexStat_reply,
13880 &Dbdict::indexStat_prepare,
13881 &Dbdict::indexStat_commit,
13882 &Dbdict::indexStat_complete,
13884 &Dbdict::indexStat_abortParse,
13885 &Dbdict::indexStat_abortPrepare
13889 Dbdict::indexStat_seize(SchemaOpPtr op_ptr)
13891 return seizeOpRec<IndexStatRec>(op_ptr);
13895 Dbdict::indexStat_release(SchemaOpPtr op_ptr)
13897 releaseOpRec<IndexStatRec>(op_ptr);
13901 Dbdict::execINDEX_STAT_REQ(
Signal* signal)
13916 SchemaOpPtr op_ptr;
13917 IndexStatRecPtr indexStatPtr;
13920 startClientReq(op_ptr, indexStatPtr, req, impl_req, error);
13921 if (hasError(error)) {
13927 impl_req->transId = req->transId;
13928 impl_req->requestFlag = req->requestFlag;
13929 impl_req->indexId = req->indexId;
13930 impl_req->indexVersion = req->indexVersion;
13931 impl_req->tableId = req->tableId;
13932 impl_req->fragId = ZNIL;
13933 impl_req->fragCount = ZNIL;
13935 handleClientReq(signal, op_ptr, handle);
13939 releaseSections(handle);
13942 ref->senderRef = reference();
13943 ref->clientData = req->clientData;
13944 ref->transId = req->transId;
13945 getError(error, ref);
13947 sendSignal(req->clientRef, GSN_INDEX_STAT_REF, signal,
13948 IndexStatRef::SignalLength, JBB);
13954 Dbdict::indexStat_parse(
Signal* signal,
bool master,
13955 SchemaOpPtr op_ptr,
13958 D(
"indexStat_parse");
13960 IndexStatRecPtr indexStatPtr;
13961 getOpRec(op_ptr, indexStatPtr);
13965 TableRecordPtr indexPtr;
13966 if (!(impl_req->indexId < c_tableRecordPool.getSize())) {
13968 setError(error, IndexStatRef::InvalidIndex, __LINE__);
13971 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
13973 if (!indexPtr.p->isOrderedIndex()) {
13975 setError(error, IndexStatRef::InvalidIndex, __LINE__);
13979 XSchemaFile* xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
13981 if (te->m_tableState != SchemaFile::SF_CREATE &&
13982 te->m_tableState != SchemaFile::SF_IN_USE) {
13984 setError(error, IndexStatRef::InvalidIndex, __LINE__);
13989 if (impl_req->fragId != ZNIL) {
13991 setError(error, IndexStatRef::InvalidRequest, __LINE__);
13994 impl_req->fragCount = indexPtr.p->fragmentCount;
13996 switch (impl_req->requestType) {
13997 case IndexStatReq::RT_UPDATE_STAT:
14000 indexStatPtr.p->m_subOpCount = 4;
14001 indexStatPtr.p->m_subOpIndex = 0;
14003 case IndexStatReq::RT_DELETE_STAT:
14006 indexStatPtr.p->m_subOpCount = 3;
14007 indexStatPtr.p->m_subOpIndex = 0;
14009 case IndexStatReq::RT_SCAN_FRAG:
14010 case IndexStatReq::RT_CLEAN_NEW:
14011 case IndexStatReq::RT_CLEAN_OLD:
14012 case IndexStatReq::RT_CLEAN_ALL:
14013 case IndexStatReq::RT_DROP_HEAD:
14014 case IndexStatReq::RT_START_MON:
14015 case IndexStatReq::RT_STOP_MON:
14018 if (master && refToBlock(op_ptr.p->m_clientRef) != DBDICT) {
14020 setError(error, IndexStatRef::InvalidRequest, __LINE__);
14023 indexStatPtr.p->m_subOpCount = 0;
14024 indexStatPtr.p->m_subOpIndex = 0;
14028 setError(error, IndexStatRef::InvalidRequest, __LINE__);
14034 Dbdict::indexStat_subOps(
Signal* signal, SchemaOpPtr op_ptr)
14036 D(
"indexStat_subOps" << V(op_ptr.i) << V(*op_ptr.p));
14038 IndexStatRecPtr indexStatPtr;
14039 getOpRec(op_ptr, indexStatPtr);
14042 const Uint32 subOpIndex = indexStatPtr.p->m_subOpIndex;
14043 const Uint32 subOpCount = indexStatPtr.p->m_subOpCount;
14044 if (subOpIndex >= subOpCount) {
14046 ndbrequire(subOpIndex == subOpCount);
14050 Uint32 requestType = 0;
14052 switch (impl_req->requestType) {
14053 case IndexStatReq::RT_UPDATE_STAT:
14054 if (subOpIndex == 0)
14055 requestType = IndexStatReq::RT_CLEAN_NEW;
14056 else if (subOpIndex == 1)
14057 requestType = IndexStatReq::RT_SCAN_FRAG;
14058 else if (subOpIndex == 2)
14059 requestType = IndexStatReq::RT_CLEAN_OLD;
14060 else if (subOpIndex == 3)
14061 requestType = IndexStatReq::RT_START_MON;
14064 case IndexStatReq::RT_DELETE_STAT:
14066 if (subOpIndex == 0)
14067 requestType = IndexStatReq::RT_STOP_MON;
14068 else if (subOpIndex == 1)
14069 requestType = IndexStatReq::RT_DROP_HEAD;
14070 else if (subOpIndex == 2)
14071 requestType = IndexStatReq::RT_CLEAN_ALL;
14075 ndbrequire(requestType != 0);
14077 safe_cast(&Dbdict::indexStat_fromIndexStat),
14080 op_ptr.p->m_callback = c;
14081 indexStat_toIndexStat(signal, op_ptr, requestType);
14086 Dbdict::indexStat_toIndexStat(
Signal* signal, SchemaOpPtr op_ptr,
14087 Uint32 requestType)
14089 D(
"indexStat_toIndexStat");
14091 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
14092 IndexStatRecPtr indexStatPtr;
14093 getOpRec(op_ptr, indexStatPtr);
14098 Uint32 requestInfo = 0;
14099 DictSignal::setRequestType(requestInfo, requestType);
14100 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
14102 TableRecordPtr indexPtr;
14103 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
14105 req->clientRef = reference();
14106 req->clientData = op_ptr.p->op_key;
14107 req->transId = trans_ptr.p->m_transId;
14108 req->transKey = trans_ptr.p->trans_key;
14109 req->requestInfo = requestInfo;
14110 req->requestFlag = 0;
14111 req->indexId = impl_req->indexId;
14112 req->indexVersion = indexPtr.p->tableVersion;
14113 req->tableId = impl_req->tableId;
14115 sendSignal(reference(), GSN_INDEX_STAT_REQ,
14116 signal, IndexStatReq::SignalLength, JBB);
14120 Dbdict::indexStat_fromIndexStat(
Signal* signal, Uint32 op_key, Uint32 ret)
14123 D(
"indexStat_fromIndexStat");
14125 SchemaOpPtr op_ptr;
14126 IndexStatRecPtr indexStatPtr;
14128 findSchemaOp(op_ptr, indexStatPtr, op_key);
14129 ndbrequire(!op_ptr.isNull());
14130 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
14137 ndbrequire(conf->transId == trans_ptr.p->m_transId);
14138 ndbrequire(indexStatPtr.p->m_subOpIndex < indexStatPtr.p->m_subOpCount);
14139 indexStatPtr.p->m_subOpIndex += 1;
14140 createSubOps(signal, op_ptr);
14147 setError(error, ref);
14148 abortSubOps(signal, op_ptr, error);
14153 Dbdict::indexStat_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
14157 SchemaTransPtr& trans_ptr = op_ptr.p->m_trans_ptr;
14158 IndexStatRecPtr indexStatPtr;
14159 getOpRec(op_ptr, indexStatPtr);
14162 D(
"indexStat_reply" << V(impl_req->indexId));
14164 TableRecordPtr indexPtr;
14165 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
14167 if (!hasError(error)) {
14169 conf->senderRef = reference();
14170 conf->clientData = op_ptr.p->m_clientData;
14171 conf->transId = trans_ptr.p->m_transId;
14173 Uint32 clientRef = op_ptr.p->m_clientRef;
14174 sendSignal(clientRef, GSN_INDEX_STAT_CONF, signal,
14175 IndexStatConf::SignalLength, JBB);
14179 ref->senderRef = reference();
14180 ref->clientData = op_ptr.p->m_clientData;
14181 ref->transId = trans_ptr.p->m_transId;
14182 getError(error, ref);
14184 Uint32 clientRef = op_ptr.p->m_clientRef;
14185 sendSignal(clientRef, GSN_INDEX_STAT_REF, signal,
14186 IndexStatRef::SignalLength, JBB);
14193 Dbdict::indexStat_prepare(
Signal* signal, SchemaOpPtr op_ptr)
14196 IndexStatRecPtr indexStatPtr;
14197 getOpRec(op_ptr, indexStatPtr);
14200 D(
"indexStat_prepare" << V(*op_ptr.p));
14202 if (impl_req->requestType == IndexStatReq::RT_UPDATE_STAT ||
14203 impl_req->requestType == IndexStatReq::RT_DELETE_STAT) {
14205 sendTransConf(signal, op_ptr);
14209 indexStat_toLocalStat(signal, op_ptr);
14213 Dbdict::indexStat_toLocalStat(
Signal* signal, SchemaOpPtr op_ptr)
14215 IndexStatRecPtr indexStatPtr;
14216 getOpRec(op_ptr, indexStatPtr);
14218 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
14220 D(
"indexStat_toLocalStat");
14222 TableRecordPtr indexPtr;
14223 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
14224 ndbrequire(indexPtr.p->isOrderedIndex());
14227 safe_cast(&Dbdict::indexStat_fromLocalStat),
14230 op_ptr.p->m_callback = c;
14234 req->senderRef = reference();
14235 req->senderData = op_ptr.p->op_key;
14236 ndbrequire(req->fragId == ZNIL);
14237 ndbrequire(indexPtr.p->indexStatFragId != ZNIL);
14238 BlockReference ref = 0;
14240 switch (impl_req->requestType) {
14241 case IndexStatReq::RT_SCAN_FRAG:
14242 req->fragId = indexPtr.p->indexStatFragId;
14243 if (indexPtr.p->indexStatNodeId != getOwnNodeId()) {
14245 D(
"skip" << V(impl_req->requestType));
14246 execute(signal, c, 0);
14252 case IndexStatReq::RT_CLEAN_NEW:
14253 case IndexStatReq::RT_CLEAN_OLD:
14254 case IndexStatReq::RT_CLEAN_ALL:
14259 req->fragId = ZNIL;
14263 case IndexStatReq::RT_DROP_HEAD:
14264 req->fragId = indexPtr.p->indexStatFragId;
14265 if (indexPtr.p->indexStatNodeId != getOwnNodeId()) {
14267 D(
"skip" << V(impl_req->requestType));
14268 execute(signal, c, 0);
14274 case IndexStatReq::RT_START_MON:
14275 req->fragId = indexPtr.p->indexStatFragId;
14276 if (indexPtr.p->indexStatNodeId != getOwnNodeId()) {
14278 req->fragId = ZNIL;
14283 case IndexStatReq::RT_STOP_MON:
14284 req->fragId = ZNIL;
14293 sendSignal(ref, GSN_INDEX_STAT_IMPL_REQ,
14294 signal, IndexStatImplReq::SignalLength, JBB);
14298 Dbdict::indexStat_fromLocalStat(
Signal* signal, Uint32 op_key, Uint32 ret)
14300 SchemaOpPtr op_ptr;
14301 IndexStatRecPtr indexStatPtr;
14302 findSchemaOp(op_ptr, indexStatPtr, op_key);
14303 ndbrequire(!op_ptr.isNull());
14308 if (impl_req->requestType != IndexStatReq::RT_CLEAN_OLD &&
14309 impl_req->requestType != IndexStatReq::RT_CLEAN_ALL &&
14310 impl_req->requestType != IndexStatReq::RT_DROP_HEAD) {
14312 setError(op_ptr, ret, __LINE__);
14313 sendTransRef(signal, op_ptr);
14316 D(
"ignore failed index stat cleanup");
14318 sendTransConf(signal, op_ptr);
14324 Dbdict::indexStat_commit(
Signal* signal, SchemaOpPtr op_ptr)
14327 IndexStatRecPtr indexStatPtr;
14328 getOpRec(op_ptr, indexStatPtr);
14329 D(
"indexStat_commit" << *op_ptr.p);
14330 sendTransConf(signal, op_ptr);
14336 Dbdict::indexStat_complete(
Signal* signal, SchemaOpPtr op_ptr)
14339 IndexStatRecPtr indexStatPtr;
14340 getOpRec(op_ptr, indexStatPtr);
14341 D(
"indexStat_complete" << *op_ptr.p);
14342 sendTransConf(signal, op_ptr);
14348 Dbdict::indexStat_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
14350 D(
"indexStat_abortParse" << *op_ptr.p);
14352 sendTransConf(signal, op_ptr);
14356 Dbdict::indexStat_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
14358 D(
"indexStat_abortPrepare" << *op_ptr.p);
14361 sendTransConf(signal, op_ptr);
14367 Dbdict::execINDEX_STAT_CONF(
Signal* signal)
14371 handleDictConf(signal, conf);
14375 Dbdict::execINDEX_STAT_REF(
Signal* signal)
14379 handleDictRef(signal, ref);
14383 Dbdict::execINDEX_STAT_IMPL_CONF(
Signal* signal)
14387 handleDictConf(signal, conf);
14391 Dbdict::execINDEX_STAT_IMPL_REF(
Signal* signal)
14395 handleDictRef(signal, ref);
14407 Dbdict::execINDEX_STAT_REP(
Signal* signal)
14412 if (c_masterNodeId != getOwnNodeId()) {
14414 BlockReference dictRef = calcDictBlockRef(c_masterNodeId);
14415 sendSignal(dictRef, GSN_INDEX_STAT_REP, signal,
14416 IndexStatRep::SignalLength, JBB);
14421 TableRecordPtr indexPtr;
14422 if (rep->indexId >= c_tableRecordPool.getSize()) {
14426 XSchemaFile* xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
14428 if (te->m_tableState != SchemaFile::SF_IN_USE) {
14432 c_tableRecordPool.
getPtr(indexPtr, rep->indexId);
14433 if (rep->indexVersion != 0 &&
14434 rep->indexVersion != indexPtr.p->tableVersion) {
14438 if (!indexPtr.p->isOrderedIndex()) {
14442 if (rep->requestType != IndexStatRep::RT_UPDATE_REQ) {
14447 D(
"index stat: " << copyRope<MAX_TAB_NAME_SIZE>(indexPtr.p->tableName)
14448 <<
" request type:" << rep->requestType);
14450 infoEvent(
"DICT: index %u stats auto-update requested", indexPtr.i);
14451 indexPtr.p->indexStatBgRequest = rep->requestType;
14455 Dbdict::indexStatBg_process(
Signal* signal)
14457 if (!c_indexStatAutoUpdate ||
14458 c_masterNodeId != getOwnNodeId() ||
14461 indexStatBg_sendContinueB(signal);
14465 D(
"indexStatBg_process" << V(c_indexStatBgId));
14466 const uint maxloop = 32;
14468 for (loop = 0; loop < maxloop; loop++, c_indexStatBgId++) {
14470 c_indexStatBgId %= c_tableRecordPool.getSize();
14473 TableRecordPtr indexPtr;
14474 XSchemaFile* xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
14476 if (te->m_tableState != SchemaFile::SF_IN_USE) {
14480 c_tableRecordPool.
getPtr(indexPtr, c_indexStatBgId);
14481 if (!indexPtr.p->isOrderedIndex()) {
14485 if (indexPtr.p->indexStatBgRequest == 0) {
14489 ndbrequire(indexPtr.p->indexStatBgRequest == IndexStatRep::RT_UPDATE_REQ);
14491 TxHandlePtr tx_ptr;
14492 if (!seizeTxHandle(tx_ptr)) {
14497 safe_cast(&Dbdict::indexStatBg_fromBeginTrans),
14500 tx_ptr.p->m_callback = c;
14501 beginSchemaTrans(signal, tx_ptr);
14505 indexStatBg_sendContinueB(signal);
14509 Dbdict::indexStatBg_fromBeginTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
14511 D(
"indexStatBg_fromBeginTrans" << V(c_indexStatBgId) << V(tx_key) << V(ret));
14513 TxHandlePtr tx_ptr;
14514 findTxHandle(tx_ptr, tx_key);
14515 ndbrequire(!tx_ptr.isNull());
14517 TableRecordPtr indexPtr;
14518 c_tableRecordPool.
getPtr(indexPtr, c_indexStatBgId);
14522 indexStatBg_sendContinueB(signal);
14527 safe_cast(&Dbdict::indexStatBg_fromIndexStat),
14530 tx_ptr.p->m_callback = c;
14533 req->clientRef = reference();
14534 req->clientData = tx_ptr.p->tx_key;
14535 req->transId = tx_ptr.p->m_transId;
14536 req->transKey = tx_ptr.p->m_transKey;
14537 req->requestInfo = IndexStatReq::RT_UPDATE_STAT;
14538 req->requestFlag = 0;
14539 req->indexId = c_indexStatBgId;
14540 req->indexVersion = indexPtr.p->tableVersion;
14541 req->tableId = indexPtr.p->primaryTableId;
14542 sendSignal(reference(), GSN_INDEX_STAT_REQ,
14543 signal, IndexStatReq::SignalLength, JBB);
14547 Dbdict::indexStatBg_fromIndexStat(
Signal* signal, Uint32 tx_key, Uint32 ret)
14549 D(
"indexStatBg_fromIndexStat" << V(c_indexStatBgId) << V(tx_key) << (ret));
14551 TxHandlePtr tx_ptr;
14552 findTxHandle(tx_ptr, tx_key);
14553 ndbrequire(!tx_ptr.isNull());
14555 TableRecordPtr indexPtr;
14556 c_tableRecordPool.
getPtr(indexPtr, c_indexStatBgId);
14560 setError(tx_ptr.p->m_error, ret, __LINE__);
14561 warningEvent(
"DICT: index %u stats auto-update error: %d", indexPtr.i, ret);
14565 safe_cast(&Dbdict::indexStatBg_fromEndTrans),
14568 tx_ptr.p->m_callback = c;
14571 if (hasError(tx_ptr.p->m_error))
14572 flags |= SchemaTransEndReq::SchemaTransAbort;
14573 endSchemaTrans(signal, tx_ptr, flags);
14577 Dbdict::indexStatBg_fromEndTrans(
Signal* signal, Uint32 tx_key, Uint32 ret)
14579 D(
"indexStatBg_fromEndTrans" << V(c_indexStatBgId) << V(tx_key) << (ret));
14581 TxHandlePtr tx_ptr;
14582 findTxHandle(tx_ptr, tx_key);
14583 ndbrequire(!tx_ptr.isNull());
14585 TableRecordPtr indexPtr;
14586 c_tableRecordPool.
getPtr(indexPtr, c_indexStatBgId);
14591 warningEvent(
"DICT: index %u stats auto-update error: %d", indexPtr.i, ret);
14595 indexPtr.p->indexStatBgRequest = 0;
14596 infoEvent(
"DICT: index %u stats auto-update done", indexPtr.i);
14599 releaseTxHandle(tx_ptr);
14601 indexStatBg_sendContinueB(signal);
14605 Dbdict::indexStatBg_sendContinueB(
Signal* signal)
14607 D(
"indexStatBg_sendContinueB" << V(c_indexStatBgId));
14608 signal->theData[0] = ZINDEX_STAT_BG_PROCESS;
14609 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 1000, 1);
14616 const Dbdict::OpInfo
14617 Dbdict::CopyDataRec::g_opInfo = {
14618 {
'D',
'C',
'D', 0 },
14619 GSN_COPY_DATA_IMPL_REQ,
14620 CopyDataImplReq::SignalLength,
14623 &Dbdict::copyData_seize,
14624 &Dbdict::copyData_release,
14626 &Dbdict::copyData_parse,
14627 &Dbdict::copyData_subOps,
14628 &Dbdict::copyData_reply,
14630 &Dbdict::copyData_prepare,
14631 &Dbdict::copyData_commit,
14632 &Dbdict::copyData_complete,
14634 &Dbdict::copyData_abortParse,
14635 &Dbdict::copyData_abortPrepare
14639 Dbdict::copyData_seize(SchemaOpPtr op_ptr)
14641 return seizeOpRec<CopyDataRec>(op_ptr);
14645 Dbdict::copyData_release(SchemaOpPtr op_ptr)
14647 releaseOpRec<CopyDataRec>(op_ptr);
14651 Dbdict::execCOPY_DATA_REQ(
Signal* signal)
14666 SchemaOpPtr op_ptr;
14667 CopyDataRecPtr copyDataPtr;
14670 startClientReq(op_ptr, copyDataPtr, req, impl_req, error);
14671 if (hasError(error)) {
14676 impl_req->srcTableId = req->srcTableId;
14677 impl_req->dstTableId = req->dstTableId;
14678 impl_req->srcFragments = req->srcFragments;
14680 handleClientReq(signal, op_ptr, handle);
14684 releaseSections(handle);
14687 ref->senderRef = reference();
14688 ref->senderData = req->clientData;
14689 ref->transId = req->transId;
14690 getError(error, ref);
14692 sendSignal(req->clientRef, GSN_COPY_DATA_REF, signal,
14693 CopyDataRef::SignalLength, JBB);
14699 Dbdict::copyData_parse(
Signal* signal,
bool master,
14700 SchemaOpPtr op_ptr,
14703 D(
"copyData_parse");
14711 Dbdict::copyData_subOps(
Signal* signal, SchemaOpPtr op_ptr)
14713 D(
"copyData_subOps" << V(op_ptr.i) << *op_ptr.p);
14719 Dbdict::copyData_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
14723 SchemaTransPtr& trans_ptr = op_ptr.p->m_trans_ptr;
14724 CopyDataRecPtr copyDataPtr;
14725 getOpRec(op_ptr, copyDataPtr);
14728 if (!hasError(error)) {
14730 conf->senderRef = reference();
14731 conf->senderData = op_ptr.p->m_clientData;
14732 conf->transId = trans_ptr.p->m_transId;
14734 Uint32 clientRef = op_ptr.p->m_clientRef;
14735 sendSignal(clientRef, GSN_COPY_DATA_CONF, signal,
14736 CopyDataConf::SignalLength, JBB);
14740 ref->senderRef = reference();
14741 ref->senderData = op_ptr.p->m_clientData;
14742 ref->transId = trans_ptr.p->m_transId;
14743 getError(error, ref);
14745 Uint32 clientRef = op_ptr.p->m_clientRef;
14746 sendSignal(clientRef, GSN_COPY_DATA_REF, signal,
14747 CopyDataRef::SignalLength, JBB);
14754 Dbdict::copyData_prepare(
Signal* signal, SchemaOpPtr op_ptr)
14758 CopyDataRecPtr copyDataPtr;
14759 getOpRec(op_ptr, copyDataPtr);
14761 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
14764 * req = * impl_req;
14765 req->senderRef = reference();
14766 req->senderData = op_ptr.p->op_key;
14767 req->transId = trans_ptr.p->m_transId;
14768 req->srcFragments = 0;
14771 safe_cast(&Dbdict::copyData_fromLocal),
14774 op_ptr.p->m_callback = c;
14777 Uint32 tmp[MAX_ATTRIBUTES_IN_TABLE];
14778 bool tabHasDiskCols =
false;
14779 TableRecordPtr tabPtr;
14780 c_tableRecordPool.
getPtr(tabPtr, impl_req->srcTableId);
14783 tabPtr.p->m_attributes);
14784 AttributeRecordPtr attrPtr;
14785 for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr))
14787 if (AttributeDescriptor::getPrimaryKey(attrPtr.p->attributeDescriptor))
14788 tmp[cnt++] = attrPtr.p->attributeId;
14790 for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr))
14792 if (!AttributeDescriptor::getPrimaryKey(attrPtr.p->attributeDescriptor))
14794 tmp[cnt++] = attrPtr.p->attributeId;
14796 if (AttributeDescriptor::getDiskBased(attrPtr.p->attributeDescriptor))
14797 tabHasDiskCols =
true;
14803 if (tabHasDiskCols)
14806 req->requestInfo |= CopyDataReq::TupOrder;
14810 ls_ptr[0].sz = cnt;
14813 sendSignal(TRIX_REF, GSN_COPY_DATA_IMPL_REQ, signal,
14814 CopyDataImplReq::SignalLength, JBB, ls_ptr, 1);
14818 Dbdict::copyData_fromLocal(
Signal* signal, Uint32 op_key, Uint32 ret)
14820 SchemaOpPtr op_ptr;
14821 CopyDataRecPtr copyDataPtr;
14822 findSchemaOp(op_ptr, copyDataPtr, op_key);
14823 ndbrequire(!op_ptr.isNull());
14825 if (ERROR_INSERTED(6214))
14827 CLEAR_ERROR_INSERT_VALUE;
14833 sendTransConf(signal, op_ptr);
14836 setError(op_ptr, ret, __LINE__);
14837 sendTransRef(signal, op_ptr);
14845 Dbdict::copyData_commit(
Signal* signal, SchemaOpPtr op_ptr)
14849 sendTransConf(signal, op_ptr);
14855 Dbdict::copyData_complete(
Signal* signal, SchemaOpPtr op_ptr)
14859 CopyDataRecPtr copyDataPtr;
14860 getOpRec(op_ptr, copyDataPtr);
14862 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
14865 * req = * impl_req;
14866 req->senderRef = reference();
14867 req->senderData = op_ptr.p->op_key;
14868 req->transId = trans_ptr.p->m_transId;
14869 req->requestType = CopyDataImplReq::ReorgDelete;
14872 safe_cast(&Dbdict::copyData_fromLocal),
14875 op_ptr.p->m_callback = c;
14878 Uint32 tmp[MAX_ATTRIBUTES_IN_TABLE];
14879 bool tabHasDiskCols =
false;
14880 TableRecordPtr tabPtr;
14881 c_tableRecordPool.
getPtr(tabPtr, impl_req->srcTableId);
14884 tabPtr.p->m_attributes);
14885 AttributeRecordPtr attrPtr;
14886 for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr))
14888 if (AttributeDescriptor::getPrimaryKey(attrPtr.p->attributeDescriptor))
14889 tmp[cnt++] = attrPtr.p->attributeId;
14892 if (AttributeDescriptor::getDiskBased(attrPtr.p->attributeDescriptor))
14893 tabHasDiskCols =
true;
14899 if (tabHasDiskCols)
14902 req->requestInfo |= CopyDataReq::TupOrder;
14906 ls_ptr[0].sz = cnt;
14909 sendSignal(TRIX_REF, GSN_COPY_DATA_IMPL_REQ, signal,
14910 CopyDataImplReq::SignalLength, JBB, ls_ptr, 1);
14916 Dbdict::copyData_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
14918 D(
"copyData_abortParse" << *op_ptr.p);
14920 sendTransConf(signal, op_ptr);
14924 Dbdict::copyData_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
14926 D(
"copyData_abortPrepare" << *op_ptr.p);
14929 sendTransConf(signal, op_ptr);
14933 Dbdict::execCOPY_DATA_CONF(
Signal* signal)
14937 handleDictConf(signal, conf);
14941 Dbdict::execCOPY_DATA_REF(
Signal* signal)
14945 handleDictRef(signal, ref);
14949 Dbdict::execCOPY_DATA_IMPL_CONF(
Signal* signal)
14953 ndbrequire(refToNode(conf->senderRef) == getOwnNodeId());
14954 handleDictConf(signal, conf);
14958 Dbdict::execCOPY_DATA_IMPL_REF(
Signal* signal)
14962 ndbrequire(refToNode(ref->senderRef) == getOwnNodeId());
14963 handleDictRef(signal, ref);
14977 Dbdict::sendSignalUtilReq(Callback *pcallback,
14978 BlockReference ref,
14979 GlobalSignalNumber gsn,
14982 JobBufferLevel jbuf,
14984 Uint32 noOfSections)
14988 OpSignalUtilPtr utilRecPtr;
14991 if (!c_opSignalUtil.
seize(utilRecPtr)) {
14995 utilRecPtr.p->m_callback = *pcallback;
14999 utilRecPtr.p->m_userData = req->getSenderData();
15000 req->setSenderData(utilRecPtr.i);
15004 sendSignal(ref, gsn, signal, length, jbuf, ptr, noOfSections);
15007 sendSignal(ref, gsn, signal, length, jbuf);
15014 Dbdict::recvSignalUtilReq(
Signal* signal, Uint32 returnCode)
15019 OpSignalUtilPtr utilRecPtr;
15020 utilRecPtr.i = req->getSenderData();
15021 if ((utilRecPtr.p = c_opSignalUtil.
getPtr(utilRecPtr.i)) == NULL) {
15026 req->setSenderData(utilRecPtr.p->m_userData);
15027 Callback c = utilRecPtr.p->m_callback;
15028 c_opSignalUtil.
release(utilRecPtr);
15030 execute(signal, c, returnCode);
15034 void Dbdict::execUTIL_PREPARE_CONF(
Signal *signal)
15038 ndbrequire(recvSignalUtilReq(signal, 0) == 0);
15042 Dbdict::execUTIL_PREPARE_REF(
Signal *signal)
15046 signal->getDataPtr());
15047 Uint32
code = ref->errorCode;
15048 if (code == UtilPrepareRef::DICT_TAB_INFO_ERROR)
15049 code = ref->dictErrCode;
15051 ndbrequire(recvSignalUtilReq(signal, code) == 0);
15054 void Dbdict::execUTIL_EXECUTE_CONF(
Signal *signal)
15058 ndbrequire(recvSignalUtilReq(signal, 0) == 0);
15061 void Dbdict::execUTIL_EXECUTE_REF(
Signal *signal)
15069 ndbout_c(
"execUTIL_EXECUTE_REF");
15070 ndbout_c(
"senderData %u",ref->getSenderData());
15071 ndbout_c(
"errorCode %u",ref->getErrorCode());
15072 ndbout_c(
"TCErrorCode %u",ref->getTCErrorCode());
15075 ndbrequire(recvSignalUtilReq(signal, 1) == 0);
15077 void Dbdict::execUTIL_RELEASE_CONF(
Signal *signal)
15082 ndbrequire(recvSignalUtilReq(signal, 0) == 0);
15084 void Dbdict::execUTIL_RELEASE_REF(
Signal *signal)
15089 ndbrequire(recvSignalUtilReq(signal, 1) == 0);
15112 sysTab_NDBEVENTS_0_szs[] =
15127 sysTab_NDBEVENTS_0_offsets[] =
15141 Dbdict::prepareTransactionEventSysTable (Callback *pcallback,
15144 UtilPrepareReq::OperationTypeValue prepReq)
15147 DictObject * opj_ptr_p = get_object(EVENT_SYSTEM_TABLE_NAME,
15148 sizeof(EVENT_SYSTEM_TABLE_NAME));
15150 ndbrequire(opj_ptr_p != 0);
15151 TableRecordPtr tablePtr;
15152 c_tableRecordPool.
getPtr(tablePtr, opj_ptr_p->m_id);
15153 ndbrequire(tablePtr.i != RNIL);
15155 Uint32 tableId = tablePtr.p->tableId;
15156 Uint32 noAttr = tablePtr.p->noOfAttributes;
15157 if (noAttr > EVENT_SYSTEM_TABLE_LENGTH)
15160 noAttr = EVENT_SYSTEM_TABLE_LENGTH;
15164 case UtilPrepareReq::Update:
15165 case UtilPrepareReq::Insert:
15166 case UtilPrepareReq::Write:
15167 case UtilPrepareReq::Read:
15170 case UtilPrepareReq::Delete:
15175 prepareUtilTransaction(pcallback, signal, senderData, tableId, NULL,
15176 prepReq, noAttr, NULL, NULL);
15180 Dbdict::prepareUtilTransaction(Callback *pcallback,
15184 const char* tableName,
15185 UtilPrepareReq::OperationTypeValue prepReq,
15188 const char *attrNames[])
15196 utilPrepareReq->setSenderRef(reference());
15197 utilPrepareReq->setSenderData(senderData);
15199 const Uint32 pageSizeInWords = 128;
15200 Uint32 propPage[pageSizeInWords];
15204 w.add(UtilPrepareReq::OperationType, prepReq);
15210 w.add(UtilPrepareReq::TableId, tableId);
15212 for(Uint32 i = 0; i < noAttr; i++)
15219 w.add(UtilPrepareReq::AttributeId, attrIds[i]);
15222 w.add(UtilPrepareReq::AttributeId, i);
15228 printf(
"Dict::prepareInsertTransactions: Sent SimpleProperties:\n");
15229 reader.printAll(ndbout);
15233 sectionsPtr[UtilPrepareReq::PROPERTIES_SECTION].p = propPage;
15234 sectionsPtr[UtilPrepareReq::PROPERTIES_SECTION].sz = w.getWordsUsed();
15236 sendSignalUtilReq(pcallback, DBUTIL_REF, GSN_UTIL_PREPARE_REQ, signal,
15237 UtilPrepareReq::SignalLength, JBB,
15238 sectionsPtr, UtilPrepareReq::NoOfSections);
15257 Dbdict::execCREATE_EVNT_REQ(Signal* signal)
15267 tmp.clearWaitingFor();
15268 tmp.setWaitingFor(3);
15269 ndbrequire(!tmp.done());
15270 ndbout_c(
"Allocted");
15272 ndbrequire(!handle.done());
15275 tmp.clearWaitingFor(3);
15276 ndbrequire(tmp.done());
15277 ndbout_c(
"Deallocted");
15279 ndbrequire(handle.done());
15292 while((i = nodes.
find(i)) != NodeBitmask::NotFound){
15293 ndbout_c(
"1 Node id = %u", i);
15300 ndbrequire(rt2.done());
15301 ndbrequire(!rt2.hasRef());
15302 ndbrequire(!rt2.hasConf());
15303 rt2.init<
CreateEvntRef>(c_counterMgr, rg, GSN_CREATE_EVNT_REF, 13);
15306 rt3.init<
CreateEvntRef>(c_counterMgr, rg, GSN_CREATE_EVNT_REF, 13);
15308 ndbrequire(!rt2.done());
15309 ndbrequire(!rt3.done());
15311 rt2.reportRef(c_counterMgr, 2);
15312 rt3.reportConf(c_counterMgr, 2);
15314 ndbrequire(!rt2.done());
15315 ndbrequire(!rt3.done());
15317 rt2.reportConf(c_counterMgr, 3);
15318 rt3.reportConf(c_counterMgr, 3);
15320 ndbrequire(!rt2.done());
15321 ndbrequire(!rt3.done());
15323 rt2.reportConf(c_counterMgr, 4);
15324 rt3.reportConf(c_counterMgr, 4);
15326 ndbrequire(!rt2.done());
15327 ndbrequire(!rt3.done());
15329 rt2.reportConf(c_counterMgr, 5);
15330 rt3.reportConf(c_counterMgr, 5);
15332 ndbrequire(rt2.done());
15333 ndbrequire(rt3.done());
15344 const CreateEvntReq::RequestType requestType = req->getRequestType();
15345 const Uint32 requestFlag = req->getRequestFlag();
15348 if (refToBlock(signal->senderBlockRef()) != DBDICT &&
15349 getOwnNodeId() != c_masterNodeId)
15352 releaseSections(handle);
15355 ref->setUserRef(reference());
15356 ref->setErrorCode(CreateEvntRef::NotMaster);
15357 ref->setErrorLine(__LINE__);
15358 ref->setErrorNode(reference());
15359 ref->setMasterNode(c_masterNodeId);
15360 sendSignal(signal->senderBlockRef(), GSN_CREATE_EVNT_REF, signal,
15361 CreateEvntRef::SignalLength2, JBB);
15365 OpCreateEventPtr evntRecPtr;
15367 if (!c_opCreateEvent.seize(evntRecPtr)) {
15370 releaseSections(handle);
15373 ret->senderRef = reference();
15374 ret->setErrorCode(747);
15375 ret->setErrorLine(__LINE__);
15376 ret->setErrorNode(reference());
15377 sendSignal(signal->senderBlockRef(), GSN_CREATE_EVNT_REF, signal,
15378 CreateEvntRef::SignalLength, JBB);
15383 ndbout_c(
"DBDICT::execCREATE_EVNT_REQ from %u evntRecId = (%d)", refToNode(signal->getSendersBlockRef()), evntRecPtr.i);
15386 ndbrequire(req->getUserRef() == signal->getSendersBlockRef());
15388 evntRecPtr.p->init(req,
this);
15390 if (requestFlag & (Uint32)CreateEvntReq::RT_DICT_AFTER_GET) {
15393 releaseSections(handle);
15395 if (ERROR_INSERTED(6023))
15398 signal->theData[0] = 9999;
15399 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 1000, 1);
15403 createEvent_RT_DICT_AFTER_GET(signal, evntRecPtr);
15406 if (requestType == CreateEvntReq::RT_USER_GET) {
15409 createEvent_RT_USER_GET(signal, evntRecPtr, handle);
15412 if (requestType == CreateEvntReq::RT_USER_CREATE) {
15415 createEvent_RT_USER_CREATE(signal, evntRecPtr, handle);
15420 ndbout <<
"Dbdict.cpp: Dbdict::execCREATE_EVNT_REQ other" << endl;
15423 releaseSections(handle);
15425 evntRecPtr.p->m_errorCode = 1;
15426 evntRecPtr.p->m_errorLine = __LINE__;
15427 evntRecPtr.p->m_errorNode = reference();
15429 createEvent_sendReply(signal, evntRecPtr);
15439 Dbdict::createEvent_RT_USER_CREATE(
Signal* signal,
15440 OpCreateEventPtr evntRecPtr,
15444 DBUG_ENTER(
"Dbdict::createEvent_RT_USER_CREATE");
15445 evntRecPtr.p->m_request.setUserRef(signal->senderBlockRef());
15448 ndbout <<
"Dbdict.cpp: Dbdict::execCREATE_EVNT_REQ RT_USER" << endl;
15449 char buf[128] = {0};
15450 AttributeMask mask = evntRecPtr.p->m_request.getAttrListBitmask();
15452 ndbout_c(
"mask = %s", buf);
15459 ndbrequire(handle.getSection(ssPtr, CreateEvntReq::EVENT_NAME_SECTION));
15463 r0.printAll(ndbout);
15466 if ((!r0.first()) ||
15467 (r0.getValueType() != SimpleProperties::StringValue) ||
15468 (r0.getValueLen() <= 0)) {
15470 releaseSections(handle);
15472 evntRecPtr.p->m_errorCode = 1;
15473 evntRecPtr.p->m_errorLine = __LINE__;
15474 evntRecPtr.p->m_errorNode = reference();
15476 createEvent_sendReply(signal, evntRecPtr);
15479 r0.getString(evntRecPtr.p->m_eventRec.NAME);
15481 int len = strlen(evntRecPtr.p->m_eventRec.NAME);
15482 memset(evntRecPtr.p->m_eventRec.NAME+len, 0, MAX_TAB_NAME_SIZE-len);
15484 printf(
"CreateEvntReq::RT_USER_CREATE; EventName %s, len %u\n",
15485 evntRecPtr.p->m_eventRec.NAME, len);
15486 for(
int i = 0; i < MAX_TAB_NAME_SIZE/4; i++)
15487 printf(
"H'%.8x ", ((Uint32*)evntRecPtr.p->m_eventRec.NAME)[i]);
15492 if ((!r0.next()) ||
15493 (r0.getValueType() != SimpleProperties::StringValue) ||
15494 (r0.getValueLen() <= 0)) {
15497 evntRecPtr.p->m_errorCode = 1;
15499 evntRecPtr.p->m_errorLine = __LINE__;
15500 evntRecPtr.p->m_errorNode = reference();
15502 releaseSections(handle);
15504 createEvent_sendReply(signal, evntRecPtr);
15507 r0.getString(evntRecPtr.p->m_eventRec.TABLE_NAME);
15509 int len = strlen(evntRecPtr.p->m_eventRec.TABLE_NAME);
15510 memset(evntRecPtr.p->m_eventRec.TABLE_NAME+len, 0, MAX_TAB_NAME_SIZE-len);
15513 if (handle.m_cnt >= CreateEvntReq::ATTRIBUTE_MASK)
15516 handle.getSection(ssPtr, CreateEvntReq::ATTRIBUTE_MASK);
15517 if (ssPtr.sz >= NDB_ARRAY_SIZE(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2))
15520 evntRecPtr.p->m_errorCode = 1;
15523 bzero(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2,
15524 sizeof(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2));
15525 copy(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2, ssPtr);
15526 memcpy(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK,
15527 evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2,
15528 sizeof(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK));
15534 Uint32 sz0 = m.getSizeInWords();
15535 Uint32 sz1 = NDB_ARRAY_SIZE(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK);
15536 ndbrequire(sz1 == sz0);
15537 bzero(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK,
15538 sizeof(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK));
15539 bzero(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2,
15540 sizeof(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2));
15547 releaseSections(handle);
15555 sumaIdReq->senderRef = reference();
15556 sumaIdReq->senderData = evntRecPtr.i;
15558 ndbout <<
"sumaIdReq->senderData = " << sumaIdReq->senderData << endl;
15560 sendSignal(SUMA_REF, GSN_CREATE_SUBID_REQ, signal,
15561 CreateSubscriptionIdReq::SignalLength, JBB);
15567 void Dbdict::execCREATE_SUBID_REF(
Signal* signal)
15570 DBUG_ENTER(
"Dbdict::execCREATE_SUBID_REF");
15573 OpCreateEventPtr evntRecPtr;
15575 evntRecPtr.i = ref->senderData;
15576 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
15578 if (ref->errorCode)
15580 evntRecPtr.p->m_errorCode = ref->errorCode;
15581 evntRecPtr.p->m_errorLine = __LINE__;
15585 evntRecPtr.p->m_errorCode = 1;
15586 evntRecPtr.p->m_errorLine = __LINE__;
15588 evntRecPtr.p->m_errorNode = reference();
15590 createEvent_sendReply(signal, evntRecPtr);
15594 void Dbdict::execCREATE_SUBID_CONF(
Signal* signal)
15597 DBUG_ENTER(
"Dbdict::execCREATE_SUBID_CONF");
15602 Uint32 evntRecId = sumaIdConf->senderData;
15603 OpCreateEvent *evntRec;
15605 ndbrequire((evntRec = c_opCreateEvent.
getPtr(evntRecId)) != NULL);
15607 evntRec->m_request.setEventId(sumaIdConf->subscriptionId);
15608 evntRec->m_request.setEventKey(sumaIdConf->subscriptionKey);
15610 Callback c = { safe_cast(&Dbdict::createEventUTIL_PREPARE), 0 };
15612 prepareTransactionEventSysTable(&c, signal, evntRecId,
15613 UtilPrepareReq::Insert);
15618 Dbdict::createEventComplete_RT_USER_CREATE(
Signal* signal,
15619 OpCreateEventPtr evntRecPtr){
15621 createEvent_sendReply(signal, evntRecPtr);
15631 void interpretUtilPrepareErrorCode(UtilPrepareRef::ErrorCode errorCode,
15632 Uint32& error, Uint32& line,
15635 DBUG_ENTER(
"interpretUtilPrepareErrorCode");
15636 switch (errorCode) {
15637 case UtilPrepareRef::NO_ERROR:
15642 case UtilPrepareRef::PREPARE_SEIZE_ERROR:
15647 case UtilPrepareRef::PREPARE_PAGES_SEIZE_ERROR:
15652 case UtilPrepareRef::PREPARED_OPERATION_SEIZE_ERROR:
15657 case UtilPrepareRef::DICT_TAB_INFO_ERROR:
15662 case UtilPrepareRef::MISSING_PROPERTIES_SECTION:
15677 Dbdict::createEventUTIL_PREPARE(
Signal* signal,
15678 Uint32 callbackData,
15683 if (returnCode == 0) {
15685 OpCreateEventPtr evntRecPtr;
15687 evntRecPtr.i = req->getSenderData();
15688 const Uint32 prepareId = req->getPrepareId();
15690 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
15692 Callback c = { safe_cast(&Dbdict::createEventUTIL_EXECUTE), 0 };
15694 switch (evntRecPtr.p->m_requestType) {
15695 case CreateEvntReq::RT_USER_GET:
15697 executeTransEventSysTable(&c, signal,
15698 evntRecPtr.i, evntRecPtr.p->m_eventRec,
15699 prepareId, UtilPrepareReq::Read);
15701 case CreateEvntReq::RT_USER_CREATE:
15703 evntRecPtr.p->m_eventRec.EVENT_TYPE =
15704 evntRecPtr.p->m_request.getEventType() | evntRecPtr.p->m_request.getReportFlags();
15705 evntRecPtr.p->m_eventRec.TABLEID = evntRecPtr.p->m_request.getTableId();
15706 evntRecPtr.p->m_eventRec.TABLEVERSION=evntRecPtr.p->m_request.getTableVersion();
15707 evntRecPtr.p->m_eventRec.SUBID = evntRecPtr.p->m_request.getEventId();
15708 evntRecPtr.p->m_eventRec.SUBKEY = evntRecPtr.p->m_request.getEventKey();
15710 (
"CREATE: event name: %s table name: %s table id: %u table version: %u",
15711 evntRecPtr.p->m_eventRec.NAME,
15712 evntRecPtr.p->m_eventRec.TABLE_NAME,
15713 evntRecPtr.p->m_eventRec.TABLEID,
15714 evntRecPtr.p->m_eventRec.TABLEVERSION));
15718 executeTransEventSysTable(&c, signal,
15719 evntRecPtr.i, evntRecPtr.p->m_eventRec,
15720 prepareId, UtilPrepareReq::Insert);
15724 printf(
"type = %d\n", evntRecPtr.p->m_requestType);
15725 printf(
"bet type = %d\n", CreateEvntReq::RT_USER_GET);
15726 printf(
"create type = %d\n", CreateEvntReq::RT_USER_CREATE);
15733 const UtilPrepareRef::ErrorCode errorCode =
15734 (UtilPrepareRef::ErrorCode)ref->getErrorCode();
15736 OpCreateEventPtr evntRecPtr;
15737 evntRecPtr.i = ref->getSenderData();
15738 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
15740 interpretUtilPrepareErrorCode(errorCode, evntRecPtr.p->m_errorCode,
15741 evntRecPtr.p->m_errorLine,
this);
15742 evntRecPtr.p->m_errorNode = reference();
15744 createEvent_sendReply(signal, evntRecPtr);
15750 countPrefixBytes(Uint32 len,
const Uint8 * mask)
15752 while (len && mask[len - 1] == 0)
15757 void Dbdict::executeTransEventSysTable(Callback *pcallback,
Signal *signal,
15760 const Uint32 prepareId,
15761 UtilPrepareReq::OperationTypeValue prepReq)
15765 DictObject * opj_ptr_p = get_object(EVENT_SYSTEM_TABLE_NAME,
15766 sizeof(EVENT_SYSTEM_TABLE_NAME));
15768 ndbrequire(opj_ptr_p != 0);
15769 TableRecordPtr tablePtr;
15770 c_tableRecordPool.
getPtr(tablePtr, opj_ptr_p->m_id);
15771 ndbrequire(tablePtr.i != RNIL);
15773 Uint32 noAttr = tablePtr.p->noOfAttributes;
15774 if (noAttr > EVENT_SYSTEM_TABLE_LENGTH)
15777 noAttr = EVENT_SYSTEM_TABLE_LENGTH;
15780 Uint32 total_len = 0;
15782 Uint32* attrHdr = signal->theData + 25;
15783 Uint32* attrPtr = attrHdr;
15784 Uint32* dataPtr = attrHdr + noAttr;
15789 char *base = (
char*)&m_eventRec;
15790 Uint32 sz = sysTab_NDBEVENTS_0_szs[
id];
15791 const Uint32 *src = (
const Uint32*)(base +sysTab_NDBEVENTS_0_offsets[
id]);
15792 memcpy(dataPtr, src, sz);
15793 dataPtr += (sz / 4);
15801 case UtilPrepareReq::Read:
15806 bzero(m_eventRec.ATTRIBUTE_MASK2,
sizeof(m_eventRec.ATTRIBUTE_MASK2));
15809 while (
id < noAttr )
15811 ndbrequire(
id == noAttr);
15813 case UtilPrepareReq::Insert:
15817 char *base = (
char*)&m_eventRec;
15818 while (
id < noAttr )
15820 if (
id != EVENT_SYSTEM_TABLE_ATTRIBUTE_MASK2_ID)
15823 Uint32 sz = sysTab_NDBEVENTS_0_szs[
id];
15825 const Uint32 *src = (
const Uint32*)(base +sysTab_NDBEVENTS_0_offsets[
id]);
15826 memcpy(dataPtr, src, sz);
15827 dataPtr += (sz / 4);
15828 total_len += sysTab_NDBEVENTS_0_szs[
id];
15833 Uint32 szBytes = countPrefixBytes(
sizeof(m_eventRec.ATTRIBUTE_MASK2) - 4,
15834 (Uint8*)m_eventRec.ATTRIBUTE_MASK2);
15837 Uint8 * lenbytes = (Uint8*)dataPtr;
15838 lenbytes[0] = (szBytes & 0xFF);
15839 lenbytes[1] = (szBytes / 256);
15840 memcpy(lenbytes + 2, m_eventRec.ATTRIBUTE_MASK2, szBytes);
15843 bzero(lenbytes + 2 + szBytes, 4 - (szBytes & 3));
15846 dataPtr += (szBytes + 3) / 4;
15847 total_len += 4 * ((szBytes + 3) / 4);
15853 case UtilPrepareReq::Delete:
15854 ndbrequire(
id == 1);
15863 headerPtr.p = attrHdr;
15866 lsdataPtr.p = attrHdr + noAttr;
15867 lsdataPtr.sz = total_len/4;
15870 printf(
"Header size %u\n", headerPtr.sz);
15871 for(
int i = 0; i < (int)headerPtr.sz; i++)
15872 printf(
"H'%.8x ", attrHdr[i]);
15875 printf(
"Data size %u\n", lsdataPtr.sz);
15876 for(
int i = 0; i < (int)lsdataPtr.sz; i++)
15877 printf(
"H'%.8x ", dataPage[i]);
15881 executeTransaction(pcallback, signal,
15889 void Dbdict::executeTransaction(Callback *pcallback,
15903 utilExecuteReq->setSenderRef(reference());
15904 utilExecuteReq->setSenderData(senderData);
15905 utilExecuteReq->setPrepareId(prepareId);
15906 utilExecuteReq->setReleaseFlag();
15909 printf(
"Header size %u\n", headerPtr.sz);
15910 for(
int i = 0; i < (int)headerPtr.sz; i++)
15911 printf(
"H'%.8x ", headerBuffer[i]);
15914 printf(
"Data size %u\n", dataPtr.sz);
15915 for(
int i = 0; i < (int)dataPtr.sz; i++)
15916 printf(
"H'%.8x ", dataBuffer[i]);
15921 sectionsPtr[UtilExecuteReq::HEADER_SECTION].p = headerPtr.p;
15922 sectionsPtr[UtilExecuteReq::HEADER_SECTION].sz = noAttr;
15923 sectionsPtr[UtilExecuteReq::DATA_SECTION].p = dataPtr.p;
15924 sectionsPtr[UtilExecuteReq::DATA_SECTION].sz = dataPtr.sz;
15926 sendSignalUtilReq(pcallback, DBUTIL_REF, GSN_UTIL_EXECUTE_REQ, signal,
15927 UtilExecuteReq::SignalLength, JBB,
15928 sectionsPtr, UtilExecuteReq::NoOfSections);
15931 void Dbdict::parseReadEventSys(Signal* signal, sysTab_NDBEVENTS_0& m_eventRec)
15937 handle.getSection(headerPtr, UtilExecuteReq::HEADER_SECTION);
15938 SectionReader headerReader(headerPtr, getSectionSegmentPool());
15940 handle.getSection(dataPtr, UtilExecuteReq::DATA_SECTION);
15941 SectionReader dataReader(dataPtr, getSectionSegmentPool());
15943 char *base = (
char*)&m_eventRec;
15945 DictObject * opj_ptr_p = get_object(EVENT_SYSTEM_TABLE_NAME,
15946 sizeof(EVENT_SYSTEM_TABLE_NAME));
15948 ndbrequire(opj_ptr_p != 0);
15949 TableRecordPtr tablePtr;
15950 c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_id);
15951 ndbrequire(tablePtr.i != RNIL);
15953 Uint32 noAttr = tablePtr.p->noOfAttributes;
15954 if (noAttr > EVENT_SYSTEM_TABLE_LENGTH)
15957 noAttr = EVENT_SYSTEM_TABLE_LENGTH;
15960 for (Uint32 i = 0; i < noAttr; i++)
15964 headerReader.getWord(&headerWord);
15965 Uint32 sz = AttributeHeader::getDataSize(headerWord);
15966 ndbrequire(4 * sz <= sysTab_NDBEVENTS_0_szs[i]);
15967 Uint32 * dst = (Uint32*)(base + sysTab_NDBEVENTS_0_offsets[i]);
15968 for (Uint32 j = 0; j < sz; j++)
15969 dataReader.getWord(dst++);
15972 releaseSections(handle);
15974 if (noAttr < EVENT_SYSTEM_TABLE_LENGTH)
15977 bzero(m_eventRec.ATTRIBUTE_MASK2,
sizeof(m_eventRec.ATTRIBUTE_MASK2));
15978 memcpy(m_eventRec.ATTRIBUTE_MASK2, m_eventRec.ATTRIBUTE_MASK,
15979 sizeof(m_eventRec.ATTRIBUTE_MASK));
15984 Uint8* lenbytes = (Uint8*)m_eventRec.ATTRIBUTE_MASK2;
15985 Uint32 szBytes = lenbytes[0] + (lenbytes[1] * 256);
15986 memmove(lenbytes, lenbytes + 2, szBytes);
15987 bzero(lenbytes + szBytes,
sizeof(m_eventRec.ATTRIBUTE_MASK2) - szBytes);
15991 void Dbdict::createEventUTIL_EXECUTE(
Signal *signal,
15992 Uint32 callbackData,
15997 if (returnCode == 0) {
16001 OpCreateEventPtr evntRecPtr;
16002 evntRecPtr.i = conf->getSenderData();
16004 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
16005 OpCreateEvent *evntRec = evntRecPtr.p;
16007 switch (evntRec->m_requestType) {
16008 case CreateEvntReq::RT_USER_GET: {
16009 parseReadEventSys(signal, evntRecPtr.p->m_eventRec);
16011 evntRec->m_request.setEventType(evntRecPtr.p->m_eventRec.EVENT_TYPE);
16012 evntRec->m_request.setReportFlags(evntRecPtr.p->m_eventRec.EVENT_TYPE);
16013 evntRec->m_request.setTableId(evntRecPtr.p->m_eventRec.TABLEID);
16014 evntRec->m_request.setTableVersion(evntRecPtr.p->m_eventRec.TABLEVERSION);
16015 Uint32 sz = NDB_ARRAY_SIZE(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK);
16016 evntRec->m_request.setAttrListBitmask(sz, evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK);
16017 evntRec->m_request.setEventId(evntRecPtr.p->m_eventRec.SUBID);
16018 evntRec->m_request.setEventKey(evntRecPtr.p->m_eventRec.SUBKEY);
16021 (
"GET: event name: %s table name: %s table id: %u table version: %u",
16022 evntRecPtr.p->m_eventRec.NAME,
16023 evntRecPtr.p->m_eventRec.TABLE_NAME,
16024 evntRecPtr.p->m_eventRec.TABLEID,
16025 evntRecPtr.p->m_eventRec.TABLEVERSION));
16028 DictObject* obj_ptr_p = get_object(evntRecPtr.p->m_eventRec.TABLE_NAME);
16031 evntRecPtr.p->m_errorCode = 723;
16032 evntRecPtr.p->m_errorLine = __LINE__;
16033 evntRecPtr.p->m_errorNode = reference();
16035 createEvent_sendReply(signal, evntRecPtr);
16039 TableRecordPtr tablePtr;
16040 c_tableRecordPool.
getPtr(tablePtr, obj_ptr_p->m_id);
16041 evntRec->m_request.setTableId(tablePtr.p->tableId);
16042 evntRec->m_request.setTableVersion(tablePtr.p->tableVersion);
16044 createEventComplete_RT_USER_GET(signal, evntRecPtr);
16047 case CreateEvntReq::RT_USER_CREATE: {
16049 printf(
"create type = %d\n", CreateEvntReq::RT_USER_CREATE);
16052 createEventComplete_RT_USER_CREATE(signal, evntRecPtr);
16061 OpCreateEventPtr evntRecPtr;
16062 evntRecPtr.i = ref->getSenderData();
16063 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
16065 evntRecPtr.p->m_errorNode = reference();
16066 evntRecPtr.p->m_errorLine = __LINE__;
16068 switch (ref->getErrorCode()) {
16069 case UtilExecuteRef::TCError:
16070 switch (ref->getTCErrorCode()) {
16073 evntRecPtr.p->m_errorCode = 4710;
16075 case ZALREADYEXIST:
16077 evntRecPtr.p->m_errorCode = 746;
16081 evntRecPtr.p->m_errorCode = ref->getTCErrorCode();
16087 evntRecPtr.p->m_errorCode = ref->getErrorCode();
16091 createEvent_sendReply(signal, evntRecPtr);
16102 Dbdict::createEvent_RT_USER_GET(
Signal* signal,
16103 OpCreateEventPtr evntRecPtr,
16107 #ifdef EVENT_PH2_DEBUG
16108 ndbout_c(
"DBDICT(Coordinator) got GSN_CREATE_EVNT_REQ::RT_USER_GET evntRecPtr.i = (%d), ref = %u", evntRecPtr.i, evntRecPtr.p->m_request.getUserRef());
16113 handle.getSection(ssPtr, 0);
16117 r0.printAll(ndbout);
16119 if ((!r0.first()) ||
16120 (r0.getValueType() != SimpleProperties::StringValue) ||
16121 (r0.getValueLen() <= 0)) {
16123 releaseSections(handle);
16125 evntRecPtr.p->m_errorCode = 1;
16126 evntRecPtr.p->m_errorLine = __LINE__;
16127 evntRecPtr.p->m_errorNode = reference();
16129 createEvent_sendReply(signal, evntRecPtr);
16133 r0.getString(evntRecPtr.p->m_eventRec.NAME);
16134 int len = strlen(evntRecPtr.p->m_eventRec.NAME);
16135 memset(evntRecPtr.p->m_eventRec.NAME+len, 0, MAX_TAB_NAME_SIZE-len);
16137 releaseSections(handle);
16139 Callback c = { safe_cast(&Dbdict::createEventUTIL_PREPARE), 0 };
16141 prepareTransactionEventSysTable(&c, signal, evntRecPtr.i,
16142 UtilPrepareReq::Read);
16150 Dbdict::createEventComplete_RT_USER_GET(
Signal* signal,
16151 OpCreateEventPtr evntRecPtr){
16157 *req = evntRecPtr.p->m_request;
16158 req->senderRef = reference();
16159 req->senderData = evntRecPtr.i;
16161 req->addRequestFlag(CreateEvntReq::RT_DICT_AFTER_GET);
16163 #ifdef EVENT_PH2_DEBUG
16164 ndbout_c(
"DBDICT(Coordinator) sending GSN_CREATE_EVNT_REQ::RT_DICT_AFTER_GET to DBDICT participants evntRecPtr.i = (%d)", evntRecPtr.i);
16169 if (!p.init<
CreateEvntRef>(c_counterMgr, rg, GSN_CREATE_EVNT_REF,
16173 evntRecPtr.p->m_errorCode = 701;
16174 createEvent_sendReply(signal, evntRecPtr);
16178 sendSignal(rg, GSN_CREATE_EVNT_REQ, signal, CreateEvntReq::SignalLength, JBB);
16183 Dbdict::createEvent_nodeFailCallback(
Signal* signal, Uint32 eventRecPtrI,
16184 Uint32 returnCode){
16185 OpCreateEventPtr evntRecPtr;
16186 c_opCreateEvent.
getPtr(evntRecPtr, eventRecPtrI);
16187 createEvent_sendReply(signal, evntRecPtr);
16190 void Dbdict::execCREATE_EVNT_REF(
Signal* signal)
16195 OpCreateEventPtr evntRecPtr;
16197 evntRecPtr.i = ref->getUserData();
16198 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
16200 #ifdef EVENT_PH2_DEBUG
16201 ndbout_c(
"DBDICT(Coordinator) got GSN_CREATE_EVNT_REF evntRecPtr.i = (%d)", evntRecPtr.i);
16208 if (ref->errorCode == CreateEvntRef::NF_FakeErrorREF)
16211 evntRecPtr.p->m_reqTracker.ignoreRef(c_counterMgr,
16212 refToNode(ref->senderRef));
16219 if (evntRecPtr.p->m_reqTracker.done())
16227 ptr[0].p = (Uint32 *)evntRecPtr.p->m_eventRec.TABLE_NAME;
16228 ptr[0].sz = Uint32((strlen(evntRecPtr.p->m_eventRec.TABLE_NAME)+4)/4);
16229 ptr[1].p = evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2;
16230 ptr[1].sz = NDB_ARRAY_SIZE(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2) - 1;
16238 evntRecPtr.p->m_errorCode = ref->errorCode;
16239 evntRecPtr.p->m_reqTracker.reportRef(c_counterMgr,
16240 refToNode(ref->senderRef));
16243 createEvent_sendReply(signal, evntRecPtr, ptr0, noLSP);
16248 void Dbdict::execCREATE_EVNT_CONF(
Signal* signal)
16253 OpCreateEventPtr evntRecPtr;
16255 evntRecPtr.i = conf->getUserData();
16257 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
16259 #ifdef EVENT_PH2_DEBUG
16260 ndbout_c(
"DBDICT(Coordinator) got GSN_CREATE_EVNT_CONF evntRecPtr.i = (%d)", evntRecPtr.i);
16263 evntRecPtr.p->m_reqTracker.reportConf(c_counterMgr, refToNode(conf->senderRef));
16268 ptr[0].p = (Uint32 *)evntRecPtr.p->m_eventRec.TABLE_NAME;
16270 Uint32(strlen(evntRecPtr.p->m_eventRec.TABLE_NAME)+4)/4;
16271 ptr[1].p = evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2;
16272 ptr[1].sz = NDB_ARRAY_SIZE(evntRecPtr.p->m_eventRec.ATTRIBUTE_MASK2) - 1;
16274 createEvent_sendReply(signal, evntRecPtr, ptr, 2);
16286 Dbdict::createEvent_RT_DICT_AFTER_GET(
Signal* signal, OpCreateEventPtr evntRecPtr){
16287 DBUG_ENTER(
"Dbdict::createEvent_RT_DICT_AFTER_GET");
16289 evntRecPtr.p->m_request.setUserRef(signal->senderBlockRef());
16291 #ifdef EVENT_PH2_DEBUG
16292 ndbout_c(
"DBDICT(Participant) got CREATE_EVNT_REQ::RT_DICT_AFTER_GET evntRecPtr.i = (%d)", evntRecPtr.i);
16301 CRASH_INSERTION2(6009, getOwnNodeId() != c_masterNodeId);
16305 sumaReq->senderRef = reference();
16306 sumaReq->senderData = evntRecPtr.i;
16307 sumaReq->subscriptionId = evntRecPtr.p->m_request.getEventId();
16308 sumaReq->subscriptionKey = evntRecPtr.p->m_request.getEventKey();
16309 sumaReq->subscriptionType = SubCreateReq::TableEvent;
16310 if (evntRecPtr.p->m_request.getReportAll())
16311 sumaReq->subscriptionType|= SubCreateReq::ReportAll;
16312 if (evntRecPtr.p->m_request.getReportSubscribe())
16313 sumaReq->subscriptionType|= SubCreateReq::ReportSubscribe;
16314 if (! evntRecPtr.p->m_request.getReportDDL())
16316 sumaReq->subscriptionType |= SubCreateReq::NoReportDDL;
16318 sumaReq->tableId = evntRecPtr.p->m_request.getTableId();
16319 sumaReq->schemaTransId = 0;
16321 #ifdef EVENT_PH2_DEBUG
16322 ndbout_c(
"sending GSN_SUB_CREATE_REQ");
16325 sendSignal(SUMA_REF, GSN_SUB_CREATE_REQ, signal,
16326 SubCreateReq::SignalLength, JBB);
16330 void Dbdict::execSUB_CREATE_REF(
Signal* signal)
16333 DBUG_ENTER(
"Dbdict::execSUB_CREATE_REF");
16336 OpCreateEventPtr evntRecPtr;
16338 evntRecPtr.i = ref->senderData;
16339 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
16341 if (ref->errorCode == SubCreateRef::NotStarted)
16348 else if (ref->errorCode)
16351 evntRecPtr.p->m_errorCode = ref->errorCode;
16352 evntRecPtr.p->m_errorLine = __LINE__;
16353 evntRecPtr.p->m_errorNode = reference();
16358 evntRecPtr.p->m_errorCode = 1;
16359 evntRecPtr.p->m_errorLine = __LINE__;
16360 evntRecPtr.p->m_errorNode = reference();
16363 createEvent_sendReply(signal, evntRecPtr);
16367 void Dbdict::execSUB_CREATE_CONF(
Signal* signal)
16370 DBUG_ENTER(
"Dbdict::execSUB_CREATE_CONF");
16374 OpCreateEventPtr evntRecPtr;
16375 evntRecPtr.i = sumaConf->senderData;
16376 ndbrequire((evntRecPtr.p = c_opCreateEvent.
getPtr(evntRecPtr.i)) != NULL);
16378 createEvent_sendReply(signal, evntRecPtr);
16389 void Dbdict::createEvent_sendReply(
Signal* signal,
16390 OpCreateEventPtr evntRecPtr,
16399 if (!evntRecPtr.p->m_reqTracker.done()) {
16404 if (evntRecPtr.p->m_reqTracker.hasRef()) {
16406 if (!evntRecPtr.p->hasError()) {
16407 evntRecPtr.p->m_errorCode = 1;
16408 evntRecPtr.p->m_errorLine = __LINE__;
16409 evntRecPtr.p->m_errorNode = reference();
16417 Uint32 senderRef = evntRecPtr.p->m_request.getUserRef();
16418 Uint32 signalLength;
16421 if (evntRecPtr.p->hasError()) {
16426 ret->setEventId(evntRecPtr.p->m_request.getEventId());
16427 ret->setEventKey(evntRecPtr.p->m_request.getEventKey());
16428 ret->setUserData(evntRecPtr.p->m_request.getUserData());
16429 ret->senderRef = reference();
16430 ret->setTableId(evntRecPtr.p->m_request.getTableId());
16431 ret->setTableVersion(evntRecPtr.p->m_request.getTableVersion());
16432 ret->setEventType(evntRecPtr.p->m_request.getEventType());
16433 ret->setRequestType(evntRecPtr.p->m_request.getRequestType());
16435 ret->setErrorCode(evntRecPtr.p->m_errorCode);
16436 ret->setErrorLine(evntRecPtr.p->m_errorLine);
16437 ret->setErrorNode(evntRecPtr.p->m_errorNode);
16439 signalLength = CreateEvntRef::SignalLength;
16440 #ifdef EVENT_PH2_DEBUG
16441 ndbout_c(
"DBDICT sending GSN_CREATE_EVNT_REF to evntRecPtr.i = (%d) node = %u ref = %u", evntRecPtr.i, refToNode(senderRef), senderRef);
16442 ndbout_c(
"errorCode = %u", evntRecPtr.p->m_errorCode);
16443 ndbout_c(
"errorLine = %u", evntRecPtr.p->m_errorLine);
16445 gsn = GSN_CREATE_EVNT_REF;
16452 evntConf->setEventId(evntRecPtr.p->m_request.getEventId());
16453 evntConf->setEventKey(evntRecPtr.p->m_request.getEventKey());
16454 evntConf->setUserData(evntRecPtr.p->m_request.getUserData());
16455 evntConf->senderRef = reference();
16456 evntConf->setTableId(evntRecPtr.p->m_request.getTableId());
16457 evntConf->setTableVersion(evntRecPtr.p->m_request.getTableVersion());
16458 evntConf->setAttrListBitmask(evntRecPtr.p->m_request.getAttrListBitmask());
16459 evntConf->setEventType(evntRecPtr.p->m_request.getEventType());
16460 evntConf->setRequestType(evntRecPtr.p->m_request.getRequestType());
16462 signalLength = CreateEvntConf::SignalLength;
16463 #ifdef EVENT_PH2_DEBUG
16464 ndbout_c(
"DBDICT sending GSN_CREATE_EVNT_CONF to evntRecPtr.i = (%d) node = %u ref = %u", evntRecPtr.i, refToNode(senderRef), senderRef);
16466 gsn = GSN_CREATE_EVNT_CONF;
16471 sendSignal(senderRef, gsn, signal, signalLength, JBB, ptr, noLSP);
16474 sendSignal(senderRef, gsn, signal, signalLength, JBB);
16477 c_opCreateEvent.
release(evntRecPtr);
16488 void Dbdict::execSUB_START_REQ(
Signal* signal)
16492 Uint32 origSenderRef = signal->senderBlockRef();
16494 if (refToBlock(origSenderRef) != DBDICT &&
16495 getOwnNodeId() != c_masterNodeId)
16501 ref->senderRef = reference();
16502 ref->errorCode = SubStartRef::NotMaster;
16503 ref->m_masterNodeId = c_masterNodeId;
16504 sendSignal(origSenderRef, GSN_SUB_START_REF, signal,
16505 SubStartRef::SignalLength2, JBB);
16508 OpSubEventPtr subbPtr;
16509 Uint32 errCode = 0;
16511 if (!c_opSubEvent.
seize(subbPtr)) {
16512 errCode = SubStartRef::Busy;
16518 Uint32 subcriberRef = ((
SubStartReq*)signal->getDataPtr())->subscriberRef;
16519 ref->subscriberRef = subcriberRef;
16525 ref->senderRef = reference();
16526 ref->errorCode = errCode;
16527 ref->m_masterNodeId = c_masterNodeId;
16529 sendSignal(origSenderRef, GSN_SUB_START_REF, signal,
16530 SubStartRef::SL_MasterNode, JBB);
16536 subbPtr.p->m_senderRef = req->senderRef;
16537 subbPtr.p->m_senderData = req->senderData;
16538 subbPtr.p->m_errorCode = 0;
16539 subbPtr.p->m_gsn = GSN_SUB_START_REQ;
16540 subbPtr.p->m_subscriptionId = req->subscriptionId;
16541 subbPtr.p->m_subscriptionKey = req->subscriptionKey;
16542 subbPtr.p->m_subscriberRef = req->subscriberRef;
16543 subbPtr.p->m_subscriberData = req->subscriberData;
16544 bzero(subbPtr.p->m_buckets_per_ng,
sizeof(subbPtr.p->m_buckets_per_ng));
16547 if (refToBlock(origSenderRef) != DBDICT) {
16553 if (c_masterNodeId != getOwnNodeId())
16556 c_opSubEvent.
release(subbPtr);
16557 errCode = SubStartRef::NotMaster;
16561 if (!c_sub_startstop_lock.
isclear())
16564 c_opSubEvent.
release(subbPtr);
16565 errCode = SubStartRef::BusyWithNR;
16569 subbPtr.p->m_senderRef = origSenderRef;
16573 if (!p.init<
SubStartRef>(c_counterMgr, rg, GSN_SUB_START_REF, subbPtr.i))
16575 c_opSubEvent.
release(subbPtr);
16576 errCode = SubStartRef::Busy;
16582 req->senderRef = reference();
16583 req->senderData = subbPtr.i;
16585 #ifdef EVENT_PH3_DEBUG
16586 ndbout_c(
"DBDICT(Coordinator) sending GSN_SUB_START_REQ to DBDICT participants subbPtr.i = (%d)", subbPtr.i);
16589 if (ERROR_INSERTED(6011))
16591 ndbout_c(
"sending delayed to self...");
16592 if (ERROR_INSERTED(6011))
16594 rg.m_nodes.clear(getOwnNodeId());
16596 sendSignal(rg, GSN_SUB_START_REQ, signal,
16597 SubStartReq::SignalLength, JBB);
16598 sendSignalWithDelay(reference(),
16600 signal, 5000, SubStartReq::SignalLength);
16604 c_outstanding_sub_startstop++;
16605 sendSignal(rg, GSN_SUB_START_REQ, signal,
16606 SubStartReq::SignalLength, JBB);
16613 ndbrequire(refToBlock(origSenderRef) == DBDICT);
16615 CRASH_INSERTION(6007);
16620 req->senderRef = reference();
16621 req->senderData = subbPtr.i;
16623 #ifdef EVENT_PH3_DEBUG
16624 ndbout_c(
"DBDICT(Participant) sending GSN_SUB_START_REQ to SUMA subbPtr.i = (%d)", subbPtr.i);
16626 sendSignal(SUMA_REF, GSN_SUB_START_REQ, signal, SubStartReq::SignalLength, JBB);
16631 Dbdict::upgrade_suma_NotStarted(Uint32 err, Uint32 ref)
const
16640 if (!ndb_suma_not_started_ref(
getNodeInfo(refToNode(ref)).m_version))
16646 void Dbdict::execSUB_START_REF(
Signal* signal)
16651 Uint32 senderRef = ref->senderRef;
16652 Uint32 err = ref->errorCode;
16654 OpSubEventPtr subbPtr;
16655 c_opSubEvent.
getPtr(subbPtr, ref->senderData);
16657 if (refToBlock(senderRef) == SUMA)
16664 #ifdef EVENT_PH3_DEBUG
16665 ndbout_c(
"DBDICT(Participant) got GSN_SUB_START_REF = (%d)", subbPtr.i);
16668 if (upgrade_suma_NotStarted(err, subbPtr.p->m_senderRef))
16671 err = SubStartRef::NF_FakeErrorREF;
16675 ref->senderRef = reference();
16676 ref->senderData = subbPtr.p->m_senderData;
16677 ref->errorCode = err;
16678 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_START_REF,
16679 signal, SubStartRef::SignalLength2, JBB);
16680 c_opSubEvent.
release(subbPtr);
16686 ndbrequire(refToBlock(senderRef) == DBDICT);
16687 #ifdef EVENT_PH3_DEBUG
16688 ndbout_c(
"DBDICT(Coordinator) got GSN_SUB_START_REF = (%d)", subbPtr.i);
16690 if (err == SubStartRef::NotStarted)
16693 subbPtr.p->m_reqTracker.ignoreRef(c_counterMgr, refToNode(senderRef));
16697 if (err == SubStartRef::NF_FakeErrorREF)
16700 err = SubStartRef::NodeDied;
16703 if (subbPtr.p->m_errorCode == 0)
16705 subbPtr.p->m_errorCode= err ? err : 1;
16707 subbPtr.p->m_reqTracker.reportRef(c_counterMgr, refToNode(senderRef));
16709 completeSubStartReq(signal,subbPtr.i,0);
16712 void Dbdict::execSUB_START_CONF(
Signal* signal)
16717 Uint32 senderRef = conf->senderRef;
16718 Uint32 buckets = conf->bucketCount;
16719 Uint32 nodegroup = conf->nodegroup;
16721 OpSubEventPtr subbPtr;
16722 c_opSubEvent.
getPtr(subbPtr, conf->senderData);
16724 if (refToBlock(senderRef) == SUMA) {
16731 #ifdef EVENT_PH3_DEBUG
16732 ndbout_c(
"DBDICT(Participant) got GSN_SUB_START_CONF = (%d)", subbPtr.i);
16735 conf->senderRef = reference();
16736 conf->senderData = subbPtr.p->m_senderData;
16737 conf->bucketCount = buckets;
16738 conf->nodegroup = nodegroup;
16740 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_START_CONF,
16741 signal, SubStartConf::SignalLength, JBB);
16742 c_opSubEvent.
release(subbPtr);
16748 ndbrequire(refToBlock(senderRef) == DBDICT);
16749 #ifdef EVENT_PH3_DEBUG
16750 ndbout_c(
"DBDICT(Coordinator) got GSN_SUB_START_CONF = (%d)", subbPtr.i);
16752 #define ARRAY_SIZE(x) (sizeof(x)/(sizeof(x[0])))
16757 ndbrequire(nodegroup < ARRAY_SIZE(subbPtr.p->m_buckets_per_ng));
16758 ndbrequire(subbPtr.p->m_buckets_per_ng[nodegroup] == 0 ||
16759 subbPtr.p->m_buckets_per_ng[nodegroup] == buckets);
16760 subbPtr.p->m_buckets_per_ng[nodegroup] = buckets;
16762 subbPtr.p->m_sub_start_conf = *conf;
16763 subbPtr.p->m_reqTracker.reportConf(c_counterMgr, refToNode(senderRef));
16764 completeSubStartReq(signal,subbPtr.i,0);
16770 void Dbdict::completeSubStartReq(
Signal* signal,
16772 Uint32 returnCode){
16775 OpSubEventPtr subbPtr;
16776 c_opSubEvent.
getPtr(subbPtr, ptrI);
16778 if (!subbPtr.p->m_reqTracker.done()){
16783 if (subbPtr.p->m_reqTracker.hasRef())
16787 ndbout_c(
"SUB_START_REF");
16790 if (subbPtr.p->m_reqTracker.hasConf())
16795 ndbrequire(p.init<
SubStopRef>(c_counterMgr, rg, GSN_SUB_STOP_REF,
16800 req->senderRef = reference();
16801 req->senderData = subbPtr.i;
16802 req->subscriptionId = subbPtr.p->m_subscriptionId;
16803 req->subscriptionKey = subbPtr.p->m_subscriptionKey;
16804 req->subscriberRef = subbPtr.p->m_subscriberRef;
16805 req->subscriberData = subbPtr.p->m_subscriberData;
16806 req->requestInfo = SubStopReq::RI_ABORT_START;
16807 sendSignal(rg, GSN_SUB_STOP_REQ, signal, SubStopReq::SignalLength, JBB);
16813 completeSubStopReq(signal, subbPtr.i, 0);
16818 ndbout_c(
"SUB_START_CONF");
16821 ndbrequire(c_outstanding_sub_startstop);
16822 c_outstanding_sub_startstop--;
16824 * conf = subbPtr.p->m_sub_start_conf;
16827 for (Uint32 i = 0; i<ARRAY_SIZE(subbPtr.p->m_buckets_per_ng); i++)
16828 cnt += subbPtr.p->m_buckets_per_ng[i];
16829 conf->bucketCount = cnt;
16831 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_START_CONF,
16832 signal, SubStartConf::SignalLength, JBB);
16833 c_opSubEvent.
release(subbPtr);
16842 void Dbdict::execSUB_STOP_REQ(
Signal* signal)
16846 Uint32 origSenderRef = signal->senderBlockRef();
16848 OpSubEventPtr subbPtr;
16849 Uint32 errCode = 0;
16850 if (!c_opSubEvent.
seize(subbPtr)) {
16851 errCode = SubStopRef::Busy;
16858 ref->senderRef = reference();
16859 ref->errorCode = errCode;
16860 ref->m_masterNodeId = c_masterNodeId;
16862 sendSignal(origSenderRef, GSN_SUB_STOP_REF, signal,
16863 SubStopRef::SL_MasterNode, JBB);
16869 subbPtr.p->m_senderRef = req->senderRef;
16870 subbPtr.p->m_senderData = req->senderData;
16871 subbPtr.p->m_errorCode = 0;
16872 subbPtr.p->m_gsn = GSN_SUB_STOP_REQ;
16873 subbPtr.p->m_subscriptionId = req->subscriptionId;
16874 subbPtr.p->m_subscriptionKey = req->subscriptionKey;
16875 subbPtr.p->m_subscriberRef = req->subscriberRef;
16876 subbPtr.p->m_subscriberData = req->subscriberData;
16877 bzero(&subbPtr.p->m_sub_stop_conf,
sizeof(subbPtr.p->m_sub_stop_conf));
16879 if (signal->getLength() < SubStopReq::SignalLength)
16882 req->requestInfo = 0;
16886 if (refToBlock(origSenderRef) != DBDICT) {
16892 if (c_masterNodeId != getOwnNodeId())
16895 c_opSubEvent.
release(subbPtr);
16896 errCode = SubStopRef::NotMaster;
16900 if (!c_sub_startstop_lock.
isclear())
16903 c_opSubEvent.
release(subbPtr);
16904 errCode = SubStopRef::BusyWithNR;
16909 ndbout_c(
"SUB_STOP_REQ 1");
16911 subbPtr.p->m_senderRef = origSenderRef;
16914 if (!p.init<
SubStopRef>(c_counterMgr, rg, GSN_SUB_STOP_REF, subbPtr.i))
16917 c_opSubEvent.
release(subbPtr);
16918 errCode = SubStopRef::Busy;
16924 req->senderRef = reference();
16925 req->senderData = subbPtr.i;
16927 c_outstanding_sub_startstop++;
16928 sendSignal(rg, GSN_SUB_STOP_REQ, signal, SubStopReq::SignalLength, JBB);
16935 ndbout_c(
"SUB_STOP_REQ 2");
16937 ndbrequire(refToBlock(origSenderRef) == DBDICT);
16939 CRASH_INSERTION(6008);
16944 req->senderRef = reference();
16945 req->senderData = subbPtr.i;
16947 sendSignal(SUMA_REF, GSN_SUB_STOP_REQ, signal, SubStopReq::SignalLength, JBB);
16951 void Dbdict::execSUB_STOP_REF(
Signal* signal)
16955 Uint32 senderRef = ref->senderRef;
16956 Uint32 err = ref->errorCode;
16958 OpSubEventPtr subbPtr;
16959 c_opSubEvent.
getPtr(subbPtr, ref->senderData);
16961 if (refToBlock(senderRef) == SUMA)
16968 if (upgrade_suma_NotStarted(err, subbPtr.p->m_senderRef))
16971 err = SubStopRef::NF_FakeErrorREF;
16975 ref->senderRef = reference();
16976 ref->senderData = subbPtr.p->m_senderData;
16977 ref->errorCode = err;
16978 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_STOP_REF,
16979 signal, SubStopRef::SignalLength, JBB);
16980 c_opSubEvent.
release(subbPtr);
16986 ndbrequire(refToBlock(senderRef) == DBDICT);
16987 if (err == SubStopRef::NF_FakeErrorREF || err == SubStopRef::NotStarted)
16990 subbPtr.p->m_reqTracker.ignoreRef(c_counterMgr, refToNode(senderRef));
16995 if (subbPtr.p->m_errorCode == 0)
16997 subbPtr.p->m_errorCode= err ? err : 1;
16999 subbPtr.p->m_reqTracker.reportRef(c_counterMgr, refToNode(senderRef));
17001 completeSubStopReq(signal,subbPtr.i,0);
17004 void Dbdict::execSUB_STOP_CONF(
Signal* signal)
17009 Uint32 senderRef = conf->senderRef;
17011 OpSubEventPtr subbPtr;
17012 c_opSubEvent.
getPtr(subbPtr, conf->senderData);
17014 if (refToBlock(senderRef) == SUMA) {
17021 conf->senderRef = reference();
17022 conf->senderData = subbPtr.p->m_senderData;
17024 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_STOP_CONF,
17025 signal, SubStopConf::SignalLength, JBB);
17026 c_opSubEvent.
release(subbPtr);
17032 ndbrequire(refToBlock(senderRef) == DBDICT);
17033 Uint64 old_gci, new_gci = 0;
17035 Uint32 old_gci_hi = subbPtr.p->m_sub_stop_conf.gci_hi;
17036 Uint32 old_gci_lo = subbPtr.p->m_sub_stop_conf.gci_lo;
17037 old_gci = old_gci_lo | (Uint64(old_gci_hi) << 32);
17038 if (signal->getLength() >= SubStopConf::SignalLengthWithGci)
17040 Uint32 new_gci_hi = conf->gci_hi;
17041 Uint32 new_gci_lo = conf->gci_lo;
17042 new_gci = new_gci_lo | (Uint64(new_gci_hi) << 32);
17045 subbPtr.p->m_sub_stop_conf = *conf;
17046 if (old_gci > new_gci)
17048 subbPtr.p->m_sub_stop_conf.gci_hi= Uint32(old_gci>>32);
17049 subbPtr.p->m_sub_stop_conf.gci_lo= Uint32(old_gci);
17051 subbPtr.p->m_reqTracker.reportConf(c_counterMgr, refToNode(senderRef));
17052 completeSubStopReq(signal,subbPtr.i,0);
17058 void Dbdict::completeSubStopReq(
Signal* signal,
17060 Uint32 returnCode){
17061 OpSubEventPtr subbPtr;
17062 c_opSubEvent.
getPtr(subbPtr, ptrI);
17064 if (!subbPtr.p->m_reqTracker.done()){
17069 ndbrequire(c_outstanding_sub_startstop);
17070 c_outstanding_sub_startstop--;
17072 if (subbPtr.p->m_gsn == GSN_SUB_START_REQ)
17076 ref->senderRef = reference();
17077 ref->senderData = subbPtr.p->m_senderData;
17078 ref->errorCode = subbPtr.p->m_errorCode;
17080 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_START_REF,
17081 signal, SubStartRef::SignalLength, JBB);
17082 c_opSubEvent.
release(subbPtr);
17086 if (subbPtr.p->m_reqTracker.hasRef()) {
17089 ndbout_c(
"SUB_STOP_REF");
17093 ref->senderRef = reference();
17094 ref->senderData = subbPtr.p->m_senderData;
17095 ref->errorCode = subbPtr.p->m_errorCode;
17097 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_STOP_REF,
17098 signal, SubStopRef::SignalLength, JBB);
17099 if (subbPtr.p->m_reqTracker.hasConf()) {
17102 c_opSubEvent.
release(subbPtr);
17106 ndbout_c(
"SUB_STOP_CONF");
17109 * conf = subbPtr.p->m_sub_stop_conf;
17110 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_STOP_CONF,
17111 signal, SubStopConf::SignalLength, JBB);
17112 c_opSubEvent.
release(subbPtr);
17124 Dbdict::execDROP_EVNT_REQ(
Signal* signal)
17127 DBUG_ENTER(
"Dbdict::execDROP_EVNT_REQ");
17130 const Uint32 senderRef = signal->senderBlockRef();
17131 OpDropEventPtr evntRecPtr;
17134 if (refToBlock(senderRef) != DBDICT &&
17135 getOwnNodeId() != c_masterNodeId)
17138 releaseSections(handle);
17141 ref->setUserRef(reference());
17142 ref->setErrorCode(DropEvntRef::NotMaster);
17143 ref->setErrorLine(__LINE__);
17144 ref->setErrorNode(reference());
17145 ref->setMasterNode(c_masterNodeId);
17146 sendSignal(senderRef, GSN_DROP_EVNT_REF, signal,
17147 DropEvntRef::SignalLength2, JBB);
17152 if (!c_opDropEvent.
seize(evntRecPtr)) {
17155 releaseSections(handle);
17158 ret->setErrorCode(747);
17159 ret->setErrorLine(__LINE__);
17160 ret->setErrorNode(reference());
17161 sendSignal(senderRef, GSN_DROP_EVNT_REF, signal,
17162 DropEvntRef::SignalLength, JBB);
17167 ndbout_c(
"DBDICT::execDROP_EVNT_REQ evntRecId = (%d)", evntRecPtr.i);
17170 OpDropEvent* evntRec = evntRecPtr.p;
17171 evntRec->init(req);
17175 handle.getSection(ssPtr, 0);
17179 r0.printAll(ndbout);
17182 if ((!r0.first()) ||
17183 (r0.getValueType() != SimpleProperties::StringValue) ||
17184 (r0.getValueLen() <= 0)) {
17186 releaseSections(handle);
17188 evntRecPtr.p->m_errorCode = 1;
17189 evntRecPtr.p->m_errorLine = __LINE__;
17190 evntRecPtr.p->m_errorNode = reference();
17192 dropEvent_sendReply(signal, evntRecPtr);
17195 r0.getString(evntRecPtr.p->m_eventRec.NAME);
17197 int len = strlen(evntRecPtr.p->m_eventRec.NAME);
17198 memset(evntRecPtr.p->m_eventRec.NAME+len, 0, MAX_TAB_NAME_SIZE-len);
17200 printf(
"DropEvntReq; EventName %s, len %u\n",
17201 evntRecPtr.p->m_eventRec.NAME, len);
17202 for(
int i = 0; i < MAX_TAB_NAME_SIZE/4; i++)
17203 printf(
"H'%.8x ", ((Uint32*)evntRecPtr.p->m_eventRec.NAME)[i]);
17208 releaseSections(handle);
17210 Callback c = { safe_cast(&Dbdict::dropEventUTIL_PREPARE_READ), 0 };
17212 prepareTransactionEventSysTable(&c, signal, evntRecPtr.i,
17213 UtilPrepareReq::Read);
17218 Dbdict::dropEventUTIL_PREPARE_READ(
Signal* signal,
17219 Uint32 callbackData,
17224 if (returnCode != 0) {
17226 dropEventUtilPrepareRef(signal, callbackData, returnCode);
17231 OpDropEventPtr evntRecPtr;
17232 evntRecPtr.i = req->getSenderData();
17233 const Uint32 prepareId = req->getPrepareId();
17235 ndbrequire((evntRecPtr.p = c_opDropEvent.
getPtr(evntRecPtr.i)) != NULL);
17237 Callback c = { safe_cast(&Dbdict::dropEventUTIL_EXECUTE_READ), 0 };
17239 executeTransEventSysTable(&c, signal,
17240 evntRecPtr.i, evntRecPtr.p->m_eventRec,
17241 prepareId, UtilPrepareReq::Read);
17245 Dbdict::dropEventUTIL_EXECUTE_READ(
Signal* signal,
17246 Uint32 callbackData,
17251 if (returnCode != 0) {
17253 dropEventUtilExecuteRef(signal, callbackData, returnCode);
17257 OpDropEventPtr evntRecPtr;
17260 evntRecPtr.i = ref->getSenderData();
17261 ndbrequire((evntRecPtr.p = c_opDropEvent.
getPtr(evntRecPtr.i)) != NULL);
17263 parseReadEventSys(signal, evntRecPtr.p->m_eventRec);
17267 if (!p.init<
SubRemoveRef>(c_counterMgr, rg, GSN_SUB_REMOVE_REF,
17270 evntRecPtr.p->m_errorCode = 701;
17271 dropEvent_sendReply(signal, evntRecPtr);
17277 req->senderRef = reference();
17278 req->senderData = evntRecPtr.i;
17279 req->subscriptionId = evntRecPtr.p->m_eventRec.SUBID;
17280 req->subscriptionKey = evntRecPtr.p->m_eventRec.SUBKEY;
17282 sendSignal(rg, GSN_SUB_REMOVE_REQ, signal, SubRemoveReq::SignalLength, JBB);
17290 Dbdict::execSUB_REMOVE_REQ(
Signal* signal)
17293 DBUG_ENTER(
"Dbdict::execSUB_REMOVE_REQ");
17295 Uint32 origSenderRef = signal->senderBlockRef();
17297 OpSubEventPtr subbPtr;
17298 if (!c_opSubEvent.
seize(subbPtr)) {
17301 ref->senderRef = reference();
17302 ref->errorCode = SubRemoveRef::Busy;
17304 sendSignal(origSenderRef, GSN_SUB_REMOVE_REF, signal,
17305 SubRemoveRef::SignalLength, JBB);
17311 subbPtr.p->m_senderRef = req->senderRef;
17312 subbPtr.p->m_senderData = req->senderData;
17313 subbPtr.p->m_errorCode = 0;
17314 subbPtr.p->m_gsn = GSN_SUB_REMOVE_REQ;
17315 subbPtr.p->m_subscriptionId = req->subscriptionId;
17316 subbPtr.p->m_subscriptionKey = req->subscriptionKey;
17317 subbPtr.p->m_subscriberRef = RNIL;
17318 subbPtr.p->m_subscriberData = RNIL;
17321 CRASH_INSERTION2(6010, getOwnNodeId() != c_masterNodeId);
17324 req->senderRef = reference();
17325 req->senderData = subbPtr.i;
17327 sendSignal(SUMA_REF, GSN_SUB_REMOVE_REQ, signal, SubRemoveReq::SignalLength, JBB);
17336 Dbdict::execSUB_REMOVE_REF(
Signal* signal)
17339 DBUG_ENTER(
"Dbdict::execSUB_REMOVE_REF");
17342 Uint32 senderRef = ref->senderRef;
17343 Uint32 err= ref->errorCode;
17345 if (refToBlock(senderRef) == SUMA)
17351 OpSubEventPtr subbPtr;
17352 c_opSubEvent.
getPtr(subbPtr, ref->senderData);
17353 if (err == SubRemoveRef::NoSuchSubscription)
17359 conf->senderRef = reference();
17360 conf->senderData = subbPtr.p->m_senderData;
17361 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_REMOVE_CONF,
17362 signal, SubRemoveConf::SignalLength, JBB);
17368 if (upgrade_suma_NotStarted(err, subbPtr.p->m_senderRef))
17371 err = SubRemoveRef::NF_FakeErrorREF;
17375 ref->senderRef = reference();
17376 ref->senderData = subbPtr.p->m_senderData;
17377 ref->errorCode = err;
17378 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_REMOVE_REF,
17379 signal, SubRemoveRef::SignalLength, JBB);
17381 c_opSubEvent.
release(subbPtr);
17387 ndbrequire(refToBlock(senderRef) == DBDICT);
17388 OpDropEventPtr eventRecPtr;
17389 c_opDropEvent.
getPtr(eventRecPtr, ref->senderData);
17390 if (err == SubRemoveRef::NF_FakeErrorREF || err == SubRemoveRef::NotStarted)
17393 eventRecPtr.p->m_reqTracker.ignoreRef(c_counterMgr, refToNode(senderRef));
17398 if (eventRecPtr.p->m_errorCode == 0)
17400 eventRecPtr.p->m_errorCode= err ? err : 1;
17401 eventRecPtr.p->m_errorLine= __LINE__;
17402 eventRecPtr.p->m_errorNode= reference();
17404 eventRecPtr.p->m_reqTracker.reportRef(c_counterMgr, refToNode(senderRef));
17406 completeSubRemoveReq(signal,eventRecPtr.i,0);
17411 Dbdict::execSUB_REMOVE_CONF(
Signal* signal)
17415 Uint32 senderRef = conf->senderRef;
17417 if (refToBlock(senderRef) == SUMA) {
17422 OpSubEventPtr subbPtr;
17423 c_opSubEvent.
getPtr(subbPtr, conf->senderData);
17425 conf->senderRef = reference();
17426 conf->senderData = subbPtr.p->m_senderData;
17427 sendSignal(subbPtr.p->m_senderRef, GSN_SUB_REMOVE_CONF,
17428 signal, SubRemoveConf::SignalLength, JBB);
17429 c_opSubEvent.
release(subbPtr);
17435 ndbrequire(refToBlock(senderRef) == DBDICT);
17436 OpDropEventPtr eventRecPtr;
17437 c_opDropEvent.
getPtr(eventRecPtr, conf->senderData);
17438 eventRecPtr.p->m_reqTracker.reportConf(c_counterMgr, refToNode(senderRef));
17439 completeSubRemoveReq(signal,eventRecPtr.i,0);
17443 Dbdict::completeSubRemoveReq(
Signal* signal, Uint32 ptrI, Uint32 xxx)
17445 OpDropEventPtr evntRecPtr;
17446 c_opDropEvent.
getPtr(evntRecPtr, ptrI);
17448 if (!evntRecPtr.p->m_reqTracker.done()){
17453 if (evntRecPtr.p->m_reqTracker.hasRef()) {
17455 if ( evntRecPtr.p->m_errorCode == 0 )
17457 evntRecPtr.p->m_errorNode = reference();
17458 evntRecPtr.p->m_errorLine = __LINE__;
17459 evntRecPtr.p->m_errorCode = 1;
17461 dropEvent_sendReply(signal, evntRecPtr);
17465 Callback c = { safe_cast(&Dbdict::dropEventUTIL_PREPARE_DELETE), 0 };
17467 prepareTransactionEventSysTable(&c, signal, evntRecPtr.i,
17468 UtilPrepareReq::Delete);
17472 Dbdict::dropEventUTIL_PREPARE_DELETE(
Signal* signal,
17473 Uint32 callbackData,
17478 if (returnCode != 0) {
17480 dropEventUtilPrepareRef(signal, callbackData, returnCode);
17485 OpDropEventPtr evntRecPtr;
17487 evntRecPtr.i = req->getSenderData();
17488 const Uint32 prepareId = req->getPrepareId();
17490 ndbrequire((evntRecPtr.p = c_opDropEvent.
getPtr(evntRecPtr.i)) != NULL);
17492 printf(
"DropEvntUTIL_PREPARE; evntRecPtr.i len %u\n",evntRecPtr.i);
17495 Callback c = { safe_cast(&Dbdict::dropEventUTIL_EXECUTE_DELETE), 0 };
17497 executeTransEventSysTable(&c, signal,
17498 evntRecPtr.i, evntRecPtr.p->m_eventRec,
17499 prepareId, UtilPrepareReq::Delete);
17503 Dbdict::dropEventUTIL_EXECUTE_DELETE(
Signal* signal,
17504 Uint32 callbackData,
17509 if (returnCode != 0) {
17511 dropEventUtilExecuteRef(signal, callbackData, returnCode);
17515 OpDropEventPtr evntRecPtr;
17518 evntRecPtr.i = ref->getSenderData();
17519 ndbrequire((evntRecPtr.p = c_opDropEvent.
getPtr(evntRecPtr.i)) != NULL);
17521 dropEvent_sendReply(signal, evntRecPtr);
17525 Dbdict::dropEventUtilPrepareRef(
Signal* signal,
17526 Uint32 callbackData,
17532 OpDropEventPtr evntRecPtr;
17533 evntRecPtr.i = ref->getSenderData();
17534 ndbrequire((evntRecPtr.p = c_opDropEvent.
getPtr(evntRecPtr.i)) != NULL);
17536 interpretUtilPrepareErrorCode((UtilPrepareRef::ErrorCode)ref->getErrorCode(),
17537 evntRecPtr.p->m_errorCode,
17538 evntRecPtr.p->m_errorLine,
this);
17539 evntRecPtr.p->m_errorNode = reference();
17541 dropEvent_sendReply(signal, evntRecPtr);
17545 Dbdict::dropEventUtilExecuteRef(
Signal* signal,
17546 Uint32 callbackData,
17551 OpDropEventPtr evntRecPtr;
17554 evntRecPtr.i = ref->getSenderData();
17555 ndbrequire((evntRecPtr.p = c_opDropEvent.
getPtr(evntRecPtr.i)) != NULL);
17557 evntRecPtr.p->m_errorNode = reference();
17558 evntRecPtr.p->m_errorLine = __LINE__;
17560 switch (ref->getErrorCode()) {
17561 case UtilExecuteRef::TCError:
17562 switch (ref->getTCErrorCode()) {
17565 evntRecPtr.p->m_errorCode = 4710;
17569 evntRecPtr.p->m_errorCode = ref->getTCErrorCode();
17575 evntRecPtr.p->m_errorCode = ref->getErrorCode();
17578 dropEvent_sendReply(signal, evntRecPtr);
17581 void Dbdict::dropEvent_sendReply(
Signal* signal,
17582 OpDropEventPtr evntRecPtr)
17586 Uint32 senderRef = evntRecPtr.p->m_request.getUserRef();
17588 if (evntRecPtr.p->hasError()) {
17592 ret->setUserData(evntRecPtr.p->m_request.getUserData());
17593 ret->setUserRef(evntRecPtr.p->m_request.getUserRef());
17595 ret->setErrorCode(evntRecPtr.p->m_errorCode);
17596 ret->setErrorLine(evntRecPtr.p->m_errorLine);
17597 ret->setErrorNode(evntRecPtr.p->m_errorNode);
17599 sendSignal(senderRef, GSN_DROP_EVNT_REF, signal,
17600 DropEvntRef::SignalLength, JBB);
17605 evntConf->setUserData(evntRecPtr.p->m_request.getUserData());
17606 evntConf->setUserRef(evntRecPtr.p->m_request.getUserRef());
17608 sendSignal(senderRef, GSN_DROP_EVNT_CONF, signal,
17609 DropEvntConf::SignalLength, JBB);
17612 c_opDropEvent.
release(evntRecPtr);
17617 const Dbdict::OpInfo
17618 Dbdict::CreateTriggerRec::g_opInfo = {
17619 {
'C',
'T',
'r', 0 },
17620 GSN_CREATE_TRIG_IMPL_REQ,
17621 CreateTrigImplReq::SignalLength,
17623 &Dbdict::createTrigger_seize,
17624 &Dbdict::createTrigger_release,
17626 &Dbdict::createTrigger_parse,
17627 &Dbdict::createTrigger_subOps,
17628 &Dbdict::createTrigger_reply,
17630 &Dbdict::createTrigger_prepare,
17631 &Dbdict::createTrigger_commit,
17632 &Dbdict::createTrigger_complete,
17634 &Dbdict::createTrigger_abortParse,
17635 &Dbdict::createTrigger_abortPrepare
17639 Dbdict::createTrigger_seize(SchemaOpPtr op_ptr)
17641 return seizeOpRec<CreateTriggerRec>(op_ptr);
17645 Dbdict::createTrigger_release(SchemaOpPtr op_ptr)
17647 releaseOpRec<CreateTriggerRec>(op_ptr);
17651 Dbdict::execCREATE_TRIG_REQ(
Signal* signal)
17666 SchemaOpPtr op_ptr;
17667 CreateTriggerRecPtr createTriggerPtr;
17670 startClientReq(op_ptr, createTriggerPtr, req, impl_req, error);
17671 if (hasError(error)) {
17676 impl_req->tableId = req->tableId;
17677 impl_req->tableVersion = req->tableVersion;
17678 impl_req->indexId = req->indexId;
17679 impl_req->indexVersion = req->indexVersion;
17680 impl_req->triggerNo = req->triggerNo;
17681 impl_req->triggerId = req->forceTriggerId;
17682 impl_req->triggerInfo = req->triggerInfo;
17683 impl_req->receiverRef = req->receiverRef;
17685 handleClientReq(signal, op_ptr, handle);
17689 releaseSections(handle);
17693 ref->senderRef = reference();
17694 ref->clientData = req->clientData;
17695 ref->transId = req->transId;
17696 ref->tableId = req->tableId;
17697 ref->indexId = req->indexId;
17698 ref->triggerInfo = req->triggerInfo;
17699 getError(error, ref);
17701 sendSignal(req->clientRef, GSN_CREATE_TRIG_REF, signal,
17702 CreateTrigRef::SignalLength, JBB);
17708 Dbdict::createTrigger_parse(
Signal* signal,
bool master,
17709 SchemaOpPtr op_ptr,
17712 D(
"createTrigger_parse" << V(op_ptr.i) << *op_ptr.p);
17714 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
17715 CreateTriggerRecPtr createTriggerPtr;
17716 getOpRec(op_ptr, createTriggerPtr);
17720 Uint32 requestType = impl_req->requestType;
17721 switch (CreateTrigReq::getOnlineFlag(requestType)) {
17722 case CreateTrigImplReq::CreateTriggerOnline:
17724 case CreateTrigImplReq::CreateTriggerOffline:
17728 setError(error, CreateTrigRef::BadRequestType, __LINE__);
17734 const Uint32 tableId = impl_req->tableId;
17735 if (! (tableId < c_tableRecordPool.getSize()))
17738 setError(error, CreateTrigRef::InvalidTable, __LINE__);
17743 if ((err = check_read_obj(tableId, trans_ptr.p->m_transId)))
17746 setError(error, err, __LINE__);
17751 switch(CreateTrigReq::getEndpointFlag(requestType)){
17752 case CreateTrigReq::MainTrigger:
17754 createTriggerPtr.p->m_main_op =
true;
17756 case CreateTrigReq::TriggerDst:
17758 case CreateTrigReq::TriggerSrc:
17764 setError(error, CreateTrigRef::BadRequestType, __LINE__);
17767 createTriggerPtr.p->m_main_op =
false;
17768 createTrigger_parse_endpoint(signal, op_ptr, error);
17773 handle.getSection(ss_ptr, CreateTrigReq::TRIGGER_NAME_SECTION);
17778 SimpleProperties::unpack(r, &tableDesc,
17779 DictTabInfo::TableMapping,
17780 DictTabInfo::TableMappingSize,
17783 if (status != SimpleProperties::Eof ||
17784 tableDesc.TableName[0] == 0)
17788 setError(error, CreateTrigRef::InvalidName, __LINE__);
17791 const Uint32 bytesize =
sizeof(createTriggerPtr.p->m_triggerName);
17792 memcpy(createTriggerPtr.p->m_triggerName, tableDesc.TableName, bytesize);
17793 D(
"trigger " << createTriggerPtr.p->m_triggerName);
17796 if (get_object(createTriggerPtr.p->m_triggerName) != 0) {
17798 D(
"duplicate trigger name " << createTriggerPtr.p->m_triggerName);
17799 setError(error, CreateTrigRef::TriggerExists, __LINE__);
17803 TriggerRecordPtr triggerPtr;
17807 if (impl_req->triggerId == RNIL)
17810 impl_req->triggerId = getFreeTriggerRecord();
17811 if (impl_req->triggerId == RNIL)
17814 setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
17817 c_triggerRecordPool.
getPtr(triggerPtr, impl_req->triggerId);
17818 ndbrequire(triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED);
17819 D(
"master allocated triggerId " << impl_req->triggerId);
17823 if (!(impl_req->triggerId < c_triggerRecordPool.getSize()))
17826 setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
17829 c_triggerRecordPool.
getPtr(triggerPtr, impl_req->triggerId);
17830 if (triggerPtr.p->triggerState != TriggerRecord::TS_NOT_DEFINED)
17833 setError(error, CreateTrigRef::TriggerExists, __LINE__);
17836 D(
"master forced triggerId " << impl_req->triggerId);
17843 if (! (impl_req->triggerId < c_triggerRecordPool.getSize()))
17846 setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
17849 c_triggerRecordPool.
getPtr(triggerPtr, impl_req->triggerId);
17850 if (triggerPtr.p->triggerState != TriggerRecord::TS_NOT_DEFINED)
17853 setError(error, CreateTrigRef::TriggerExists, __LINE__);
17856 D(
"slave allocated triggerId " << hex << impl_req->triggerId);
17859 initialiseTriggerRecord(triggerPtr);
17861 triggerPtr.p->triggerId = impl_req->triggerId;
17862 triggerPtr.p->tableId = impl_req->tableId;
17863 triggerPtr.p->indexId = RNIL;
17864 triggerPtr.p->triggerInfo = impl_req->triggerInfo;
17865 triggerPtr.p->receiverRef = impl_req->receiverRef;
17866 triggerPtr.p->triggerState = TriggerRecord::TS_DEFINING;
17868 if (handle.m_cnt >= 2)
17872 handle.getSection(mask_ptr, CreateTrigReq::ATTRIBUTE_MASK_SECTION);
17873 if (mask_ptr.sz > triggerPtr.p->attributeMask.getSizeInWords())
17876 setError(error, CreateTrigRef::BadRequestType, __LINE__);
17879 ::copy(triggerPtr.p->attributeMask.rep.data, mask_ptr);
17880 if (mask_ptr.sz < triggerPtr.p->attributeMask.getSizeInWords())
17883 Uint32 len = triggerPtr.p->attributeMask.getSizeInWords() - mask_ptr.sz;
17884 bzero(triggerPtr.p->attributeMask.rep.data + mask_ptr.sz,
17891 setError(error, CreateTrigRef::BadRequestType, __LINE__);
17896 Rope name(c_rope_pool, triggerPtr.p->triggerName);
17897 if (!name.assign(createTriggerPtr.p->m_triggerName)) {
17899 setError(error, CreateTrigRef::OutOfStringBuffer, __LINE__);
17907 seizeDictObject(op_ptr, obj_ptr, triggerPtr.p->triggerName);
17909 obj_ptr.p->m_id = impl_req->triggerId;
17910 obj_ptr.p->m_type =
17911 TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
17912 triggerPtr.p->m_obj_ptr_i = obj_ptr.i;
17916 TriggerType::Value type =
17917 TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
17919 case TriggerType::REORG_TRIGGER:
17921 createTrigger_create_drop_trigger_operation(signal, op_ptr, error);
17922 case TriggerType::SECONDARY_INDEX:
17924 createTriggerPtr.p->m_sub_dst =
false;
17925 createTriggerPtr.p->m_sub_src =
false;
17927 case TriggerType::ORDERED_INDEX:
17928 case TriggerType::READ_ONLY_CONSTRAINT:
17930 createTriggerPtr.p->m_sub_dst =
true;
17931 createTriggerPtr.p->m_sub_src =
false;
17934 case TriggerType::SUBSCRIPTION:
17935 case TriggerType::SUBSCRIPTION_BEFORE:
17937 setError(error, CreateTrigRef::UnsupportedTriggerType, __LINE__);
17942 if (ERROR_INSERTED(6124))
17945 CLEAR_ERROR_INSERT_VALUE;
17946 setError(error, 9124, __LINE__);
17950 if (impl_req->indexId != RNIL)
17952 TableRecordPtr indexPtr;
17953 c_tableRecordPool.
getPtr(indexPtr, impl_req->indexId);
17954 triggerPtr.p->indexId = impl_req->indexId;
17955 indexPtr.p->triggerId = impl_req->triggerId;
17960 Dbdict::createTrigger_parse_endpoint(
Signal* signal,
17961 SchemaOpPtr op_ptr,
17966 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
17967 CreateTriggerRecPtr createTriggerPtr;
17968 getOpRec(op_ptr, createTriggerPtr);
17972 Uint32 requestType = impl_req->requestType;
17973 switch(CreateTrigReq::getEndpointFlag(requestType)){
17974 case CreateTrigReq::TriggerDst:
17976 createTriggerPtr.p->m_block_list[0] = DBTC_REF;
17978 case CreateTrigReq::TriggerSrc:
17980 createTriggerPtr.p->m_block_list[0] = DBLQH_REF;
17984 setError(error, CreateTrigRef::BadRequestType, __LINE__);
17989 c_triggerRecordPool.
getPtr(triggerPtr, impl_req->triggerId);
17990 switch(TriggerInfo::getTriggerType(triggerPtr.p->
triggerInfo)){
17991 case TriggerType::REORG_TRIGGER:
17993 createTrigger_create_drop_trigger_operation(signal, op_ptr, error);
18001 Dbdict::createTrigger_create_drop_trigger_operation(
Signal* signal,
18002 SchemaOpPtr op_ptr,
18007 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
18008 CreateTriggerRecPtr createTriggerPtr;
18009 getOpRec(op_ptr, createTriggerPtr);
18015 SchemaOpPtr& oplnk_ptr = op_ptr.p->m_oplnk_ptr;
18016 ndbrequire(oplnk_ptr.isNull());
18017 DropTriggerRecPtr dropTriggerPtr;
18018 seizeSchemaOp(oplnk_ptr, dropTriggerPtr);
18019 if (oplnk_ptr.isNull())
18022 setError(error, CreateTrigRef::TooManyTriggers, __LINE__);
18028 aux_impl_req->senderRef = reference();
18029 aux_impl_req->senderData = op_ptr.p->op_key;
18030 aux_impl_req->requestType = 0;
18031 aux_impl_req->tableId = impl_req->tableId;
18032 aux_impl_req->tableVersion = 0;
18033 aux_impl_req->indexId = 0;
18034 aux_impl_req->indexVersion = 0;
18035 aux_impl_req->triggerNo = 0;
18036 aux_impl_req->triggerId = impl_req->triggerId;
18037 aux_impl_req->triggerInfo = impl_req->triggerInfo;
18040 oplnk_ptr.p->m_opbck_ptr = op_ptr;
18041 oplnk_ptr.p->m_trans_ptr = trans_ptr;
18042 dropTriggerPtr.p->m_main_op = createTriggerPtr.p->m_main_op;
18044 if (createTriggerPtr.p->m_main_op)
18050 switch(refToBlock(createTriggerPtr.p->m_block_list[0])){
18053 dropTriggerPtr.p->m_block_list[0] = DBLQH_REF;
18057 dropTriggerPtr.p->m_block_list[0] = DBTC_REF;
18061 setError(error, CreateTrigRef::BadRequestType, __LINE__);
18067 Dbdict::createTrigger_subOps(
Signal* signal, SchemaOpPtr op_ptr)
18069 D(
"createTrigger_subOps" << V(op_ptr.i) << *op_ptr.p);
18071 CreateTriggerRecPtr createTriggerPtr;
18072 getOpRec(op_ptr, createTriggerPtr);
18074 Uint32 requestType =
18075 DictSignal::getRequestType(createTriggerPtr.p->m_request.requestType);
18076 switch(CreateTrigReq::getEndpointFlag(requestType)){
18077 case CreateTrigReq::MainTrigger:
18080 case CreateTrigReq::TriggerDst:
18081 case CreateTrigReq::TriggerSrc:
18089 if (!createTriggerPtr.p->m_sub_dst)
18092 createTriggerPtr.p->m_sub_dst =
true;
18094 safe_cast(&Dbdict::createTrigger_fromCreateEndpoint),
18097 op_ptr.p->m_callback = c;
18098 createTrigger_toCreateEndpoint(signal, op_ptr,
18099 CreateTrigReq::TriggerDst);
18103 if (!createTriggerPtr.p->m_sub_src)
18106 createTriggerPtr.p->m_sub_src =
true;
18108 safe_cast(&Dbdict::createTrigger_fromCreateEndpoint),
18111 op_ptr.p->m_callback = c;
18112 createTrigger_toCreateEndpoint(signal, op_ptr,
18113 CreateTrigReq::TriggerSrc);
18121 Dbdict::createTrigger_toCreateEndpoint(
Signal* signal,
18122 SchemaOpPtr op_ptr,
18123 CreateTrigReq::EndpointFlag endpoint)
18125 D(
"alterIndex_toCreateTrigger");
18127 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
18128 CreateTriggerRecPtr createTriggerPtr;
18129 getOpRec(op_ptr, createTriggerPtr);
18135 CreateTrigReq::setOnlineFlag(type, CreateTrigReq::CreateTriggerOnline);
18136 CreateTrigReq::setEndpointFlag(type, endpoint);
18138 Uint32 requestInfo = 0;
18139 DictSignal::setRequestType(requestInfo, type);
18140 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
18142 req->clientRef = reference();
18143 req->clientData = op_ptr.p->op_key;
18144 req->transId = trans_ptr.p->m_transId;
18145 req->transKey = trans_ptr.p->trans_key;
18146 req->requestInfo = requestInfo;
18147 req->tableId = impl_req->tableId;
18148 req->tableVersion = impl_req->tableVersion;
18149 req->indexId = impl_req->indexId;
18150 req->indexVersion = impl_req->indexVersion;
18151 req->forceTriggerId = impl_req->triggerId;
18152 req->triggerInfo = impl_req->triggerInfo;
18154 sendSignal(reference(), GSN_CREATE_TRIG_REQ, signal,
18155 CreateTrigReq::SignalLength, JBB);
18159 Dbdict::createTrigger_fromCreateEndpoint(
Signal* signal,
18160 Uint32 op_key, Uint32 ret)
18162 SchemaOpPtr op_ptr;
18163 CreateTriggerRecPtr createTriggerPtr;
18164 findSchemaOp(op_ptr, createTriggerPtr, op_key);
18165 ndbrequire(!op_ptr.isNull());
18166 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
18174 ndbrequire(conf->transId == trans_ptr.p->m_transId);
18175 createSubOps(signal, op_ptr);
18183 setError(error, ref);
18184 abortSubOps(signal, op_ptr, error);
18189 Dbdict::createTrigger_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
18193 SchemaTransPtr& trans_ptr = op_ptr.p->m_trans_ptr;
18194 CreateTriggerRecPtr createTriggerPtr;
18195 getOpRec(op_ptr, createTriggerPtr);
18198 D(
"createTrigger_reply" << V(impl_req->triggerId) << *op_ptr.p);
18200 if (!hasError(error)) {
18202 conf->senderRef = reference();
18203 conf->clientData = op_ptr.p->m_clientData;
18204 conf->transId = trans_ptr.p->m_transId;
18205 conf->tableId = impl_req->tableId;
18206 conf->indexId = impl_req->indexId;
18207 conf->triggerId = impl_req->triggerId;
18208 conf->triggerInfo = impl_req->triggerInfo;
18210 Uint32 clientRef = op_ptr.p->m_clientRef;
18211 sendSignal(clientRef, GSN_CREATE_TRIG_CONF, signal,
18212 CreateTrigConf::SignalLength, JBB);
18216 ref->senderRef = reference();
18217 ref->clientData = op_ptr.p->m_clientData;
18218 ref->transId = trans_ptr.p->m_transId;
18219 ref->tableId = impl_req->tableId;
18220 ref->indexId = impl_req->indexId;
18221 ref->triggerInfo =impl_req->triggerInfo;
18222 getError(error, ref);
18224 Uint32 clientRef = op_ptr.p->m_clientRef;
18225 sendSignal(clientRef, GSN_CREATE_TRIG_REF, signal,
18226 CreateTrigRef::SignalLength, JBB);
18233 Dbdict::createTrigger_prepare(
Signal* signal, SchemaOpPtr op_ptr)
18236 CreateTriggerRecPtr createTriggerPtr;
18237 getOpRec(op_ptr, createTriggerPtr);
18239 if (createTriggerPtr.p->m_main_op)
18242 sendTransConf(signal, op_ptr);
18246 if (ERROR_INSERTED(6213))
18248 CLEAR_ERROR_INSERT_VALUE;
18249 setError(op_ptr, 1, __LINE__);
18250 sendTransRef(signal, op_ptr);
18254 Callback c = { safe_cast(&Dbdict::createTrigger_prepare_fromLocal),
18258 op_ptr.p->m_callback = c;
18259 send_create_trig_req(signal, op_ptr);
18263 Dbdict::createTrigger_prepare_fromLocal(
Signal* signal,
18264 Uint32 op_key, Uint32 ret)
18266 SchemaOpPtr op_ptr;
18267 CreateTriggerRecPtr createTriggerPtr;
18268 findSchemaOp(op_ptr, createTriggerPtr, op_key);
18269 ndbrequire(!op_ptr.isNull());
18270 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
18275 createTriggerPtr.p->m_created =
true;
18276 sendTransConf(signal, op_ptr);
18281 setError(op_ptr, ret, __LINE__);
18282 sendTransRef(signal, op_ptr);
18289 Dbdict::createTrigger_commit(
Signal* signal, SchemaOpPtr op_ptr)
18293 CreateTriggerRecPtr createTriggerPtr;
18294 getOpRec(op_ptr, createTriggerPtr);
18297 if (!op_ptr.p->m_oplnk_ptr.isNull())
18300 sendTransConf(signal, op_ptr);
18304 if (createTriggerPtr.p->m_main_op)
18308 Uint32 triggerId = impl_req->triggerId;
18309 TriggerRecordPtr triggerPtr;
18310 c_triggerRecordPool.
getPtr(triggerPtr, triggerId);
18312 triggerPtr.p->triggerState = TriggerRecord::TS_ONLINE;
18313 unlinkDictObject(op_ptr);
18316 sendTransConf(signal, op_ptr);
18322 Dbdict::createTrigger_complete(
Signal* signal, SchemaOpPtr op_ptr)
18326 CreateTriggerRecPtr createTriggerPtr;
18327 getOpRec(op_ptr, createTriggerPtr);
18329 if (!op_ptr.p->m_oplnk_ptr.isNull())
18336 if (hasDictObject(op_ptr))
18339 DictObjectPtr obj_ptr;
18340 getDictObject(op_ptr, obj_ptr);
18341 unlinkDictObject(op_ptr);
18342 linkDictObject(op_ptr.p->m_oplnk_ptr, obj_ptr);
18344 op_ptr.p->m_oplnk_ptr.p->m_state = SchemaOp::OS_COMPLETING;
18345 dropTrigger_commit(signal, op_ptr.p->m_oplnk_ptr);
18349 sendTransConf(signal, op_ptr);
18355 Dbdict::createTrigger_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
18357 D(
"createTrigger_abortParse" << *op_ptr.p);
18359 CreateTriggerRecPtr createTriggerPtr;
18360 getOpRec(op_ptr, createTriggerPtr);
18362 Uint32 triggerId = impl_req->triggerId;
18364 if (createTriggerPtr.p->m_main_op)
18368 TriggerRecordPtr triggerPtr;
18369 if (! (triggerId < c_triggerRecordPool.getSize()))
18375 c_triggerRecordPool.
getPtr(triggerPtr, triggerId);
18377 if (triggerPtr.p->triggerState == TriggerRecord::TS_DEFINING)
18380 triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
18383 if (triggerPtr.p->indexId != RNIL)
18385 TableRecordPtr indexPtr;
18386 c_tableRecordPool.
getPtr(indexPtr, triggerPtr.p->indexId);
18387 triggerPtr.p->indexId = RNIL;
18388 indexPtr.p->triggerId = RNIL;
18393 if (hasDictObject(op_ptr))
18396 releaseDictObject(op_ptr);
18402 sendTransConf(signal, op_ptr);
18406 Dbdict::createTrigger_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
18408 D(
"createTrigger_abortPrepare" << *op_ptr.p);
18410 CreateTriggerRecPtr createTriggerPtr;
18411 getOpRec(op_ptr, createTriggerPtr);
18414 if (createTriggerPtr.p->m_main_op)
18417 sendTransConf(signal, op_ptr);
18421 if (createTriggerPtr.p->m_created ==
false)
18424 sendTransConf(signal, op_ptr);
18428 Callback c = { safe_cast(&Dbdict::createTrigger_abortPrepare_fromLocal),
18431 op_ptr.p->m_callback = c;
18434 req->senderRef = reference();
18435 req->senderData = op_ptr.p->op_key;
18436 req->requestType = 0;
18437 req->tableId = impl_req->tableId;
18438 req->tableVersion = 0;
18439 req->indexId = impl_req->indexId;
18440 req->indexVersion = 0;
18441 req->triggerNo = 0;
18442 req->triggerId = impl_req->triggerId;
18443 req->triggerInfo = impl_req->triggerInfo;
18444 req->receiverRef = impl_req->receiverRef;
18446 BlockReference ref = createTriggerPtr.p->m_block_list[0];
18447 sendSignal(ref, GSN_DROP_TRIG_IMPL_REQ, signal,
18448 DropTrigImplReq::SignalLength, JBB);
18452 Dbdict::createTrigger_abortPrepare_fromLocal(
Signal* signal,
18453 Uint32 op_key, Uint32 ret)
18455 SchemaOpPtr op_ptr;
18456 CreateTriggerRecPtr createTriggerPtr;
18457 findSchemaOp(op_ptr, createTriggerPtr, op_key);
18458 ndbrequire(!op_ptr.isNull());
18460 ndbrequire(ret == 0);
18462 sendTransConf(signal, op_ptr);
18466 Dbdict::send_create_trig_req(
Signal* signal,
18467 SchemaOpPtr op_ptr)
18469 CreateTriggerRecPtr createTriggerPtr;
18470 getOpRec(op_ptr, createTriggerPtr);
18473 TriggerRecordPtr triggerPtr;
18474 c_triggerRecordPool.
getPtr(triggerPtr, impl_req->triggerId);
18476 D(
"send_create_trig_req");
18480 req->senderRef = reference();
18481 req->senderData = op_ptr.p->op_key;
18482 req->requestType = 0;
18483 req->tableId = triggerPtr.p->tableId;
18484 req->tableVersion = 0;
18485 req->indexId = triggerPtr.p->indexId;
18486 req->indexVersion = 0;
18487 req->triggerNo = 0;
18488 req->triggerId = triggerPtr.p->triggerId;
18489 req->triggerInfo = triggerPtr.p->triggerInfo;
18490 req->receiverRef = triggerPtr.p->receiverRef;
18497 tmp[0] = triggerPtr.p->triggerId;
18498 tmp[1] = triggerPtr.p->triggerId;
18499 tmp[2] = triggerPtr.p->triggerId;
18501 TableRecordPtr indexPtr;
18502 if (triggerPtr.p->indexId != RNIL)
18505 c_tableRecordPool.
getPtr(indexPtr, triggerPtr.p->indexId);
18506 if (indexPtr.p->m_upgrade_trigger_handling.m_upgrade)
18509 tmp[0] = indexPtr.p->m_upgrade_trigger_handling.insertTriggerId;
18510 tmp[1] = indexPtr.p->m_upgrade_trigger_handling.updateTriggerId;
18511 tmp[2] = indexPtr.p->m_upgrade_trigger_handling.deleteTriggerId;
18514 req->upgradeExtra[0] = tmp[0];
18515 req->upgradeExtra[1] = tmp[1];
18516 req->upgradeExtra[2] = tmp[2];
18520 ptr[0].p = triggerPtr.p->attributeMask.rep.data;
18521 ptr[0].sz = triggerPtr.p->attributeMask.getSizeInWords();
18523 BlockReference ref = createTriggerPtr.p->m_block_list[0];
18524 sendSignal(ref, GSN_CREATE_TRIG_IMPL_REQ, signal,
18525 CreateTrigImplReq::SignalLength, JBB, ptr, 1);
18531 Dbdict::execCREATE_TRIG_CONF(
Signal* signal)
18535 handleDictConf(signal, conf);
18539 Dbdict::execCREATE_TRIG_REF(
Signal* signal)
18543 handleDictRef(signal, ref);
18547 Dbdict::execCREATE_TRIG_IMPL_CONF(
Signal* signal)
18551 ndbrequire(refToNode(conf->senderRef) == getOwnNodeId());
18552 handleDictConf(signal, conf);
18556 Dbdict::execCREATE_TRIG_IMPL_REF(
Signal* signal)
18560 ndbrequire(refToNode(ref->senderRef) == getOwnNodeId());
18561 handleDictRef(signal, ref);
18568 const Dbdict::OpInfo
18569 Dbdict::DropTriggerRec::g_opInfo = {
18570 {
'D',
'T',
'r', 0 },
18571 GSN_DROP_TRIG_IMPL_REQ,
18572 DropTrigImplReq::SignalLength,
18574 &Dbdict::dropTrigger_seize,
18575 &Dbdict::dropTrigger_release,
18577 &Dbdict::dropTrigger_parse,
18578 &Dbdict::dropTrigger_subOps,
18579 &Dbdict::dropTrigger_reply,
18581 &Dbdict::dropTrigger_prepare,
18582 &Dbdict::dropTrigger_commit,
18583 &Dbdict::dropTrigger_complete,
18585 &Dbdict::dropTrigger_abortParse,
18586 &Dbdict::dropTrigger_abortPrepare
18590 Dbdict::dropTrigger_seize(SchemaOpPtr op_ptr)
18592 return seizeOpRec<DropTriggerRec>(op_ptr);
18596 Dbdict::dropTrigger_release(SchemaOpPtr op_ptr)
18598 releaseOpRec<DropTriggerRec>(op_ptr);
18602 Dbdict::execDROP_TRIG_REQ(
Signal* signal)
18617 SchemaOpPtr op_ptr;
18618 DropTriggerRecPtr dropTriggerPtr;
18621 startClientReq(op_ptr, dropTriggerPtr, req, impl_req, error);
18622 if (hasError(error)) {
18627 impl_req->tableId = req->tableId;
18628 impl_req->tableVersion = req->tableVersion;
18629 impl_req->indexId = req->indexId;
18630 impl_req->indexVersion = req->indexVersion;
18631 impl_req->triggerNo = req->triggerNo;
18632 impl_req->triggerId = req->triggerId;
18633 impl_req->triggerInfo = ~(Uint32)0;
18635 handleClientReq(signal, op_ptr, handle);
18639 releaseSections(handle);
18643 ref->senderRef = reference();
18644 ref->clientData = req->clientData;
18645 ref->transId = req->transId;
18646 ref->tableId = req->tableId;
18647 ref->indexId = req->indexId;
18648 getError(error, ref);
18650 sendSignal(req->clientRef, GSN_DROP_TRIG_REF, signal,
18651 DropTrigRef::SignalLength, JBB);
18657 Dbdict::dropTrigger_parse(
Signal* signal,
bool master,
18658 SchemaOpPtr op_ptr,
18661 D(
"dropTrigger_parse" << V(op_ptr.i) << *op_ptr.p);
18663 DropTriggerRecPtr dropTriggerPtr;
18664 getOpRec(op_ptr, dropTriggerPtr);
18667 bool reqByName =
false;
18668 if (handle.m_cnt > 0) {
18670 ndbrequire(handle.m_cnt == 1);
18677 handle.getSection(ss_ptr, DropTrigImplReq::TRIGGER_NAME_SECTION);
18682 SimpleProperties::unpack(
18684 DictTabInfo::TableMapping, DictTabInfo::TableMappingSize,
18687 if (status != SimpleProperties::Eof ||
18688 tableDesc.TableName[0] == 0)
18692 setError(error, DropTrigRef::InvalidName, __LINE__);
18695 const Uint32 bytesize =
sizeof(dropTriggerPtr.p->m_triggerName);
18696 memcpy(dropTriggerPtr.p->m_triggerName, tableDesc.TableName, bytesize);
18697 D(
"parsed trigger name: " << dropTriggerPtr.p->m_triggerName);
18700 DictObjectPtr obj_ptr;
18701 if (!findDictObject(op_ptr, obj_ptr, dropTriggerPtr.p->m_triggerName)) {
18703 setError(error, DropTrigRef::TriggerNotFound, __LINE__);
18706 if (impl_req->triggerId != RNIL &&
18707 impl_req->triggerId != obj_ptr.p->m_id) {
18710 setError(error, DropTrigRef::TriggerNotFound, __LINE__);
18713 impl_req->triggerId = obj_ptr.p->m_id;
18717 TriggerRecordPtr triggerPtr;
18719 if (!(impl_req->triggerId < c_triggerRecordPool.getSize())) {
18721 setError(error, DropTrigImplRef::TriggerNotFound, __LINE__);
18724 c_triggerRecordPool.
getPtr(triggerPtr, impl_req->triggerId);
18728 D(
"trigger " << copyRope<MAX_TAB_NAME_SIZE>(triggerPtr.p->triggerName));
18729 impl_req->triggerInfo = triggerPtr.p->triggerInfo;
18730 Uint32 requestType = impl_req->requestType;
18732 switch(DropTrigReq::getEndpointFlag(requestType)){
18733 case DropTrigReq::MainTrigger:
18735 dropTriggerPtr.p->m_main_op =
true;
18737 case DropTrigReq::TriggerDst:
18738 case DropTrigReq::TriggerSrc:
18744 setError(error, DropTrigRef::BadRequestType, __LINE__);
18747 dropTriggerPtr.p->m_main_op =
false;
18748 dropTrigger_parse_endpoint(signal, op_ptr, error);
18755 DictObjectPtr obj_ptr;
18756 if (!findDictObject(op_ptr, obj_ptr, triggerPtr.p->m_obj_ptr_i)) {
18759 setError(error, DropTrigRef::TriggerNotFound, __LINE__);
18762 ndbrequire(obj_ptr.p->m_id == triggerPtr.p->triggerId);
18766 name.copy(dropTriggerPtr.p->m_triggerName);
18771 if (impl_req->tableId != triggerPtr.p->tableId) {
18773 setError(error, DropTrigRef::InvalidTable, __LINE__);
18780 if (impl_req->indexId != triggerPtr.p->indexId) {
18782 setError(error, DropTrigRef::InvalidTable, __LINE__);
18788 TriggerType::Value type =
18789 TriggerInfo::getTriggerType(triggerPtr.p->triggerInfo);
18791 case TriggerType::SECONDARY_INDEX:
18793 dropTriggerPtr.p->m_sub_dst =
false;
18794 dropTriggerPtr.p->m_sub_src =
false;
18796 case TriggerType::ORDERED_INDEX:
18797 case TriggerType::READ_ONLY_CONSTRAINT:
18799 dropTriggerPtr.p->m_sub_dst =
true;
18800 dropTriggerPtr.p->m_sub_src =
false;
18803 case TriggerType::SUBSCRIPTION:
18804 case TriggerType::SUBSCRIPTION_BEFORE:
18806 setError(error, DropTrigRef::UnsupportedTriggerType, __LINE__);
18811 if (ERROR_INSERTED(6124)) {
18813 CLEAR_ERROR_INSERT_VALUE;
18814 setError(error, 9124, __LINE__);
18820 Dbdict::dropTrigger_parse_endpoint(
Signal* signal,
18821 SchemaOpPtr op_ptr,
18824 DropTriggerRecPtr dropTriggerPtr;
18825 getOpRec(op_ptr, dropTriggerPtr);
18829 Uint32 requestType = impl_req->requestType;
18830 switch(DropTrigReq::getEndpointFlag(requestType)){
18831 case DropTrigReq::TriggerDst:
18833 dropTriggerPtr.p->m_block_list[0] = DBTC_REF;
18835 case DropTrigReq::TriggerSrc:
18837 dropTriggerPtr.p->m_block_list[0] = DBLQH_REF;
18841 setError(error, DropTrigRef::BadRequestType, __LINE__);
18847 Dbdict::dropTrigger_subOps(
Signal* signal, SchemaOpPtr op_ptr)
18849 D(
"dropTrigger_subOps" << V(op_ptr.i) << *op_ptr.p);
18851 DropTriggerRecPtr dropTriggerPtr;
18852 getOpRec(op_ptr, dropTriggerPtr);
18854 Uint32 requestType = dropTriggerPtr.p->m_request.requestType;
18855 switch(DropTrigReq::getEndpointFlag(requestType)){
18856 case DropTrigReq::MainTrigger:
18859 case DropTrigReq::TriggerDst:
18860 case DropTrigReq::TriggerSrc:
18868 if (!dropTriggerPtr.p->m_sub_src)
18871 dropTriggerPtr.p->m_sub_src =
true;
18873 safe_cast(&Dbdict::dropTrigger_fromDropEndpoint),
18876 op_ptr.p->m_callback = c;
18877 dropTrigger_toDropEndpoint(signal, op_ptr,
18878 DropTrigReq::TriggerSrc);
18882 if (!dropTriggerPtr.p->m_sub_dst)
18885 dropTriggerPtr.p->m_sub_dst =
true;
18887 safe_cast(&Dbdict::dropTrigger_fromDropEndpoint),
18890 op_ptr.p->m_callback = c;
18891 dropTrigger_toDropEndpoint(signal, op_ptr,
18892 DropTrigReq::TriggerDst);
18900 Dbdict::dropTrigger_toDropEndpoint(
Signal* signal,
18901 SchemaOpPtr op_ptr,
18902 DropTrigReq::EndpointFlag endpoint)
18904 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
18905 DropTriggerRecPtr dropTriggerPtr;
18906 getOpRec(op_ptr, dropTriggerPtr);
18911 Uint32 requestType = 0;
18912 DropTrigReq::setEndpointFlag(requestType, endpoint);
18914 Uint32 requestInfo = 0;
18915 DictSignal::setRequestType(requestInfo, requestType);
18916 DictSignal::addRequestFlagsGlobal(requestInfo, op_ptr.p->m_requestInfo);
18918 req->clientRef = reference();
18919 req->clientData = op_ptr.p->op_key;
18920 req->transId = trans_ptr.p->m_transId;
18921 req->transKey = trans_ptr.p->trans_key;
18922 req->requestInfo = requestInfo;
18923 req->tableId = impl_req->tableId;
18924 req->tableVersion = impl_req->tableVersion;
18925 req->indexId = impl_req->indexId;
18926 req->indexVersion = impl_req->indexVersion;
18927 req->triggerId = impl_req->triggerId;
18928 req->triggerNo = 0;
18930 sendSignal(reference(), GSN_DROP_TRIG_REQ, signal,
18931 DropTrigReq::SignalLength, JBB);
18935 Dbdict::dropTrigger_fromDropEndpoint(
Signal* signal,
18936 Uint32 op_key, Uint32 ret)
18938 SchemaOpPtr op_ptr;
18939 DropTriggerRecPtr dropTriggerPtr;
18940 findSchemaOp(op_ptr, dropTriggerPtr, op_key);
18941 ndbrequire(!op_ptr.isNull());
18942 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
18950 ndbrequire(conf->transId == trans_ptr.p->m_transId);
18951 createSubOps(signal, op_ptr);
18959 setError(error, ref);
18960 abortSubOps(signal, op_ptr, error);
18965 Dbdict::dropTrigger_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
18968 SchemaTransPtr& trans_ptr = op_ptr.p->m_trans_ptr;
18969 DropTriggerRecPtr dropTriggerPtr;
18970 getOpRec(op_ptr, dropTriggerPtr);
18973 D(
"dropTrigger_reply" << V(impl_req->triggerId));
18975 if (!hasError(error)) {
18977 conf->senderRef = reference();
18978 conf->clientData = op_ptr.p->m_clientData;
18979 conf->transId = trans_ptr.p->m_transId;
18980 conf->tableId = impl_req->tableId;
18981 conf->indexId = impl_req->indexId;
18982 conf->triggerId = impl_req->triggerId;
18984 Uint32 clientRef = op_ptr.p->m_clientRef;
18985 sendSignal(clientRef, GSN_DROP_TRIG_CONF, signal,
18986 DropTrigConf::SignalLength, JBB);
18990 ref->senderRef = reference();
18991 ref->clientData = op_ptr.p->m_clientData;
18992 ref->transId = trans_ptr.p->m_transId;
18993 ref->tableId = impl_req->tableId;
18994 ref->indexId = impl_req->indexId;
18995 ref->triggerId = impl_req->triggerId;
18996 getError(error, ref);
18998 Uint32 clientRef = op_ptr.p->m_clientRef;
18999 sendSignal(clientRef, GSN_DROP_TRIG_REF, signal,
19000 DropTrigRef::SignalLength, JBB);
19007 Dbdict::dropTrigger_prepare(
Signal* signal, SchemaOpPtr op_ptr)
19010 D(
"dropTrigger_prepare");
19016 sendTransConf(signal, op_ptr);
19022 Dbdict::dropTrigger_commit(
Signal* signal, SchemaOpPtr op_ptr)
19025 DropTriggerRecPtr dropTriggerPtr;
19026 getOpRec(op_ptr, dropTriggerPtr);
19028 if (dropTriggerPtr.p->m_main_op)
19032 Uint32 triggerId = dropTriggerPtr.p->m_request.triggerId;
19034 TriggerRecordPtr triggerPtr;
19035 c_triggerRecordPool.
getPtr(triggerPtr, triggerId);
19037 if (triggerPtr.p->indexId != RNIL)
19039 TableRecordPtr indexPtr;
19040 c_tableRecordPool.
getPtr(indexPtr, triggerPtr.p->indexId);
19041 triggerPtr.p->indexId = RNIL;
19042 indexPtr.p->triggerId = RNIL;
19046 releaseDictObject(op_ptr);
19047 triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
19049 sendTransConf(signal, op_ptr);
19053 Callback c = { safe_cast(&Dbdict::dropTrigger_commit_fromLocal),
19057 op_ptr.p->m_callback = c;
19058 send_drop_trig_req(signal, op_ptr);
19062 Dbdict::dropTrigger_commit_fromLocal(
Signal* signal,
19063 Uint32 op_key, Uint32 ret)
19065 SchemaOpPtr op_ptr;
19066 DropTriggerRecPtr dropTriggerPtr;
19067 findSchemaOp(op_ptr, dropTriggerPtr, op_key);
19068 ndbrequire(!op_ptr.isNull());
19069 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
19074 warningEvent(
"Got error code %u from %x (DROP_TRIG_IMPL_REQ)",
19076 dropTriggerPtr.p->m_block_list[0]);
19079 sendTransConf(signal, op_ptr);
19083 Dbdict::send_drop_trig_req(
Signal* signal, SchemaOpPtr op_ptr)
19085 DropTriggerRecPtr dropTriggerPtr;
19086 getOpRec(op_ptr, dropTriggerPtr);
19091 req->senderRef = reference();
19092 req->senderData = op_ptr.p->op_key;
19093 req->requestType = impl_req->requestType;
19094 req->tableId = impl_req->tableId;
19095 req->tableVersion = 0;
19096 req->indexId = impl_req->indexId;
19097 req->indexVersion = 0;
19098 req->triggerNo = 0;
19099 req->triggerId = impl_req->triggerId;
19100 req->triggerInfo = impl_req->triggerInfo;
19101 req->receiverRef = impl_req->receiverRef;
19103 BlockReference ref = dropTriggerPtr.p->m_block_list[0];
19104 sendSignal(ref, GSN_DROP_TRIG_IMPL_REQ, signal,
19105 DropTrigImplReq::SignalLength, JBB);
19111 Dbdict::dropTrigger_complete(
Signal* signal, SchemaOpPtr op_ptr)
19114 sendTransConf(signal, op_ptr);
19120 Dbdict::dropTrigger_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
19122 DropTriggerRecPtr dropTriggerPtr;
19123 getOpRec(op_ptr, dropTriggerPtr);
19125 D(
"dropTrigger_abortParse" << *op_ptr.p);
19127 if (hasDictObject(op_ptr)) {
19129 unlinkDictObject(op_ptr);
19131 sendTransConf(signal, op_ptr);
19135 Dbdict::dropTrigger_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
19137 D(
"dropTrigger_abortPrepare" << *op_ptr.p);
19139 sendTransConf(signal, op_ptr);
19145 Dbdict::execDROP_TRIG_CONF(
Signal* signal)
19149 handleDictConf(signal, conf);
19153 Dbdict::execDROP_TRIG_REF(
Signal* signal)
19157 handleDictRef(signal, ref);
19161 Dbdict::execDROP_TRIG_IMPL_CONF(
Signal* signal)
19165 ndbrequire(refToNode(conf->senderRef) == getOwnNodeId());
19166 handleDictConf(signal, conf);
19170 Dbdict::execDROP_TRIG_IMPL_REF(
Signal* signal)
19174 ndbrequire(refToNode(ref->senderRef) == getOwnNodeId());
19175 handleDictRef(signal, ref);
19193 Dbdict::getTableKeyList(TableRecordPtr tablePtr,
19198 list.id[list.sz++] = AttributeHeader::FRAGMENT;
19200 tablePtr.p->m_attributes);
19201 AttributeRecordPtr attrPtr;
19202 for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr)) {
19203 if (attrPtr.p->tupleKey) {
19204 list.id[list.sz++] = attrPtr.p->attributeId;
19207 ndbrequire(list.sz == (uint)(tablePtr.p->noOfPrimkey + 1));
19208 ndbrequire(list.sz <= MAX_ATTRIBUTES_IN_INDEX + 1);
19213 Dbdict::getIndexAttr(TableRecordPtr indexPtr, Uint32 itAttr, Uint32*
id)
19218 char name[MAX_ATTR_NAME_SIZE];
19219 TableRecordPtr tablePtr;
19220 AttributeRecordPtr attrPtr;
19222 c_tableRecordPool.
getPtr(tablePtr, indexPtr.p->primaryTableId);
19223 AttributeRecord* iaRec = c_attributeRecordPool.
getPtr(itAttr);
19225 ConstRope tmp(c_rope_pool, iaRec->attributeName);
19230 tablePtr.p->m_attributes);
19231 for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr)){
19232 ConstRope tmp(c_rope_pool, attrPtr.p->attributeName);
19233 if(tmp.compare(name, len) == 0){
19234 id[0] = attrPtr.p->attributeId;
19246 memset(list.id, 0,
sizeof(list.id));
19247 ndbrequire(indexPtr.p->noOfAttributes >= 2);
19250 indexPtr.p->m_attributes);
19251 AttributeRecordPtr attrPtr;
19252 for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr)) {
19254 AttributeRecordPtr tempPtr = attrPtr;
19255 if (! alist.next(tempPtr))
19261 getIndexAttr(indexPtr, attrPtr.i, &list.id[list.sz]);
19264 ndbrequire(indexPtr.p->noOfAttributes == list.sz + 1);
19268 Dbdict::getIndexAttrMask(TableRecordPtr indexPtr,
AttributeMask& mask)
19272 ndbrequire(indexPtr.p->noOfAttributes >= 2);
19274 AttributeRecordPtr attrPtr, currPtr;
19276 indexPtr.p->m_attributes);
19279 for (alist.first(attrPtr); currPtr = attrPtr, alist.next(attrPtr); ){
19281 getIndexAttr(indexPtr, currPtr.i, &
id);
19289 Dbdict::getDictLockType(Uint32 lockType)
19291 static const DictLockType lt[] = {
19292 { DictLockReq::NodeRestartLock,
"NodeRestart" }
19293 ,{ DictLockReq::SchemaTransLock,
"SchemaTransLock" }
19294 ,{ DictLockReq::CreateFileLock,
"CreateFile" }
19295 ,{ DictLockReq::CreateFilegroupLock,
"CreateFilegroup" }
19296 ,{ DictLockReq::DropFileLock,
"DropFile" }
19297 ,{ DictLockReq::DropFilegroupLock,
"DropFilegroup" }
19299 for (
unsigned int i = 0; i <
sizeof(lt)/
sizeof(lt[0]); i++) {
19300 if ((Uint32) lt[
i].lockType == lockType)
19307 Dbdict::sendDictLockInfoEvent(
Signal*,
const UtilLockReq* req,
const char* text)
19313 (
unsigned)refToNode(req->senderRef), lt->text);
19317 Dbdict::execDICT_LOCK_REQ(
Signal* signal)
19323 lockReq.senderRef = req.userRef;
19324 lockReq.senderData = req.userPtr;
19325 lockReq.lockId = 0;
19326 lockReq.requestInfo = 0;
19327 lockReq.extra = req.lockType;
19329 const DictLockType* lt = getDictLockType(req.lockType);
19332 if (req.lockType == DictLockReq::SumaStartMe ||
19333 req.lockType == DictLockReq::SumaHandOver)
19337 if (c_outstanding_sub_startstop)
19340 g_eventLogger->
info(
"refing dict lock to %u", refToNode(req.userRef));
19341 err = DictLockRef::TooManyRequests;
19345 if (req.lockType == DictLockReq::SumaHandOver &&
19346 !c_sub_startstop_lock.
isclear())
19348 g_eventLogger->
info(
"refing dict lock to %u", refToNode(req.userRef));
19349 err = DictLockRef::TooManyRequests;
19353 c_sub_startstop_lock.
set(refToNode(req.userRef));
19355 g_eventLogger->
info(
"granting dict lock to %u", refToNode(req.userRef));
19357 conf->userPtr = req.userPtr;
19358 conf->lockType = req.lockType;
19360 sendSignal(req.userRef, GSN_DICT_LOCK_CONF, signal,
19361 DictLockConf::SignalLength, JBB);
19365 if (req.lockType == DictLockReq::NodeRestartLock)
19368 lockReq.requestInfo |= UtilLockReq::SharedLock;
19373 if (getOwnNodeId() != c_masterNodeId)
19376 err = DictLockRef::NotMaster;
19383 err = DictLockRef::InvalidLockType;
19387 if (req.userRef != signal->getSendersBlockRef() ||
19391 err = DictLockRef::BadUserRef;
19395 if (c_aliveNodes.
get(refToNode(req.userRef)))
19398 err = DictLockRef::TooLate;
19402 res = m_dict_lock.lock(
this, m_dict_lock_pool, &lockReq, 0);
19406 sendDictLockInfoEvent(signal, &lockReq,
"locked by node");
19409 case UtilLockRef::OutOfLockRecords:
19411 err = DictLockRef::TooManyRequests;
19416 sendDictLockInfoEvent(signal, &lockReq,
"lock request by node");
19424 ref->userPtr = lockReq.senderData;
19425 ref->lockType = lockReq.extra;
19426 ref->errorCode = err;
19428 sendSignal(lockReq.senderRef, GSN_DICT_LOCK_REF, signal,
19429 DictLockRef::SignalLength, JBB);
19437 conf->userPtr = lockReq.senderData;
19438 conf->lockType = lockReq.extra;
19439 conf->lockPtr = lockReq.senderData;
19441 sendSignal(lockReq.senderRef, GSN_DICT_LOCK_CONF, signal,
19442 DictLockConf::SignalLength, JBB);
19448 Dbdict::execDICT_UNLOCK_ORD(
Signal* signal)
19454 req.userPtr = ord->senderData;
19455 req.userRef = ord->senderRef;
19457 if (signal->getLength() < DictUnlockOrd::SignalLength)
19460 req.userPtr = ord->lockPtr;
19461 req.userRef = signal->getSendersBlockRef();
19464 if (ord->lockType == DictLockReq::SumaStartMe ||
19465 ord->lockType == DictLockReq::SumaHandOver)
19468 g_eventLogger->
info(
"clearing dict lock for %u", refToNode(ord->senderRef));
19469 c_sub_startstop_lock.
clear(refToNode(ord->senderRef));
19474 lockReq.senderData = req.userPtr;
19475 lockReq.senderRef = req.userRef;
19476 lockReq.extra = DictLockReq::NodeRestartLock;
19479 case UtilUnlockRef::OK:
19481 sendDictLockInfoEvent(signal, &lockReq,
"unlocked by node");
19483 case UtilUnlockRef::NotLockOwner:
19485 sendDictLockInfoEvent(signal, &lockReq,
"lock request removed by node");
19495 Dbdict::execDICT_TAKEOVER_REQ(
Signal* signal)
19506 Uint32 masterRef = req->senderRef;
19507 Uint32 op_count = 0;
19508 Uint32 rollforward_op = 0;
19509 Uint32 rollforward_op_state = SchemaOp::OS_COMPLETED;
19510 Uint32 rollback_op = 0;
19511 Uint32 rollback_op_state = SchemaOp::OS_INITIAL;
19512 Uint32 lowest_op = 0;
19513 Uint32 lowest_op_state = SchemaOp::OS_COMPLETED;
19514 Uint32 lowest_op_impl_req_gsn = 0;
19515 Uint32 highest_op = 0;
19516 Uint32 highest_op_state = SchemaOp::OS_INITIAL;
19517 Uint32 highest_op_impl_req_gsn = 0;
19518 SchemaTransPtr trans_ptr;
19519 bool ending =
false;
19522 bool pending_trans = c_schemaTransList.
first(trans_ptr);
19523 if (!pending_trans)
19530 ref->senderRef = reference();
19531 ref->masterRef = masterRef;
19532 ref->errorCode = DictTakeoverRef::NoTransaction;
19533 sendSignal(masterRef, GSN_DICT_TAKEOVER_REF, signal,
19534 DictTakeoverRef::SignalLength, JBB);
19537 while (pending_trans)
19539 trans_ptr.p->m_masterRef = masterRef;
19541 ndbout_c(
"Dbdict::execDICT_TAKEOVER_REQ: trans %u(0x%8x), state %u, op_list %s", trans_ptr.i, (uint)trans_ptr.p->trans_key, trans_ptr.p->m_state, (trans_ptr.p->m_op_list.in_use)?
"yes":
"no");
19544 SchemaOpPtr op_ptr;
19546 bool pending_op = list.first(op_ptr);
19548 (trans_ptr.p->m_state == SchemaTrans::TS_COMPLETING ||
19549 trans_ptr.p->m_state == SchemaTrans::TS_ENDING))
19557 lowest_op = op_ptr.p->op_key;
19558 lowest_op_state = op_ptr.p->m_state;
19564 lowest_op_impl_req_gsn = getOpInfo(op_ptr).m_impl_req_gsn;
19570 ndbrequire(!op_ptr.isNull());
19571 ndbrequire(trans_ptr.i == op_ptr.p->m_trans_ptr.i);
19573 ndbout_c(
"Dbdict::execDICT_TAKEOVER_REQ: op %u state %u", op_ptr.p->op_key, op_ptr.p->m_state);
19579 switch(op_ptr.p->m_state) {
19580 case SchemaOp::OS_PARSING:
19581 case SchemaOp::OS_PREPARING:
19582 case SchemaOp::OS_ABORTING_PREPARE:
19583 case SchemaOp::OS_ABORTING_PARSE:
19584 case SchemaOp::OS_COMMITTING:
19585 case SchemaOp::OS_COMPLETING:
19588 Uint32* data = &signal->theData[0];
19589 data[0] = ZDICT_TAKEOVER_REQ;
19590 memmove(&data[1], &data[0], DictTakeoverReq::SignalLength << 2);
19591 sendSignal(reference(), GSN_CONTINUEB, signal,
19592 1 + DictTakeoverReq::SignalLength, JBB);
19600 pending_op = list.next(op_ptr);
19603 if (trans_ptr.p->m_state == SchemaTrans::TS_STARTED ||
19604 trans_ptr.p->m_state == SchemaTrans::TS_PARSING)
19611 highest_op = op_ptr.p->op_key;
19612 highest_op_state = op_ptr.p->m_state;
19617 highest_op_impl_req_gsn = getOpInfo(op_ptr).m_impl_req_gsn;
19623 ndbout_c(
"Op %u, state %u, rollforward %u/%u, rollback %u/%u",op_ptr.p->op_key,op_ptr.p->m_state, rollforward_op, rollforward_op_state, rollback_op, rollback_op_state);
19629 if (SchemaOp::weight(op_ptr.p->m_state) <
19630 SchemaOp::weight(rollforward_op_state))
19632 rollforward_op = op_ptr.p->op_key;
19633 rollforward_op_state = op_ptr.p->m_state;
19639 if (SchemaOp::weight(op_ptr.p->m_state) >=
19640 SchemaOp::weight(rollback_op_state))
19642 rollback_op = op_ptr.p->op_key;
19643 rollback_op_state = op_ptr.p->m_state;
19646 pending_op = list.next(op_ptr);
19649 ndbout_c(
"Slave transaction %u has %u schema operations, rf %u/%u, rb %u/%u", trans_ptr.p->trans_key, op_count, rollforward_op, rollforward_op_state, rollback_op, rollback_op_state);
19652 conf->senderRef = reference();
19653 conf->clientRef = trans_ptr.p->m_clientRef;
19654 conf->trans_key = trans_ptr.p->trans_key;
19655 conf->trans_state = trans_ptr.p->m_state;
19656 conf->op_count = op_count;
19657 conf->rollforward_op = rollforward_op;
19658 conf->rollforward_op_state = rollforward_op_state;
19659 conf->rollback_op = rollback_op;
19660 conf->rollback_op_state = rollback_op_state;
19661 if (trans_ptr.p->m_state == SchemaTrans::TS_STARTED ||
19662 trans_ptr.p->m_state == SchemaTrans::TS_PARSING)
19667 conf->highest_op = highest_op;
19668 conf->highest_op_state = highest_op_state;
19669 conf->highest_op_impl_req_gsn = highest_op_impl_req_gsn;
19676 conf->lowest_op = lowest_op;
19677 conf->lowest_op_state = lowest_op_state;
19678 conf->lowest_op_impl_req_gsn = lowest_op_impl_req_gsn;
19680 sendSignal(masterRef, GSN_DICT_TAKEOVER_CONF, signal,
19681 DictTakeoverConf::SignalLength, JBB);
19682 ndbrequire(!(pending_trans = c_schemaTransList.
next(trans_ptr)));
19687 Dbdict::execDICT_TAKEOVER_REF(
Signal* signal)
19690 Uint32 senderRef = ref->senderRef;
19691 Uint32 nodeId = refToNode(senderRef);
19692 Uint32 masterRef = ref->masterRef;
19693 NodeRecordPtr masterNodePtr;
19696 ndbout_c(
"Dbdict::execDICT_TAKEOVER_REF: error %u, from %u", ref->errorCode, nodeId);
19702 ndbassert(refToNode(masterRef) == c_masterNodeId);
19703 c_nodes.
getPtr(masterNodePtr, c_masterNodeId);
19704 masterNodePtr.p->m_nodes.clear(nodeId);
19709 SafeCounter sc(c_counterMgr, masterNodePtr.p->m_counter);
19710 if (!sc.clearWaitingFor(nodeId)) {
19715 check_takeover_replies(signal);
19719 Dbdict::execDICT_TAKEOVER_CONF(
Signal* signal)
19724 Uint32 senderRef = conf->senderRef;
19725 Uint32 nodeId = refToNode(senderRef);
19733 NodeRecordPtr masterNodePtr;
19738 NodeRecordPtr nodePtr;
19739 c_nodes.
getPtr(nodePtr, nodeId);
19740 nodePtr.p->takeOverConf = *conf;
19742 ndbassert(getOwnNodeId() == c_masterNodeId);
19743 c_nodes.
getPtr(masterNodePtr, c_masterNodeId);
19745 ndbout_c(
"execDICT_TAKEOVER_CONF: Node %u, trans %u(%u), count %u, rollf %u/%u, rb %u/%u",
19746 nodeId, conf->trans_key, conf->trans_state, conf->op_count, conf->rollforward_op,
19747 conf->rollforward_op_state, conf->rollback_op, conf->rollback_op_state);
19754 SafeCounter sc(c_counterMgr, masterNodePtr.p->m_counter);
19755 if (!sc.clearWaitingFor(nodeId)) {
19760 check_takeover_replies(signal);
19763 void Dbdict::check_takeover_replies(
Signal* signal)
19765 SchemaTransPtr trans_ptr;
19766 NodeRecordPtr masterNodePtr;
19769 c_nodes.
getPtr(masterNodePtr, c_masterNodeId);
19770 if (masterNodePtr.p->m_nodes.isclear())
19776 send_nf_complete_rep(signal, &masterNodePtr.p->nodeFailRep);
19784 bool pending_trans = c_schemaTransList.
first(trans_ptr);
19785 while (pending_trans) {
19787 Uint32 trans_key = trans_ptr.p->trans_key;
19789 lockReq.userPtr = trans_key;
19790 lockReq.userRef = reference();
19791 lockReq.lockType = DictLockReq::SchemaTransLock;
19793 if (lockError != 0)
19797 ndbout_c(
"New master failed locking transaction %u, error %u", trans_key, lockError);
19805 ndbout_c(
"New master locked transaction %u", trans_key);
19808 trans_ptr.p->m_isMaster =
true;
19809 trans_ptr.p->m_nodes.clear();
19810 trans_ptr.p->m_rollforward_op = -1;
19811 trans_ptr.p->m_rollforward_op_state = SchemaOp::OS_COMPLETED;
19812 trans_ptr.p->m_rollback_op = 0;
19813 trans_ptr.p->m_rollback_op_state = SchemaOp::OS_INITIAL;
19814 trans_ptr.p->m_lowest_trans_state = SchemaTrans::TS_ENDING;
19815 trans_ptr.p->m_highest_trans_state = SchemaTrans::TS_INITIAL;
19816 trans_ptr.p->check_partial_rollforward =
false;
19817 trans_ptr.p->ressurected_op =
false;
19818 pending_trans = c_schemaTransList.
next(trans_ptr);
19823 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
19825 NodeRecordPtr nodePtr;
19826 if (masterNodePtr.p->m_nodes.get(i))
19829 c_nodes.
getPtr(nodePtr, i);
19832 Uint32 clientRef = conf->clientRef;
19833 Uint32 rollforward_op = conf->rollforward_op;
19834 Uint32 rollforward_op_state = conf->rollforward_op_state;
19835 Uint32 rollback_op = conf->highest_op;
19836 Uint32 rollback_op_state = conf->rollback_op_state;
19837 Uint32 trans_key = conf->trans_key;
19838 Uint32 trans_state = conf->trans_state;
19839 SchemaTransPtr trans_ptr;
19841 if (!findSchemaTrans(trans_ptr, trans_key))
19847 if (!seizeSchemaTrans(trans_ptr, trans_key))
19853 ndbout_c(
"New master seized transaction %u", trans_key);
19859 lockReq.userPtr = trans_ptr.p->trans_key;
19860 lockReq.userRef = reference();
19861 lockReq.lockType = DictLockReq::SchemaTransLock;
19863 if (lockError != 0)
19867 ndbout_c(
"New master failed locking transaction %u, error %u", trans_key, lockError);
19875 ndbout_c(
"New master locked transaction %u", trans_key);
19878 trans_ptr.p->m_rollforward_op = -1;
19879 trans_ptr.p->m_rollforward_op_state = SchemaOp::OS_COMPLETED;
19880 trans_ptr.p->m_rollback_op = 0;
19881 trans_ptr.p->m_rollback_op_state = SchemaOp::OS_INITIAL;
19882 trans_ptr.p->m_lowest_trans_state = SchemaTrans::TS_ENDING;
19883 trans_ptr.p->m_highest_trans_state = SchemaTrans::TS_INITIAL;
19886 trans_ptr.p->m_isMaster =
true;
19887 trans_ptr.p->m_masterRef = reference();
19888 trans_ptr.p->m_clientRef = clientRef;
19889 trans_ptr.p->m_nodes.set(i);
19891 ndbout_c(
"Adding node %u to transaction %u", i, trans_ptr.p->trans_key);
19897 if ((SchemaOp::weight(rollforward_op_state) <
19898 SchemaOp::weight(trans_ptr.p->m_rollforward_op_state)) ||
19899 ((rollforward_op_state ==
19900 trans_ptr.p->m_rollforward_op_state &&
19901 rollforward_op < trans_ptr.p->m_rollforward_op)))
19904 trans_ptr.p->m_rollforward_op = rollforward_op;
19905 trans_ptr.p->m_rollforward_op_state = rollforward_op_state;
19912 if ((SchemaOp::weight(rollback_op_state) >
19913 SchemaOp::weight(trans_ptr.p->m_rollback_op_state)) ||
19914 ((rollback_op_state ==
19915 trans_ptr.p->m_rollback_op_state &&
19916 rollback_op > trans_ptr.p->m_rollback_op)))
19919 trans_ptr.p->m_rollback_op = rollback_op;
19920 trans_ptr.p->m_rollback_op_state = rollback_op_state;
19923 if (SchemaTrans::weight(trans_state) <
19924 SchemaTrans::weight(trans_ptr.p->m_lowest_trans_state))
19927 trans_ptr.p->m_lowest_trans_state = trans_state;
19929 if (SchemaTrans::weight(trans_state) >
19930 SchemaTrans::weight(trans_ptr.p->m_highest_trans_state))
19933 trans_ptr.p->m_highest_trans_state = trans_state;
19942 pending_trans = c_schemaTransList.
first(trans_ptr);
19943 while (pending_trans)
19947 ndbout_c(
"Analyzing transaction progress, trans %u/%u, lowest/highest %u/%u", trans_ptr.p->trans_key, trans_ptr.p->m_state, trans_ptr.p->m_lowest_trans_state, trans_ptr.p->m_highest_trans_state);
19949 switch(trans_ptr.p->m_highest_trans_state) {
19950 case SchemaTrans::TS_INITIAL:
19951 case SchemaTrans::TS_STARTING:
19952 case SchemaTrans::TS_STARTED:
19953 case SchemaTrans::TS_PARSING:
19954 case SchemaTrans::TS_SUBOP:
19955 case SchemaTrans::TS_ROLLBACK_SP:
19956 case SchemaTrans::TS_FLUSH_PREPARE:
19957 case SchemaTrans::TS_PREPARING:
19958 case SchemaTrans::TS_ABORTING_PREPARE:
19959 case SchemaTrans::TS_ABORTING_PARSE:
19961 trans_ptr.p->m_master_recovery_state = SchemaTrans::TRS_ROLLBACK;
19963 case SchemaTrans::TS_FLUSH_COMMIT:
19964 case SchemaTrans::TS_COMMITTING:
19965 case SchemaTrans::TS_FLUSH_COMPLETE:
19966 case SchemaTrans::TS_COMPLETING:
19967 case SchemaTrans::TS_ENDING:
19969 trans_ptr.p->m_master_recovery_state = SchemaTrans::TRS_ROLLFORWARD;
19973 if (trans_ptr.p->m_master_recovery_state == SchemaTrans::TRS_ROLLFORWARD)
19980 infoEvent(
"Pending schema transaction %u will be rolled forward", trans_ptr.p->trans_key);
19981 trans_ptr.p->check_partial_rollforward =
true;
19982 trans_ptr.p->m_state = trans_ptr.p->m_lowest_trans_state;
19984 ndbout_c(
"Setting transaction state to %u for rollforward", trans_ptr.p->m_state);
19994 infoEvent(
"Pending schema transaction %u will be rolled back", trans_ptr.p->trans_key);
19995 trans_ptr.p->m_state = trans_ptr.p->m_highest_trans_state;
19997 ndbout_c(
"Setting transaction state to %u for rollback", trans_ptr.p->m_state);
20001 ndbout_c(
"Setting start state for transaction %u to %u", trans_ptr.p->trans_key, trans_ptr.p->m_state);
20003 pending_trans = c_schemaTransList.
next(trans_ptr);
20009 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
20011 NodeRecordPtr nodePtr;
20012 c_nodes.
getPtr(nodePtr, i);
20013 nodePtr.p->recoveryState = NodeRecord::RS_NORMAL;
20016 pending_trans = c_schemaTransList.
first(trans_ptr);
20017 while (pending_trans)
20024 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
20026 NodeRecordPtr nodePtr;
20027 if (trans_ptr.p->m_nodes.get(i))
20030 c_nodes.
getPtr(nodePtr, i);
20032 ndbout_c(
"Node %u had %u operations, master has %u",i , nodePtr.p->takeOverConf.op_count, masterNodePtr.p->takeOverConf.op_count);
20034 if (nodePtr.p->takeOverConf.op_count == 0)
20036 if (SchemaTrans::weight(trans_ptr.p->m_state)
20037 < SchemaTrans::weight(SchemaTrans::TS_PREPARING))
20045 ndbout_c(
"Node %u had no operations for transaction %u, ignore it when aborting", i, trans_ptr.p->trans_key);
20047 nodePtr.p->start_op = 0;
20048 nodePtr.p->start_op_state = SchemaOp::OS_PARSED;
20059 else if (nodePtr.p->takeOverConf.op_count <
20060 masterNodePtr.p->takeOverConf.op_count)
20066 if (SchemaTrans::weight(trans_ptr.p->m_state) <
20067 SchemaTrans::weight(SchemaTrans::TS_PREPARING))
20075 ndbout_c(
"Node %u did not have all operations for transaction %u, skip > %u", i, trans_ptr.p->trans_key, nodePtr.p->takeOverConf.highest_op);
20077 nodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLBACK;
20078 nodePtr.p->start_op = nodePtr.p->takeOverConf.highest_op;
20079 nodePtr.p->start_op_state = nodePtr.p->takeOverConf.highest_op_state;
20088 ndbout_c(
"Node %u did not have all operations for transaction %u, skip < %u", i, trans_ptr.p->trans_key, nodePtr.p->takeOverConf.lowest_op);
20090 nodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLFORWARD;
20091 nodePtr.p->start_op = nodePtr.p->takeOverConf.lowest_op;
20092 nodePtr.p->start_op_state = nodePtr.p->takeOverConf.lowest_op_state;
20095 else if (nodePtr.p->takeOverConf.op_count >
20096 masterNodePtr.p->takeOverConf.op_count)
20102 if (SchemaTrans::weight(trans_ptr.p->m_state)
20103 < SchemaTrans::weight(SchemaTrans::TS_PREPARING))
20109 if (masterNodePtr.p->recoveryState !=
20110 NodeRecord::RS_PARTIAL_ROLLBACK)
20119 SchemaOpPtr missing_op_ptr;
20120 const OpInfo& info =
20121 *findOpInfo(nodePtr.p->takeOverConf.highest_op_impl_req_gsn);
20122 if (seizeSchemaOp(missing_op_ptr,
20123 nodePtr.p->takeOverConf.highest_op,
20128 ndbout_c(
"Created missing operation %u, on new master", missing_op_ptr.p->op_key);
20130 addSchemaOp(trans_ptr, missing_op_ptr);
20131 missing_op_ptr.p->m_state = nodePtr.p->takeOverConf.highest_op_state;
20132 masterNodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLBACK;
20133 masterNodePtr.p->start_op = masterNodePtr.p->takeOverConf.highest_op;
20134 masterNodePtr.p->start_op_state = masterNodePtr.p->takeOverConf.highest_op_state;
20141 trans_ptr.p->m_nodes.set(c_masterNodeId);
20143 ndbout_c(
"Adding master node %u to transaction %u", c_masterNodeId, trans_ptr.p->trans_key);
20147 else if (SchemaTrans::weight(trans_ptr.p->m_state)
20148 >= SchemaTrans::weight(SchemaTrans::TS_PREPARING) &&
20149 (!trans_ptr.p->ressurected_op))
20160 SchemaOpPtr missing_op_ptr;
20161 Uint32 op_key = nodePtr.p->takeOverConf.lowest_op;
20162 Uint32 op_state = nodePtr.p->takeOverConf.lowest_op_state;
20163 const OpInfo& info =
20164 *findOpInfo(nodePtr.p->takeOverConf.lowest_op_impl_req_gsn);
20165 if (seizeSchemaOp(missing_op_ptr,
20171 ndbout_c(
"Created ressurected operation %u, on new master", op_key);
20173 addSchemaOp(trans_ptr, missing_op_ptr);
20174 trans_ptr.p->ressurected_op =
true;
20175 missing_op_ptr.p->m_state = op_state;
20176 nodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLFORWARD;
20177 nodePtr.p->start_op = op_key;
20178 nodePtr.p->start_op_state = op_state;
20195 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
20197 NodeRecordPtr nodePtr;
20198 if (trans_ptr.p->m_nodes.get(i))
20201 c_nodes.
getPtr(nodePtr, i);
20203 ndbout_c(
"Comparing node %u rollforward(%u(%u)<%u(%u))/rollback(%u(%u)<%u(%u))", i, nodePtr.p->takeOverConf.rollforward_op_state, nodePtr.p->takeOverConf.rollforward_op, trans_ptr.p->m_rollforward_op_state, trans_ptr.p->m_rollforward_op, nodePtr.p->takeOverConf.rollback_op_state, nodePtr.p->takeOverConf.rollback_op, trans_ptr.p->m_rollback_op_state, trans_ptr.p->m_rollback_op);
20205 if (trans_ptr.p->m_master_recovery_state == SchemaTrans::TRS_ROLLFORWARD)
20208 if (trans_ptr.p->m_lowest_trans_state == SchemaTrans::TS_PREPARING &&
20209 nodePtr.p->takeOverConf.trans_state == SchemaTrans::TS_COMMITTING)
20216 nodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLFORWARD;
20218 ndbout_c(
"Node %u will be partially rolled forward, skipping RT_FLUSH_COMMIT", nodePtr.i);
20221 else if (SchemaOp::weight(nodePtr.p->takeOverConf.rollforward_op_state) >
20222 SchemaOp::weight(trans_ptr.p->m_rollforward_op_state) ||
20223 nodePtr.p->takeOverConf.rollforward_op >
20224 trans_ptr.p->m_rollforward_op)
20231 nodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLFORWARD;
20232 nodePtr.p->start_op = nodePtr.p->takeOverConf.rollforward_op;
20233 nodePtr.p->start_op_state = nodePtr.p->takeOverConf.rollforward_op_state;
20235 ndbout_c(
"Node %u will be partially rolled forward to operation %u, state %u", nodePtr.i, nodePtr.p->start_op, nodePtr.p->start_op_state);
20237 if (i == c_masterNodeId)
20245 SchemaOpPtr op_ptr;
20246 ndbrequire(findSchemaOp(op_ptr,
20247 trans_ptr.p->m_rollforward_op));
20249 ndbout_c(
"Changed op %u from state %u to %u", trans_ptr.p->m_rollforward_op, op_ptr.p->m_state, trans_ptr.p->m_rollforward_op_state);
20251 op_ptr.p->m_state = trans_ptr.p->m_rollforward_op_state;
20254 else if (trans_ptr.p->m_lowest_trans_state == SchemaTrans::TS_COMMITTING &&
20255 nodePtr.p->takeOverConf.trans_state >= SchemaTrans::TS_FLUSH_COMPLETE)
20262 nodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLFORWARD;
20264 ndbout_c(
"Node %u will be partially rolled forward, skipping RT_FLUSH_COMPLETE", nodePtr.i);
20271 if (SchemaOp::weight(nodePtr.p->takeOverConf.rollback_op_state) <
20272 SchemaOp::weight(trans_ptr.p->m_rollback_op_state) ||
20273 nodePtr.p->takeOverConf.rollback_op <
20274 trans_ptr.p->m_rollback_op)
20282 nodePtr.p->recoveryState = NodeRecord::RS_PARTIAL_ROLLBACK;
20283 nodePtr.p->start_op = nodePtr.p->takeOverConf.rollback_op;
20284 nodePtr.p->start_op_state = nodePtr.p->takeOverConf.rollback_op_state;
20286 ndbout_c(
"Node %u will be partially rolled back from operation %u, state %u", nodePtr.i, nodePtr.p->start_op, nodePtr.p->start_op_state);
20288 if (i == c_masterNodeId &&
20289 (SchemaTrans::weight(trans_ptr.p->m_state) <=
20290 SchemaTrans::weight(SchemaTrans::TS_PREPARING)))
20298 SchemaOpPtr op_ptr;
20299 ndbrequire(findSchemaOp(op_ptr,
20300 trans_ptr.p->m_rollback_op));
20302 ndbout_c(
"Changed op %u from state %u to %u", trans_ptr.p->m_rollback_op, op_ptr.p->m_state, trans_ptr.p->m_rollback_op_state);
20304 op_ptr.p->m_state = trans_ptr.p->m_rollback_op_state;
20314 if (trans_ptr.p->m_master_recovery_state == SchemaTrans::TRS_ROLLFORWARD)
20317 SchemaOpPtr rollforward_op_ptr;
20318 ndbrequire(findSchemaOp(rollforward_op_ptr, trans_ptr.p->m_rollforward_op));
20319 trans_ptr.p->m_curr_op_ptr_i = rollforward_op_ptr.i;
20321 ndbout_c(
"execDICT_TAKEOVER_CONF: Transaction %u rolled forward starting at %u(%u)", trans_ptr.p->trans_key, trans_ptr.p->m_rollforward_op, trans_ptr.p->m_curr_op_ptr_i);
20327 if (trans_ptr.p->m_state >= SchemaTrans::TS_PARSING)
20333 SchemaOpPtr rollback_op_ptr;
20334 ndbrequire(findSchemaOp(rollback_op_ptr, trans_ptr.p->m_rollback_op));
20335 trans_ptr.p->m_curr_op_ptr_i = rollback_op_ptr.i;
20337 ndbout_c(
"execDICT_TAKEOVER_CONF: Transaction %u rolled back starting at %u(%u)", trans_ptr.p->trans_key, trans_ptr.p->m_rollback_op, trans_ptr.p->m_curr_op_ptr_i);
20342 trans_recover(signal, trans_ptr);
20343 pending_trans = c_schemaTransList.
next(trans_ptr);
20351 Dbdict::removeStaleDictLocks(
Signal* signal,
const Uint32* theFailedNodes)
20354 if (m_dict_lock.first(
this, m_dict_lock_pool, iter))
20361 refToNode(iter.m_curr.p->m_req.senderRef)))
20363 if (iter.m_curr.p->m_req.requestInfo & UtilLockReq::Granted)
20366 infoEvent(
"Removed lock for node %u", refToNode(iter.m_curr.p->m_req.senderRef));
20367 sendDictLockInfoEvent(signal, &iter.m_curr.p->m_req,
20368 "remove lock by failed node");
20373 infoEvent(
"Removed lock request for node %u", refToNode(iter.m_curr.p->m_req.senderRef));
20374 sendDictLockInfoEvent(signal, &iter.m_curr.p->m_req,
20375 "remove lock request by failed node");
20378 ord->senderRef = iter.m_curr.p->m_req.senderRef;
20379 ord->senderData = iter.m_curr.p->m_req.senderData;
20380 ord->lockPtr = iter.m_curr.p->m_req.senderData;
20381 ord->lockType = iter.m_curr.p->m_req.extra;
20382 sendSignal(reference(), GSN_DICT_UNLOCK_ORD, signal,
20383 DictUnlockOrd::SignalLength, JBB);
20385 }
while (m_dict_lock.next(iter));
20394 req.senderData = _req->userPtr;
20395 req.senderRef = _req->userRef;
20396 req.extra = _req->lockType;
20397 req.requestInfo = UtilLockReq::TryLock | UtilLockReq::Notify;
20399 Uint32 res = m_dict_lock.lock(
this, m_dict_lock_pool, &req, &lockOwner);
20401 case UtilLockRef::OK:
20404 case UtilLockRef::LockAlreadyHeld:
20406 if (lockOwner->extra == DictLockReq::NodeRestartLock)
20409 return SchemaTransBeginRef::BusyWithNR;
20412 case UtilLockRef::OutOfLockRecords:
20415 case UtilLockRef::InLockQueue:
20424 infoEvent(
"Busy with schema transaction");
20426 return SchemaTransBeginRef::Busy;
20433 req.senderData = _req->userPtr;
20434 req.senderRef = _req->userRef;
20436 Uint32 res = m_dict_lock.unlock(
this, m_dict_lock_pool, &req);
20438 case UtilUnlockRef::OK:
20439 case UtilUnlockRef::NotLockOwner:
20441 case UtilUnlockRef::NotInLockQueue:
20448 if (m_dict_lock.first(
this, m_dict_lock_pool, iter))
20461 conf->userPtr = lockReq.senderData;
20462 conf->lockPtr = lockReq.senderData;
20463 conf->lockType = lockReq.extra;
20464 sendSignal(lockReq.senderRef, GSN_DICT_LOCK_CONF, signal,
20465 DictLockConf::SignalLength, JBB);
20468 if (!m_dict_lock.next(iter))
20477 Dbdict::execBACKUP_LOCK_TAB_REQ(
Signal* signal)
20481 Uint32 senderRef = req->m_senderRef;
20482 Uint32 tableId = req->m_tableId;
20483 Uint32 lock = req->m_lock_unlock;
20485 TableRecordPtr tablePtr;
20486 c_tableRecordPool.
getPtr(tablePtr, tableId,
true);
20489 if(lock == BackupLockTab::LOCK_TABLE)
20492 if ((err = check_write_obj(tableId)) == 0)
20495 tablePtr.p->m_read_locked = 1;
20501 tablePtr.p->m_read_locked = 0;
20504 req->errorCode = err;
20505 sendSignal(senderRef, GSN_BACKUP_LOCK_TAB_CONF, signal,
20506 BackupLockTab::SignalLength, JBB);
20520 Dbdict::initSchemaFile(XSchemaFile * xsf, Uint32 firstPage, Uint32 lastPage,
20523 ndbrequire(lastPage <= xsf->noOfPages);
20524 for (Uint32 n = firstPage; n < lastPage; n++) {
20527 memset(sf, 0, NDB_SF_PAGE_SIZE);
20529 Uint32 ndb_version = NDB_VERSION;
20530 if (ndb_version < NDB_SF_VERSION_5_0_6)
20531 ndb_version = NDB_SF_VERSION_5_0_6;
20533 memcpy(sf->Magic, NDB_SF_MAGIC,
sizeof(sf->Magic));
20534 sf->ByteOrder = 0x12345678;
20535 sf->NdbVersion = ndb_version;
20536 sf->FileSize = xsf->noOfPages * NDB_SF_PAGE_SIZE;
20537 sf->PageNumber =
n;
20539 sf->NoOfTableEntries = NDB_SF_PAGE_ENTRIES;
20541 computeChecksum(xsf, n);
20546 Dbdict::resizeSchemaFile(XSchemaFile * xsf, Uint32 noOfPages)
20548 ndbrequire(noOfPages <= NDB_SF_MAX_PAGES);
20549 if (xsf->noOfPages < noOfPages) {
20551 Uint32 firstPage = xsf->noOfPages;
20552 xsf->noOfPages = noOfPages;
20553 initSchemaFile(xsf, 0, firstPage,
false);
20554 initSchemaFile(xsf, firstPage, xsf->noOfPages,
true);
20556 if (xsf->noOfPages > noOfPages) {
20558 Uint32 tableId = noOfPages * NDB_SF_PAGE_ENTRIES;
20559 while (tableId < xsf->noOfPages * NDB_SF_PAGE_ENTRIES) {
20561 if (te->m_tableState != SchemaFile::SF_UNUSED)
20567 xsf->noOfPages = noOfPages;
20568 initSchemaFile(xsf, 0, xsf->noOfPages,
false);
20573 Dbdict::computeChecksum(XSchemaFile * xsf, Uint32 pageNo){
20576 sf->CheckSum = computeChecksum((Uint32*)sf, NDB_SF_PAGE_SIZE_IN_WORDS);
20580 Dbdict::validateChecksum(
const XSchemaFile * xsf){
20582 for (Uint32 n = 0; n < xsf->noOfPages; n++) {
20584 Uint32 c = computeChecksum((Uint32*)sf, NDB_SF_PAGE_SIZE_IN_WORDS);
20592 Dbdict::computeChecksum(
const Uint32 * src, Uint32 len){
20594 for(Uint32 i = 0; i<len; i++)
20600 Dbdict::getTableEntry(Uint32 tableId)
20602 return getTableEntry(&c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE], tableId);
20606 Dbdict::getTableEntry(XSchemaFile * xsf, Uint32 tableId)
20608 Uint32 n = tableId / NDB_SF_PAGE_ENTRIES;
20609 Uint32 i = tableId % NDB_SF_PAGE_ENTRIES;
20610 ndbrequire(n < xsf->noOfPages);
20613 return &sf->TableEntries[
i];
20617 Dbdict::getTableEntry(
const XSchemaFile * xsf, Uint32 tableId)
20619 Uint32 n = tableId / NDB_SF_PAGE_ENTRIES;
20620 Uint32 i = tableId % NDB_SF_PAGE_ENTRIES;
20621 ndbrequire(n < xsf->noOfPages);
20624 return &sf->TableEntries[
i];
20631 const Dbdict::OpInfo
20632 Dbdict::CreateFileRec::g_opInfo = {
20633 {
'C',
'F',
'l', 0 },
20634 GSN_CREATE_FILE_IMPL_REQ,
20635 CreateFileImplReq::SignalLength,
20637 &Dbdict::createFile_seize,
20638 &Dbdict::createFile_release,
20640 &Dbdict::createFile_parse,
20641 &Dbdict::createFile_subOps,
20642 &Dbdict::createFile_reply,
20644 &Dbdict::createFile_prepare,
20645 &Dbdict::createFile_commit,
20646 &Dbdict::createFile_complete,
20648 &Dbdict::createFile_abortParse,
20649 &Dbdict::createFile_abortPrepare
20653 Dbdict::execCREATE_FILE_REQ(
Signal* signal)
20668 SchemaOpPtr op_ptr;
20669 CreateFileRecPtr createFilePtr;
20672 startClientReq(op_ptr, createFilePtr, req, impl_req, error);
20673 if (hasError(error)) {
20678 impl_req->file_id = RNIL;
20679 impl_req->file_version = 0;
20680 impl_req->requestInfo = CreateFileImplReq::Create;
20681 if (req->requestInfo & CreateFileReq::ForceCreateFile)
20684 impl_req->requestInfo = CreateFileImplReq::CreateForce;
20687 handleClientReq(signal, op_ptr, handle);
20691 releaseSections(handle);
20694 ref->senderRef = reference();
20695 ref->transId = req->transId;
20696 ref->senderData = req->senderData;
20697 getError(error, ref);
20699 sendSignal(req->senderRef, GSN_CREATE_FILE_REF, signal,
20700 CreateFileRef::SignalLength, JBB);
20704 Dbdict::createFile_seize(SchemaOpPtr op_ptr)
20706 return seizeOpRec<CreateFileRec>(op_ptr);
20710 Dbdict::createFile_release(SchemaOpPtr op_ptr)
20712 releaseOpRec<CreateFileRec>(op_ptr);
20718 Dbdict::createFile_parse(
Signal* signal,
bool master,
20719 SchemaOpPtr op_ptr,
20724 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
20725 CreateFileRecPtr createFilePtr;
20726 getOpRec(op_ptr, createFilePtr);
20731 bool ok = handle.getSection(objInfoPtr, 0);
20735 setError(error, CreateTableRef::InvalidFormat, __LINE__);
20742 FilePtr filePtr; filePtr.setNull();
20746 status = SimpleProperties::unpack(it, &f,
20747 DictFilegroupInfo::FileMapping,
20748 DictFilegroupInfo::FileMappingSize,
20751 if (status != SimpleProperties::Eof)
20754 setError(error, CreateFileRef::InvalidFormat, __LINE__);
20761 if (f.FilegroupId == RNIL && f.FilegroupVersion == RNIL)
20764 Filegroup_hash::Iterator it;
20765 c_filegroup_hash.
first(it);
20766 while (!it.isNull())
20775 f.FilegroupId = it.curr.p->key;
20776 f.FilegroupVersion = it.curr.p->m_version;
20779 c_filegroup_hash.
next(it);
20784 FilegroupPtr fg_ptr;
20785 if(!c_filegroup_hash.
find(fg_ptr, f.FilegroupId))
20788 setError(error, CreateFileRef::NoSuchFilegroup, __LINE__, f.FileName);
20792 if(fg_ptr.p->m_version != f.FilegroupVersion)
20795 setError(error, CreateFileRef::InvalidFilegroupVersion, __LINE__,
20800 switch(f.FileType){
20806 setError(error, CreateFileRef::InvalidFileType, __LINE__, f.FileName);
20816 setError(error, CreateFileRef::InvalidFileType, __LINE__, f.FileName);
20823 setError(error, CreateFileRef::InvalidFileType, __LINE__, f.FileName);
20827 Uint32 len = Uint32(strlen(f.FileName) + 1);
20828 Uint32 hash = Rope::hash(f.FileName, len);
20829 if(get_object(f.FileName, len, hash) != 0)
20832 setError(error, CreateFileRef::FilenameAlreadyExists, __LINE__, f.FileName);
20839 m_ctx.m_config.getOwnConfigIterator();
20840 if(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &dl) && dl)
20843 setError(error, CreateFileRef::NotSupportedWhenDiskless, __LINE__,
20850 f.FileSizeHi == 0 &&
20851 f.FileSizeLo < fg_ptr.p->m_tablespace.m_extent_size)
20854 setError(error, CreateFileRef::FileSizeTooSmall, __LINE__, f.FileName);
20858 if(!c_obj_pool.
seize(obj_ptr))
20861 setError(error, CreateTableRef::NoMoreTableRecords, __LINE__, f.FileName);
20866 if (! c_file_pool.
seize(filePtr))
20869 setError(error, CreateFileRef::OutOfFileRecords, __LINE__, f.FileName);
20873 new (filePtr.p) File();
20876 Rope name(c_rope_pool, obj_ptr.p->m_name);
20877 if(!name.assign(f.FileName, len, hash))
20880 setError(error, CreateTableRef::OutOfStringBuffer, __LINE__, f.FileName);
20889 Uint32 objId = getFreeObjId(0);
20893 setError(error, CreateFilegroupRef::NoMoreObjectRecords, __LINE__,
20897 Uint32 version = getTableEntry(objId)->m_tableVersion;
20899 impl_req->file_id = objId;
20900 impl_req->file_version = create_obj_inc_schema_version(version);
20902 else if (op_ptr.p->m_restart)
20905 impl_req->file_id = c_restartRecord.activeTable;
20906 impl_req->file_version = c_restartRecord.m_entry.m_tableVersion;
20907 switch(op_ptr.p->m_restart){
20910 impl_req->requestInfo = CreateFileImplReq::Open;
20913 impl_req->requestInfo = CreateFileImplReq::CreateForce;
20921 filePtr.p->key = impl_req->file_id;
20922 filePtr.p->m_file_size = ((Uint64)f.FileSizeHi) << 32 | f.FileSizeLo;
20926 const Uint64 page_size = (Uint64)File_formats::NDB_PAGE_SIZE;
20927 const Uint64 extent_size = (Uint64)fg_ptr.p->m_tablespace.m_extent_size;
20928 ndbrequire(extent_size != 0);
20929 if (filePtr.p->m_file_size % page_size != 0 &&
20930 !ERROR_INSERTED(6030))
20933 filePtr.p->m_file_size /= page_size;
20934 filePtr.p->m_file_size *= page_size;
20935 createFilePtr.p->m_warningFlags |= CreateFileConf::WarnDatafileRoundDown;
20937 if (filePtr.p->m_file_size % extent_size != 0 &&
20938 !ERROR_INSERTED(6030))
20941 filePtr.p->m_file_size +=
20942 extent_size - filePtr.p->m_file_size % extent_size;
20943 createFilePtr.p->m_warningFlags |= CreateFileConf::WarnDatafileRoundUp;
20949 const Uint64 page_size = (Uint64)File_formats::NDB_PAGE_SIZE;
20950 if (filePtr.p->m_file_size % page_size != 0 &&
20951 !ERROR_INSERTED(6030))
20954 filePtr.p->m_file_size /= page_size;
20955 filePtr.p->m_file_size *= page_size;
20956 createFilePtr.p->m_warningFlags |= CreateFileConf::WarnUndofileRoundDown;
20959 filePtr.p->m_path = obj_ptr.p->m_name;
20960 filePtr.p->m_obj_ptr_i = obj_ptr.i;
20961 filePtr.p->m_filegroup_id = f.FilegroupId;
20962 filePtr.p->m_type = f.FileType;
20963 filePtr.p->m_version = impl_req->file_version;
20965 obj_ptr.p->m_id = impl_req->file_id;
20966 obj_ptr.p->m_type = f.FileType;
20967 obj_ptr.p->m_ref_count = 0;
20971 te.m_tableState = SchemaFile::SF_CREATE;
20972 te.m_tableVersion = filePtr.p->m_version;
20973 te.m_tableType = filePtr.p->m_type;
20974 te.m_info_words = objInfoPtr.sz;
20976 te.m_transId = trans_ptr.p->m_transId;
20978 Uint32 err = trans_log_schema_op(op_ptr, impl_req->file_id, &te);
20982 setError(error, err, __LINE__);
20987 c_obj_hash.
add(obj_ptr);
20988 c_file_hash.
add(filePtr);
20991 saveOpSection(op_ptr, handle, 0);
20993 switch(fg_ptr.p->m_type){
20997 increase_ref_count(fg_ptr.p->m_obj_ptr_i);
21003 Local_file_list list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
21011 createFilePtr.p->m_parsed =
true;
21016 g_eventLogger->
info(
"Dbdict: create name=%s,id=%u,obj_ptr_i=%d,"
21017 "type=%s,bytes=%llu,warn=0x%x",
21020 filePtr.p->m_obj_ptr_i,
21024 filePtr.p->m_file_size,
21025 createFilePtr.p->m_warningFlags);
21028 send_event(signal, trans_ptr,
21029 NDB_LE_CreateSchemaObject,
21031 impl_req->file_version,
21036 if (!filePtr.isNull())
21039 c_file_pool.
release(filePtr);
21042 if (!obj_ptr.isNull())
21045 release_object(obj_ptr.i, obj_ptr.p);
21050 Dbdict::createFile_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
21052 CreateFileRecPtr createFilePtr;
21053 getOpRec(op_ptr, createFilePtr);
21056 if (createFilePtr.p->m_parsed)
21059 FilegroupPtr fg_ptr;
21060 ndbrequire(c_file_hash.
find(f_ptr, impl_req->file_id));
21061 ndbrequire(c_filegroup_hash.
find(fg_ptr, f_ptr.p->m_filegroup_id));
21065 decrease_ref_count(fg_ptr.p->m_obj_ptr_i);
21070 Local_file_list list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
21071 list.remove(f_ptr);
21074 release_object(f_ptr.p->m_obj_ptr_i);
21078 sendTransConf(signal, op_ptr);
21082 Dbdict::createFile_subOps(
Signal* signal, SchemaOpPtr op_ptr)
21088 Dbdict::createFile_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
21090 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
21091 CreateFileRecPtr createFileRecPtr;
21092 getOpRec(op_ptr, createFileRecPtr);
21095 if (!hasError(error))
21099 conf->senderRef = reference();
21100 conf->senderData = op_ptr.p->m_clientData;
21101 conf->transId = trans_ptr.p->m_transId;
21102 conf->fileId = impl_req->file_id;
21103 conf->fileVersion = impl_req->file_version;
21104 conf->warningFlags = createFileRecPtr.p->m_warningFlags;
21105 Uint32 clientRef = op_ptr.p->m_clientRef;
21106 sendSignal(clientRef, GSN_CREATE_FILE_CONF, signal,
21107 CreateFileConf::SignalLength, JBB);
21113 ref->senderRef = reference();
21114 ref->senderData = op_ptr.p->m_clientData;
21115 ref->transId = trans_ptr.p->m_transId;
21116 getError(error, ref);
21118 Uint32 clientRef = op_ptr.p->m_clientRef;
21119 sendSignal(clientRef, GSN_CREATE_FILE_REF, signal,
21120 CreateFileRef::SignalLength, JBB);
21127 Dbdict::createFile_prepare(
Signal* signal, SchemaOpPtr op_ptr)
21131 CreateFileRecPtr createFileRecPtr;
21132 getOpRec(op_ptr, createFileRecPtr);
21136 safe_cast(&Dbdict::createFile_fromWriteObjInfo), op_ptr.p->op_key
21139 if (ZRESTART_NO_WRITE_AFTER_READ && op_ptr.p->m_restart == 1)
21145 execute(signal, cb, 0);
21149 const OpSection& objInfoSec = getOpSection(op_ptr, 0);
21150 writeTableFile(signal, impl_req->file_id, objInfoSec, &cb);
21154 Dbdict::createFile_fromWriteObjInfo(
Signal* signal,
21158 SchemaOpPtr op_ptr;
21159 CreateFileRecPtr createFileRecPtr;
21160 ndbrequire(findSchemaOp(op_ptr, createFileRecPtr, op_key));
21166 setError(op_ptr, ret, __LINE__);
21167 sendTransRef(signal, op_ptr);
21176 FilegroupPtr fg_ptr;
21178 ndbrequire(c_file_hash.
find(f_ptr, impl_req->file_id));
21179 ndbrequire(c_filegroup_hash.
find(fg_ptr, f_ptr.p->m_filegroup_id));
21181 req->senderData = op_ptr.p->op_key;
21182 req->senderRef = reference();
21184 req->file_id = f_ptr.p->key;
21185 req->filegroup_id = f_ptr.p->m_filegroup_id;
21186 req->filegroup_version = fg_ptr.p->m_version;
21187 req->file_size_hi = (Uint32)(f_ptr.p->m_file_size >> 32);
21188 req->file_size_lo = (Uint32)(f_ptr.p->m_file_size & 0xFFFFFFFF);
21189 req->requestInfo = impl_req->requestInfo;
21193 switch(f_ptr.p->m_type){
21198 len = CreateFileImplReq::DatafileLength;
21199 req->tablespace.extent_size = fg_ptr.p->m_tablespace.m_extent_size;
21206 len = CreateFileImplReq::UndofileLength;
21213 char name[PATH_MAX];
21214 ConstRope tmp(c_rope_pool, f_ptr.p->m_path);
21217 ptr[0].p = (Uint32*)&name[0];
21218 ptr[0].sz = Uint32(strlen(name)+1+3)/4;
21219 sendSignal(ref, GSN_CREATE_FILE_IMPL_REQ, signal, len, JBB, ptr, 1);
21222 safe_cast(&Dbdict::createFile_fromLocal), op_ptr.p->op_key
21224 op_ptr.p->m_callback = c;
21228 Dbdict::createFile_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
21232 FilegroupPtr fg_ptr;
21234 CreateFileRecPtr createFileRecPtr;
21235 getOpRec(op_ptr, createFileRecPtr);
21238 ndbrequire(c_file_hash.
find(f_ptr, impl_req->file_id));
21239 ndbrequire(c_filegroup_hash.
find(fg_ptr, f_ptr.p->m_filegroup_id));
21241 req->senderData = op_ptr.p->op_key;
21242 req->senderRef = reference();
21243 req->requestInfo = CreateFileImplReq::Abort;
21244 req->file_id = f_ptr.p->key;
21245 req->filegroup_id = f_ptr.p->m_filegroup_id;
21246 req->filegroup_version = fg_ptr.p->m_version;
21249 switch(f_ptr.p->m_type){
21266 sendSignal(ref, GSN_CREATE_FILE_IMPL_REQ, signal,
21267 CreateFileImplReq::AbortLength, JBB);
21270 safe_cast(&Dbdict::createFile_fromLocal), op_ptr.p->op_key
21272 op_ptr.p->m_callback = c;
21278 Dbdict::createFile_commit(
Signal* signal, SchemaOpPtr op_ptr)
21282 CreateFileRecPtr createFileRecPtr;
21283 getOpRec(op_ptr, createFileRecPtr);
21291 FilegroupPtr fg_ptr;
21294 ndbrequire(c_file_hash.
find(f_ptr, impl_req->file_id));
21295 ndbrequire(c_filegroup_hash.
find(fg_ptr, f_ptr.p->m_filegroup_id));
21297 req->senderData = op_ptr.p->op_key;
21298 req->senderRef = reference();
21299 req->requestInfo = CreateFileImplReq::Commit;
21301 req->file_id = f_ptr.p->key;
21302 req->filegroup_id = f_ptr.p->m_filegroup_id;
21303 req->filegroup_version = fg_ptr.p->m_version;
21306 switch(f_ptr.p->m_type){
21322 sendSignal(ref, GSN_CREATE_FILE_IMPL_REQ, signal,
21323 CreateFileImplReq::CommitLength, JBB);
21326 safe_cast(&Dbdict::createFile_fromLocal), op_ptr.p->op_key
21328 op_ptr.p->m_callback = c;
21334 Dbdict::createFile_complete(
Signal* signal, SchemaOpPtr op_ptr)
21337 sendTransConf(signal, op_ptr);
21341 Dbdict::createFile_fromLocal(
Signal* signal, Uint32 op_key, Uint32 ret)
21344 SchemaOpPtr op_ptr;
21345 CreateFileRecPtr createFilePtr;
21346 ndbrequire(findSchemaOp(op_ptr, createFilePtr, op_key));
21351 sendTransConf(signal, op_ptr);
21356 setError(op_ptr, ret, __LINE__);
21357 sendTransRef(signal, op_ptr);
21362 Dbdict::execCREATE_FILE_IMPL_REF(
Signal* signal)
21366 handleDictRef(signal, ref);
21370 Dbdict::execCREATE_FILE_IMPL_CONF(
Signal* signal)
21374 handleDictConf(signal, conf);
21381 const Dbdict::OpInfo
21382 Dbdict::CreateFilegroupRec::g_opInfo = {
21383 {
'C',
'F',
'G', 0 },
21384 GSN_CREATE_FILEGROUP_IMPL_REQ,
21385 CreateFilegroupImplReq::SignalLength,
21387 &Dbdict::createFilegroup_seize,
21388 &Dbdict::createFilegroup_release,
21390 &Dbdict::createFilegroup_parse,
21391 &Dbdict::createFilegroup_subOps,
21392 &Dbdict::createFilegroup_reply,
21394 &Dbdict::createFilegroup_prepare,
21395 &Dbdict::createFilegroup_commit,
21396 &Dbdict::createFilegroup_complete,
21398 &Dbdict::createFilegroup_abortParse,
21399 &Dbdict::createFilegroup_abortPrepare
21403 Dbdict::execCREATE_FILEGROUP_REQ(
Signal* signal)
21418 SchemaOpPtr op_ptr;
21419 CreateFilegroupRecPtr createFilegroupPtr;
21422 startClientReq(op_ptr, createFilegroupPtr, req, impl_req, error);
21423 if (hasError(error)) {
21428 impl_req->filegroup_id = RNIL;
21429 impl_req->filegroup_version = 0;
21431 handleClientReq(signal, op_ptr, handle);
21435 releaseSections(handle);
21438 ref->senderRef = reference();
21439 ref->transId = req->transId;
21440 ref->senderData = req->senderData;
21441 getError(error, ref);
21443 sendSignal(req->senderRef, GSN_CREATE_FILEGROUP_REF, signal,
21444 CreateFilegroupRef::SignalLength, JBB);
21448 Dbdict::createFilegroup_seize(SchemaOpPtr op_ptr)
21450 return seizeOpRec<CreateFilegroupRec>(op_ptr);
21454 Dbdict::createFilegroup_release(SchemaOpPtr op_ptr)
21456 releaseOpRec<CreateFilegroupRec>(op_ptr);
21462 Dbdict::createFilegroup_parse(
Signal* signal,
bool master,
21463 SchemaOpPtr op_ptr,
21468 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
21469 CreateFilegroupRecPtr createFilegroupPtr;
21470 getOpRec(op_ptr, createFilegroupPtr);
21475 bool ok = handle.getSection(objInfoPtr, 0);
21479 setError(error, CreateTableRef::InvalidFormat, __LINE__);
21486 FilegroupPtr fg_ptr; fg_ptr.setNull();
21490 SimpleProperties::unpack(it, &fg,
21491 DictFilegroupInfo::Mapping,
21492 DictFilegroupInfo::MappingSize,
21495 if(status != SimpleProperties::Eof)
21498 setError(error, CreateTableRef::InvalidFormat, __LINE__);
21504 if(!fg.TS_ExtentSize)
21507 setError(error, CreateFilegroupRef::InvalidExtentSize, __LINE__);
21514 if (fg.TS_LogfileGroupId == RNIL && fg.TS_LogfileGroupVersion == RNIL)
21517 Filegroup_hash::Iterator it;
21518 if (c_filegroup_hash.
first(it))
21521 fg.TS_LogfileGroupId = it.curr.p->key;
21522 fg.TS_LogfileGroupVersion = it.curr.p->m_version;
21531 if(fg.LF_UndoBufferSize < 3 * File_formats::NDB_PAGE_SIZE)
21534 setError(error, CreateFilegroupRef::InvalidUndoBufferSize, __LINE__);
21539 Uint32 len = Uint32(strlen(fg.FilegroupName) + 1);
21540 Uint32 hash = Rope::hash(fg.FilegroupName, len);
21541 if(get_object(fg.FilegroupName, len, hash) != 0)
21544 setError(error, CreateTableRef::TableAlreadyExist, __LINE__);
21548 if(!c_obj_pool.
seize(obj_ptr))
21551 setError(error, CreateTableRef::NoMoreTableRecords, __LINE__);
21556 Uint32 inc_obj_ptr_i = RNIL;
21557 if(!c_filegroup_pool.
seize(fg_ptr))
21560 setError(error, CreateTableRef::NoMoreTableRecords, __LINE__);
21564 new (fg_ptr.p) Filegroup();
21567 Rope name(c_rope_pool, obj_ptr.p->m_name);
21568 if(!name.assign(fg.FilegroupName, len, hash))
21571 setError(error, CreateTableRef::OutOfStringBuffer, __LINE__);
21576 switch(fg.FilegroupType){
21580 fg_ptr.p->m_tablespace.m_extent_size = fg.TS_ExtentSize;
21582 const Uint32 page_size = (Uint32)File_formats::NDB_PAGE_SIZE;
21583 if (fg_ptr.p->m_tablespace.m_extent_size % page_size != 0 &&
21584 !ERROR_INSERTED(6030))
21587 fg_ptr.p->m_tablespace.m_extent_size +=
21588 page_size - fg_ptr.p->m_tablespace.m_extent_size % page_size;
21589 createFilegroupPtr.p->m_warningFlags |= CreateFilegroupConf::WarnExtentRoundUp;
21591 #if defined VM_TRACE || defined ERROR_INSERT
21592 ndbout <<
"DD dict: ts id:" <<
"?" <<
" extent bytes:" << fg_ptr.p->m_tablespace.m_extent_size <<
" warn:" << hex << createFilegroupPtr.p->m_warningFlags << endl;
21594 fg_ptr.p->m_tablespace.m_default_logfile_group_id = fg.TS_LogfileGroupId;
21597 if (!c_filegroup_hash.
find(lg_ptr, fg.TS_LogfileGroupId))
21600 setError(error, CreateFilegroupRef::NoSuchLogfileGroup, __LINE__);
21604 if (lg_ptr.p->m_version != fg.TS_LogfileGroupVersion)
21607 setError(error, CreateFilegroupRef::InvalidFilegroupVersion, __LINE__);
21610 inc_obj_ptr_i = lg_ptr.p->m_obj_ptr_i;
21616 fg_ptr.p->m_logfilegroup.m_undo_buffer_size = fg.LF_UndoBufferSize;
21618 const Uint32 page_size = (Uint32)File_formats::NDB_PAGE_SIZE;
21619 if (fg_ptr.p->m_logfilegroup.m_undo_buffer_size % page_size != 0 &&
21620 !ERROR_INSERTED(6030))
21623 fg_ptr.p->m_logfilegroup.m_undo_buffer_size +=
21624 page_size - fg_ptr.p->m_logfilegroup.m_undo_buffer_size % page_size;
21625 createFilegroupPtr.p->m_warningFlags |= CreateFilegroupConf::WarnUndobufferRoundUp;
21627 #if defined VM_TRACE || defined ERROR_INSERT
21628 ndbout <<
"DD dict: fg id:" <<
"?" <<
" undo buffer bytes:" << fg_ptr.p->m_logfilegroup.m_undo_buffer_size <<
" warn:" << hex << createFilegroupPtr.p->m_warningFlags << endl;
21630 fg_ptr.p->m_logfilegroup.m_files.init();
21642 Uint32 objId = getFreeObjId(0);
21646 setError(error, CreateFilegroupRef::NoMoreObjectRecords, __LINE__);
21649 Uint32 version = getTableEntry(objId)->m_tableVersion;
21651 impl_req->filegroup_id = objId;
21652 impl_req->filegroup_version = create_obj_inc_schema_version(version);
21654 else if (op_ptr.p->m_restart)
21657 impl_req->filegroup_id = c_restartRecord.activeTable;
21658 impl_req->filegroup_version = c_restartRecord.m_entry.m_tableVersion;
21661 fg_ptr.p->key = impl_req->filegroup_id;
21662 fg_ptr.p->m_obj_ptr_i = obj_ptr.i;
21663 fg_ptr.p->m_type = fg.FilegroupType;
21664 fg_ptr.p->m_version = impl_req->filegroup_version;
21665 fg_ptr.p->m_name = obj_ptr.p->m_name;
21667 obj_ptr.p->m_id = impl_req->filegroup_id;
21668 obj_ptr.p->m_type = fg.FilegroupType;
21669 obj_ptr.p->m_ref_count = 0;
21674 releaseSections(handle);
21676 packFilegroupIntoPages(w, fg_ptr, 0, 0);
21677 w.getPtr(objInfoPtr);
21678 handle.m_ptr[0] = objInfoPtr;
21684 te.m_tableState = SchemaFile::SF_CREATE;
21685 te.m_tableVersion = fg_ptr.p->m_version;
21686 te.m_tableType = fg_ptr.p->m_type;
21687 te.m_info_words = objInfoPtr.sz;
21689 te.m_transId = trans_ptr.p->m_transId;
21691 Uint32 err = trans_log_schema_op(op_ptr, impl_req->filegroup_id, &te);
21695 setError(error, err, __LINE__);
21700 c_obj_hash.
add(obj_ptr);
21701 c_filegroup_hash.
add(fg_ptr);
21704 saveOpSection(op_ptr, handle, 0);
21706 if (inc_obj_ptr_i != RNIL)
21709 increase_ref_count(inc_obj_ptr_i);
21711 createFilegroupPtr.p->m_parsed =
true;
21713 #if defined VM_TRACE || defined ERROR_INSERT
21714 ndbout_c(
"Dbdict: create name=%s,id=%u,obj_ptr_i=%d",
21715 fg.FilegroupName, impl_req->filegroup_id, fg_ptr.p->m_obj_ptr_i);
21722 if (!fg_ptr.isNull())
21725 c_filegroup_pool.
release(fg_ptr);
21728 if (!obj_ptr.isNull())
21731 release_object(obj_ptr.i, obj_ptr.p);
21736 Dbdict::createFilegroup_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
21738 CreateFilegroupRecPtr createFilegroupPtr;
21739 getOpRec(op_ptr, createFilegroupPtr);
21741 if (createFilegroupPtr.p->m_parsed)
21746 FilegroupPtr fg_ptr;
21747 ndbrequire(c_filegroup_hash.
find(fg_ptr, impl_req->filegroup_id));
21752 FilegroupPtr lg_ptr;
21753 ndbrequire(c_filegroup_hash.
find
21754 (lg_ptr, fg_ptr.p->m_tablespace.m_default_logfile_group_id));
21755 decrease_ref_count(lg_ptr.p->m_obj_ptr_i);
21758 release_object(fg_ptr.p->m_obj_ptr_i);
21759 c_filegroup_hash.
release(fg_ptr);
21762 sendTransConf(signal, op_ptr);
21767 Dbdict::createFilegroup_subOps(
Signal* signal, SchemaOpPtr op_ptr)
21773 Dbdict::createFilegroup_reply(
Signal* signal,
21774 SchemaOpPtr op_ptr,
21779 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
21780 CreateFilegroupRecPtr createFilegroupRecPtr;
21781 getOpRec(op_ptr, createFilegroupRecPtr);
21784 if (!hasError(error))
21788 conf->senderRef = reference();
21789 conf->senderData = op_ptr.p->m_clientData;
21790 conf->transId = trans_ptr.p->m_transId;
21791 conf->filegroupId = impl_req->filegroup_id;
21792 conf->filegroupVersion = impl_req->filegroup_version;
21793 conf->warningFlags = createFilegroupRecPtr.p->m_warningFlags;
21794 Uint32 clientRef = op_ptr.p->m_clientRef;
21795 sendSignal(clientRef, GSN_CREATE_FILEGROUP_CONF, signal,
21796 CreateFilegroupConf::SignalLength, JBB);
21800 ref->senderRef = reference();
21801 ref->senderData = op_ptr.p->m_clientData;
21802 ref->transId = trans_ptr.p->m_transId;
21803 getError(error, ref);
21805 Uint32 clientRef = op_ptr.p->m_clientRef;
21806 sendSignal(clientRef, GSN_CREATE_FILEGROUP_REF, signal,
21807 CreateFilegroupRef::SignalLength, JBB);
21814 Dbdict::createFilegroup_prepare(
Signal* signal, SchemaOpPtr op_ptr)
21818 CreateFilegroupRecPtr createFilegroupRecPtr;
21819 getOpRec(op_ptr, createFilegroupRecPtr);
21823 safe_cast(&Dbdict::createFilegroup_fromWriteObjInfo), op_ptr.p->op_key
21826 if (ZRESTART_NO_WRITE_AFTER_READ && op_ptr.p->m_restart == 1)
21832 execute(signal, cb, 0);
21836 const OpSection& objInfoSec = getOpSection(op_ptr, 0);
21837 writeTableFile(signal, impl_req->filegroup_id, objInfoSec, &cb);
21841 Dbdict::createFilegroup_fromWriteObjInfo(
Signal* signal,
21845 SchemaOpPtr op_ptr;
21846 CreateFilegroupRecPtr createFilegroupRecPtr;
21847 ndbrequire(findSchemaOp(op_ptr, createFilegroupRecPtr, op_key));
21851 setError(op_ptr, ret, __LINE__);
21852 sendTransRef(signal, op_ptr);
21864 req->senderData = op_ptr.p->op_key;
21865 req->senderRef = reference();
21866 req->filegroup_id = impl_req->filegroup_id;
21867 req->filegroup_version = impl_req->filegroup_version;
21869 FilegroupPtr fg_ptr;
21870 ndbrequire(c_filegroup_hash.
find(fg_ptr, impl_req->filegroup_id));
21874 switch(fg_ptr.p->m_type){
21879 len = CreateFilegroupImplReq::TablespaceLength;
21880 req->tablespace.extent_size = fg_ptr.p->m_tablespace.m_extent_size;
21881 req->tablespace.logfile_group_id =
21882 fg_ptr.p->m_tablespace.m_default_logfile_group_id;
21889 len = CreateFilegroupImplReq::LogfileGroupLength;
21890 req->logfile_group.buffer_size =
21891 fg_ptr.p->m_logfilegroup.m_undo_buffer_size;
21898 sendSignal(ref, GSN_CREATE_FILEGROUP_IMPL_REQ, signal, len, JBB);
21901 safe_cast(&Dbdict::createFilegroup_fromLocal), op_ptr.p->op_key
21903 op_ptr.p->m_callback = c;
21909 Dbdict::createFilegroup_commit(
Signal* signal, SchemaOpPtr op_ptr)
21916 sendTransConf(signal, op_ptr);
21922 Dbdict::createFilegroup_complete(
Signal* signal, SchemaOpPtr op_ptr)
21925 sendTransConf(signal, op_ptr);
21929 Dbdict::createFilegroup_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
21931 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
21932 CreateFilegroupRecPtr createFilegroupRecPtr;
21933 getOpRec(op_ptr, createFilegroupRecPtr);
21936 if (createFilegroupRecPtr.p->m_prepared)
21939 safe_cast(&Dbdict::createFilegroup_fromLocal), op_ptr.p->op_key
21941 op_ptr.p->m_callback = c;
21943 send_drop_fg(signal, op_ptr.p->op_key, impl_req->filegroup_id,
21944 DropFilegroupImplReq::Prepare);
21947 sendTransConf(signal, op_ptr);
21951 Dbdict::createFilegroup_fromLocal(
Signal* signal, Uint32 op_key, Uint32 ret)
21954 SchemaOpPtr op_ptr;
21955 CreateFilegroupRecPtr createFilegroupPtr;
21956 ndbrequire(findSchemaOp(op_ptr, createFilegroupPtr, op_key));
21957 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
21962 createFilegroupPtr.p->m_prepared =
true;
21963 sendTransConf(signal, op_ptr);
21968 setError(op_ptr, ret, __LINE__);
21969 sendTransRef(signal, op_ptr);
21974 Dbdict::execCREATE_FILEGROUP_IMPL_REF(
Signal* signal)
21978 handleDictRef(signal, ref);
21982 Dbdict::execCREATE_FILEGROUP_IMPL_CONF(
Signal* signal)
21987 handleDictConf(signal, conf);
21994 const Dbdict::OpInfo
21995 Dbdict::DropFileRec::g_opInfo = {
21996 {
'D',
'F',
'l', 0 },
21997 GSN_DROP_FILE_IMPL_REQ,
21998 DropFileImplReq::SignalLength,
22000 &Dbdict::dropFile_seize,
22001 &Dbdict::dropFile_release,
22003 &Dbdict::dropFile_parse,
22004 &Dbdict::dropFile_subOps,
22005 &Dbdict::dropFile_reply,
22007 &Dbdict::dropFile_prepare,
22008 &Dbdict::dropFile_commit,
22009 &Dbdict::dropFile_complete,
22011 &Dbdict::dropFile_abortParse,
22012 &Dbdict::dropFile_abortPrepare
22016 Dbdict::execDROP_FILE_REQ(
Signal* signal)
22031 SchemaOpPtr op_ptr;
22032 DropFileRecPtr dropFilePtr;
22035 startClientReq(op_ptr, dropFilePtr, req, impl_req, error);
22036 if (hasError(error)) {
22041 impl_req->file_id = req->file_id;
22042 impl_req->file_version = req->file_version;
22044 handleClientReq(signal, op_ptr, handle);
22048 releaseSections(handle);
22051 ref->senderRef = reference();
22052 ref->transId = req->transId;
22053 ref->senderData = req->senderData;
22054 getError(error, ref);
22056 sendSignal(req->senderRef, GSN_DROP_FILE_REF, signal,
22057 DropFileRef::SignalLength, JBB);
22061 Dbdict::dropFile_seize(SchemaOpPtr op_ptr)
22063 return seizeOpRec<DropFileRec>(op_ptr);
22067 Dbdict::dropFile_release(SchemaOpPtr op_ptr)
22069 releaseOpRec<DropFileRec>(op_ptr);
22075 Dbdict::dropFile_parse(
Signal* signal,
bool master,
22076 SchemaOpPtr op_ptr,
22079 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22080 DropFileRecPtr dropFileRecPtr;
22081 getOpRec(op_ptr, dropFileRecPtr);
22085 if (!c_file_hash.
find(f_ptr, impl_req->file_id))
22088 setError(error, DropFileRef::NoSuchFile, __LINE__);
22092 if (f_ptr.p->m_version != impl_req->file_version)
22095 setError(error, DropFileRef::InvalidSchemaObjectVersion, __LINE__);
22102 setError(error, DropFileRef::DropUndoFileNotSupported, __LINE__);
22106 if (check_write_obj(impl_req->file_id,
22107 trans_ptr.p->m_transId,
22108 SchemaFile::SF_DROP, error))
22115 te.m_tableState = SchemaFile::SF_DROP;
22116 te.m_transId = trans_ptr.p->m_transId;
22117 Uint32 err = trans_log_schema_op(op_ptr, impl_req->file_id, &te);
22121 setError(error, err, __LINE__);
22125 #if defined VM_TRACE || defined ERROR_INSERT
22128 Rope name(c_rope_pool, f_ptr.p->m_path);
22130 ndbout_c(
"Dbdict: drop name=%s,id=%u,obj_id=%u", buf,
22132 f_ptr.p->m_obj_ptr_i);
22138 Dbdict::dropFile_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
22141 sendTransConf(signal, op_ptr);
22145 Dbdict::dropFile_subOps(
Signal* signal, SchemaOpPtr op_ptr)
22151 Dbdict::dropFile_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
22154 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22155 DropFileRecPtr dropFileRecPtr;
22156 getOpRec(op_ptr, dropFileRecPtr);
22159 if (!hasError(error))
22163 conf->senderRef = reference();
22164 conf->senderData = op_ptr.p->m_clientData;
22165 conf->transId = trans_ptr.p->m_transId;
22166 conf->fileId = impl_req->file_id;
22167 conf->fileVersion = impl_req->file_version;
22168 Uint32 clientRef = op_ptr.p->m_clientRef;
22169 sendSignal(clientRef, GSN_DROP_FILE_CONF, signal,
22170 DropFileConf::SignalLength, JBB);
22176 ref->senderRef = reference();
22177 ref->senderData = op_ptr.p->m_clientData;
22178 ref->transId = trans_ptr.p->m_transId;
22179 getError(error, ref);
22181 Uint32 clientRef = op_ptr.p->m_clientRef;
22182 sendSignal(clientRef, GSN_DROP_FILE_REF, signal,
22183 DropFileRef::SignalLength, JBB);
22190 Dbdict::dropFile_prepare(
Signal* signal, SchemaOpPtr op_ptr)
22194 DropFileRecPtr dropFileRecPtr;
22195 getOpRec(op_ptr, dropFileRecPtr);
22199 safe_cast(&Dbdict::dropFile_fromLocal), op_ptr.p->op_key
22201 op_ptr.p->m_callback = c;
22203 send_drop_file(signal, op_ptr.p->op_key, impl_req->file_id,
22204 DropFileImplReq::Prepare);
22208 Dbdict::dropFile_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
22210 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22211 DropFileRecPtr dropFilePtr;
22212 getOpRec(op_ptr, dropFilePtr);
22216 safe_cast(&Dbdict::dropFile_fromLocal), op_ptr.p->op_key
22218 op_ptr.p->m_callback = c;
22220 send_drop_file(signal, op_ptr.p->op_key, impl_req->file_id,
22221 DropFileImplReq::Abort);
22227 Dbdict::dropFile_commit(
Signal* signal, SchemaOpPtr op_ptr)
22231 DropFileRecPtr dropFileRecPtr;
22232 getOpRec(op_ptr, dropFileRecPtr);
22236 safe_cast(&Dbdict::dropFile_fromLocal), op_ptr.p->op_key
22238 op_ptr.p->m_callback = c;
22241 send_drop_file(signal, op_ptr.p->op_key, impl_req->file_id,
22242 DropFileImplReq::Commit);
22248 Dbdict::dropFile_complete(
Signal* signal, SchemaOpPtr op_ptr)
22252 DropFileRecPtr dropFileRecPtr;
22253 getOpRec(op_ptr, dropFileRecPtr);
22257 FilegroupPtr fg_ptr;
22260 ndbrequire(c_file_hash.
find(f_ptr, impl_req->file_id));
22261 ndbrequire(c_filegroup_hash.
find(fg_ptr, f_ptr.p->m_filegroup_id));
22262 decrease_ref_count(fg_ptr.p->m_obj_ptr_i);
22263 release_object(f_ptr.p->m_obj_ptr_i);
22266 sendTransConf(signal, op_ptr);
22270 Dbdict::dropFile_fromLocal(
Signal* signal, Uint32 op_key, Uint32 ret)
22273 SchemaOpPtr op_ptr;
22274 DropFileRecPtr dropFilePtr;
22275 ndbrequire(findSchemaOp(op_ptr, dropFilePtr, op_key));
22280 sendTransConf(signal, op_ptr);
22285 setError(op_ptr, ret, __LINE__);
22286 sendTransRef(signal, op_ptr);
22291 Dbdict::execDROP_FILE_IMPL_REF(
Signal* signal)
22295 handleDictRef(signal, ref);
22299 Dbdict::execDROP_FILE_IMPL_CONF(
Signal* signal)
22303 handleDictConf(signal, conf);
22307 Dbdict::send_drop_file(
Signal* signal, Uint32 op_key, Uint32 fileId,
22308 DropFileImplReq::RequestInfo type)
22312 FilegroupPtr fg_ptr;
22315 ndbrequire(c_file_hash.
find(f_ptr, fileId));
22316 ndbrequire(c_filegroup_hash.
find(fg_ptr, f_ptr.p->m_filegroup_id));
22318 req->senderData = op_key;
22319 req->senderRef = reference();
22320 req->requestInfo =
type;
22322 req->file_id = f_ptr.p->key;
22323 req->filegroup_id = f_ptr.p->m_filegroup_id;
22324 req->filegroup_version = fg_ptr.p->m_version;
22327 switch(f_ptr.p->m_type){
22343 sendSignal(ref, GSN_DROP_FILE_IMPL_REQ, signal,
22344 DropFileImplReq::SignalLength, JBB);
22351 const Dbdict::OpInfo
22352 Dbdict::DropFilegroupRec::g_opInfo = {
22353 {
'D',
'F',
'g', 0 },
22354 GSN_DROP_FILEGROUP_IMPL_REQ,
22355 DropFilegroupImplReq::SignalLength,
22357 &Dbdict::dropFilegroup_seize,
22358 &Dbdict::dropFilegroup_release,
22360 &Dbdict::dropFilegroup_parse,
22361 &Dbdict::dropFilegroup_subOps,
22362 &Dbdict::dropFilegroup_reply,
22364 &Dbdict::dropFilegroup_prepare,
22365 &Dbdict::dropFilegroup_commit,
22366 &Dbdict::dropFilegroup_complete,
22368 &Dbdict::dropFilegroup_abortParse,
22369 &Dbdict::dropFilegroup_abortPrepare
22373 Dbdict::execDROP_FILEGROUP_REQ(
Signal* signal)
22388 SchemaOpPtr op_ptr;
22389 DropFilegroupRecPtr dropFilegroupPtr;
22392 startClientReq(op_ptr, dropFilegroupPtr, req, impl_req, error);
22393 if (hasError(error)) {
22398 impl_req->filegroup_id = req->filegroup_id;
22399 impl_req->filegroup_version = req->filegroup_version;
22401 handleClientReq(signal, op_ptr, handle);
22405 releaseSections(handle);
22408 ref->senderRef = reference();
22409 ref->transId = req->transId;
22410 ref->senderData = req->senderData;
22411 getError(error, ref);
22413 sendSignal(req->senderRef, GSN_DROP_FILEGROUP_REF, signal,
22414 DropFilegroupRef::SignalLength, JBB);
22418 Dbdict::dropFilegroup_seize(SchemaOpPtr op_ptr)
22420 return seizeOpRec<DropFilegroupRec>(op_ptr);
22424 Dbdict::dropFilegroup_release(SchemaOpPtr op_ptr)
22426 releaseOpRec<DropFilegroupRec>(op_ptr);
22432 Dbdict::dropFilegroup_parse(
Signal* signal,
bool master,
22433 SchemaOpPtr op_ptr,
22436 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22437 DropFilegroupRecPtr dropFilegroupRecPtr;
22438 getOpRec(op_ptr, dropFilegroupRecPtr);
22441 FilegroupPtr fg_ptr;
22442 if (!c_filegroup_hash.
find(fg_ptr, impl_req->filegroup_id))
22445 setError(error, DropFilegroupRef::NoSuchFilegroup, __LINE__);
22449 if (fg_ptr.p->m_version != impl_req->filegroup_version)
22452 setError(error, DropFilegroupRef::InvalidSchemaObjectVersion, __LINE__);
22457 if (obj->m_ref_count)
22460 setError(error, DropFilegroupRef::FilegroupInUse, __LINE__);
22464 if (check_write_obj(impl_req->filegroup_id,
22465 trans_ptr.p->m_transId,
22466 SchemaFile::SF_DROP, error))
22473 te.m_tableState = SchemaFile::SF_DROP;
22474 te.m_transId = trans_ptr.p->m_transId;
22475 Uint32 err = trans_log_schema_op(op_ptr, impl_req->filegroup_id, &te);
22479 setError(error, err, __LINE__);
22483 #if defined VM_TRACE || defined ERROR_INSERT
22486 Rope name(c_rope_pool, fg_ptr.p->m_name);
22488 ndbout_c(
"Dbdict: drop name=%s,id=%u,obj_id=%u", buf,
22489 impl_req->filegroup_id,
22490 fg_ptr.p->m_obj_ptr_i);
22496 Dbdict::dropFilegroup_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
22499 sendTransConf(signal, op_ptr);
22503 Dbdict::dropFilegroup_subOps(
Signal* signal, SchemaOpPtr op_ptr)
22509 Dbdict::dropFilegroup_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
22512 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22513 DropFilegroupRecPtr dropFilegroupRecPtr;
22514 getOpRec(op_ptr, dropFilegroupRecPtr);
22517 if (!hasError(error))
22521 conf->senderRef = reference();
22522 conf->senderData = op_ptr.p->m_clientData;
22523 conf->transId = trans_ptr.p->m_transId;
22524 conf->filegroupId = impl_req->filegroup_id;
22525 conf->filegroupVersion = impl_req->filegroup_version;
22526 Uint32 clientRef = op_ptr.p->m_clientRef;
22527 sendSignal(clientRef, GSN_DROP_FILEGROUP_CONF, signal,
22528 DropFilegroupConf::SignalLength, JBB);
22534 ref->senderRef = reference();
22535 ref->senderData = op_ptr.p->m_clientData;
22536 ref->transId = trans_ptr.p->m_transId;
22537 getError(error, ref);
22539 Uint32 clientRef = op_ptr.p->m_clientRef;
22540 sendSignal(clientRef, GSN_DROP_FILEGROUP_REF, signal,
22541 DropFilegroupRef::SignalLength, JBB);
22548 Dbdict::dropFilegroup_prepare(
Signal* signal, SchemaOpPtr op_ptr)
22551 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22552 DropFilegroupRecPtr dropFilegroupRecPtr;
22553 getOpRec(op_ptr, dropFilegroupRecPtr);
22557 safe_cast(&Dbdict::dropFilegroup_fromLocal), op_ptr.p->op_key
22559 op_ptr.p->m_callback = c;
22561 send_drop_fg(signal, op_ptr.p->op_key, impl_req->filegroup_id,
22562 DropFilegroupImplReq::Prepare);
22564 FilegroupPtr fg_ptr;
22565 ndbrequire(c_filegroup_hash.
find(fg_ptr, impl_req->filegroup_id));
22569 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
22571 Local_file_list list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
22572 for(list.first(filePtr); !filePtr.isNull(); list.next(filePtr))
22576 DictObjectPtr objPtr;
22577 c_obj_pool.
getPtr(objPtr, filePtr.p->m_obj_ptr_i);
22579 entry->m_tableState = SchemaFile::SF_DROP;
22580 entry->m_transId = trans_ptr.p->m_transId;
22586 Dbdict::dropFilegroup_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
22589 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22590 DropFilegroupRecPtr dropFilegroupPtr;
22591 getOpRec(op_ptr, dropFilegroupPtr);
22595 safe_cast(&Dbdict::dropFilegroup_fromLocal), op_ptr.p->op_key
22597 op_ptr.p->m_callback = c;
22599 send_drop_fg(signal, op_ptr.p->op_key, impl_req->filegroup_id,
22600 DropFilegroupImplReq::Abort);
22602 FilegroupPtr fg_ptr;
22603 ndbrequire(c_filegroup_hash.
find(fg_ptr, impl_req->filegroup_id));
22608 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
22610 Local_file_list list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
22611 for(list.first(filePtr); !filePtr.isNull(); list.next(filePtr))
22615 DictObjectPtr objPtr;
22616 c_obj_pool.
getPtr(objPtr, filePtr.p->m_obj_ptr_i);
22618 entry->m_tableState = SchemaFile::SF_IN_USE;
22619 entry->m_transId = 0;
22627 Dbdict::dropFilegroup_commit(
Signal* signal, SchemaOpPtr op_ptr)
22630 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22631 DropFilegroupRecPtr dropFilegroupRecPtr;
22632 getOpRec(op_ptr, dropFilegroupRecPtr);
22636 safe_cast(&Dbdict::dropFilegroup_fromLocal), op_ptr.p->op_key
22638 op_ptr.p->m_callback = c;
22640 send_drop_fg(signal, op_ptr.p->op_key, impl_req->filegroup_id,
22641 DropFilegroupImplReq::Commit);
22643 FilegroupPtr fg_ptr;
22644 ndbrequire(c_filegroup_hash.
find(fg_ptr, impl_req->filegroup_id));
22652 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
22655 Local_file_list list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
22656 for(list.first(filePtr); !filePtr.isNull(); list.next(filePtr))
22660 DictObjectPtr objPtr;
22661 c_obj_pool.
getPtr(objPtr, filePtr.p->m_obj_ptr_i);
22663 entry->m_tableState = SchemaFile::SF_UNUSED;
22664 entry->m_transId = 0;
22666 release_object(objPtr.i, objPtr.p);
22667 c_file_hash.
remove(filePtr);
22674 FilegroupPtr lg_ptr;
22675 ndbrequire(c_filegroup_hash.
22677 fg_ptr.p->m_tablespace.m_default_logfile_group_id));
22679 decrease_ref_count(lg_ptr.p->m_obj_ptr_i);
22686 Dbdict::dropFilegroup_complete(
Signal* signal, SchemaOpPtr op_ptr)
22690 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22691 DropFilegroupRecPtr dropFilegroupRecPtr;
22692 getOpRec(op_ptr, dropFilegroupRecPtr);
22695 FilegroupPtr fg_ptr;
22696 ndbrequire(c_filegroup_hash.
find(fg_ptr, impl_req->filegroup_id));
22698 release_object(fg_ptr.p->m_obj_ptr_i);
22699 c_filegroup_hash.
release(fg_ptr);
22701 sendTransConf(signal, op_ptr);
22705 Dbdict::dropFilegroup_fromLocal(
Signal* signal, Uint32 op_key, Uint32 ret)
22708 SchemaOpPtr op_ptr;
22709 DropFilegroupRecPtr dropFilegroupPtr;
22710 ndbrequire(findSchemaOp(op_ptr, dropFilegroupPtr, op_key));
22715 sendTransConf(signal, op_ptr);
22720 setError(op_ptr, ret, __LINE__);
22721 sendTransRef(signal, op_ptr);
22726 Dbdict::execDROP_FILEGROUP_IMPL_REF(
Signal* signal)
22730 handleDictRef(signal, ref);
22734 Dbdict::execDROP_FILEGROUP_IMPL_CONF(
Signal* signal)
22738 handleDictConf(signal, conf);
22743 Dbdict::send_drop_fg(
Signal* signal, Uint32 op_key, Uint32 filegroupId,
22744 DropFilegroupImplReq::RequestInfo type)
22748 FilegroupPtr fg_ptr;
22749 ndbrequire(c_filegroup_hash.
find(fg_ptr, filegroupId));
22751 req->senderData = op_key;
22752 req->senderRef = reference();
22753 req->requestInfo =
type;
22755 req->filegroup_id = fg_ptr.p->key;
22756 req->filegroup_version = fg_ptr.p->m_version;
22759 switch(fg_ptr.p->m_type){
22770 sendSignal(ref, GSN_DROP_FILEGROUP_IMPL_REQ, signal,
22771 DropFilegroupImplReq::SignalLength, JBB);
22778 const Dbdict::OpInfo
22779 Dbdict::CreateNodegroupRec::g_opInfo = {
22780 {
'C',
'N',
'G', 0 },
22781 GSN_CREATE_NODEGROUP_IMPL_REQ,
22782 CreateNodegroupImplReq::SignalLength,
22784 &Dbdict::createNodegroup_seize,
22785 &Dbdict::createNodegroup_release,
22787 &Dbdict::createNodegroup_parse,
22788 &Dbdict::createNodegroup_subOps,
22789 &Dbdict::createNodegroup_reply,
22791 &Dbdict::createNodegroup_prepare,
22792 &Dbdict::createNodegroup_commit,
22793 &Dbdict::createNodegroup_complete,
22795 &Dbdict::createNodegroup_abortParse,
22796 &Dbdict::createNodegroup_abortPrepare
22800 Dbdict::execCREATE_NODEGROUP_REQ(
Signal* signal)
22815 SchemaOpPtr op_ptr;
22816 CreateNodegroupRecPtr createNodegroupRecPtr;
22819 startClientReq(op_ptr, createNodegroupRecPtr, req, impl_req, error);
22820 if (hasError(error)) {
22825 impl_req->nodegroupId = req->nodegroupId;
22826 for (Uint32 i = 0; i<NDB_ARRAY_SIZE(req->nodes) &&
22827 i<NDB_ARRAY_SIZE(impl_req->nodes); i++)
22829 impl_req->nodes[
i] = req->nodes[
i];
22832 handleClientReq(signal, op_ptr, handle);
22836 releaseSections(handle);
22839 ref->senderRef = reference();
22840 ref->transId = req->transId;
22841 ref->senderData = req->senderData;
22842 getError(error, ref);
22844 sendSignal(req->senderRef, GSN_CREATE_NODEGROUP_REF, signal,
22845 CreateNodegroupRef::SignalLength, JBB);
22849 Dbdict::createNodegroup_seize(SchemaOpPtr op_ptr)
22851 return seizeOpRec<CreateNodegroupRec>(op_ptr);
22855 Dbdict::createNodegroup_release(SchemaOpPtr op_ptr)
22857 releaseOpRec<CreateNodegroupRec>(op_ptr);
22863 Dbdict::createNodegroup_parse(
Signal* signal,
bool master,
22864 SchemaOpPtr op_ptr,
22867 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22868 CreateNodegroupRecPtr createNodegroupRecPtr;
22869 getOpRec(op_ptr, createNodegroupRecPtr);
22874 Uint32 save = impl_req->requestType;
22875 impl_req->requestType = CreateNodegroupImplReq::RT_PARSE;
22876 memcpy(signal->theData, impl_req, 4*CreateNodegroupImplReq::SignalLength);
22877 impl_req->requestType = save;
22880 CreateNodegroupImplReq::SignalLength);
22883 Uint32 ret = signal->theData[0];
22887 setError(error, ret, __LINE__);
22891 impl_req->senderRef = reference();
22892 impl_req->senderData = op_ptr.p->op_key;
22893 impl_req->nodegroupId = signal->theData[1];
22899 trans_ptr.p->m_wait_gcp_on_commit =
false;
22903 Dbdict::createNodegroup_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
22906 sendTransConf(signal, op_ptr);
22910 Dbdict::createNodegroup_subOps(
Signal* signal, SchemaOpPtr op_ptr)
22912 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22913 CreateNodegroupRecPtr createNodegroupRecPtr;
22914 getOpRec(op_ptr, createNodegroupRecPtr);
22917 if (createNodegroupRecPtr.p->m_map_created ==
false)
22920 createNodegroupRecPtr.p->m_map_created =
true;
22928 Uint32 buckets = 240;
22929 Uint32 fragments = get_default_fragments(signal, 1);
22930 char buf[MAX_TAB_NAME_SIZE+1];
22935 if (get_object(buf) != 0)
22943 safe_cast(&Dbdict::createNodegroup_fromCreateHashMap),
22946 op_ptr.p->m_callback = c;
22949 req->clientRef = reference();
22950 req->clientData = op_ptr.p->op_key;
22951 req->requestInfo = 0;
22952 req->transId = trans_ptr.p->m_transId;
22953 req->transKey = trans_ptr.p->trans_key;
22954 req->buckets = buckets;
22955 req->fragments = fragments;
22956 sendSignal(DBDICT_REF, GSN_CREATE_HASH_MAP_REQ, signal,
22957 CreateHashMapReq::SignalLength, JBB);
22965 Dbdict::createNodegroup_fromCreateHashMap(
Signal* signal,
22969 SchemaOpPtr op_ptr;
22970 CreateNodegroupRecPtr createNodegroupRecPtr;
22971 findSchemaOp(op_ptr, createNodegroupRecPtr, op_key);
22972 ndbrequire(!op_ptr.isNull());
22977 createSubOps(signal, op_ptr);
22985 setError(error, ref);
22986 abortSubOps(signal, op_ptr, error);
22991 Dbdict::createNodegroup_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
22994 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
22995 CreateNodegroupRecPtr createNodegroupRecPtr;
22996 getOpRec(op_ptr, createNodegroupRecPtr);
22999 if (!hasError(error))
23003 conf->senderRef = reference();
23004 conf->senderData = op_ptr.p->m_clientData;
23005 conf->transId = trans_ptr.p->m_transId;
23006 conf->nodegroupId = impl_req->nodegroupId;
23007 Uint32 clientRef = op_ptr.p->m_clientRef;
23008 sendSignal(clientRef, GSN_CREATE_NODEGROUP_CONF, signal,
23009 CreateNodegroupConf::SignalLength, JBB);
23015 ref->senderRef = reference();
23016 ref->senderData = op_ptr.p->m_clientData;
23017 ref->transId = trans_ptr.p->m_transId;
23018 getError(error, ref);
23020 Uint32 clientRef = op_ptr.p->m_clientRef;
23021 sendSignal(clientRef, GSN_CREATE_NODEGROUP_REF, signal,
23022 CreateNodegroupRef::SignalLength, JBB);
23029 Dbdict::createNodegroup_prepare(
Signal* signal, SchemaOpPtr op_ptr)
23032 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23033 CreateNodegroupRecPtr createNodegroupRecPtr;
23034 getOpRec(op_ptr, createNodegroupRecPtr);
23037 impl_req->requestType = CreateNodegroupImplReq::RT_PREPARE;
23038 createNodegroupRecPtr.p->m_blockCnt = 2;
23039 createNodegroupRecPtr.p->m_blockIndex = 0;
23040 createNodegroupRecPtr.p->m_blockNo[0] = DBDIH_REF;
23041 createNodegroupRecPtr.p->m_blockNo[1] = SUMA_REF;
23044 safe_cast(&Dbdict::createNodegroup_fromBlockSubStartStop),
23047 op_ptr.p->m_callback = c;
23049 block_substartstop(signal, op_ptr);
23053 Dbdict::createNodegroup_fromBlockSubStartStop(
Signal* signal,
23057 SchemaOpPtr op_ptr;
23058 CreateNodegroupRecPtr createNodegroupRecPtr;
23059 findSchemaOp(op_ptr, createNodegroupRecPtr, op_key);
23060 ndbrequire(!op_ptr.isNull());
23066 createNodegroupRecPtr.p->m_substartstop_blocked =
true;
23067 createNodegroup_toLocal(signal, op_ptr);
23072 setError(op_ptr, ret, __LINE__);
23073 sendTransRef(signal, op_ptr);
23078 Dbdict::createNodegroup_toLocal(
Signal* signal, SchemaOpPtr op_ptr)
23080 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23081 CreateNodegroupRecPtr createNodegroupRecPtr;
23082 getOpRec(op_ptr, createNodegroupRecPtr);
23085 const Uint32 blockIndex = createNodegroupRecPtr.p->m_blockIndex;
23086 if (blockIndex == createNodegroupRecPtr.p->m_blockCnt)
23090 if (op_ptr.p->m_state == SchemaOp::OS_PREPARING)
23098 safe_cast(&Dbdict::createNodegroup_fromWaitGCP),
23101 op_ptr.p->m_callback = c;
23103 createNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23104 createNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::BlockStartGcp;
23105 wait_gcp(signal, op_ptr, WaitGCPReq::BlockStartGcp);
23109 if (op_ptr.p->m_state == SchemaOp::OS_COMPLETING)
23116 safe_cast(&Dbdict::createNodegroup_fromWaitGCP),
23119 op_ptr.p->m_callback = c;
23121 createNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23122 createNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::UnblockStartGcp;
23123 wait_gcp(signal, op_ptr, WaitGCPReq::UnblockStartGcp);
23127 sendTransConf(signal, op_ptr);
23132 safe_cast(&Dbdict::createNodegroup_fromLocal),
23135 op_ptr.p->m_callback = c;
23137 Uint32 ref = createNodegroupRecPtr.p->m_blockNo[blockIndex];
23139 memcpy(req, impl_req, 4*CreateNodegroupImplReq::SignalLength);
23140 sendSignal(ref, GSN_CREATE_NODEGROUP_IMPL_REQ, signal,
23141 CreateNodegroupImplReq::SignalLength, JBB);
23145 Dbdict::createNodegroup_fromLocal(
Signal* signal,
23149 SchemaOpPtr op_ptr;
23150 CreateNodegroupRecPtr createNodegroupRecPtr;
23151 findSchemaOp(op_ptr, createNodegroupRecPtr, op_key);
23152 ndbrequire(!op_ptr.isNull());
23155 Uint32 blockIndex = createNodegroupRecPtr.p->m_blockIndex;
23156 ndbrequire(blockIndex < createNodegroupRecPtr.p->m_blockCnt);
23160 setError(op_ptr, ret, __LINE__);
23161 sendTransRef(signal, op_ptr);
23165 Uint32 idx = createNodegroupRecPtr.p->m_blockIndex;
23166 if (op_ptr.p->m_state == SchemaOp::OS_COMPLETING &&
23167 createNodegroupRecPtr.p->m_blockNo[idx] == DBDIH_REF)
23173 impl_req->gci_hi = conf->gci_hi;
23174 impl_req->gci_lo = conf->gci_lo;
23177 createNodegroupRecPtr.p->m_blockIndex++;
23178 createNodegroup_toLocal(signal, op_ptr);
23182 Dbdict::createNodegroup_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
23184 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23185 CreateNodegroupRecPtr createNodegroupRecPtr;
23186 getOpRec(op_ptr, createNodegroupRecPtr);
23189 if (createNodegroupRecPtr.p->m_substartstop_blocked)
23192 unblock_substartstop();
23195 if (createNodegroupRecPtr.p->m_gcp_blocked)
23200 safe_cast(&Dbdict::createNodegroup_fromWaitGCP),
23203 op_ptr.p->m_callback = c;
23205 createNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23206 createNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::UnblockStartGcp;
23207 wait_gcp(signal, op_ptr, WaitGCPReq::UnblockStartGcp);
23211 sendTransConf(signal, op_ptr);
23217 Dbdict::createNodegroup_commit(
Signal* signal, SchemaOpPtr op_ptr)
23220 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23221 CreateNodegroupRecPtr createNodegroupRecPtr;
23222 getOpRec(op_ptr, createNodegroupRecPtr);
23225 impl_req->requestType = CreateNodegroupImplReq::RT_COMMIT;
23226 createNodegroupRecPtr.p->m_blockCnt = 2;
23227 createNodegroupRecPtr.p->m_blockIndex = 0;
23228 createNodegroupRecPtr.p->m_blockNo[0] = DBDIH_REF;
23229 createNodegroupRecPtr.p->m_blockNo[1] = NDBCNTR_REF;
23232 safe_cast(&Dbdict::createNodegroup_fromWaitGCP),
23235 op_ptr.p->m_callback = c;
23237 createNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23238 createNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::WaitEpoch;
23239 wait_gcp(signal, op_ptr, WaitGCPReq::WaitEpoch);
23243 Dbdict::createNodegroup_fromWaitGCP(
Signal* signal,
23248 SchemaOpPtr op_ptr;
23249 CreateNodegroupRecPtr createNodegroupRecPtr;
23250 findSchemaOp(op_ptr, createNodegroupRecPtr, op_key);
23251 ndbrequire(!op_ptr.isNull());
23253 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23260 Uint32 wait_type = createNodegroupRecPtr.p->m_wait_gcp_type;
23261 if (op_ptr.p->m_state == SchemaOp::OS_ABORTED_PREPARE)
23264 ndbrequire(wait_type == WaitGCPReq::UnblockStartGcp);
23265 sendTransConf(signal, op_ptr);
23268 else if (op_ptr.p->m_state == SchemaOp::OS_PREPARING)
23271 ndbrequire(wait_type == WaitGCPReq::BlockStartGcp);
23272 createNodegroupRecPtr.p->m_gcp_blocked =
true;
23273 sendTransConf(signal, op_ptr);
23276 else if (op_ptr.p->m_state == SchemaOp::OS_COMMITTING)
23279 ndbrequire(wait_type == WaitGCPReq::WaitEpoch);
23280 createNodegroup_toLocal(signal, op_ptr);
23286 ndbrequire(op_ptr.p->m_state == SchemaOp::OS_COMPLETING);
23288 if (wait_type == WaitGCPReq::UnblockStartGcp)
23292 createNodegroupRecPtr.p->m_wait_gcp_type = wait_type;
23299 unblock_substartstop();
23302 sendTransConf(signal, op_ptr);
23307 createNodegroupRecPtr.p->m_cnt_waitGCP++;
23309 case WaitGCPRef::NoWaitGCPRecords:
23311 case WaitGCPRef::NF_CausedAbortOfProcedure:
23313 case WaitGCPRef::NF_MasterTakeOverInProgress:
23318 wait_gcp(signal, op_ptr, createNodegroupRecPtr.p->m_wait_gcp_type);
23324 Dbdict::createNodegroup_complete(
Signal* signal, SchemaOpPtr op_ptr)
23327 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23328 CreateNodegroupRecPtr createNodegroupRecPtr;
23329 getOpRec(op_ptr, createNodegroupRecPtr);
23332 impl_req->requestType = CreateNodegroupImplReq::RT_COMPLETE;
23333 createNodegroupRecPtr.p->m_blockCnt = 2;
23334 createNodegroupRecPtr.p->m_blockIndex = 0;
23335 createNodegroupRecPtr.p->m_blockNo[0] = DBDIH_REF;
23336 createNodegroupRecPtr.p->m_blockNo[1] = SUMA_REF;
23338 createNodegroup_toLocal(signal, op_ptr);
23342 Dbdict::execCREATE_NODEGROUP_IMPL_REF(
Signal* signal)
23346 handleDictRef(signal, ref);
23350 Dbdict::execCREATE_NODEGROUP_IMPL_CONF(
Signal* signal)
23354 handleDictConf(signal, conf);
23358 Dbdict::execCREATE_HASH_MAP_REF(
Signal* signal)
23362 handleDictRef(signal, ref);
23366 Dbdict::execCREATE_HASH_MAP_CONF(
Signal* signal)
23370 handleDictConf(signal, conf);
23377 const Dbdict::OpInfo
23378 Dbdict::DropNodegroupRec::g_opInfo = {
23379 {
'D',
'N',
'G', 0 },
23380 GSN_DROP_NODEGROUP_IMPL_REQ,
23381 DropNodegroupImplReq::SignalLength,
23383 &Dbdict::dropNodegroup_seize,
23384 &Dbdict::dropNodegroup_release,
23386 &Dbdict::dropNodegroup_parse,
23387 &Dbdict::dropNodegroup_subOps,
23388 &Dbdict::dropNodegroup_reply,
23390 &Dbdict::dropNodegroup_prepare,
23391 &Dbdict::dropNodegroup_commit,
23392 &Dbdict::dropNodegroup_complete,
23394 &Dbdict::dropNodegroup_abortParse,
23395 &Dbdict::dropNodegroup_abortPrepare
23399 Dbdict::execDROP_NODEGROUP_REQ(
Signal* signal)
23414 SchemaOpPtr op_ptr;
23415 DropNodegroupRecPtr dropNodegroupRecPtr;
23418 startClientReq(op_ptr, dropNodegroupRecPtr, req, impl_req, error);
23419 if (hasError(error)) {
23424 impl_req->nodegroupId = req->nodegroupId;
23426 handleClientReq(signal, op_ptr, handle);
23430 releaseSections(handle);
23433 ref->senderRef = reference();
23434 ref->transId = req->transId;
23435 ref->senderData = req->senderData;
23436 getError(error, ref);
23438 sendSignal(req->senderRef, GSN_DROP_NODEGROUP_REF, signal,
23439 DropNodegroupRef::SignalLength, JBB);
23443 Dbdict::dropNodegroup_seize(SchemaOpPtr op_ptr)
23445 return seizeOpRec<DropNodegroupRec>(op_ptr);
23449 Dbdict::dropNodegroup_release(SchemaOpPtr op_ptr)
23451 releaseOpRec<DropNodegroupRec>(op_ptr);
23457 Dbdict::dropNodegroup_parse(
Signal* signal,
bool master,
23458 SchemaOpPtr op_ptr,
23461 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23462 DropNodegroupRecPtr dropNodegroupRecPtr;
23463 getOpRec(op_ptr, dropNodegroupRecPtr);
23466 impl_req->senderRef = reference();
23467 impl_req->senderData = op_ptr.p->op_key;
23473 trans_ptr.p->m_wait_gcp_on_commit =
false;
23477 Dbdict::dropNodegroup_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
23480 sendTransConf(signal, op_ptr);
23484 Dbdict::dropNodegroup_subOps(
Signal* signal, SchemaOpPtr op_ptr)
23490 Dbdict::dropNodegroup_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
23493 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23494 DropNodegroupRecPtr dropNodegroupRecPtr;
23495 getOpRec(op_ptr, dropNodegroupRecPtr);
23498 if (!hasError(error))
23502 conf->senderRef = reference();
23503 conf->senderData = op_ptr.p->m_clientData;
23504 conf->transId = trans_ptr.p->m_transId;
23505 Uint32 clientRef = op_ptr.p->m_clientRef;
23506 sendSignal(clientRef, GSN_DROP_NODEGROUP_CONF, signal,
23507 DropNodegroupConf::SignalLength, JBB);
23513 ref->senderRef = reference();
23514 ref->senderData = op_ptr.p->m_clientData;
23515 ref->transId = trans_ptr.p->m_transId;
23516 getError(error, ref);
23518 Uint32 clientRef = op_ptr.p->m_clientRef;
23519 sendSignal(clientRef, GSN_DROP_NODEGROUP_REF, signal,
23520 DropNodegroupRef::SignalLength, JBB);
23527 Dbdict::dropNodegroup_prepare(
Signal* signal, SchemaOpPtr op_ptr)
23530 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23531 DropNodegroupRecPtr dropNodegroupRecPtr;
23532 getOpRec(op_ptr, dropNodegroupRecPtr);
23535 impl_req->requestType = DropNodegroupImplReq::RT_PREPARE;
23536 dropNodegroupRecPtr.p->m_blockCnt = 2;
23537 dropNodegroupRecPtr.p->m_blockIndex = 0;
23538 dropNodegroupRecPtr.p->m_blockNo[0] = DBDIH_REF;
23539 dropNodegroupRecPtr.p->m_blockNo[1] = SUMA_REF;
23542 safe_cast(&Dbdict::dropNodegroup_fromBlockSubStartStop),
23545 op_ptr.p->m_callback = c;
23547 block_substartstop(signal, op_ptr);
23551 Dbdict::dropNodegroup_fromBlockSubStartStop(
Signal* signal,
23555 SchemaOpPtr op_ptr;
23556 DropNodegroupRecPtr dropNodegroupRecPtr;
23557 findSchemaOp(op_ptr, dropNodegroupRecPtr, op_key);
23558 ndbrequire(!op_ptr.isNull());
23564 dropNodegroupRecPtr.p->m_substartstop_blocked =
true;
23565 dropNodegroup_toLocal(signal, op_ptr);
23570 setError(op_ptr, ret, __LINE__);
23571 sendTransRef(signal, op_ptr);
23576 Dbdict::dropNodegroup_toLocal(
Signal* signal, SchemaOpPtr op_ptr)
23578 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23579 DropNodegroupRecPtr dropNodegroupRecPtr;
23580 getOpRec(op_ptr, dropNodegroupRecPtr);
23583 const Uint32 blockIndex = dropNodegroupRecPtr.p->m_blockIndex;
23584 if (blockIndex == dropNodegroupRecPtr.p->m_blockCnt)
23588 if (op_ptr.p->m_state == SchemaOp::OS_PREPARING)
23596 safe_cast(&Dbdict::dropNodegroup_fromWaitGCP),
23599 op_ptr.p->m_callback = c;
23601 dropNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23602 dropNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::BlockStartGcp;
23603 wait_gcp(signal, op_ptr, WaitGCPReq::BlockStartGcp);
23607 if (op_ptr.p->m_state == SchemaOp::OS_COMPLETING)
23614 safe_cast(&Dbdict::dropNodegroup_fromWaitGCP),
23617 op_ptr.p->m_callback = c;
23619 dropNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23620 dropNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::UnblockStartGcp;
23621 wait_gcp(signal, op_ptr, WaitGCPReq::UnblockStartGcp);
23625 sendTransConf(signal, op_ptr);
23630 safe_cast(&Dbdict::dropNodegroup_fromLocal),
23633 op_ptr.p->m_callback = c;
23635 Uint32 ref = dropNodegroupRecPtr.p->m_blockNo[blockIndex];
23637 memcpy(req, impl_req, 4*DropNodegroupImplReq::SignalLength);
23638 sendSignal(ref, GSN_DROP_NODEGROUP_IMPL_REQ, signal,
23639 DropNodegroupImplReq::SignalLength, JBB);
23643 Dbdict::dropNodegroup_fromLocal(
Signal* signal,
23647 SchemaOpPtr op_ptr;
23648 DropNodegroupRecPtr dropNodegroupRecPtr;
23649 findSchemaOp(op_ptr, dropNodegroupRecPtr, op_key);
23650 ndbrequire(!op_ptr.isNull());
23653 Uint32 blockIndex = dropNodegroupRecPtr.p->m_blockIndex;
23654 ndbrequire(blockIndex < dropNodegroupRecPtr.p->m_blockCnt);
23659 setError(op_ptr, ret, __LINE__);
23660 sendTransRef(signal, op_ptr);
23664 Uint32 idx = dropNodegroupRecPtr.p->m_blockIndex;
23665 if (op_ptr.p->m_state == SchemaOp::OS_COMMITTING &&
23666 dropNodegroupRecPtr.p->m_blockNo[idx] == DBDIH_REF)
23672 impl_req->gci_hi = conf->gci_hi;
23673 impl_req->gci_lo = conf->gci_lo;
23677 dropNodegroupRecPtr.p->m_blockIndex++;
23678 dropNodegroup_toLocal(signal, op_ptr);
23683 Dbdict::dropNodegroup_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
23685 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23686 DropNodegroupRecPtr dropNodegroupRecPtr;
23687 getOpRec(op_ptr, dropNodegroupRecPtr);
23690 if (dropNodegroupRecPtr.p->m_substartstop_blocked)
23693 unblock_substartstop();
23696 if (dropNodegroupRecPtr.p->m_gcp_blocked)
23701 safe_cast(&Dbdict::dropNodegroup_fromWaitGCP),
23704 op_ptr.p->m_callback = c;
23706 dropNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23707 dropNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::UnblockStartGcp;
23708 wait_gcp(signal, op_ptr, WaitGCPReq::UnblockStartGcp);
23712 sendTransConf(signal, op_ptr);
23718 Dbdict::dropNodegroup_commit(
Signal* signal, SchemaOpPtr op_ptr)
23721 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23722 DropNodegroupRecPtr dropNodegroupRecPtr;
23723 getOpRec(op_ptr, dropNodegroupRecPtr);
23726 impl_req->requestType = DropNodegroupImplReq::RT_COMMIT;
23728 dropNodegroupRecPtr.p->m_blockIndex = 0;
23729 dropNodegroupRecPtr.p->m_blockCnt = 1;
23730 dropNodegroupRecPtr.p->m_blockNo[0] = DBDIH_REF;
23733 safe_cast(&Dbdict::dropNodegroup_fromWaitGCP),
23736 op_ptr.p->m_callback = c;
23738 dropNodegroupRecPtr.p->m_cnt_waitGCP = 0;
23739 dropNodegroupRecPtr.p->m_wait_gcp_type = WaitGCPReq::WaitEpoch;
23740 wait_gcp(signal, op_ptr, WaitGCPReq::WaitEpoch);
23744 Dbdict::dropNodegroup_fromWaitGCP(
Signal* signal,
23749 SchemaOpPtr op_ptr;
23750 DropNodegroupRecPtr dropNodegroupRecPtr;
23751 findSchemaOp(op_ptr, dropNodegroupRecPtr, op_key);
23752 ndbrequire(!op_ptr.isNull());
23754 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23761 Uint32 wait_type = dropNodegroupRecPtr.p->m_wait_gcp_type;
23762 if (op_ptr.p->m_state == SchemaOp::OS_ABORTING_PREPARE)
23765 ndbrequire(wait_type == WaitGCPReq::UnblockStartGcp);
23766 sendTransConf(signal, op_ptr);
23769 else if (op_ptr.p->m_state == SchemaOp::OS_PREPARING)
23772 ndbrequire(wait_type == WaitGCPReq::BlockStartGcp);
23773 dropNodegroupRecPtr.p->m_gcp_blocked =
true;
23774 sendTransConf(signal, op_ptr);
23777 else if (op_ptr.p->m_state == SchemaOp::OS_COMMITTING)
23780 ndbrequire(wait_type == WaitGCPReq::WaitEpoch);
23781 dropNodegroup_toLocal(signal, op_ptr);
23788 ndbrequire(op_ptr.p->m_state == SchemaOp::OS_COMPLETING);
23789 if (wait_type == WaitGCPReq::UnblockStartGcp)
23802 unblock_substartstop();
23804 sendTransConf(signal, op_ptr);
23809 dropNodegroupRecPtr.p->m_cnt_waitGCP++;
23811 case WaitGCPRef::NoWaitGCPRecords:
23813 case WaitGCPRef::NF_CausedAbortOfProcedure:
23815 case WaitGCPRef::NF_MasterTakeOverInProgress:
23820 wait_gcp(signal, op_ptr, dropNodegroupRecPtr.p->m_wait_gcp_type);
23826 Dbdict::dropNodegroup_complete(
Signal* signal, SchemaOpPtr op_ptr)
23830 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23831 DropNodegroupRecPtr dropNodegroupRecPtr;
23832 getOpRec(op_ptr, dropNodegroupRecPtr);
23835 impl_req->requestType = DropNodegroupImplReq::RT_COMPLETE;
23836 dropNodegroupRecPtr.p->m_blockIndex = 0;
23837 dropNodegroupRecPtr.p->m_blockCnt = 3;
23838 dropNodegroupRecPtr.p->m_blockNo[0] = SUMA_REF;
23839 dropNodegroupRecPtr.p->m_blockNo[1] = DBDIH_REF;
23840 dropNodegroupRecPtr.p->m_blockNo[2] = NDBCNTR_REF;
23842 dropNodegroup_toLocal(signal, op_ptr);
23846 Dbdict::execDROP_NODEGROUP_IMPL_REF(
Signal* signal)
23850 handleDictRef(signal, ref);
23854 Dbdict::execDROP_NODEGROUP_IMPL_CONF(
Signal* signal)
23858 handleDictConf(signal, conf);
23869 int Dbdict::checkSingleUserMode(Uint32 senderRef)
23871 Uint32 nodeId = refToNode(senderRef);
23883 Dbdict::setError(ErrorInfo& e,
23891 D(
"setError" << V(code) << V(line) << V(nodeId) << V(e.errorCount));
23894 if (e.errorCount == 0) {
23895 e.errorCode = code;
23896 e.errorLine = line;
23897 e.errorNodeId = nodeId ? nodeId : getOwnNodeId();
23898 e.errorStatus = status;
23907 Dbdict::setError(ErrorInfo& e,
23912 setError(e, code, line, 0, 0, 0, name);
23916 Dbdict::setError(ErrorInfo& e,
const ErrorInfo& e2)
23918 setError(e, e2.errorCode, e2.errorLine, e2.errorNodeId);
23922 Dbdict::setError(ErrorInfo& e,
const ParseDictTabInfoRecord& e2)
23924 setError(e, e2.errorCode, e2.errorLine, 0, e2.status, e2.errorKey);
23928 Dbdict::setError(SchemaOpPtr op_ptr, Uint32 code, Uint32 line, Uint32 nodeId)
23930 D(
"setError" << *op_ptr.p << V(code) << V(line) << V(nodeId));
23931 setError(op_ptr.p->m_error, code, line, nodeId);
23933 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
23935 if (!trans_ptr.isNull()) {
23936 setError(trans_ptr.p->m_error, op_ptr.p->m_error);
23941 Dbdict::setError(SchemaOpPtr op_ptr,
const ErrorInfo& e2)
23943 setError(op_ptr, e2.errorCode, e2.errorLine, e2.errorNodeId);
23947 Dbdict::setError(SchemaTransPtr trans_ptr, Uint32 code, Uint32 line, Uint32 nodeId)
23949 D(
"setError" << *trans_ptr.p << V(code) << V(line) << V(nodeId));
23950 setError(trans_ptr.p->m_error, code, line, nodeId);
23954 Dbdict::setError(SchemaTransPtr trans_ptr,
const ErrorInfo& e2)
23956 setError(trans_ptr, e2.errorCode, e2.errorLine, e2.errorNodeId);
23960 Dbdict::setError(TxHandlePtr tx_ptr, Uint32 code, Uint32 line, Uint32 nodeId)
23962 D(
"setError" << *tx_ptr.p << V(code) << V(line) << V(nodeId));
23963 setError(tx_ptr.p->m_error, code, line, nodeId);
23967 Dbdict::setError(TxHandlePtr tx_ptr,
const ErrorInfo& e2)
23969 setError(tx_ptr, e2.errorCode, e2.errorLine, e2.errorNodeId);
23973 Dbdict::hasError(
const ErrorInfo& e)
23975 return e.errorCount != 0;
23979 Dbdict::resetError(ErrorInfo& e)
23981 new (&e) ErrorInfo();
23985 Dbdict::resetError(SchemaOpPtr op_ptr)
23987 if (hasError(op_ptr.p->m_error)) {
23989 D(
"resetError" << *op_ptr.p);
23990 resetError(op_ptr.p->m_error);
23995 Dbdict::resetError(SchemaTransPtr trans_ptr)
23997 if (hasError(trans_ptr.p->m_error)) {
23999 D(
"resetError" << *trans_ptr.p);
24000 resetError(trans_ptr.p->m_error);
24005 Dbdict::resetError(TxHandlePtr tx_ptr)
24007 if (hasError(tx_ptr.p->m_error)) {
24009 D(
"resetError" << *tx_ptr.p);
24010 resetError(tx_ptr.p->m_error);
24016 const Dbdict::OpInfo*
24017 Dbdict::g_opInfoList[] = {
24018 &Dbdict::CreateTableRec::g_opInfo,
24019 &Dbdict::DropTableRec::g_opInfo,
24020 &Dbdict::AlterTableRec::g_opInfo,
24021 &Dbdict::CreateTriggerRec::g_opInfo,
24022 &Dbdict::DropTriggerRec::g_opInfo,
24023 &Dbdict::CreateIndexRec::g_opInfo,
24024 &Dbdict::DropIndexRec::g_opInfo,
24025 &Dbdict::AlterIndexRec::g_opInfo,
24026 &Dbdict::BuildIndexRec::g_opInfo,
24027 &Dbdict::IndexStatRec::g_opInfo,
24028 &Dbdict::CreateFilegroupRec::g_opInfo,
24029 &Dbdict::CreateFileRec::g_opInfo,
24030 &Dbdict::DropFilegroupRec::g_opInfo,
24031 &Dbdict::DropFileRec::g_opInfo,
24032 &Dbdict::CreateHashMapRec::g_opInfo,
24033 &Dbdict::CopyDataRec::g_opInfo,
24034 &Dbdict::CreateNodegroupRec::g_opInfo,
24035 &Dbdict::DropNodegroupRec::g_opInfo,
24039 const Dbdict::OpInfo*
24040 Dbdict::findOpInfo(Uint32 gsn)
24043 while (g_opInfoList[i]) {
24044 const OpInfo* info = g_opInfoList[
i];
24045 if (info->m_impl_req_gsn == 0)
24047 if (info->m_impl_req_gsn == gsn)
24062 const Uint32 size = 1024;
24067 Uint32 len = ss_ptr.sz;
24071 ndbrequire(reader.getWords(buf, size));
24072 if (!copyIn(op_sec, buf, size))
24080 ndbrequire(reader.getWords(buf, len));
24081 if (!copyIn(op_sec, buf, len))
24091 Dbdict::copyIn(OpSection& op_sec,
const Uint32* src, Uint32 srcSize)
24093 OpSectionBuffer buffer(c_opSectionBufferPool, op_sec.m_head);
24094 if (!buffer.append(src, srcSize)) {
24108 for(; !iter.isNull() && n < len; buffer.next(iter))
24110 dst[
n] = *iter.data;
24120 const Uint32 size = 1024;
24123 Uint32 len = op_sec.getSize();
24124 OpSectionBufferHead tmp_head = op_sec.m_head;
24125 OpSectionBuffer buffer(c_opSectionBufferPool, tmp_head);
24127 OpSectionBufferConstIterator iter;
24128 buffer.
first(iter);
24129 Uint32 ptrI = RNIL;
24132 if (!copyOut(buffer, iter, buf, size))
24137 if (!appendToSection(ptrI, buf, size))
24145 if (!copyOut(buffer, iter, buf, len))
24151 if (!appendToSection(ptrI, buf, len))
24157 getSection(ss_ptr, ptrI);
24161 releaseSection(ptrI);
24166 Dbdict::copyOut(
const OpSection& op_sec, Uint32* dst, Uint32 dstSize)
24168 if (op_sec.getSize() > dstSize) {
24174 OpSectionBufferHead tmp_head = op_sec.m_head;
24175 OpSectionBuffer buffer(c_opSectionBufferPool, tmp_head);
24177 OpSectionBufferConstIterator iter;
24179 for(buffer.
first(iter); !iter.isNull(); buffer.next(iter)) {
24181 dst[
n] = *iter.data;
24184 ndbrequire(n == op_sec.getSize());
24189 Dbdict::release(OpSection& op_sec)
24191 OpSectionBuffer buffer(c_opSectionBufferPool, op_sec.m_head);
24197 const Dbdict::OpInfo&
24198 Dbdict::getOpInfo(SchemaOpPtr op_ptr)
24200 ndbrequire(!op_ptr.isNull());
24201 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
24202 ndbrequire(!oprec_ptr.isNull());
24203 return oprec_ptr.p->m_opInfo;
24207 Dbdict::seizeSchemaOp(SchemaOpPtr& op_ptr, Uint32 op_key,
const OpInfo& info)
24209 if ((ERROR_INSERTED(6111) &&
24210 (info.m_impl_req_gsn == GSN_CREATE_TAB_REQ ||
24211 info.m_impl_req_gsn == GSN_DROP_TAB_REQ ||
24212 info.m_impl_req_gsn == GSN_ALTER_TAB_REQ)) ||
24213 (ERROR_INSERTED(6112) &&
24214 (info.m_impl_req_gsn == GSN_CREATE_INDX_IMPL_REQ ||
24215 info.m_impl_req_gsn == GSN_DROP_INDX_IMPL_REQ)) ||
24216 (ERROR_INSERTED(6113) &&
24217 (info.m_impl_req_gsn == GSN_ALTER_INDX_IMPL_REQ)) ||
24218 (ERROR_INSERTED(6114) &&
24219 (info.m_impl_req_gsn == GSN_CREATE_TRIG_IMPL_REQ ||
24220 info.m_impl_req_gsn == GSN_DROP_TRIG_IMPL_REQ)) ||
24221 (ERROR_INSERTED(6116) &&
24222 (info.m_impl_req_gsn == GSN_BUILD_INDX_IMPL_REQ)))
24225 CLEAR_ERROR_INSERT_VALUE;
24230 if (!findSchemaOp(op_ptr, op_key)) {
24232 if (c_schemaOpHash.
seize(op_ptr)) {
24234 new (op_ptr.p) SchemaOp();
24235 op_ptr.p->op_key = op_key;
24236 if ((this->*(info.m_seize))(op_ptr)) {
24238 c_schemaOpHash.
add(op_ptr);
24239 op_ptr.p->m_magic = SchemaOp::DICT_MAGIC;
24240 D(
"seizeSchemaOp" << V(op_key) << V(info.m_opType));
24243 c_schemaOpPool.
release(op_ptr);
24251 Dbdict::findSchemaOp(SchemaOpPtr& op_ptr, Uint32 op_key)
24253 SchemaOp op_rec(op_key);
24254 if (c_schemaOpHash.
find(op_ptr, op_rec)) {
24256 const OpRecPtr& oprec_ptr = op_ptr.p->m_oprec_ptr;
24257 ndbrequire(!oprec_ptr.isNull());
24258 ndbrequire(op_ptr.p->m_magic == SchemaOp::DICT_MAGIC);
24259 D(
"findSchemaOp" << V(op_key));
24266 Dbdict::releaseSchemaOp(SchemaOpPtr& op_ptr)
24268 D(
"releaseSchemaOp" << V(op_ptr.p->op_key));
24270 const OpInfo& info = getOpInfo(op_ptr);
24271 (this->*(info.m_release))(op_ptr);
24273 while (op_ptr.p->m_sections != 0) {
24275 releaseOpSection(op_ptr, op_ptr.p->m_sections - 1);
24278 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
24279 Uint32 obj_ptr_i = oprec_ptr.p->m_obj_ptr_i;
24280 if (obj_ptr_i != RNIL) {
24282 unlinkDictObject(op_ptr);
24285 if (!op_ptr.p->m_oplnk_ptr.isNull()) {
24287 releaseSchemaOp(op_ptr.p->m_oplnk_ptr);
24290 ndbrequire(op_ptr.p->m_magic == SchemaOp::DICT_MAGIC);
24291 op_ptr.p->m_magic = 0;
24292 c_schemaOpHash.
release(op_ptr);
24298 const Dbdict::OpSection&
24299 Dbdict::getOpSection(SchemaOpPtr op_ptr, Uint32 ss_no)
24301 ndbrequire(ss_no < op_ptr.p->m_sections);
24302 return op_ptr.p->m_section[ss_no];
24306 Dbdict::saveOpSection(SchemaOpPtr op_ptr,
24310 bool ok = handle.getSection(ss_ptr, ss_no);
24312 return saveOpSection(op_ptr, ss_ptr, ss_no);
24316 Dbdict::saveOpSection(SchemaOpPtr op_ptr,
24319 ndbrequire(ss_no <= 2 && op_ptr.p->m_sections == ss_no);
24320 OpSection& op_sec = op_ptr.p->m_section[ss_no];
24321 op_ptr.p->m_sections++;
24323 bool ok = copyIn(op_sec, ss_ptr);
24329 Dbdict::releaseOpSection(SchemaOpPtr op_ptr, Uint32 ss_no)
24331 ndbrequire(ss_no + 1 == op_ptr.p->m_sections);
24332 OpSection& op_sec = op_ptr.p->m_section[ss_no];
24334 op_ptr.p->m_sections = ss_no;
24340 Dbdict::addSchemaOp(SchemaTransPtr trans_ptr, SchemaOpPtr& op_ptr)
24343 list.addLast(op_ptr);
24345 op_ptr.p->m_trans_ptr = trans_ptr;
24349 const Uint32& src_info = trans_ptr.p->m_requestInfo;
24350 DictSignal::addRequestFlagsGlobal(op_ptr.p->m_requestInfo, src_info);
24359 Dbdict::hasDictObject(SchemaOpPtr op_ptr)
24361 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
24362 return oprec_ptr.p->m_obj_ptr_i != RNIL;
24367 Dbdict::getDictObject(SchemaOpPtr op_ptr, DictObjectPtr& obj_ptr)
24369 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
24370 ndbrequire(oprec_ptr.p->m_obj_ptr_i != RNIL);
24371 c_obj_pool.
getPtr(obj_ptr, oprec_ptr.p->m_obj_ptr_i);
24376 Dbdict::linkDictObject(SchemaOpPtr op_ptr, DictObjectPtr obj_ptr)
24378 ndbrequire(!obj_ptr.isNull());
24379 D(
"linkDictObject" << V(op_ptr.p->op_key) << V(obj_ptr.i));
24381 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
24382 ndbrequire(oprec_ptr.p->m_obj_ptr_i == RNIL);
24383 oprec_ptr.p->m_obj_ptr_i = obj_ptr.i;
24385 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
24386 if (!trans_ptr.isNull()) {
24388 ndbrequire(trans_ptr.p->trans_key != 0);
24389 if (obj_ptr.p->m_op_ref_count == 0) {
24391 obj_ptr.p->m_trans_key = trans_ptr.p->trans_key;
24393 ndbrequire(obj_ptr.p->m_trans_key == trans_ptr.p->trans_key);
24398 ndbrequire(memcmp(oprec_ptr.p->m_opType,
"CTa", 4) == 0);
24402 obj_ptr.p->m_op_ref_count += 1;
24403 D(
"linkDictObject done" << *obj_ptr.p);
24408 Dbdict::unlinkDictObject(SchemaOpPtr op_ptr)
24410 DictObjectPtr obj_ptr;
24411 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
24412 ndbrequire(oprec_ptr.p->m_obj_ptr_i != RNIL);
24413 c_obj_pool.
getPtr(obj_ptr, oprec_ptr.p->m_obj_ptr_i);
24415 D(
"unlinkDictObject" << V(op_ptr.p->op_key) << V(obj_ptr.i));
24417 oprec_ptr.p->m_obj_ptr_i = RNIL;
24418 ndbrequire(obj_ptr.p->m_op_ref_count != 0);
24419 obj_ptr.p->m_op_ref_count -= 1;
24420 ndbrequire(obj_ptr.p->m_trans_key != 0);
24421 if (obj_ptr.p->m_op_ref_count == 0) {
24423 obj_ptr.p->m_trans_key = 0;
24425 D(
"unlinkDictObject done" << *obj_ptr.p);
24430 Dbdict::seizeDictObject(SchemaOpPtr op_ptr,
24431 DictObjectPtr& obj_ptr,
24434 D(
"seizeDictObject" << *op_ptr.p);
24436 bool ok = c_obj_hash.
seize(obj_ptr);
24440 obj_ptr.p->m_name =
name;
24441 c_obj_hash.
add(obj_ptr);
24442 obj_ptr.p->m_ref_count = 0;
24444 linkDictObject(op_ptr, obj_ptr);
24445 D(
"seizeDictObject done" << *obj_ptr.p);
24450 Dbdict::findDictObject(SchemaOpPtr op_ptr,
24451 DictObjectPtr& obj_ptr,
24454 D(
"findDictObject" << *op_ptr.p << V(name));
24455 if (get_object(obj_ptr, name)) {
24457 linkDictObject(op_ptr, obj_ptr);
24465 Dbdict::findDictObject(SchemaOpPtr op_ptr,
24466 DictObjectPtr& obj_ptr,
24469 D(
"findDictObject" << *op_ptr.p << V(obj_ptr.i));
24470 if (obj_ptr_i != RNIL) {
24472 c_obj_pool.
getPtr(obj_ptr, obj_ptr_i);
24473 linkDictObject(op_ptr, obj_ptr);
24481 Dbdict::releaseDictObject(SchemaOpPtr op_ptr)
24483 DictObjectPtr obj_ptr;
24484 getDictObject(op_ptr, obj_ptr);
24486 D(
"releaseDictObject" << *op_ptr.p << V(obj_ptr.i) << *obj_ptr.p);
24488 unlinkDictObject(op_ptr);
24491 ndbrequire(obj_ptr.p->m_ref_count == 0);
24492 if (obj_ptr.p->m_op_ref_count == 0) {
24494 release_object(obj_ptr.i);
24500 Dbdict::findDictObjectOp(SchemaOpPtr& op_ptr, DictObjectPtr obj_ptr)
24502 D(
"findDictObjectOp" << *obj_ptr.p);
24505 Uint32 trans_key = obj_ptr.p->m_trans_key;
24507 if (trans_key == 0) {
24513 SchemaTransPtr trans_ptr;
24514 findSchemaTrans(trans_ptr, trans_key);
24515 if (trans_ptr.isNull()) {
24517 D(
"trans not found");
24520 D(
"found" << *trans_ptr.p);
24524 SchemaOpPtr loop_ptr;
24525 list.first(loop_ptr);
24526 while (!loop_ptr.isNull()) {
24528 OpRecPtr oprec_ptr = loop_ptr.p->m_oprec_ptr;
24529 if (oprec_ptr.p->m_obj_ptr_i == obj_ptr.i) {
24532 D(
"found candidate" << *op_ptr.p);
24534 list.next(loop_ptr);
24546 Dbdict::seizeSchemaTrans(SchemaTransPtr& trans_ptr, Uint32 trans_key)
24548 if (ERROR_INSERTED(6101)) {
24550 CLEAR_ERROR_INSERT_VALUE;
24551 trans_ptr.setNull();
24554 if (!findSchemaTrans(trans_ptr, trans_key)) {
24556 if (c_schemaTransHash.
seize(trans_ptr)) {
24558 new (trans_ptr.p) SchemaTrans();
24559 trans_ptr.p->trans_key = trans_key;
24560 c_schemaTransHash.
add(trans_ptr);
24561 c_schemaTransList.addLast(trans_ptr);
24562 c_schemaTransCount++;
24563 trans_ptr.p->m_magic = SchemaTrans::DICT_MAGIC;
24564 D(
"seizeSchemaTrans" << V(trans_key));
24568 trans_ptr.setNull();
24573 Dbdict::seizeSchemaTrans(SchemaTransPtr& trans_ptr)
24575 Uint32 trans_key = c_opRecordSequence + 1;
24576 if (seizeSchemaTrans(trans_ptr, trans_key)) {
24578 ndbout_c(
"Dbdict::seizeSchemaTrans: Seized schema trans %u", trans_key);
24580 c_opRecordSequence = trans_key;
24584 ndbout_c(
"Dbdict::seizeSchemaTrans: Failed to seize schema trans");
24590 Dbdict::findSchemaTrans(SchemaTransPtr& trans_ptr, Uint32 trans_key)
24592 SchemaTrans trans_rec(trans_key);
24593 if (c_schemaTransHash.
find(trans_ptr, trans_rec)) {
24595 ndbrequire(trans_ptr.p->m_magic == SchemaTrans::DICT_MAGIC);
24596 D(
"findSchemaTrans" << V(trans_key));
24599 trans_ptr.setNull();
24604 Dbdict::releaseSchemaTrans(SchemaTransPtr& trans_ptr)
24606 D(
"releaseSchemaTrans" << V(trans_ptr.p->trans_key));
24609 SchemaOpPtr op_ptr;
24610 while (list.first(op_ptr)) {
24611 list.remove(op_ptr);
24612 releaseSchemaOp(op_ptr);
24614 ndbrequire(trans_ptr.p->m_magic == SchemaTrans::DICT_MAGIC);
24615 trans_ptr.p->m_magic = 0;
24616 ndbrequire(c_schemaTransCount != 0);
24617 c_schemaTransCount--;
24618 c_schemaTransList.remove(trans_ptr);
24619 c_schemaTransHash.
release(trans_ptr);
24620 trans_ptr.setNull();
24622 if (c_schemaTransCount == 0)
24626 ndbrequire(c_schemaOpPool.getNoOfFree() == c_schemaOpPool.getSize());
24627 ndbrequire(c_opSectionBufferPool.getNoOfFree() == c_opSectionBufferPool.getSize());
24630 check_consistency();
24638 Dbdict::execSCHEMA_TRANS_BEGIN_REQ(
Signal* signal)
24643 Uint32 clientRef = req->clientRef;
24645 ndbout_c(
"Dbdict::execSCHEMA_TRANS_BEGIN_REQ: received GSN_SCHEMA_TRANS_BEGIN_REQ from 0x%8x", clientRef);
24648 Uint32 transId = req->transId;
24649 Uint32 requestInfo = req->requestInfo;
24651 bool localTrans = (requestInfo & DictSignal::RF_LOCAL_TRANS);
24653 SchemaTransPtr trans_ptr;
24656 if (getOwnNodeId() != c_masterNodeId && !localTrans) {
24658 setError(error, SchemaTransBeginRef::NotMaster, __LINE__);
24662 if (!check_ndb_versions() && !localTrans)
24665 setError(error, SchemaTransBeginRef::IncompatibleVersions, __LINE__);
24669 if (!seizeSchemaTrans(trans_ptr)) {
24672 setError(error, SchemaTransBeginRef::TooManySchemaTrans, __LINE__);
24676 trans_ptr.p->m_isMaster =
true;
24677 trans_ptr.p->m_masterRef = reference();
24678 trans_ptr.p->m_clientRef = clientRef;
24679 trans_ptr.p->m_transId = transId;
24680 trans_ptr.p->m_requestInfo = requestInfo;
24681 trans_ptr.p->m_obj_id = getFreeObjId(0);
24691 trans_ptr.p->m_obj_id = getFreeObjId(0,
true);
24697 trans_ptr.p->m_nodes = c_aliveNodes;
24702 trans_ptr.p->m_nodes.clear();
24703 trans_ptr.p->m_nodes.set(getOwnNodeId());
24705 trans_ptr.p->m_clientState = TransClient::BeginReq;
24709 lockReq.userPtr = trans_ptr.p->trans_key;
24710 lockReq.userRef = reference();
24711 lockReq.lockType = DictLockReq::SchemaTransLock;
24713 if (lockError != 0)
24716 releaseSchemaTrans(trans_ptr);
24717 setError(error, lockError, __LINE__);
24722 trans_ptr.p->m_state = SchemaTrans::TS_STARTING;
24728 trans_ptr.p->m_ref_nodes.clear();
24731 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
24736 if (ERROR_INSERTED(6140))
24742 Uint32 nodeId = rand() % MAX_NDB_NODES;
24743 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
24744 nodeId = rand() % MAX_NDB_NODES;
24746 infoEvent(
"Simulating node %u missing RT_START", nodeId);
24747 rg.m_nodes.clear(nodeId);
24748 signal->theData[0] = 9999;
24749 signal->theData[1] = ERROR_INSERT_VALUE;
24750 CLEAR_ERROR_INSERT_VALUE;
24751 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
24756 req->senderRef = reference();
24757 req->transKey = trans_ptr.p->trans_key;
24759 req->requestInfo = SchemaTransImplReq::RT_START;
24760 req->start.clientRef = trans_ptr.p->m_clientRef;
24761 req->start.objectId = trans_ptr.p->m_obj_id;
24762 req->transId = trans_ptr.p->m_transId;
24763 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
24764 SchemaTransImplReq::SignalLengthStart, JBB);
24767 if (ERROR_INSERTED(6102)) {
24769 CLEAR_ERROR_INSERT_VALUE;
24770 signal->theData[0] = refToNode(clientRef);
24771 sendSignal(QMGR_REF, GSN_API_FAILREQ, signal, 1, JBB);
24776 SchemaTrans tmp_trans;
24777 trans_ptr.i = RNIL;
24778 trans_ptr.p = &tmp_trans;
24779 trans_ptr.p->trans_key = 0;
24780 trans_ptr.p->m_clientRef = clientRef;
24781 trans_ptr.p->m_transId = transId;
24782 trans_ptr.p->m_clientState = TransClient::BeginReq;
24783 setError(trans_ptr.p->m_error, error);
24784 sendTransClientReply(signal, trans_ptr);
24788 Dbdict::trans_start_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
24792 switch(trans_ptr.p->m_state){
24793 case SchemaTrans::TS_STARTING:
24794 if (hasError(trans_ptr.p->m_error))
24801 trans_ptr.p->m_nodes.bitANDC(trans_ptr.p->m_ref_nodes);
24806 trans_end_start(signal, trans_ptr);
24812 sendTransClientReply(signal, trans_ptr);
24817 jamLine(trans_ptr.p->m_state);
24823 Dbdict::execSCHEMA_TRANS_END_REQ(
Signal* signal)
24828 Uint32 clientRef = req->clientRef;
24829 Uint32 transId = req->transId;
24830 Uint32 trans_key = req->transKey;
24831 Uint32 requestInfo = req->requestInfo;
24832 Uint32 flags = req->flags;
24834 SchemaTransPtr trans_ptr;
24837 findSchemaTrans(trans_ptr, trans_key);
24838 if (trans_ptr.isNull()) {
24841 setError(error, SchemaTransEndRef::InvalidTransKey, __LINE__);
24845 if (trans_ptr.p->m_transId != transId) {
24848 setError(error, SchemaTransEndRef::InvalidTransId, __LINE__);
24852 bool localTrans = (trans_ptr.p->m_requestInfo & DictSignal::RF_LOCAL_TRANS);
24854 if (getOwnNodeId() != c_masterNodeId && !localTrans) {
24858 setError(error, SchemaTransEndRef::NotMaster, __LINE__);
24862 ndbout_c(
"Dbdict::execSCHEMA_TRANS_END_REQ: trans %u, state %u", trans_ptr.i, trans_ptr.p->m_state);
24867 if (hasError(trans_ptr.p->m_error))
24871 setError(error, SchemaTransEndRef::InvalidTransState, __LINE__);
24875 bool localTrans2 = requestInfo & DictSignal::RF_LOCAL_TRANS;
24876 if (localTrans != localTrans2)
24880 setError(error, SchemaTransEndRef::InvalidTransState, __LINE__);
24884 trans_ptr.p->m_clientState = TransClient::EndReq;
24886 const bool doBackground = flags & SchemaTransEndReq::SchemaTransBackground;
24891 sendTransClientReply(signal, trans_ptr);
24892 trans_ptr.p->m_clientState = TransClient::EndReq;
24895 trans_ptr.p->m_clientFlags |= TransClient::Background;
24896 takeOverTransClient(signal, trans_ptr);
24899 if (flags & SchemaTransEndReq::SchemaTransAbort)
24902 trans_abort_prepare_start(signal, trans_ptr);
24905 else if ((flags & SchemaTransEndReq::SchemaTransPrepare) == 0)
24908 trans_ptr.p->m_clientFlags |= TransClient::Commit;
24911 trans_prepare_start(signal, trans_ptr);
24915 SchemaTrans tmp_trans;
24916 trans_ptr.i = RNIL;
24917 trans_ptr.p = &tmp_trans;
24918 trans_ptr.p->trans_key = trans_key;
24919 trans_ptr.p->m_clientRef = clientRef;
24920 trans_ptr.p->m_transId = transId;
24921 trans_ptr.p->m_clientState = TransClient::EndReq;
24922 setError(trans_ptr.p->m_error, error);
24923 sendTransClientReply(signal, trans_ptr);
24929 Dbdict::handleClientReq(
Signal* signal, SchemaOpPtr op_ptr,
24932 D(
"handleClientReq" << *op_ptr.p);
24934 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
24936 if (trans_ptr.p->m_state == SchemaTrans::TS_SUBOP)
24939 SchemaOpPtr baseOp;
24940 c_schemaOpPool.
getPtr(baseOp, trans_ptr.p->m_curr_op_ptr_i);
24941 op_ptr.p->m_base_op_ptr_i = baseOp.i;
24944 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
24945 op_ptr.p->m_state = SchemaOp::OS_PARSE_MASTER;
24948 const OpInfo& info = getOpInfo(op_ptr);
24950 if (checkSingleUserMode(trans_ptr.p->m_clientRef))
24953 setError(error, AlterTableRef::SingleUser, __LINE__);
24958 (this->*(info.m_parse))(signal,
true, op_ptr, handle, error);
24961 if (hasError(error))
24964 setError(trans_ptr, error);
24965 releaseSections(handle);
24966 trans_rollback_sp_start(signal, trans_ptr);
24970 trans_ptr.p->m_state = SchemaTrans::TS_PARSING;
24971 op_ptr.p->m_state = SchemaOp::OS_PARSING;
24973 Uint32 gsn = info.m_impl_req_gsn;
24974 const Uint32* src = op_ptr.p->m_oprec_ptr.p->m_impl_req_data;
24976 Uint32* data = signal->getDataPtrSend();
24977 Uint32
skip = SchemaTransImplReq::SignalLength;
24978 Uint32 extra_length = info.m_impl_req_length;
24979 ndbrequire(skip + extra_length <= 25);
24982 for (i = 0; i < extra_length; i++)
24983 data[skip + i] = src[i];
24985 Uint32 requestInfo = 0;
24986 DictSignal::setRequestType(requestInfo, SchemaTransImplReq::RT_PARSE);
24987 DictSignal::addRequestFlags(requestInfo, op_ptr.p->m_requestInfo);
24988 DictSignal::addRequestExtra(requestInfo, op_ptr.p->m_requestInfo);
24990 trans_ptr.p->m_ref_nodes.clear();
24991 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
24996 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25001 if (ERROR_INSERTED(6141))
25007 Uint32 nodeId = rand() % MAX_NDB_NODES;
25008 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
25009 nodeId = rand() % MAX_NDB_NODES;
25011 infoEvent(
"Simulating node %u missing RT_PARSE", nodeId);
25012 rg.m_nodes.clear(nodeId);
25013 signal->theData[0] = 9999;
25014 signal->theData[1] = ERROR_INSERT_VALUE;
25015 CLEAR_ERROR_INSERT_VALUE;
25016 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
25021 req->senderRef = reference();
25022 req->transKey = trans_ptr.p->trans_key;
25023 req->opKey = op_ptr.p->op_key;
25024 req->requestInfo = requestInfo;
25025 req->transId = trans_ptr.p->m_transId;
25026 req->parse.gsn = gsn;
25027 sendFragmentedSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
25028 SchemaTransImplReq::SignalLength + extra_length, JBB,
25033 Dbdict::trans_parse_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
25035 SchemaOpPtr op_ptr;
25036 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
25038 op_ptr.p->m_state = SchemaOp::OS_PARSED;
25040 if (hasError(trans_ptr.p->m_error))
25043 trans_rollback_sp_start(signal, trans_ptr);
25047 const OpInfo& info = getOpInfo(op_ptr);
25048 if ((this->*(info.m_subOps))(signal, op_ptr))
25052 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
25053 trans_ptr.p->m_state = SchemaTrans::TS_SUBOP;
25061 (this->*(info.m_reply))(signal, op_ptr, error);
25063 trans_ptr.p->m_clientState = TransClient::ParseReply;
25064 trans_ptr.p->m_state = SchemaTrans::TS_STARTED;
25068 Dbdict::execSCHEMA_TRANS_IMPL_CONF(
Signal* signal)
25071 ndbrequire(signal->getNoOfSections() == 0);
25076 SchemaTransPtr trans_ptr;
25077 ndbrequire(findSchemaTrans(trans_ptr, conf->transKey));
25079 Uint32 senderRef = conf->senderRef;
25080 Uint32 nodeId = refToNode(senderRef);
25083 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25084 if (!sc.clearWaitingFor(nodeId)) {
25090 trans_recv_reply(signal, trans_ptr);
25094 Dbdict::execSCHEMA_TRANS_IMPL_REF(
Signal* signal)
25097 ndbrequire(signal->getNoOfSections() == 0);
25102 SchemaTransPtr trans_ptr;
25103 ndbrequire(findSchemaTrans(trans_ptr, ref->transKey));
25105 Uint32 senderRef = ref->senderRef;
25106 Uint32 nodeId = refToNode(senderRef);
25109 ndbout_c(
"Got SCHEMA_TRANS_IMPL_REF from node %u, error %u", nodeId, ref->errorCode);
25111 if (ref->errorCode == SchemaTransImplRef::NF_FakeErrorREF)
25121 setError(error, ref);
25122 setError(trans_ptr, error);
25123 switch(trans_ptr.p->m_state){
25124 case SchemaTrans::TS_STARTING:
25126 trans_ptr.p->m_ref_nodes.set(nodeId);
25128 case SchemaTrans::TS_PARSING:
25130 if (ref->errorCode == SchemaTransImplRef::SeizeFailed)
25133 trans_ptr.p->m_ref_nodes.set(nodeId);
25142 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25143 if (!sc.clearWaitingFor(nodeId)) {
25149 trans_recv_reply(signal, trans_ptr);
25153 Dbdict::trans_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
25155 switch(trans_ptr.p->m_state){
25156 case SchemaTrans::TS_INITIAL:
25158 case SchemaTrans::TS_STARTING:
25160 trans_start_recv_reply(signal, trans_ptr);
25162 case SchemaTrans::TS_PARSING:
25164 trans_parse_recv_reply(signal, trans_ptr);
25166 case SchemaTrans::TS_SUBOP:
25168 case SchemaTrans::TS_ROLLBACK_SP:
25169 trans_rollback_sp_recv_reply(signal, trans_ptr);
25171 case SchemaTrans::TS_FLUSH_PREPARE:
25172 trans_prepare_first(signal, trans_ptr);
25174 case SchemaTrans::TS_PREPARING:
25176 trans_prepare_recv_reply(signal, trans_ptr);
25178 case SchemaTrans::TS_ABORTING_PREPARE:
25180 trans_abort_prepare_recv_reply(signal, trans_ptr);
25182 case SchemaTrans::TS_ABORTING_PARSE:
25184 trans_abort_parse_recv_reply(signal, trans_ptr);
25186 case SchemaTrans::TS_FLUSH_COMMIT:
25188 trans_commit_first(signal, trans_ptr);
25190 case SchemaTrans::TS_COMMITTING:
25191 trans_commit_recv_reply(signal, trans_ptr);
25193 case SchemaTrans::TS_FLUSH_COMPLETE:
25195 trans_complete_first(signal, trans_ptr);
25197 case SchemaTrans::TS_COMPLETING:
25198 trans_complete_recv_reply(signal, trans_ptr);
25200 case SchemaTrans::TS_ENDING:
25201 trans_end_recv_reply(signal, trans_ptr);
25203 case SchemaTrans::TS_STARTED:
25211 Dbdict::handleTransReply(
Signal* signal, SchemaTransPtr trans_ptr)
25213 TransLoc& tLoc = trans_ptr.p->m_transLoc;
25214 SchemaOpPtr op_ptr;
25215 getOpPtr(tLoc, op_ptr);
25221 D(
"handleTransReply" << tLoc);
25222 if (!op_ptr.isNull())
25223 D(
"have op" << *op_ptr.p);
25225 if (hasError(trans_ptr.p->m_error)) {
25227 if (tLoc.m_mode == TransMode::Normal) {
25228 if (tLoc.m_phase == TransPhase::Parse) {
25230 setTransMode(trans_ptr, TransMode::Rollback,
true);
25233 setTransMode(trans_ptr, TransMode::Abort,
true);
25238 if (tLoc.m_mode == TransMode::Normal) {
25239 if (tLoc.m_phase == TransPhase::Begin) {
25241 sendTransClientReply(signal, trans_ptr);
25243 else if (tLoc.m_phase == TransPhase::Parse) {
25250 createSubOps(signal, op_ptr,
true);
25252 else if (tLoc.m_phase == TransPhase::Prepare) {
25254 runTransMaster(signal, trans_ptr);
25256 else if (tLoc.m_phase == TransPhase::Commit) {
25258 runTransMaster(signal, trans_ptr);
25260 else if (tLoc.m_phase == TransPhase::End)
25263 trans_commit_done(signal, trans_ptr);
25270 else if (tLoc.m_mode == TransMode::Rollback) {
25271 if (tLoc.m_phase == TransPhase::Parse) {
25280 ndbrequire(hasError(trans_ptr.p->m_error));
25281 ndbrequire(!op_ptr.isNull());
25285 runTransMaster(signal, trans_ptr);
25288 if (op_ptr.p->m_opDepth != 0) {
25290 runTransMaster(signal, trans_ptr);
25295 const OpInfo& info = getOpInfo(op_ptr);
25296 (this->*(info.m_reply))(signal, op_ptr, trans_ptr.p->m_error);
25297 resetError(trans_ptr);
25300 trans_ptr.p->m_opDepth = 0;
25301 trans_ptr.p->m_clientState = TransClient::ParseReply;
25303 iteratorRemoveLastOp(tLoc, op_ptr);
25310 else if (tLoc.m_mode == TransMode::Abort) {
25311 if (tLoc.m_phase == TransPhase::Begin) {
25313 sendTransClientReply(signal, trans_ptr);
25315 const DictLockReq& lockReq = trans_ptr.p->m_lockReq;
25317 releaseSchemaTrans(trans_ptr);
25319 else if (tLoc.m_phase == TransPhase::Parse) {
25321 runTransMaster(signal, trans_ptr);
25323 else if (tLoc.m_phase == TransPhase::Prepare) {
25325 runTransMaster(signal, trans_ptr);
25338 Dbdict::createSubOps(
Signal* signal, SchemaOpPtr op_ptr,
bool first)
25340 D(
"createSubOps" << *op_ptr.p);
25342 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
25344 const OpInfo& info = getOpInfo(op_ptr);
25345 if ((this->*(info.m_subOps))(signal, op_ptr)) {
25348 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
25349 trans_ptr.p->m_state = SchemaTrans::TS_SUBOP;
25354 (this->*(info.m_reply))(signal, op_ptr, error);
25356 trans_ptr.p->m_clientState = TransClient::ParseReply;
25357 trans_ptr.p->m_state = SchemaTrans::TS_STARTED;
25362 Dbdict::abortSubOps(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
25364 D(
"abortSubOps" << *op_ptr.p << error);
25365 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
25366 setError(trans_ptr, error);
25367 trans_rollback_sp_start(signal, trans_ptr);
25371 Dbdict::trans_prepare_start(
Signal* signal, SchemaTransPtr trans_ptr)
25373 trans_ptr.p->m_state = SchemaTrans::TS_FLUSH_PREPARE;
25375 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
25379 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25384 if (ERROR_INSERTED(6013))
25387 CRASH_INSERTION(6013);
25390 if (ERROR_INSERTED(6022))
25394 signal->theData[0] = 9999;
25395 sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
25399 if (ERROR_INSERTED(6142))
25405 Uint32 nodeId = rand() % MAX_NDB_NODES;
25406 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
25407 nodeId = rand() % MAX_NDB_NODES;
25409 infoEvent(
"Simulating node %u missing RT_FLUSH_PREPARE", nodeId);
25410 rg.m_nodes.clear(nodeId);
25411 signal->theData[0] = 9999;
25412 signal->theData[1] = ERROR_INSERT_VALUE;
25413 CLEAR_ERROR_INSERT_VALUE;
25414 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
25419 req->senderRef = reference();
25420 req->transKey = trans_ptr.p->trans_key;
25422 req->requestInfo = SchemaTransImplReq::RT_FLUSH_PREPARE;
25423 req->transId = trans_ptr.p->m_transId;
25424 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
25425 SchemaTransImplReq::SignalLength, JBB);
25429 Dbdict::trans_prepare_first(
Signal* signal, SchemaTransPtr trans_ptr)
25431 if (ERROR_INSERTED(6021))
25435 signal->theData[0] = 9999;
25436 sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
25440 trans_ptr.p->m_state = SchemaTrans::TS_PREPARING;
25442 SchemaOpPtr op_ptr;
25447 first = list.first(op_ptr);
25452 trans_prepare_next(signal, trans_ptr, op_ptr);
25457 trans_prepare_done(signal, trans_ptr);
25461 Dbdict::trans_prepare_next(
Signal* signal,
25462 SchemaTransPtr trans_ptr,
25463 SchemaOpPtr op_ptr)
25465 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_PREPARING);
25467 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
25468 op_ptr.p->m_state = SchemaOp::OS_PREPARING;
25470 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
25474 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25479 if (ERROR_INSERTED(6143))
25483 if (!list.hasNext(op_ptr))
25489 Uint32 nodeId = rand() % MAX_NDB_NODES;
25490 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
25491 nodeId = rand() % MAX_NDB_NODES;
25493 infoEvent(
"Simulating node %u missing RT_PREPARE", nodeId);
25494 rg.m_nodes.clear(nodeId);
25495 signal->theData[0] = 9999;
25496 signal->theData[1] = ERROR_INSERT_VALUE;
25497 CLEAR_ERROR_INSERT_VALUE;
25498 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
25504 req->senderRef = reference();
25505 req->transKey = trans_ptr.p->trans_key;
25506 req->opKey = op_ptr.p->op_key;
25507 req->requestInfo = SchemaTransImplReq::RT_PREPARE;
25508 req->transId = trans_ptr.p->m_transId;
25509 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
25510 SchemaTransImplReq::SignalLength, JBB);
25514 Dbdict::trans_prepare_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
25518 SchemaOpPtr op_ptr;
25519 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
25520 if (hasError(trans_ptr.p->m_error))
25523 trans_ptr.p->m_state = SchemaTrans::TS_ABORTING_PREPARE;
25524 trans_abort_prepare_next(signal, trans_ptr, op_ptr);
25532 next = list.next(op_ptr);
25537 trans_prepare_next(signal, trans_ptr, op_ptr);
25542 trans_prepare_done(signal, trans_ptr);
25547 Dbdict::trans_prepare_done(
Signal* signal, SchemaTransPtr trans_ptr)
25549 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_PREPARING);
25551 if (ERROR_INSERTED(6145))
25554 trans_abort_prepare_start(signal, trans_ptr);
25558 if (trans_ptr.p->m_clientFlags & TransClient::Commit)
25561 trans_commit_start(signal, trans_ptr);
25570 Dbdict::trans_abort_parse_start(
Signal* signal, SchemaTransPtr trans_ptr)
25572 trans_ptr.p->m_state = SchemaTrans::TS_ABORTING_PARSE;
25574 SchemaOpPtr op_ptr;
25578 last = list.last(op_ptr);
25584 trans_abort_parse_next(signal, trans_ptr, op_ptr);
25588 trans_abort_parse_done(signal, trans_ptr);
25593 Dbdict::trans_abort_parse_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
25595 SchemaOpPtr op_ptr;
25596 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
25599 SchemaOpPtr last_op = op_ptr;
25603 prev = list.prev(op_ptr);
25604 list.remove(last_op);
25606 releaseSchemaOp(last_op);
25611 trans_abort_parse_next(signal, trans_ptr, op_ptr);
25616 trans_abort_parse_done(signal, trans_ptr);
25620 Dbdict::check_partial_trans_abort_parse_next(SchemaTransPtr trans_ptr,
25622 SchemaOpPtr op_ptr)
25625 NodeRecordPtr ownNodePtr;
25626 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
25627 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
25636 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
25637 NodeRecordPtr nodePtr;
25638 if (trans_ptr.p->m_nodes.get(i))
25641 c_nodes.
getPtr(nodePtr, i);
25643 ndbout_c(
"Checking node %u(%u), %u(%u)<%u", nodePtr.i, nodePtr.p->recoveryState, nodePtr.p->start_op, nodePtr.p->start_op_state, op_ptr.p->op_key);
25645 if (nodePtr.p->recoveryState == NodeRecord::RS_PARTIAL_ROLLBACK &&
25647 nodePtr.p->start_op < op_ptr.p->op_key)
25651 ndbout_c(
"Skip aborting operation %u on node %u", op_ptr.p->op_key, i);
25654 nodePtr.p->recoveryState = NodeRecord::RS_NORMAL;
25662 Dbdict::trans_abort_parse_next(
Signal* signal,
25663 SchemaTransPtr trans_ptr,
25664 SchemaOpPtr op_ptr)
25667 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_ABORTING_PARSE);
25669 ndbout_c(
"Dbdict::trans_abort_parse_next: op %u state %u", op_ptr.i,op_ptr.p->m_state);
25671 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
25672 op_ptr.p->m_state = SchemaOp::OS_ABORTING_PARSE;
25674 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
25676 check_partial_trans_abort_parse_next(trans_ptr, nodes, op_ptr);
25679 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25684 if (ERROR_INSERTED(6144))
25688 if (!list.hasNext(op_ptr))
25694 Uint32 nodeId = rand() % MAX_NDB_NODES;
25695 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
25696 nodeId = rand() % MAX_NDB_NODES;
25698 infoEvent(
"Simulating node %u missing RT_ABORT_PARSE", nodeId);
25699 rg.m_nodes.clear(nodeId);
25700 signal->theData[0] = 9999;
25701 signal->theData[1] = ERROR_INSERT_VALUE;
25702 CLEAR_ERROR_INSERT_VALUE;
25703 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
25709 req->senderRef = reference();
25710 req->transKey = trans_ptr.p->trans_key;
25711 req->opKey = op_ptr.p->op_key;
25712 req->requestInfo = SchemaTransImplReq::RT_ABORT_PARSE;
25713 req->transId = trans_ptr.p->m_transId;
25714 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
25715 SchemaTransImplReq::SignalLength, JBB);
25719 Dbdict::trans_abort_parse_done(
Signal* signal, SchemaTransPtr trans_ptr)
25721 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_ABORTING_PARSE);
25723 trans_end_start(signal, trans_ptr);
25727 Dbdict::trans_abort_prepare_start(
Signal* signal, SchemaTransPtr trans_ptr)
25729 trans_ptr.p->m_state = SchemaTrans::TS_ABORTING_PREPARE;
25732 SchemaOpPtr op_ptr;
25735 last = list.last(op_ptr);
25741 trans_abort_prepare_next(signal, trans_ptr, op_ptr);
25746 trans_abort_prepare_done(signal, trans_ptr);
25751 Dbdict::trans_abort_prepare_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
25755 SchemaOpPtr op_ptr;
25756 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
25758 op_ptr.p->m_state = SchemaOp::OS_ABORTED_PREPARE;
25763 prev = list.prev(op_ptr);
25769 trans_abort_prepare_next(signal, trans_ptr, op_ptr);
25774 trans_abort_prepare_done(signal, trans_ptr);
25779 Dbdict::check_partial_trans_abort_prepare_next(SchemaTransPtr trans_ptr,
25781 SchemaOpPtr op_ptr)
25784 NodeRecordPtr ownNodePtr;
25785 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
25786 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
25794 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
25795 NodeRecordPtr nodePtr;
25796 if (trans_ptr.p->m_nodes.get(i))
25798 c_nodes.
getPtr(nodePtr, i);
25800 ndbout_c(
"Checking node %u(%u), %u(%u)<%u", nodePtr.i, nodePtr.p->recoveryState, nodePtr.p->start_op, nodePtr.p->start_op_state, op_ptr.p->op_key);
25802 if (nodePtr.p->recoveryState == NodeRecord::RS_PARTIAL_ROLLBACK &&
25803 ((nodePtr.p->start_op_state == SchemaOp::OS_PARSED &&
25804 nodePtr.p->start_op <= op_ptr.p->op_key) ||
25805 (nodePtr.p->start_op_state == SchemaOp::OS_PREPARED &&
25806 nodePtr.p->start_op < op_ptr.p->op_key) ||
25807 (nodePtr.p->start_op_state == SchemaOp::OS_ABORTED_PREPARE &&
25808 nodePtr.p->start_op >= op_ptr.p->op_key)))
25811 ndbout_c(
"Skip aborting operation %u on node %u", op_ptr.p->op_key, i);
25814 nodePtr.p->recoveryState = NodeRecord::RS_NORMAL;
25822 Dbdict::trans_abort_prepare_next(
Signal* signal,
25823 SchemaTransPtr trans_ptr,
25824 SchemaOpPtr op_ptr)
25827 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_ABORTING_PREPARE);
25829 ndbout_c(
"Dbdict::trans_abort_prepare_next: op %u state %u", op_ptr.p->op_key, op_ptr.p->m_state);
25831 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
25833 switch(op_ptr.p->m_state){
25834 case SchemaOp::OS_PARSED:
25840 trans_abort_prepare_recv_reply(signal, trans_ptr);
25842 case SchemaOp::OS_PREPARING:
25843 case SchemaOp::OS_PREPARED:
25845 case SchemaOp::OS_INITIAL:
25846 case SchemaOp::OS_PARSE_MASTER:
25847 case SchemaOp::OS_PARSING:
25848 case SchemaOp::OS_ABORTING_PREPARE:
25849 case SchemaOp::OS_ABORTED_PREPARE:
25850 case SchemaOp::OS_ABORTING_PARSE:
25852 case SchemaOp::OS_COMMITTING:
25853 case SchemaOp::OS_COMMITTED:
25857 jamLine(op_ptr.p->m_state);
25861 op_ptr.p->m_state = SchemaOp::OS_ABORTING_PREPARE;
25863 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
25865 check_partial_trans_abort_prepare_next(trans_ptr, nodes, op_ptr);
25868 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25873 if (ERROR_INSERTED(6145))
25877 if (!list.hasPrev(op_ptr))
25883 Uint32 nodeId = rand() % MAX_NDB_NODES;
25884 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
25885 nodeId = rand() % MAX_NDB_NODES;
25887 infoEvent(
"Simulating node %u missing RT_ABORT_PREPARE", nodeId);
25888 rg.m_nodes.clear(nodeId);
25889 signal->theData[0] = 9999;
25890 signal->theData[1] = ERROR_INSERT_VALUE;
25891 CLEAR_ERROR_INSERT_VALUE;
25892 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
25898 req->senderRef = reference();
25899 req->transKey = trans_ptr.p->trans_key;
25900 req->opKey = op_ptr.p->op_key;
25901 req->requestInfo = SchemaTransImplReq::RT_ABORT_PREPARE;
25902 req->transId = trans_ptr.p->m_transId;
25903 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
25904 SchemaTransImplReq::SignalLength, JBB);
25908 Dbdict::trans_abort_prepare_done(
Signal* signal, SchemaTransPtr trans_ptr)
25911 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_ABORTING_PREPARE);
25913 ndbout_c(
"Dbdict::trans_abort_prepare_done");
25918 trans_abort_parse_start(signal, trans_ptr);
25926 Dbdict::trans_rollback_sp_start(
Signal* signal, SchemaTransPtr trans_ptr)
25928 SchemaOpPtr op_ptr;
25932 ndbrequire(list.last(op_ptr));
25935 trans_ptr.p->m_state = SchemaTrans::TS_ROLLBACK_SP;
25937 if (op_ptr.p->m_state == SchemaOp::OS_PARSE_MASTER)
25945 nodes.
set(getOwnNodeId());
25947 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
25951 const OpInfo& info = getOpInfo(op_ptr);
25952 (this->*(info.m_abortParse))(signal, op_ptr);
25953 trans_log_schema_op_abort(op_ptr);
25957 trans_rollback_sp_next(signal, trans_ptr, op_ptr);
25961 Dbdict::trans_rollback_sp_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
25965 SchemaOpPtr op_ptr;
25966 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
25968 if (op_ptr.p->m_base_op_ptr_i == RNIL)
25973 trans_rollback_sp_done(signal, trans_ptr, op_ptr);
25980 SchemaOpPtr last_op = op_ptr;
25981 ndbrequire(list.prev(op_ptr));
25982 list.remove(last_op);
25983 releaseSchemaOp(last_op);
25986 trans_rollback_sp_next(signal, trans_ptr, op_ptr);
25990 Dbdict::trans_rollback_sp_next(
Signal* signal,
25991 SchemaTransPtr trans_ptr,
25992 SchemaOpPtr op_ptr)
25994 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
25996 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
25998 nodes.
bitANDC(trans_ptr.p->m_ref_nodes);
25999 trans_ptr.p->m_ref_nodes.clear();
26002 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
26007 if (ERROR_INSERTED(6144))
26011 if (!list.hasPrev(op_ptr))
26017 Uint32 nodeId = rand() % MAX_NDB_NODES;
26018 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
26019 nodeId = rand() % MAX_NDB_NODES;
26021 infoEvent(
"Simulating node %u missing RT_ABORT_PARSE", nodeId);
26022 rg.m_nodes.clear(nodeId);
26023 signal->theData[0] = 9999;
26024 signal->theData[1] = ERROR_INSERT_VALUE;
26025 CLEAR_ERROR_INSERT_VALUE;
26026 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
26032 req->senderRef = reference();
26033 req->transKey = trans_ptr.p->trans_key;
26034 req->opKey = op_ptr.p->op_key;
26035 req->requestInfo = SchemaTransImplReq::RT_ABORT_PARSE;
26036 req->transId = trans_ptr.p->m_transId;
26037 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26038 SchemaTransImplReq::SignalLength, JBB);
26043 Dbdict::trans_rollback_sp_done(
Signal* signal,
26044 SchemaTransPtr trans_ptr,
26045 SchemaOpPtr op_ptr)
26048 ErrorInfo error = trans_ptr.p->m_error;
26049 const OpInfo info = getOpInfo(op_ptr);
26050 (this->*(info.m_reply))(signal, op_ptr, error);
26053 list.remove(op_ptr);
26054 releaseSchemaOp(op_ptr);
26056 resetError(trans_ptr);
26057 trans_ptr.p->m_clientState = TransClient::ParseReply;
26058 trans_ptr.p->m_state = SchemaTrans::TS_STARTED;
26061 void Dbdict::check_partial_trans_commit_start(SchemaTransPtr trans_ptr,
26065 NodeRecordPtr ownNodePtr;
26066 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
26067 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
26075 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
26076 NodeRecordPtr nodePtr;
26077 if (trans_ptr.p->m_nodes.get(i))
26080 c_nodes.
getPtr(nodePtr, i);
26081 if (nodePtr.p->recoveryState == NodeRecord::RS_PARTIAL_ROLLFORWARD)
26085 ndbout_c(
"Skip flushing commit on node %u", i);
26088 nodePtr.p->recoveryState = NodeRecord::RS_NORMAL;
26096 Dbdict::trans_commit_start(
Signal* signal, SchemaTransPtr trans_ptr)
26098 if (ERROR_INSERTED(6016) || ERROR_INSERTED(6017))
26101 signal->theData[0] = 9999;
26103 if (c_masterNodeId == getOwnNodeId())
26106 mask.
clear(getOwnNodeId());
26107 sendSignalWithDelay(CMVMI_REF, GSN_NDB_TAMPER, signal, 1000, 1);
26114 sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
26118 trans_ptr.p->m_state = SchemaTrans::TS_FLUSH_COMMIT;
26120 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
26122 check_partial_trans_commit_start(trans_ptr, nodes);
26125 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
26130 if (ERROR_INSERTED(6146))
26137 Uint32 nodeId = rand() % MAX_NDB_NODES;
26138 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
26139 nodeId = rand() % MAX_NDB_NODES;
26141 infoEvent(
"Simulating node %u missing RT_FLUSH_COMMIT", nodeId);
26142 rg.m_nodes.clear(nodeId);
26143 signal->theData[0] = 9999;
26144 signal->theData[1] = ERROR_INSERT_VALUE;
26145 CLEAR_ERROR_INSERT_VALUE;
26146 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
26151 req->senderRef = reference();
26152 req->transKey = trans_ptr.p->trans_key;
26154 req->requestInfo = SchemaTransImplReq::RT_FLUSH_COMMIT;
26155 req->transId = trans_ptr.p->m_transId;
26156 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26157 SchemaTransImplReq::SignalLength, JBB);
26161 Dbdict::trans_commit_first(
Signal* signal, SchemaTransPtr trans_ptr)
26165 if (ERROR_INSERTED(6018))
26169 signal->theData[0] = 9999;
26170 sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
26175 ndbout_c(
"trans_commit");
26178 trans_ptr.p->m_state = SchemaTrans::TS_COMMITTING;
26180 NodeRecordPtr ownNodePtr;
26181 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
26182 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER &&
26183 ownNodePtr.p->takeOverConf.trans_state >= SchemaTrans::TS_COMMITTING)
26189 trans_commit_mutex_locked(signal, trans_ptr.i, 0);
26191 else if (trans_ptr.p->m_wait_gcp_on_commit)
26195 signal->theData[0] = 0;
26196 signal->theData[1] = 0;
26197 signal->theData[2] = 1;
26201 Uint32 gci_hi = signal->theData[1];
26202 Uint32 gci_lo = signal->theData[2];
26204 signal->theData[0] = ZCOMMIT_WAIT_GCI;
26205 signal->theData[1] = trans_ptr.i;
26206 signal->theData[2] = gci_hi;
26207 signal->theData[3] = gci_lo;
26208 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 20, 4);
26210 signal->theData[0] = 6099;
26211 sendSignal(DBDIH_REF, GSN_DUMP_STATE_ORD, signal, 1, JBB);
26216 Mutex mutex(signal, c_mutexMgr, trans_ptr.p->m_commit_mutex);
26217 Callback c = { safe_cast(&Dbdict::trans_commit_mutex_locked), trans_ptr.i };
26220 bool ok = mutex.lock(c);
26226 Dbdict::trans_commit_wait_gci(
Signal* signal)
26229 SchemaTransPtr trans_ptr;
26230 c_schemaTransPool.
getPtr(trans_ptr, signal->theData[1]);
26232 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_COMMITTING);
26234 Uint32 gci_hi = signal->theData[2];
26235 Uint32 gci_lo = signal->theData[3];
26237 signal->theData[0] = 0;
26238 signal->theData[1] = 0;
26239 signal->theData[2] = 1;
26243 Uint32 curr_gci_hi = signal->theData[1];
26244 Uint32 curr_gci_lo = signal->theData[2];
26253 else if (curr_gci_hi == gci_hi && curr_gci_lo == gci_lo)
26256 signal->theData[0] = ZCOMMIT_WAIT_GCI;
26257 signal->theData[1] = trans_ptr.i;
26258 signal->theData[2] = gci_hi;
26259 signal->theData[3] = gci_lo;
26260 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal, 20, 4);
26264 Mutex mutex(signal, c_mutexMgr, trans_ptr.p->m_commit_mutex);
26265 Callback c = { safe_cast(&Dbdict::trans_commit_mutex_locked), trans_ptr.i };
26268 bool ok = mutex.lock(c);
26273 Dbdict::trans_commit_mutex_locked(
Signal* signal,
26279 ndbout_c(
"trans_commit_mutex_locked");
26281 SchemaTransPtr trans_ptr;
26282 c_schemaTransPool.
getPtr(trans_ptr, transPtrI);
26284 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_COMMITTING);
26286 bool first =
false;
26287 SchemaOpPtr op_ptr;
26290 first = list.first(op_ptr);
26296 trans_commit_next(signal, trans_ptr, op_ptr);
26297 if (ERROR_INSERTED(6014)) {
26299 CRASH_INSERTION(6014);
26305 trans_commit_done(signal, trans_ptr);
26306 if (ERROR_INSERTED(6015)) {
26308 CRASH_INSERTION(6015);
26313 void Dbdict::check_partial_trans_commit_next(SchemaTransPtr trans_ptr,
26315 SchemaOpPtr op_ptr)
26318 NodeRecordPtr ownNodePtr;
26319 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
26320 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER &&
26321 trans_ptr.p->check_partial_rollforward)
26329 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
26330 NodeRecordPtr nodePtr;
26332 ndbout_c(
"Node %u", i);
26334 if (trans_ptr.p->m_nodes.get(i))
26336 c_nodes.
getPtr(nodePtr, i);
26338 ndbout_c(
"Checking node %u(%u), %u<%u", nodePtr.i, nodePtr.p->recoveryState, nodePtr.p->start_op, op_ptr.p->op_key);
26340 if (nodePtr.p->recoveryState == NodeRecord::RS_PARTIAL_ROLLFORWARD &&
26341 (nodePtr.p->start_op > op_ptr.p->op_key ||
26342 nodePtr.p->start_op_state > op_ptr.p->m_state))
26345 ndbout_c(
"Skipping commit of operation %u on node %u", op_ptr.p->op_key, i);
26348 nodePtr.p->recoveryState = NodeRecord::RS_NORMAL;
26352 trans_ptr.p->check_partial_rollforward =
false;
26357 Dbdict::trans_commit_next(
Signal* signal,
26358 SchemaTransPtr trans_ptr,
26359 SchemaOpPtr op_ptr)
26363 ndbout_c(
"Dbdict::trans_commit_next: op %u state %u", op_ptr.i,op_ptr.p->m_state);
26365 op_ptr.p->m_state = SchemaOp::OS_COMMITTING;
26366 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
26368 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
26370 check_partial_trans_commit_next(trans_ptr, nodes, op_ptr);
26373 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
26378 if (ERROR_INSERTED(6147))
26381 if (!list.hasNext(op_ptr))
26388 Uint32 nodeId = rand() % MAX_NDB_NODES;
26389 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
26390 nodeId = rand() % MAX_NDB_NODES;
26392 infoEvent(
"Simulating node %u missing RT_COMMIT", nodeId);
26393 rg.m_nodes.clear(nodeId);
26394 signal->theData[0] = 9999;
26395 signal->theData[1] = ERROR_INSERT_VALUE;
26396 CLEAR_ERROR_INSERT_VALUE;
26397 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
26403 req->senderRef = reference();
26404 req->transKey = trans_ptr.p->trans_key;
26405 req->opKey = op_ptr.p->op_key;
26406 req->requestInfo = SchemaTransImplReq::RT_COMMIT;
26407 req->transId = trans_ptr.p->m_transId;
26409 if (rg.m_nodes.get(getOwnNodeId()))
26418 rg.m_nodes.clear(getOwnNodeId());
26420 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26421 SchemaTransImplReq::SignalLength, JBB);
26422 sendSignal(reference(), GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26423 SchemaTransImplReq::SignalLength, JBB);
26430 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26431 SchemaTransImplReq::SignalLength, JBB);
26436 Dbdict::trans_commit_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
26438 if (hasError(trans_ptr.p->m_error))
26446 SchemaOpPtr op_ptr;
26447 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
26452 next = list.next(op_ptr);
26458 trans_commit_next(signal, trans_ptr, op_ptr);
26459 if (ERROR_INSERTED(6014)) {
26461 CRASH_INSERTION(6014);
26468 trans_commit_done(signal, trans_ptr);
26469 if (ERROR_INSERTED(6015)) {
26471 CRASH_INSERTION(6015);
26478 Dbdict::trans_commit_done(
Signal* signal, SchemaTransPtr trans_ptr)
26481 ndbout_c(
"trans_commit_done");
26484 Mutex mutex(signal, c_mutexMgr, trans_ptr.p->m_commit_mutex);
26485 Callback c = { safe_cast(&Dbdict::trans_commit_mutex_unlocked), trans_ptr.i };
26490 Dbdict::trans_commit_mutex_unlocked(
Signal* signal,
26496 ndbout_c(
"trans_commit_mutex_unlocked");
26498 SchemaTransPtr trans_ptr;
26499 c_schemaTransPool.
getPtr(trans_ptr, transPtrI);
26501 trans_ptr.p->m_commit_mutex.release(c_mutexMgr);
26508 trans_complete_start(signal, trans_ptr);
26512 Dbdict::check_partial_trans_complete_start(SchemaTransPtr trans_ptr,
26516 NodeRecordPtr ownNodePtr;
26517 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
26518 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
26526 for (
unsigned i = 1; i < MAX_NDB_NODES; i++) {
26527 NodeRecordPtr nodePtr;
26529 ndbout_c(
"Node %u", i);
26531 if (trans_ptr.p->m_nodes.get(i))
26533 c_nodes.
getPtr(nodePtr, i);
26535 ndbout_c(
"Checking node %u(%u,%u)", nodePtr.i, nodePtr.p->recoveryState, nodePtr.p->takeOverConf.trans_state);
26537 if (nodePtr.p->takeOverConf.trans_state >= SchemaTrans::TS_FLUSH_COMPLETE)
26540 ndbout_c(
"Skipping TS_FLUSH_COMPLETE of node %u", i);
26550 Dbdict::trans_complete_start(
Signal* signal, SchemaTransPtr trans_ptr)
26554 if (ERROR_INSERTED(6019))
26558 signal->theData[0] = 9999;
26559 sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
26564 ndbout_c(
"trans_complete_start %u", trans_ptr.p->trans_key);
26566 trans_ptr.p->m_state = SchemaTrans::TS_FLUSH_COMPLETE;
26568 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
26570 check_partial_trans_complete_start(trans_ptr, nodes);
26573 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
26578 if (ERROR_INSERTED(6148))
26585 Uint32 nodeId = rand() % MAX_NDB_NODES;
26586 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
26587 nodeId = rand() % MAX_NDB_NODES;
26589 infoEvent(
"Simulating node %u missing RT_FLUSH_COMPLETE", nodeId);
26590 rg.m_nodes.clear(nodeId);
26591 signal->theData[0] = 9999;
26592 signal->theData[1] = ERROR_INSERT_VALUE;
26593 CLEAR_ERROR_INSERT_VALUE;
26594 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
26599 req->senderRef = reference();
26600 req->transKey = trans_ptr.p->trans_key;
26602 req->requestInfo = SchemaTransImplReq::RT_FLUSH_COMPLETE;
26603 req->transId = trans_ptr.p->m_transId;
26604 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26605 SchemaTransImplReq::SignalLength, JBB);
26609 Dbdict::trans_complete_first(
Signal * signal, SchemaTransPtr trans_ptr)
26613 if (ERROR_INSERTED(6020))
26617 signal->theData[0] = 9999;
26618 sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBB);
26622 trans_ptr.p->m_state = SchemaTrans::TS_COMPLETING;
26624 bool first =
false;
26625 SchemaOpPtr op_ptr;
26628 first = list.first(op_ptr);
26634 trans_complete_next(signal, trans_ptr, op_ptr);
26639 trans_complete_done(signal, trans_ptr);
26644 Dbdict::trans_complete_next(
Signal* signal,
26645 SchemaTransPtr trans_ptr, SchemaOpPtr op_ptr)
26647 op_ptr.p->m_state = SchemaOp::OS_COMPLETING;
26648 trans_ptr.p->m_curr_op_ptr_i = op_ptr.i;
26650 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
26654 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
26659 if (ERROR_INSERTED(6149))
26666 Uint32 nodeId = rand() % MAX_NDB_NODES;
26667 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
26668 nodeId = rand() % MAX_NDB_NODES;
26670 infoEvent(
"Simulating node %u missing RT_COMPLETE", nodeId);
26671 rg.m_nodes.clear(nodeId);
26672 signal->theData[0] = 9999;
26673 signal->theData[1] = ERROR_INSERT_VALUE;
26674 CLEAR_ERROR_INSERT_VALUE;
26675 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
26680 req->senderRef = reference();
26681 req->transKey = trans_ptr.p->trans_key;
26682 req->opKey = op_ptr.p->op_key;
26683 req->requestInfo = SchemaTransImplReq::RT_COMPLETE;
26684 req->transId = trans_ptr.p->m_transId;
26685 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26686 SchemaTransImplReq::SignalLength, JBB);
26690 Dbdict::trans_complete_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
26692 if (hasError(trans_ptr.p->m_error))
26700 SchemaOpPtr op_ptr;
26701 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
26706 next = list.next(op_ptr);
26712 trans_complete_next(signal, trans_ptr, op_ptr);
26718 trans_complete_done(signal, trans_ptr);
26724 Dbdict::trans_complete_done(
Signal* signal, SchemaTransPtr trans_ptr)
26727 trans_end_start(signal, trans_ptr);
26731 Dbdict::trans_end_start(
Signal* signal, SchemaTransPtr trans_ptr)
26733 ndbrequire(trans_ptr.p->m_state != SchemaTrans::TS_ENDING);
26734 trans_ptr.p->m_state = SchemaTrans::TS_ENDING;
26736 trans_ptr.p->m_nodes.bitAND(c_aliveNodes);
26740 SafeCounter sc(c_counterMgr, trans_ptr.p->m_counter);
26745 if (ERROR_INSERTED(6150))
26752 Uint32 nodeId = rand() % MAX_NDB_NODES;
26753 while(nodeId == c_masterNodeId || (!rg.m_nodes.get(nodeId)))
26754 nodeId = rand() % MAX_NDB_NODES;
26756 infoEvent(
"Simulating node %u missing RT_END", nodeId);
26757 rg.m_nodes.clear(nodeId);
26758 signal->theData[0] = 9999;
26759 signal->theData[1] = ERROR_INSERT_VALUE;
26760 CLEAR_ERROR_INSERT_VALUE;
26761 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
26766 req->senderRef = reference();
26767 req->transKey = trans_ptr.p->trans_key;
26769 req->requestInfo = SchemaTransImplReq::RT_END;
26770 req->transId = trans_ptr.p->m_transId;
26771 sendSignal(rg, GSN_SCHEMA_TRANS_IMPL_REQ, signal,
26772 SchemaTransImplReq::SignalLength, JBB);
26776 Dbdict::check_partial_trans_end_recv_reply(SchemaTransPtr trans_ptr)
26779 NodeRecordPtr ownNodePtr;
26780 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
26781 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER &&
26782 trans_ptr.p->check_partial_rollforward &&
26783 trans_ptr.p->ressurected_op)
26791 SchemaOpPtr op_ptr;
26793 list.remove(op_ptr);
26795 ndbout_c(
"Releasing ressurected op %u", op_ptr.p->op_key);
26797 releaseSchemaOp(op_ptr);
26798 trans_ptr.p->check_partial_rollforward =
false;
26803 Dbdict::trans_end_recv_reply(
Signal* signal, SchemaTransPtr trans_ptr)
26806 const DictLockReq& lockReq = trans_ptr.p->m_lockReq;
26809 sendTransClientReply(signal, trans_ptr);
26810 check_partial_trans_end_recv_reply(trans_ptr);
26811 releaseSchemaTrans(trans_ptr);
26814 void Dbdict::trans_recover(
Signal* signal, SchemaTransPtr trans_ptr)
26820 ndbout_c(
"Dbdict::trans_recover trans %u, state %u", trans_ptr.p->trans_key, trans_ptr.p->m_state);
26823 switch(trans_ptr.p->m_state) {
26824 case SchemaTrans::TS_INITIAL:
26826 case SchemaTrans::TS_STARTING:
26828 case SchemaTrans::TS_STARTED:
26830 if (trans_ptr.p->m_rollback_op == 0)
26837 ndbout_c(
"Dbdict::trans_recover: ENDING START, trans %u(0x%8x), state %u", trans_ptr.i, (uint)trans_ptr.p->trans_key, trans_ptr.p->m_state);
26839 setError(trans_ptr.p->m_error, SchemaTransEndRep::TransAborted, __LINE__);
26840 trans_end_start(signal, trans_ptr);
26843 case SchemaTrans::TS_PARSING:
26845 setError(trans_ptr.p->m_error, SchemaTransEndRep::TransAborted, __LINE__);
26846 trans_abort_parse_start(signal, trans_ptr);
26848 case SchemaTrans::TS_ABORTING_PARSE:
26852 ndbout_c(
"Dbdict::trans_recover: ABORTING_PARSE, trans %u(0x%8x), state %u", trans_ptr.i, (uint)trans_ptr.p->trans_key, trans_ptr.p->m_state);
26854 setError(trans_ptr.p->m_error, SchemaTransEndRep::TransAborted, __LINE__);
26855 SchemaOpPtr op_ptr;
26856 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
26858 op_ptr.p->m_state = SchemaOp::OS_PREPARED;
26859 trans_abort_parse_next(signal, trans_ptr, op_ptr);
26862 case SchemaTrans::TS_PREPARING:
26864 if (trans_ptr.p->m_master_recovery_state == SchemaTrans::TRS_ROLLFORWARD)
26866 setError(trans_ptr.p->m_error, SchemaTransEndRep::TransAborted, __LINE__);
26867 trans_abort_prepare_start(signal, trans_ptr);
26869 case SchemaTrans::TS_ABORTING_PREPARE:
26873 ndbout_c(
"Dbdict::trans_recover: ABORTING PREPARE, trans %u(0x%8x), state %u", trans_ptr.i, (uint)trans_ptr.p->trans_key, trans_ptr.p->m_state);
26875 setError(trans_ptr.p->m_error, SchemaTransEndRep::TransAborted, __LINE__);
26876 SchemaOpPtr op_ptr;
26877 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
26879 op_ptr.p->m_state = SchemaOp::OS_PREPARED;
26880 trans_abort_prepare_next(signal, trans_ptr, op_ptr);
26883 case SchemaTrans::TS_FLUSH_COMMIT:
26889 trans_commit_start(signal, trans_ptr);
26891 case SchemaTrans::TS_COMMITTING:
26893 if (trans_ptr.p->m_highest_trans_state <= SchemaTrans::TS_COMMITTING)
26900 SchemaOpPtr op_ptr;
26901 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
26902 if (op_ptr.p->m_state < SchemaOp::OS_COMMITTED)
26905 trans_commit_next(signal, trans_ptr, op_ptr);
26913 NodeRecordPtr masterNodePtr;
26914 c_nodes.
getPtr(masterNodePtr, c_masterNodeId);
26915 if (masterNodePtr.p->recoveryState
26916 == NodeRecord::RS_PARTIAL_ROLLFORWARD)
26923 trans_commit_mutex_unlocked(signal, trans_ptr.i, 0);
26933 trans_commit_done(signal, trans_ptr);
26937 case SchemaTrans::TS_FLUSH_COMPLETE:
26940 ndbout_c(
"Dbdict::trans_recover: COMMITTING DONE, trans %u(0x%8x), state %u", trans_ptr.i, (uint)trans_ptr.p->trans_key, trans_ptr.p->m_state);
26942 trans_complete_done(signal, trans_ptr);
26944 case SchemaTrans::TS_COMPLETING:
26951 ndbout_c(
"Dbdict::trans_recover: COMPLETING, trans %u(0x%8x), state %u", trans_ptr.i, (uint)trans_ptr.p->trans_key, trans_ptr.p->m_state);
26953 SchemaOpPtr op_ptr;
26954 c_schemaOpPool.
getPtr(op_ptr, trans_ptr.p->m_curr_op_ptr_i);
26955 if (op_ptr.p->m_state < SchemaOp::OS_COMPLETED)
26958 trans_complete_next(signal, trans_ptr, op_ptr);
26962 case SchemaTrans::TS_ENDING:
26968 ndbout_c(
"Dbdict::trans_recover: ENDING, trans %u(0x%8x), state %u", trans_ptr.i, (uint)trans_ptr.p->trans_key, trans_ptr.p->m_state);
26970 trans_end_start(signal, trans_ptr);
26982 Dbdict::execSCHEMA_TRANS_IMPL_REQ(
Signal* signal)
26992 const Uint32 rt = DictSignal::getRequestType(req->requestInfo);
26994 if (rt == SchemaTransImplReq::RT_START)
26997 if (signal->getLength() < SchemaTransImplReq::SignalLengthStart)
27000 reqCopy.start.objectId = getFreeObjId(0);
27002 slave_run_start(signal, req);
27007 SchemaTransPtr trans_ptr;
27008 const Uint32 trans_key = req->transKey;
27009 if (!findSchemaTrans(trans_ptr, trans_key))
27012 setError(error, SchemaTransImplRef::InvalidTransKey, __LINE__);
27019 case(SchemaTransImplReq::RT_START):
27020 sprintf(buf,
" RequestType: RT_START");
27022 case(SchemaTransImplReq::RT_PARSE):
27023 sprintf(buf,
" RequestType: RT_PARSE");
27025 case(SchemaTransImplReq::RT_FLUSH_PREPARE):
27026 sprintf(buf,
" RequestType: RT_FLUSH_PREPARE");
27028 case(SchemaTransImplReq::RT_PREPARE):
27029 sprintf(buf,
" RequestType: RT_PREPARE");
27031 case(SchemaTransImplReq::RT_ABORT_PARSE):
27032 sprintf(buf,
" RequestType: RT_ABORT_PARSE");
27034 case(SchemaTransImplReq::RT_ABORT_PREPARE):
27035 sprintf(buf,
" RequestType: RT_ABORT_PREPARE");
27037 case(SchemaTransImplReq::RT_FLUSH_COMMIT):
27038 sprintf(buf,
" RequestType: RT_FLUSH_COMMIT");
27040 case(SchemaTransImplReq::RT_COMMIT):
27041 sprintf(buf,
" RequestType: RT_COMMIT");
27043 case(SchemaTransImplReq::RT_FLUSH_COMPLETE):
27044 sprintf(buf,
" RequestType: RT_FLUSH_COMPLETE");
27046 case(SchemaTransImplReq::RT_COMPLETE):
27047 sprintf(buf,
" RequestType: RT_COMPLETE");
27049 case(SchemaTransImplReq::RT_END):
27050 sprintf(buf,
" RequestType: RT_END");
27053 infoEvent(
"Dbdict::execSCHEMA_TRANS_IMPL_REQ: %s", buf);
27060 case SchemaTransImplReq::RT_PARSE:
27062 slave_run_parse(signal, trans_ptr, req);
27064 case SchemaTransImplReq::RT_END:
27065 case SchemaTransImplReq::RT_FLUSH_PREPARE:
27066 case SchemaTransImplReq::RT_FLUSH_COMMIT:
27067 case SchemaTransImplReq::RT_FLUSH_COMPLETE:
27070 slave_run_flush(signal, trans_ptr, req);
27076 SchemaOpPtr op_ptr;
27077 if (!findSchemaOp(op_ptr, req->opKey))
27081 setError(error, SchemaTransImplRef::InvalidTransKey, __LINE__);
27086 const OpInfo info = getOpInfo(op_ptr);
27088 case SchemaTransImplReq::RT_START:
27089 case SchemaTransImplReq::RT_PARSE:
27090 case SchemaTransImplReq::RT_FLUSH_PREPARE:
27091 case SchemaTransImplReq::RT_FLUSH_COMMIT:
27092 case SchemaTransImplReq::RT_FLUSH_COMPLETE:
27094 case SchemaTransImplReq::RT_PREPARE:
27096 op_ptr.p->m_state = SchemaOp::OS_PREPARING;
27097 (this->*(info.m_prepare))(signal, op_ptr);
27099 case SchemaTransImplReq::RT_ABORT_PARSE:
27101 ndbrequire(op_ptr.p->nextList == RNIL);
27102 op_ptr.p->m_state = SchemaOp::OS_ABORTING_PARSE;
27103 (this->*(info.m_abortParse))(signal, op_ptr);
27104 trans_log_schema_op_abort(op_ptr);
27105 if (!trans_ptr.p->m_isMaster)
27107 trans_ptr.p->m_state = SchemaTrans::TS_ABORTING_PARSE;
27112 list.remove(op_ptr);
27113 releaseSchemaOp(op_ptr);
27116 case SchemaTransImplReq::RT_ABORT_PREPARE:
27118 op_ptr.p->m_state = SchemaOp::OS_ABORTING_PREPARE;
27119 (this->*(info.m_abortPrepare))(signal, op_ptr);
27120 if (!trans_ptr.p->m_isMaster)
27121 trans_ptr.p->m_state = SchemaTrans::TS_ABORTING_PREPARE;
27123 case SchemaTransImplReq::RT_COMMIT:
27125 op_ptr.p->m_state = SchemaOp::OS_COMMITTING;
27126 (this->*(info.m_commit))(signal, op_ptr);
27128 case SchemaTransImplReq::RT_COMPLETE:
27130 op_ptr.p->m_state = SchemaOp::OS_COMPLETING;
27131 (this->*(info.m_complete))(signal, op_ptr);
27132 trans_log_schema_op_complete(op_ptr);
27146 SchemaTransPtr trans_ptr;
27147 const Uint32 trans_key = req->transKey;
27149 Uint32 objId = getFreeObjId(req->start.objectId);
27150 if (objId != req->start.objectId)
27153 setError(error, CreateTableRef::NoMoreTableRecords, __LINE__);
27157 if (req->senderRef != reference())
27160 if (!seizeSchemaTrans(trans_ptr, trans_key))
27163 setError(error, SchemaTransImplRef::TooManySchemaTrans, __LINE__);
27166 trans_ptr.p->m_clientRef = req->start.clientRef;
27167 trans_ptr.p->m_transId = req->transId;
27168 trans_ptr.p->m_isMaster =
false;
27169 trans_ptr.p->m_masterRef = req->senderRef;
27170 trans_ptr.p->m_requestInfo = req->requestInfo;
27171 trans_ptr.p->m_state = SchemaTrans::TS_STARTED;
27177 ndbrequire(findSchemaTrans(trans_ptr, req->transKey));
27180 trans_ptr.p->m_obj_id = objId;
27181 trans_log(trans_ptr);
27183 sendTransConf(signal, trans_ptr);
27187 SchemaTrans tmp_trans;
27188 trans_ptr.i = RNIL;
27189 trans_ptr.p = &tmp_trans;
27190 trans_ptr.p->trans_key = trans_key;
27191 trans_ptr.p->m_masterRef = req->senderRef;
27192 setError(trans_ptr.p->m_error, error);
27193 sendTransRef(signal, trans_ptr);
27197 Dbdict::slave_run_parse(
Signal *signal,
27198 SchemaTransPtr trans_ptr,
27201 SchemaOpPtr op_ptr;
27202 D(
"slave_run_parse");
27204 const Uint32 op_key = req->opKey;
27205 const Uint32 gsn = req->parse.gsn;
27206 const Uint32 requestInfo = req->requestInfo;
27207 const OpInfo& info = *findOpInfo(gsn);
27210 const Uint32* src = signal->getDataPtr() + SchemaTransImplReq::SignalLength;
27211 const Uint32 len = info.m_impl_req_length;
27215 ndbrequire(op_key != RNIL);
27217 if (trans_ptr.p->m_isMaster)
27223 findSchemaOp(op_ptr, op_key);
27224 ndbrequire(!op_ptr.isNull());
27226 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
27227 const Uint32* dst = oprec_ptr.p->m_impl_req_data;
27228 ndbrequire(memcmp(dst, src, len << 2) == 0);
27232 if (checkSingleUserMode(trans_ptr.p->m_clientRef))
27235 setError(error, AlterTableRef::SingleUser, __LINE__);
27237 else if (seizeSchemaOp(op_ptr, op_key, info))
27241 DictSignal::addRequestExtra(op_ptr.p->m_requestInfo, requestInfo);
27242 DictSignal::addRequestFlags(op_ptr.p->m_requestInfo, requestInfo);
27244 OpRecPtr oprec_ptr = op_ptr.p->m_oprec_ptr;
27245 Uint32* dst = oprec_ptr.p->m_impl_req_data;
27246 memcpy(dst, src, len << 2);
27248 addSchemaOp(trans_ptr, op_ptr);
27249 op_ptr.p->m_state = SchemaOp::OS_PARSING;
27250 (this->*(info.m_parse))(signal,
false, op_ptr, handle, error);
27253 setError(error, SchemaTransImplRef::TooManySchemaOps, __LINE__);
27258 releaseSections(handle);
27260 if (hasError(error))
27263 setError(trans_ptr, error);
27264 sendTransRef(signal, trans_ptr);
27267 sendTransConf(signal, op_ptr);
27271 Dbdict::slave_run_flush(
Signal *signal,
27272 SchemaTransPtr trans_ptr,
27275 bool do_flush =
false;
27276 const Uint32 rt = DictSignal::getRequestType(req->requestInfo);
27277 const bool master = trans_ptr.p->m_isMaster;
27279 jamLine(trans_ptr.p->m_state);
27281 case SchemaTransImplReq::RT_FLUSH_PREPARE:
27285 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_FLUSH_PREPARE);
27290 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_STARTED ||
27291 trans_ptr.p->m_state == SchemaTrans::TS_ABORTING_PARSE);
27292 trans_ptr.p->m_state = SchemaTrans::TS_FLUSH_PREPARE;
27294 do_flush = trans_ptr.p->m_flush_prepare;
27296 case SchemaTransImplReq::RT_FLUSH_COMMIT:
27300 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_FLUSH_COMMIT);
27305 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_PREPARING);
27306 trans_ptr.p->m_state = SchemaTrans::TS_FLUSH_COMMIT;
27308 do_flush = trans_ptr.p->m_flush_commit;
27310 case SchemaTransImplReq::RT_FLUSH_COMPLETE:
27314 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_FLUSH_COMPLETE);
27319 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_COMMITTING);
27320 trans_ptr.p->m_state = SchemaTrans::TS_FLUSH_COMPLETE;
27322 do_flush = trans_ptr.p->m_flush_complete;
27324 case SchemaTransImplReq::RT_END:
27329 trans_ptr.p->m_state = SchemaTrans::TS_ENDING;
27330 do_flush = trans_ptr.p->m_flush_end;
27336 trans_log(trans_ptr);
27339 if (do_flush ==
false)
27347 slave_writeSchema_conf(signal, trans_ptr.p->trans_key, 0);
27352 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
27353 ndbrequire(c_writeSchemaRecord.inUse ==
false);
27354 c_writeSchemaRecord.inUse =
true;
27355 c_writeSchemaRecord.pageId = c_schemaRecord.schemaPage;
27356 c_writeSchemaRecord.newFile =
false;
27357 c_writeSchemaRecord.firstPage = 0;
27358 c_writeSchemaRecord.noOfPages = xsf->noOfPages;
27360 c_writeSchemaRecord.m_callback.m_callbackData = trans_ptr.p->trans_key;
27361 c_writeSchemaRecord.m_callback.m_callbackFunction =
27362 safe_cast(&Dbdict::slave_writeSchema_conf);
27364 for(Uint32 i = 0; i<xsf->noOfPages; i++)
27365 computeChecksum(xsf, i);
27367 startWriteSchemaFile(signal);
27371 Dbdict::slave_writeSchema_conf(
Signal* signal,
27376 ndbrequire(ret == 0);
27377 SchemaTransPtr trans_ptr;
27378 ndbrequire(findSchemaTrans(trans_ptr, trans_key));
27380 bool release =
false;
27381 if (!trans_ptr.p->m_isMaster)
27383 switch(trans_ptr.p->m_state){
27384 case SchemaTrans::TS_FLUSH_PREPARE:
27386 trans_ptr.p->m_state = SchemaTrans::TS_PREPARING;
27388 case SchemaTrans::TS_FLUSH_COMMIT:
27391 trans_ptr.p->m_state = SchemaTrans::TS_COMMITTING;
27393 Mutex mutex(signal, c_mutexMgr, trans_ptr.p->m_commit_mutex);
27394 Callback c = { safe_cast(&Dbdict::slave_commit_mutex_locked), trans_ptr.i };
27395 bool ok = mutex.lock(c);
27399 case SchemaTrans::TS_FLUSH_COMPLETE:
27402 trans_ptr.p->m_state = SchemaTrans::TS_COMPLETING;
27404 Mutex mutex(signal, c_mutexMgr, trans_ptr.p->m_commit_mutex);
27405 Callback c = { safe_cast(&Dbdict::slave_commit_mutex_unlocked), trans_ptr.i };
27409 case SchemaTrans::TS_ENDING:
27414 jamLine(trans_ptr.p->m_state);
27419 sendTransConfRelease(signal, trans_ptr);
27423 Dbdict::slave_commit_mutex_locked(
Signal* signal,
27429 ndbout_c(
"slave_commit_mutex_locked");
27431 SchemaTransPtr trans_ptr;
27432 c_schemaTransPool.
getPtr(trans_ptr, transPtrI);
27434 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_COMMITTING);
27435 sendTransConfRelease(signal, trans_ptr);
27439 Dbdict::slave_commit_mutex_unlocked(
Signal* signal,
27445 ndbout_c(
"slave_commit_mutex_unlocked");
27447 SchemaTransPtr trans_ptr;
27448 c_schemaTransPool.
getPtr(trans_ptr, transPtrI);
27450 trans_ptr.p->m_commit_mutex.release(c_mutexMgr);
27452 ndbrequire(trans_ptr.p->m_state == SchemaTrans::TS_COMPLETING);
27453 sendTransConfRelease(signal, trans_ptr);
27456 void Dbdict::sendTransConfRelease(
Signal*signal, SchemaTransPtr trans_ptr)
27459 sendTransConf(signal, trans_ptr);
27461 if ((!trans_ptr.p->m_isMaster) &&
27462 trans_ptr.p->m_state == SchemaTrans::TS_ENDING)
27465 releaseSchemaTrans(trans_ptr);
27470 Dbdict::update_op_state(SchemaOpPtr op_ptr)
27472 switch(op_ptr.p->m_state){
27473 case SchemaOp::OS_PARSE_MASTER:
27475 case SchemaOp::OS_PARSING:
27476 op_ptr.p->m_state = SchemaOp::OS_PARSED;
27478 case SchemaOp::OS_PARSED:
27480 case SchemaOp::OS_PREPARING:
27481 op_ptr.p->m_state = SchemaOp::OS_PREPARED;
27483 case SchemaOp::OS_PREPARED:
27485 case SchemaOp::OS_ABORTING_PREPARE:
27486 op_ptr.p->m_state = SchemaOp::OS_ABORTED_PREPARE;
27488 case SchemaOp::OS_ABORTED_PREPARE:
27490 case SchemaOp::OS_ABORTING_PARSE:
27493 case SchemaOp::OS_COMMITTING:
27494 op_ptr.p->m_state = SchemaOp::OS_COMMITTED;
27496 case SchemaOp::OS_COMMITTED:
27498 case SchemaOp::OS_COMPLETING:
27499 op_ptr.p->m_state = SchemaOp::OS_COMPLETED;
27501 case SchemaOp::OS_COMPLETED:
27507 Dbdict::sendTransConf(
Signal* signal, SchemaOpPtr op_ptr)
27509 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
27510 update_op_state(op_ptr);
27511 sendTransConf(signal, trans_ptr);
27515 Dbdict::sendTransConf(
Signal* signal, SchemaTransPtr trans_ptr)
27517 ndbrequire(!trans_ptr.isNull());
27518 ndbrequire(signal->getNoOfSections() == 0);
27522 conf->senderRef = reference();
27523 conf->transKey = trans_ptr.p->trans_key;
27525 const Uint32 masterRef = trans_ptr.p->m_masterRef;
27527 if (ERROR_INSERTED(6103)) {
27529 CLEAR_ERROR_INSERT_VALUE;
27533 Uint32* data = &signal->theData[0];
27534 memmove(&data[2], &data[0], SchemaTransImplConf::SignalLength << 2);
27536 data[1] = masterRef;
27537 sendSignalWithDelay(reference(), GSN_CONTINUEB, signal,
27538 5000, 2 + SchemaTransImplConf::SignalLength);
27542 sendSignal(masterRef, GSN_SCHEMA_TRANS_IMPL_CONF, signal,
27543 SchemaTransImplConf::SignalLength, JBB);
27547 Dbdict::sendTransRef(
Signal* signal, SchemaOpPtr op_ptr)
27549 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
27551 ndbrequire(hasError(op_ptr.p->m_error));
27552 ndbrequire(hasError(trans_ptr.p->m_error));
27554 update_op_state(op_ptr);
27556 sendTransRef(signal, trans_ptr);
27560 Dbdict::sendTransRef(
Signal* signal, SchemaTransPtr trans_ptr)
27563 ndbrequire(hasError(trans_ptr.p->m_error));
27569 ref->senderRef = reference();
27570 ref->transKey = trans_ptr.p->trans_key;
27571 getError(trans_ptr.p->m_error, ref);
27574 resetError(trans_ptr.p->m_error);
27576 const Uint32 masterRef = trans_ptr.p->m_masterRef;
27577 sendSignal(masterRef, GSN_SCHEMA_TRANS_IMPL_REF, signal,
27578 SchemaTransImplRef::SignalLength, JBB);
27582 Dbdict::trans_log(SchemaTransPtr trans_ptr)
27584 Uint32 objectId = trans_ptr.p->m_obj_id;
27585 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
27589 jamLine(trans_ptr.p->m_state);
27590 jamLine(entry->m_tableState);
27591 switch(trans_ptr.p->m_state){
27592 case SchemaTrans::TS_STARTED:
27593 case SchemaTrans::TS_STARTING:{
27595 Uint32 version = entry->m_tableVersion;
27596 Uint32 new_version = create_obj_inc_schema_version(version);
27598 entry->m_tableState = SchemaFile::SF_STARTED;
27599 entry->m_tableVersion = new_version;
27600 entry->m_tableType = DictTabInfo::SchemaTransaction;
27601 entry->m_info_words = 0;
27603 entry->m_transId = trans_ptr.p->m_transId;
27606 case SchemaTrans::TS_FLUSH_PREPARE:
27608 ndbrequire(entry->m_tableState == SchemaFile::SF_STARTED);
27609 entry->m_tableState = SchemaFile::SF_PREPARE;
27611 case SchemaTrans::TS_ABORTING_PREPARE:
27613 ndbrequire(entry->m_tableState == SchemaFile::SF_PREPARE);
27614 entry->m_tableState = SchemaFile::SF_ABORT;
27616 case SchemaTrans::TS_FLUSH_COMMIT:
27618 ndbrequire(entry->m_tableState == SchemaFile::SF_PREPARE);
27619 entry->m_tableState = SchemaFile::SF_COMMIT;
27621 case SchemaTrans::TS_FLUSH_COMPLETE:
27623 ndbrequire(entry->m_tableState == SchemaFile::SF_COMMIT);
27624 entry->m_tableState = SchemaFile::SF_COMPLETE;
27626 case SchemaTrans::TS_ENDING:
27628 entry->m_transId = 0;
27629 entry->m_tableState = SchemaFile::SF_UNUSED;
27640 Dbdict::trans_log_schema_op(SchemaOpPtr op_ptr,
27646 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
27649 if (oldEntry->m_transId != 0)
27652 return DropTableRef::ActiveSchemaTrans;
27656 bool restart = op_ptr.p->m_restart;
27657 switch((SchemaFile::EntryState)newEntry->m_tableState){
27658 case SchemaFile::SF_CREATE:
27659 ndbrequire(restart || oldEntry->m_tableState == SchemaFile::SF_UNUSED);
27661 case SchemaFile::SF_ALTER:
27662 ndbrequire(restart || oldEntry->m_tableState == SchemaFile::SF_IN_USE);
27664 tmp.m_info_words = newEntry->m_info_words;
27665 tmp.m_tableVersion = newEntry->m_tableVersion;
27667 case SchemaFile::SF_DROP:
27668 ndbrequire(restart || oldEntry->m_tableState == SchemaFile::SF_IN_USE);
27670 tmp.m_tableState = SchemaFile::SF_DROP;
27673 jamLine(newEntry->m_tableState);
27677 tmp.m_tableState = newEntry->m_tableState;
27678 tmp.m_transId = newEntry->m_transId;
27679 op_ptr.p->m_orig_entry_id = objectId;
27680 op_ptr.p->m_orig_entry = * oldEntry;
27684 if (op_ptr.p->m_restart != 1)
27688 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
27689 trans_ptr.p->m_flush_prepare |=
true;
27690 trans_ptr.p->m_flush_commit |=
true;
27697 Dbdict::trans_log_schema_op_abort(SchemaOpPtr op_ptr)
27699 Uint32 objectId = op_ptr.p->m_orig_entry_id;
27700 if (objectId != RNIL)
27703 op_ptr.p->m_orig_entry_id = RNIL;
27704 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
27706 * entry = op_ptr.p->m_orig_entry;
27711 Dbdict::trans_log_schema_op_complete(SchemaOpPtr op_ptr)
27713 Uint32 objectId = op_ptr.p->m_orig_entry_id;
27714 if (objectId != RNIL)
27717 op_ptr.p->m_orig_entry_id = RNIL;
27718 XSchemaFile * xsf = &c_schemaFile[SchemaRecord::NEW_SCHEMA_FILE];
27720 switch((SchemaFile::EntryState)entry->m_tableState){
27721 case SchemaFile::SF_CREATE:
27722 entry->m_tableState = SchemaFile::SF_IN_USE;
27724 case SchemaFile::SF_ALTER:
27725 entry->m_tableState = SchemaFile::SF_IN_USE;
27727 case SchemaFile::SF_DROP:
27728 entry->m_tableState = SchemaFile::SF_UNUSED;
27731 jamLine(entry->m_tableState);
27734 entry->m_transId = 0;
27741 Dbdict::sendTransClientReply(
Signal* signal, SchemaTransPtr trans_ptr)
27743 const Uint32 clientFlags = trans_ptr.p->m_clientFlags;
27744 D(
"sendTransClientReply" << hex << V(clientFlags));
27745 D(
"c_rope_pool free: " << c_rope_pool.getNoOfFree());
27747 Uint32 receiverRef = 0;
27748 Uint32 transId = 0;
27749 NodeRecordPtr ownNodePtr;
27751 c_nodes.
getPtr(ownNodePtr, getOwnNodeId());
27753 if (!(clientFlags & TransClient::TakeOver)) {
27754 receiverRef = trans_ptr.p->m_clientRef;
27755 transId = trans_ptr.p->m_transId;
27758 receiverRef = reference();
27759 transId = trans_ptr.p->m_takeOverTxKey;
27762 if (trans_ptr.p->m_clientState == TransClient::BeginReq) {
27763 if (!hasError(trans_ptr.p->m_error)) {
27767 conf->senderRef = reference();
27768 conf->transId = transId;
27769 conf->transKey = trans_ptr.p->trans_key;
27770 sendSignal(receiverRef, GSN_SCHEMA_TRANS_BEGIN_CONF, signal,
27771 SchemaTransBeginConf::SignalLength, JBB);
27776 ref->senderRef = reference();
27777 ref->transId = transId;
27778 getError(trans_ptr.p->m_error, ref);
27779 sendSignal(receiverRef, GSN_SCHEMA_TRANS_BEGIN_REF, signal,
27780 SchemaTransBeginRef::SignalLength, JBB);
27782 resetError(trans_ptr);
27783 trans_ptr.p->m_clientState = TransClient::BeginReply;
27787 if (trans_ptr.p->m_clientState == TransClient::EndReq) {
27788 if (!hasError(trans_ptr.p->m_error)) {
27792 conf->senderRef = reference();
27793 conf->transId = transId;
27794 sendSignal(receiverRef, GSN_SCHEMA_TRANS_END_CONF, signal,
27795 SchemaTransEndConf::SignalLength, JBB);
27800 ref->senderRef = reference();
27801 ref->transId = transId;
27802 getError(trans_ptr.p->m_error, ref);
27803 ref->masterNodeId = c_masterNodeId;
27804 sendSignal(receiverRef, GSN_SCHEMA_TRANS_END_REF, signal,
27805 SchemaTransEndRef::SignalLength, JBB);
27807 resetError(trans_ptr);
27808 trans_ptr.p->m_clientState = TransClient::EndReply;
27809 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
27815 goto send_node_fail_rep;
27820 if (ownNodePtr.p->nodeState == NodeRecord::NDB_MASTER_TAKEOVER)
27830 rep->senderRef = reference();
27831 rep->transId = transId;
27832 if (hasError(trans_ptr.p->m_error))
27833 getError(trans_ptr.p->m_error, rep);
27836 rep->errorCode = 0;
27837 rep->errorLine = 0;
27838 rep->errorNodeId = 0;
27840 rep->masterNodeId = c_masterNodeId;
27842 ndbout_c(
"Dbdict::sendTransClientReply: sending GSN_SCHEMA_TRANS_END_REP to 0x%8x", receiverRef);
27844 sendSignal(receiverRef, GSN_SCHEMA_TRANS_END_REP, signal,
27845 SchemaTransEndRep::SignalLength, JBB);
27847 send_node_fail_rep:
27851 send_nf_complete_rep(signal, &ownNodePtr.p->nodeFailRep);
27859 Dbdict::seizeTxHandle(TxHandlePtr& tx_ptr)
27861 Uint32 tx_key = c_opRecordSequence + 1;
27862 if (c_txHandleHash.
seize(tx_ptr)) {
27864 new (tx_ptr.p) TxHandle();
27865 tx_ptr.p->tx_key = tx_key;
27866 c_txHandleHash.
add(tx_ptr);
27867 tx_ptr.p->m_magic = TxHandle::DICT_MAGIC;
27868 D(
"seizeTxHandle" << V(tx_key));
27869 c_opRecordSequence = tx_key;
27877 Dbdict::findTxHandle(TxHandlePtr& tx_ptr, Uint32 tx_key)
27879 TxHandle tx_rec(tx_key);
27880 if (c_txHandleHash.
find(tx_ptr, tx_rec)) {
27882 ndbrequire(tx_ptr.p->m_magic == TxHandle::DICT_MAGIC);
27883 D(
"findTxHandle" << V(tx_key));
27891 Dbdict::releaseTxHandle(TxHandlePtr& tx_ptr)
27893 D(
"releaseTxHandle" << V(tx_ptr.p->tx_key));
27895 ndbrequire(tx_ptr.p->m_magic == TxHandle::DICT_MAGIC);
27896 tx_ptr.p->m_magic = 0;
27897 c_txHandleHash.
release(tx_ptr);
27901 Dbdict::beginSchemaTrans(
Signal* signal, TxHandlePtr tx_ptr)
27903 D(
"beginSchemaTrans");
27904 tx_ptr.p->m_transId = tx_ptr.p->tx_key;
27909 Uint32 requestInfo = 0;
27910 DictSignal::addRequestFlags(requestInfo, tx_ptr.p->m_requestInfo);
27912 const Uint32 clientFlags = tx_ptr.p->m_clientFlags;
27913 ndbrequire(!(clientFlags & TransClient::TakeOver));
27914 req->clientRef = reference();
27915 req->transId = tx_ptr.p->m_transId;
27916 req->requestInfo = requestInfo;
27917 sendSignal(reference(), GSN_SCHEMA_TRANS_BEGIN_REQ, signal,
27918 SchemaTransBeginReq::SignalLength, JBB);
27922 Dbdict::endSchemaTrans(
Signal* signal, TxHandlePtr tx_ptr, Uint32 flags)
27924 D(
"endSchemaTrans" << hex << V(flags));
27929 Uint32 requestInfo = 0;
27930 DictSignal::addRequestFlags(requestInfo, tx_ptr.p->m_requestInfo);
27932 const Uint32 clientFlags = tx_ptr.p->m_clientFlags;
27933 Uint32 transId = 0;
27934 if (!(clientFlags & TransClient::TakeOver)) {
27935 transId = tx_ptr.p->m_transId;
27938 transId = tx_ptr.p->m_takeOverTransId;
27939 D(
"take over mode" << hex << V(transId));
27942 req->clientRef = reference();
27943 req->transId = transId;
27944 req->transKey = tx_ptr.p->m_transKey;
27945 req->requestInfo = requestInfo;
27946 req->flags =
flags;
27947 sendSignal(reference(), GSN_SCHEMA_TRANS_END_REQ, signal,
27948 SchemaTransEndReq::SignalLength, JBB);
27952 Dbdict::execSCHEMA_TRANS_BEGIN_CONF(
Signal* signal)
27958 TxHandlePtr tx_ptr;
27959 findTxHandle(tx_ptr, conf->transId);
27960 ndbrequire(!tx_ptr.isNull());
27963 tx_ptr.p->m_transKey = conf->transKey;
27965 execute(signal, tx_ptr.p->m_callback, 0);
27969 Dbdict::execSCHEMA_TRANS_BEGIN_REF(
Signal* signal)
27975 TxHandlePtr tx_ptr;
27976 findTxHandle(tx_ptr, ref->transId);
27977 ndbrequire(!tx_ptr.isNull());
27979 setError(tx_ptr.p->m_error, ref);
27980 ndbrequire(ref->errorCode != 0);
27981 execute(signal, tx_ptr.p->m_callback, ref->errorCode);
27985 Dbdict::execSCHEMA_TRANS_END_CONF(
Signal* signal)
27991 TxHandlePtr tx_ptr;
27992 findTxHandle(tx_ptr, conf->transId);
27993 ndbrequire(!tx_ptr.isNull());
27995 execute(signal, tx_ptr.p->m_callback, 0);
27999 Dbdict::execSCHEMA_TRANS_END_REF(
Signal* signal)
28005 TxHandlePtr tx_ptr;
28006 findTxHandle(tx_ptr, ref->transId);
28007 ndbrequire(!tx_ptr.isNull());
28009 setError(tx_ptr.p->m_error, ref);
28010 ndbrequire(ref->errorCode != 0);
28011 execute(signal, tx_ptr.p->m_callback, ref->errorCode);
28015 Dbdict::execSCHEMA_TRANS_END_REP(
Signal* signal)
28021 TxHandlePtr tx_ptr;
28022 findTxHandle(tx_ptr, rep->transId);
28023 ndbrequire(!tx_ptr.isNull());
28025 if (rep->errorCode != 0)
28026 setError(tx_ptr.p->m_error, rep);
28027 execute(signal, tx_ptr.p->m_callback, rep->errorCode);
28040 Dbdict::handleApiFail(
Signal* signal,
28041 Uint32 failedApiNode)
28043 D(
"handleApiFail" << V(failedApiNode));
28045 Uint32 takeOvers = 0;
28046 SchemaTransPtr trans_ptr;
28047 c_schemaTransList.
first(trans_ptr);
28048 while (trans_ptr.i != RNIL) {
28050 D(
"check" << *trans_ptr.p);
28051 Uint32 clientRef = trans_ptr.p->m_clientRef;
28053 if (refToNode(clientRef) == failedApiNode)
28056 D(
"failed" << hex << V(clientRef));
28058 ndbrequire(!(trans_ptr.p->m_clientFlags & TransClient::ApiFail));
28059 trans_ptr.p->m_clientFlags |= TransClient::ApiFail;
28061 if (trans_ptr.p->m_isMaster)
28064 if (trans_ptr.p->m_clientFlags & TransClient::TakeOver)
28068 ndbrequire(trans_ptr.p->m_clientFlags & TransClient::Background);
28072 takeOverTransClient(signal, trans_ptr);
28075 TxHandlePtr tx_ptr;
28076 bool ok = findTxHandle(tx_ptr, trans_ptr.p->m_takeOverTxKey);
28079 tx_ptr.p->m_clientFlags |= TransClient::ApiFail;
28084 c_schemaTransList.
next(trans_ptr);
28087 D(
"handleApiFail" << V(takeOvers));
28089 if (takeOvers == 0) {
28091 apiFailBlockHandling(signal, failedApiNode);
28100 Dbdict::takeOverTransClient(
Signal* signal, SchemaTransPtr trans_ptr)
28102 D(
"takeOverTransClient" << *trans_ptr.p);
28104 TxHandlePtr tx_ptr;
28105 bool ok = seizeTxHandle(tx_ptr);
28108 ndbrequire(!(trans_ptr.p->m_clientFlags & TransClient::TakeOver));
28109 trans_ptr.p->m_clientFlags |= TransClient::TakeOver;
28110 trans_ptr.p->m_takeOverTxKey = tx_ptr.p->tx_key;
28112 tx_ptr.p->m_transId = tx_ptr.p->tx_key;
28113 tx_ptr.p->m_transKey = trans_ptr.p->trans_key;
28115 tx_ptr.p->m_clientState = trans_ptr.p->m_clientState;
28116 tx_ptr.p->m_clientFlags = trans_ptr.p->m_clientFlags;
28117 tx_ptr.p->m_takeOverRef = trans_ptr.p->m_clientRef;
28118 tx_ptr.p->m_takeOverTransId = trans_ptr.p->m_transId;
28120 runTransClientTakeOver(signal, tx_ptr.p->tx_key, 0);
28130 Dbdict::runTransClientTakeOver(
Signal* signal,
28134 TxHandlePtr tx_ptr;
28135 bool ok = findTxHandle(tx_ptr, tx_key);
28137 D(
"runClientTakeOver" << *tx_ptr.p << V(ret));
28141 setError(tx_ptr, ret, __LINE__);
28144 const TransClient::State oldState = tx_ptr.p->m_clientState;
28145 const Uint32 clientFlags = tx_ptr.p->m_clientFlags;
28146 ndbrequire(clientFlags & TransClient::TakeOver);
28148 TransClient::State newState = oldState;
28149 bool wait_sig =
false;
28150 bool at_end =
false;
28152 switch (oldState) {
28153 case TransClient::BeginReq:
28155 newState = TransClient::BeginReply;
28158 case TransClient::BeginReply:
28160 newState = TransClient::EndReply;
28162 case TransClient::ParseReq:
28164 newState = TransClient::ParseReply;
28167 case TransClient::ParseReply:
28169 newState = TransClient::EndReply;
28171 case TransClient::EndReq:
28173 newState = TransClient::EndReply;
28176 case TransClient::EndReply:
28178 newState = TransClient::StateUndef;
28186 D(
"set" << V(oldState) <<
" -> " << V(newState));
28187 tx_ptr.p->m_clientState = newState;
28192 safe_cast(&Dbdict::runTransClientTakeOver),
28195 tx_ptr.p->m_callback = c;
28200 flags |= SchemaTransEndReq::SchemaTransAbort;
28201 endSchemaTrans(signal, tx_ptr, flags);
28206 if (!hasError(tx_ptr.p->m_error)) {
28208 infoEvent(
"DICT: api:0x%8x trans:0x%8x takeover completed",
28209 tx_ptr.p->m_takeOverRef, tx_ptr.p->m_takeOverTransId);
28212 infoEvent(
"DICT: api:0x%8x trans:0x%8x takeover failed, error:%u line:%u",
28213 tx_ptr.p->m_takeOverRef, tx_ptr.p->m_takeOverTransId,
28214 tx_ptr.p->m_error.errorCode, tx_ptr.p->m_error.errorLine);
28218 if (clientFlags & TransClient::ApiFail) {
28220 finishApiFail(signal, tx_ptr);
28222 releaseTxHandle(tx_ptr);
28226 Dbdict::finishApiFail(
Signal* signal, TxHandlePtr tx_ptr)
28228 D(
"finishApiFail" << *tx_ptr.p);
28229 const Uint32 failedApiNode = refToNode(tx_ptr.p->m_takeOverRef);
28231 Uint32 takeOvers = 0;
28232 SchemaTransPtr trans_ptr;
28233 c_schemaTransList.
first(trans_ptr);
28234 while (trans_ptr.i != RNIL) {
28236 D(
"check" << *trans_ptr.p);
28237 const BlockReference clientRef = trans_ptr.p->m_clientRef;
28239 if (refToNode(clientRef) == failedApiNode) {
28241 const Uint32 clientFlags = trans_ptr.p->m_clientFlags;
28242 D(
"failed" << hex << V(clientRef) << dec << V(clientFlags));
28243 ndbrequire(clientFlags & TransClient::ApiFail);
28246 c_schemaTransList.
next(trans_ptr);
28249 D(
"finishApiFail" << V(takeOvers));
28251 if (takeOvers == 0) {
28253 apiFailBlockHandling(signal, failedApiNode);
28258 Dbdict::apiFailBlockHandling(
Signal* signal,
28259 Uint32 failedApiNode)
28261 Callback cb = { safe_cast(&Dbdict::handleApiFailureCallback),
28269 Dbdict::findCallback(Callback& callback, Uint32 any_key)
28271 SchemaOpPtr op_ptr;
28272 SchemaTransPtr trans_ptr;
28273 TxHandlePtr tx_ptr;
28275 bool ok1 = findSchemaOp(op_ptr, any_key);
28276 bool ok2 = findSchemaTrans(trans_ptr, any_key);
28277 bool ok3 = findTxHandle(tx_ptr, any_key);
28278 ndbrequire(ok1 + ok2 + ok3 <= 1);
28281 callback = op_ptr.p->m_callback;
28285 callback = trans_ptr.p->m_callback;
28289 callback = tx_ptr.p->m_callback;
28292 callback.m_callbackFunction = 0;
28293 callback.m_callbackData = 0;
28301 const Dbdict::OpInfo
28302 Dbdict::CreateHashMapRec::g_opInfo = {
28303 {
'C',
'H',
'M', 0 },
28304 GSN_CREATE_HASH_MAP_REQ,
28305 CreateHashMapReq::SignalLength,
28307 &Dbdict::createHashMap_seize,
28308 &Dbdict::createHashMap_release,
28310 &Dbdict::createHashMap_parse,
28311 &Dbdict::createHashMap_subOps,
28312 &Dbdict::createHashMap_reply,
28314 &Dbdict::createHashMap_prepare,
28315 &Dbdict::createHashMap_commit,
28316 &Dbdict::createHashMap_complete,
28318 &Dbdict::createHashMap_abortParse,
28319 &Dbdict::createHashMap_abortPrepare
28323 Dbdict::createHashMap_seize(SchemaOpPtr op_ptr)
28325 return seizeOpRec<CreateHashMapRec>(op_ptr);
28329 Dbdict::createHashMap_release(SchemaOpPtr op_ptr)
28331 releaseOpRec<CreateHashMapRec>(op_ptr);
28335 Dbdict::execCREATE_HASH_MAP_REQ(
Signal* signal)
28350 SchemaOpPtr op_ptr;
28351 CreateHashMapRecPtr createHashMapPtr;
28354 startClientReq(op_ptr, createHashMapPtr, req, impl_req, error);
28355 if (hasError(error)) {
28360 impl_req->objectId = RNIL;
28361 impl_req->objectVersion = 0;
28362 impl_req->buckets = req->buckets;
28363 impl_req->fragments = req->fragments;
28365 handleClientReq(signal, op_ptr, handle);
28369 releaseSections(handle);
28373 ref->senderRef = reference();
28374 ref->senderData= req->clientData;
28375 ref->transId = req->transId;
28376 getError(error, ref);
28378 sendSignal(req->clientRef, GSN_CREATE_HASH_MAP_REF, signal,
28379 CreateHashMapRef::SignalLength, JBB);
28385 Dbdict::get_default_fragments(
Signal* signal, Uint32 extranodegroups)
28390 sd->extraNodeGroups = extranodegroups;
28391 sd->requestType = CheckNodeGroups::Direct | CheckNodeGroups::GetDefaultFragments;
28393 CheckNodeGroups::SignalLength);
28399 Dbdict::createHashMap_parse(
Signal* signal,
bool master,
28400 SchemaOpPtr op_ptr,
28404 SchemaTransPtr trans_ptr = op_ptr.p->m_trans_ptr;
28405 CreateHashMapRecPtr createHashMapPtr;
28406 getOpRec(op_ptr, createHashMapPtr);
28417 handle.getSection(objInfoPtr, CreateHashMapReq::INFO);
28419 status = SimpleProperties::unpack(it, &hm,
28421 DictHashMapInfo::MappingSize,
28424 if (ERROR_INSERTED(6204))
28427 CLEAR_ERROR_INSERT_VALUE;
28428 setError(error, 1, __LINE__);
28432 if (status != SimpleProperties::Eof)
28435 setError(error, CreateTableRef::InvalidFormat, __LINE__);
28442 setError(error, CreateTableRef::InvalidFormat, __LINE__);
28452 if (impl_req->requestType & CreateHashMapReq::CreateDefault)
28455 impl_req->buckets = NDB_DEFAULT_HASHMAP_BUCKTETS;
28456 impl_req->fragments = 0;
28459 Uint32 buckets = impl_req->buckets;
28460 Uint32 fragments = impl_req->fragments;
28461 if (fragments == 0)
28465 fragments = get_default_fragments(signal);
28469 "DEFAULT-HASHMAP-%u-%u",
28473 if (buckets == 0 || buckets > Hash2FragmentMap::MAX_MAP)
28476 setError(error, CreateTableRef::InvalidFormat, __LINE__);
28480 hm.HashMapBuckets = buckets;
28481 for (Uint32 i = 0; i<buckets; i++)
28483 hm.HashMapValues[
i] = (i % fragments);
28490 hm.HashMapBuckets *=
sizeof(Uint16);
28493 s = SimpleProperties::pack(w,
28496 DictHashMapInfo::MappingSize,
true);
28497 ndbrequire(s == SimpleProperties::Eof);
28498 w.getPtr(objInfoPtr);
28501 handle.m_ptr[CreateHashMapReq::INFO] = objInfoPtr;
28504 Uint32 len = Uint32(strlen(hm.HashMapName) + 1);
28505 Uint32 hash = Rope::hash(hm.HashMapName, len);
28507 if (ERROR_INSERTED(6205))
28510 CLEAR_ERROR_INSERT_VALUE;
28511 setError(error, 1, __LINE__);
28515 DictObject * objptr = get_object(hm.HashMapName, len, hash);
28520 if (! (impl_req->requestType & CreateHashMapReq::CreateIfNotExists))
28523 setError(error, CreateTableRef::TableAlreadyExist, __LINE__);
28531 if (objptr->m_type != DictTabInfo::HashMap)
28534 setError(error, CreateTableRef::TableAlreadyExist, __LINE__);
28538 if (check_write_obj(objptr->m_id,
28539 trans_ptr.p->m_transId,
28540 SchemaFile::SF_CREATE, error))
28547 ndbrequire(c_hash_map_hash.
find(hm_ptr, objptr->m_id));
28549 impl_req->objectId = objptr->m_id;
28550 impl_req->objectVersion = hm_ptr.p->m_object_version;
28559 impl_req->requestType &= ~Uint32(CreateHashMapReq::CreateIfNotExists);
28562 if (ERROR_INSERTED(6206))
28565 CLEAR_ERROR_INSERT_VALUE;
28566 setError(error, 1, __LINE__);
28572 Rope tmp(c_rope_pool, name);
28573 if(!tmp.assign(hm.HashMapName, len, hash))
28576 setError(error, CreateTableRef::OutOfStringBuffer, __LINE__);
28581 Uint32 objId = RNIL;
28582 Uint32 objVersion = RNIL;
28583 Uint32 errCode = 0;
28584 Uint32 errLine = 0;
28585 DictObjectPtr obj_ptr; obj_ptr.setNull();
28586 HashMapPtr hm_ptr; hm_ptr.setNull();
28593 if (ERROR_INSERTED(6207))
28596 CLEAR_ERROR_INSERT_VALUE;
28597 setError(error, 1, __LINE__);
28601 objId = impl_req->objectId = getFreeObjId(0);
28605 errCode = CreateTableRef::NoMoreTableRecords;
28606 errLine = __LINE__;
28610 Uint32 version = getTableEntry(impl_req->objectId)->m_tableVersion;
28611 impl_req->objectVersion = create_obj_inc_schema_version(version);
28613 else if (op_ptr.p->m_restart)
28615 impl_req->objectId = c_restartRecord.activeTable;
28616 impl_req->objectVersion=c_restartRecord.m_entry.m_tableVersion;
28619 objId = impl_req->objectId;
28620 objVersion = impl_req->objectVersion;
28622 if (ERROR_INSERTED(6208))
28625 CLEAR_ERROR_INSERT_VALUE;
28626 setError(error, 1, __LINE__);
28630 if(!c_obj_pool.
seize(obj_ptr))
28633 errCode = CreateTableRef::NoMoreTableRecords;
28634 errLine = __LINE__;
28639 obj_ptr.p->m_id = objId;
28640 obj_ptr.p->m_type = DictTabInfo::HashMap;
28641 obj_ptr.p->m_ref_count = 0;
28642 obj_ptr.p->m_name =
name;
28643 c_obj_hash.
add(obj_ptr);
28645 if (ERROR_INSERTED(6209))
28648 CLEAR_ERROR_INSERT_VALUE;
28649 setError(error, 1, __LINE__);
28653 if (!g_hash_map.
seize(map_ptr))
28656 errCode = CreateTableRef::NoMoreTableRecords;
28657 errLine = __LINE__;
28661 if (ERROR_INSERTED(6210))
28664 CLEAR_ERROR_INSERT_VALUE;
28665 setError(error, 1, __LINE__);
28669 if(!c_hash_map_pool.
seize(hm_ptr))
28672 errCode = CreateTableRef::NoMoreTableRecords;
28673 errLine = __LINE__;
28677 new (hm_ptr.p) HashMapRecord();
28679 hm_ptr.p->m_object_id = objId;
28680 hm_ptr.p->m_object_version = objVersion;
28681 hm_ptr.p->m_name =
name;
28682 hm_ptr.p->m_obj_ptr_i = obj_ptr.i;
28683 hm_ptr.p->m_map_ptr_i = map_ptr.i;
28684 c_hash_map_hash.
add(hm_ptr);
28690 hm.HashMapBuckets /=
sizeof(Uint16);
28692 map_ptr.p->m_cnt = hm.HashMapBuckets;
28693 map_ptr.p->m_object_id = objId;
28696 for (Uint32 i = 0; i<hm.HashMapBuckets; i++)
28698 ndbrequire(hm.HashMapValues[i] < 256);
28699 map_ptr.p->m_map[
i] = (Uint8)hm.HashMapValues[i];
28700 if (hm.HashMapValues[i] > tmp)
28701 tmp = hm.HashMapValues[
i];
28703 map_ptr.p->m_fragments = tmp + 1;
28706 if (ERROR_INSERTED(6211))
28709 CLEAR_ERROR_INSERT_VALUE;
28710 setError(error, 1, __LINE__);
28716 te.m_tableState = SchemaFile::SF_CREATE;
28717 te.m_tableVersion = objVersion;
28718 te.m_tableType = obj_ptr.p->m_type;
28719 te.m_info_words = objInfoPtr.sz;
28721 te.m_transId = trans_ptr.p->m_transId;
28723 Uint32 err = trans_log_schema_op(op_ptr, objId, &te);
28724 ndbrequire(err == 0);
28727 saveOpSection(op_ptr, objInfoPtr, 0);
28728 handle.m_ptr[CreateHashMapReq::INFO] = objInfoPtr;
28731 #if defined VM_TRACE || defined ERROR_INSERT
28732 ndbout_c(
"Dbdict: create name=%s,id=%u,obj_ptr_i=%d",
28733 hm.HashMapName, objId, hm_ptr.p->m_obj_ptr_i);
28739 ndbrequire(hasError(error));
28741 if (!hm_ptr.isNull())
28744 c_hash_map_hash.
release(hm_ptr);
28747 if (!map_ptr.isNull())
28753 if (!obj_ptr.isNull())
28756 release_object(obj_ptr.i);
28761 Rope tmp(c_rope_pool, name);
28767 Dbdict::createHashMap_abortParse(
Signal* signal, SchemaOpPtr op_ptr)
28769 D(
"createHashMap_abortParse" << *op_ptr.p);
28771 CreateHashMapRecPtr createHashMapPtr;
28772 getOpRec(op_ptr, createHashMapPtr);
28775 if (impl_req->requestType & CreateHashMapReq::CreateIfNotExists)
28778 ndbrequire(op_ptr.p->m_orig_entry_id == RNIL);
28781 if (op_ptr.p->m_orig_entry_id != RNIL)
28786 ndbrequire(c_hash_map_hash.
find(hm_ptr, impl_req->objectId));
28788 release_object(hm_ptr.p->m_obj_ptr_i);
28789 g_hash_map.
release(hm_ptr.p->m_map_ptr_i);
28790 c_hash_map_hash.
release(hm_ptr);
28795 sendTransConf(signal, op_ptr);
28799 Dbdict::createHashMap_subOps(
Signal* signal, SchemaOpPtr op_ptr)
28805 Dbdict::createHashMap_reply(
Signal* signal, SchemaOpPtr op_ptr, ErrorInfo error)
28808 D(
"createHashMap_reply");
28810 SchemaTransPtr& trans_ptr = op_ptr.p->m_trans_ptr;
28811 CreateHashMapRecPtr createHashMapPtr;
28812 getOpRec(op_ptr, createHashMapPtr);
28815 if (!hasError(error)) {
28817 conf->senderRef = reference();
28818 conf->senderData = op_ptr.p->m_clientData;
28819 conf->transId = trans_ptr.p->m_transId;
28820 conf->objectId = impl_req->objectId;
28821 conf->objectVersion = impl_req->objectVersion;
28823 D(V(conf->objectId) << V(conf->objectVersion));
28825 Uint32 clientRef = op_ptr.p->m_clientRef;
28826 sendSignal(clientRef, GSN_CREATE_HASH_MAP_CONF, signal,
28827 CreateHashMapConf::SignalLength, JBB);
28831 ref->senderRef = reference();
28832 ref->senderData = op_ptr.p->m_clientData;
28833 ref->transId = trans_ptr.p->m_transId;
28834 getError(error, ref);
28836 Uint32 clientRef = op_ptr.p->m_clientRef;
28837 sendSignal(clientRef, GSN_CREATE_HASH_MAP_REF, signal,
28838 CreateHashMapRef::SignalLength, JBB);
28845 Dbdict::createHashMap_prepare(
Signal* signal, SchemaOpPtr op_ptr)
28848 D(
"createHashMap_prepare");
28850 CreateHashMapRecPtr createHashMapPtr;
28851 getOpRec(op_ptr, createHashMapPtr);
28854 if (impl_req->requestType & CreateHashMapReq::CreateIfNotExists)
28857 sendTransConf(signal, op_ptr);
28862 cb.m_callbackData = op_ptr.p->op_key;
28863 cb.m_callbackFunction = safe_cast(&Dbdict::createHashMap_writeObjConf);
28865 const OpSection& tabInfoSec = getOpSection(op_ptr, 0);
28866 writeTableFile(signal, impl_req->objectId, tabInfoSec, &cb);
28870 Dbdict::createHashMap_writeObjConf(
Signal* signal, Uint32 op_key, Uint32 ret)
28872 SchemaOpPtr op_ptr;
28873 CreateHashMapRecPtr createHashMapPtr;
28874 findSchemaOp(op_ptr, createHashMapPtr, op_key);
28876 ndbrequire(!op_ptr.isNull());
28878 sendTransConf(signal, op_ptr);
28884 Dbdict::createHashMap_commit(
Signal* signal, SchemaOpPtr op_ptr)
28887 D(
"createHashMap_commit");
28889 CreateHashMapRecPtr createHashMapPtr;
28890 getOpRec(op_ptr, createHashMapPtr);
28892 sendTransConf(signal, op_ptr);
28898 Dbdict::createHashMap_complete(
Signal* signal, SchemaOpPtr op_ptr)
28901 sendTransConf(signal, op_ptr);
28907 Dbdict::createHashMap_abortPrepare(
Signal* signal, SchemaOpPtr op_ptr)
28909 D(
"createHashMap_abortPrepare" << *op_ptr.p);
28911 sendTransConf(signal, op_ptr);
28921 g_hash_map.
getPtr(map_ptr, hm_ptr.p->m_map_ptr_i);
28923 ConstRope r(c_rope_pool, hm_ptr.p->m_name);
28924 r.copy(hm.HashMapName);
28925 hm.HashMapBuckets = map_ptr.p->m_cnt;
28926 hm.HashMapObjectId = hm_ptr.p->m_object_id;
28927 hm.HashMapVersion = hm_ptr.p->m_object_version;
28929 for (Uint32 i = 0; i<hm.HashMapBuckets; i++)
28931 hm.HashMapValues[
i] = map_ptr.p->m_map[
i];
28938 hm.HashMapBuckets *=
sizeof(Uint16);
28940 s = SimpleProperties::pack(w,
28943 DictHashMapInfo::MappingSize,
true);
28945 ndbrequire(s == SimpleProperties::Eof);
28956 operator<<(NdbOut& out,
const Dbdict::ErrorInfo& a)
28963 Dbdict::ErrorInfo::print(NdbOut& out)
const
28966 out <<
" code: " << errorCode;
28967 out <<
" line: " << errorLine;
28968 out <<
" node: " << errorNodeId;
28969 out <<
" count: " << errorCount;
28970 out <<
" status: " << errorStatus;
28971 out <<
" key: " << errorKey;
28972 out <<
" name: '" << errorObjectName <<
"'";
28988 Dbdict::DictObject::print(NdbOut& out)
const
28991 out <<
" (DictObject";
28992 out << dec << V(m_id);
28993 out << dec << V(m_type);
28994 out <<
" name:" << dict->copyRope<PATH_MAX>(m_name);
28995 out << dec << V(m_ref_count);
28996 out << dec << V(m_trans_key);
28997 out << dec << V(m_op_ref_count);
29005 operator<<(NdbOut& out,
const Dbdict::SchemaOp& a)
29012 Dbdict::SchemaOp::print(NdbOut& out)
const
29015 const Dbdict::OpInfo& info = m_oprec_ptr.p->m_opInfo;
29016 out <<
" (SchemaOp";
29017 out <<
" " << info.m_opType;
29018 out << dec << V(op_key);
29019 if (m_error.errorCode != 0)
29021 if (m_sections != 0)
29022 out << dec << V(m_sections);
29023 if (m_base_op_ptr_i == RNIL)
29027 out <<
"-> " << m_base_op_ptr_i;
29038 operator<<(NdbOut& out,
const Dbdict::SchemaTrans& a)
29045 Dbdict::SchemaTrans::print(NdbOut& out)
const
29047 out <<
" (SchemaTrans";
29048 out << dec << V(m_state);
29049 out << dec << V(trans_key);
29050 out << dec << V(m_isMaster);
29051 out << hex << V(m_clientRef);
29052 out << hex << V(m_transId);
29053 out << dec << V(m_clientState);
29054 out << hex << V(m_clientFlags);
29061 operator<<(NdbOut& out,
const Dbdict::TxHandle& a)
29068 Dbdict::TxHandle::print(NdbOut& out)
const
29070 out <<
" (TxHandle";
29071 out << dec << V(tx_key);
29072 out << hex << V(m_transId);
29073 out << dec << V(m_transKey);
29074 out << dec << V(m_clientState);
29075 out << hex << V(m_clientFlags);
29076 out << hex << V(m_takeOverRef);
29077 out << hex << V(m_takeOverTransId);
29084 #define SZ PATH_MAX
29087 Dbdict::check_consistency()
29089 D(
"check_consistency");
29093 TableRecordPtr tablePtr;
29094 for (tablePtr.i = 0;
29095 tablePtr.i < c_tableRecordPool.getSize();
29097 if (check_read_obj(tablePtr.i,
29099 c_tableRecordPool.
getPtr(tablePtr);
29101 switch (tablePtr.p->tabState) {
29102 case TableRecord::NOT_DEFINED:
29107 check_consistency_entry(tablePtr);
29112 TriggerRecordPtr triggerPtr;
29113 for (triggerPtr.i = 0;
29114 triggerPtr.i < c_triggerRecordPool.getSize();
29116 c_triggerRecordPool.
getPtr(triggerPtr);
29117 switch (triggerPtr.p->triggerState) {
29118 case TriggerRecord::TS_NOT_DEFINED:
29123 check_consistency_trigger(triggerPtr);
29128 Dbdict::check_consistency_entry(TableRecordPtr tablePtr)
29130 switch (tablePtr.p->tableType) {
29131 case DictTabInfo::SystemTable:
29133 check_consistency_table(tablePtr);
29135 case DictTabInfo::UserTable:
29137 check_consistency_table(tablePtr);
29139 case DictTabInfo::UniqueHashIndex:
29141 check_consistency_index(tablePtr);
29143 case DictTabInfo::OrderedIndex:
29145 check_consistency_index(tablePtr);
29160 Dbdict::check_consistency_table(TableRecordPtr tablePtr)
29162 D(
"table " << copyRope<SZ>(tablePtr.p->tableName));
29163 ndbrequire(tablePtr.p->tableId == tablePtr.i);
29165 switch (tablePtr.p->tableType) {
29166 case DictTabInfo::SystemTable:
29169 case DictTabInfo::UserTable:
29177 DictObjectPtr obj_ptr;
29178 obj_ptr.i = tablePtr.p->m_obj_ptr_i;
29179 ndbrequire(obj_ptr.i != RNIL);
29180 c_obj_pool.
getPtr(obj_ptr);
29181 check_consistency_object(obj_ptr);
29183 ndbrequire(obj_ptr.p->m_id == tablePtr.p->tableId);
29184 ndbrequire(!strcmp(
29185 copyRope<SZ>(obj_ptr.p->m_name),
29186 copyRope<SZ>(tablePtr.p->tableName)));
29190 Dbdict::check_consistency_index(TableRecordPtr indexPtr)
29192 D(
"index " << copyRope<SZ>(indexPtr.p->tableName));
29193 ndbrequire(indexPtr.p->tableId == indexPtr.i);
29195 switch (indexPtr.p->indexState) {
29196 case TableRecord::IS_ONLINE:
29204 TableRecordPtr tablePtr;
29205 tablePtr.i = indexPtr.p->primaryTableId;
29206 ndbrequire(tablePtr.i != RNIL);
29207 c_tableRecordPool.
getPtr(tablePtr);
29208 check_consistency_table(tablePtr);
29210 bool is_unique_index =
false;
29211 switch (indexPtr.p->tableType) {
29212 case DictTabInfo::UniqueHashIndex:
29214 is_unique_index =
true;
29216 case DictTabInfo::OrderedIndex:
29225 triggerPtr.i = indexPtr.p->triggerId;
29226 ndbrequire(triggerPtr.i != RNIL);
29227 c_triggerRecordPool.
getPtr(triggerPtr);
29229 ndbrequire(triggerPtr.p->
tableId == tablePtr.p->tableId);
29230 ndbrequire(triggerPtr.p->
indexId == indexPtr.p->tableId);
29231 ndbrequire(triggerPtr.p->
triggerId == triggerPtr.i);
29233 check_consistency_trigger(triggerPtr);
29236 TriggerInfo::unpackTriggerInfo(triggerPtr.p->
triggerInfo, ti);
29237 ndbrequire(ti.triggerEvent == TriggerEvent::TE_CUSTOM);
29239 DictObjectPtr obj_ptr;
29240 obj_ptr.i = triggerPtr.p->m_obj_ptr_i;
29241 ndbrequire(obj_ptr.i != RNIL);
29242 c_obj_pool.
getPtr(obj_ptr);
29243 check_consistency_object(obj_ptr);
29245 ndbrequire(obj_ptr.p->m_id == triggerPtr.p->
triggerId);
29246 ndbrequire(!strcmp(copyRope<SZ>(obj_ptr.p->m_name),
29251 Dbdict::check_consistency_trigger(TriggerRecordPtr triggerPtr)
29253 if (! (triggerPtr.p->triggerState == TriggerRecord::TS_FAKE_UPGRADE))
29255 ndbrequire(triggerPtr.p->triggerState == TriggerRecord::TS_ONLINE);
29257 ndbrequire(triggerPtr.p->triggerId == triggerPtr.i);
29259 TableRecordPtr tablePtr;
29260 tablePtr.i = triggerPtr.p->tableId;
29261 ndbrequire(tablePtr.i != RNIL);
29262 c_tableRecordPool.
getPtr(tablePtr);
29263 check_consistency_table(tablePtr);
29265 if (triggerPtr.p->indexId != RNIL)
29268 TableRecordPtr indexPtr;
29269 indexPtr.i = triggerPtr.p->indexId;
29270 c_tableRecordPool.
getPtr(indexPtr);
29271 ndbrequire(check_read_obj(indexPtr.i) == 0);
29272 ndbrequire(indexPtr.p->indexState == TableRecord::IS_ONLINE);
29274 TriggerInfo::unpackTriggerInfo(triggerPtr.p->triggerInfo, ti);
29275 switch (ti.triggerEvent) {
29276 case TriggerEvent::TE_CUSTOM:
29277 if (! (triggerPtr.p->triggerState == TriggerRecord::TS_FAKE_UPGRADE))
29279 ndbrequire(triggerPtr.i == indexPtr.p->triggerId);
29288 TriggerInfo::unpackTriggerInfo(triggerPtr.p->triggerInfo, ti);
29289 ndbrequire(ti.triggerType == TriggerType::REORG_TRIGGER);
29294 Dbdict::check_consistency_object(DictObjectPtr obj_ptr)
29296 ndbrequire(obj_ptr.p->m_trans_key == 0);
29297 ndbrequire(obj_ptr.p->m_op_ref_count == 0);
29303 Dbdict::send_event(
Signal* signal,
29304 SchemaTransPtr& trans_ptr,
29310 if (!trans_ptr.p->m_isMaster)
29316 case NDB_LE_CreateSchemaObject:
29317 case NDB_LE_AlterSchemaObject:
29318 case NDB_LE_DropSchemaObject:
29324 signal->theData[0] = ev;
29325 signal->theData[1] =
id;
29326 signal->theData[2] = version;
29327 signal->theData[3] =
type;
29328 signal->theData[4] = refToNode(trans_ptr.p->m_clientRef);
29329 sendSignal(CMVMI_REF, GSN_EVENT_REP, signal, 5, JBB);