20 #include <SimpleProperties.hpp>
21 #include <Bitmask.hpp>
22 #include <AttributeList.hpp>
23 #include <AttributeHeader.hpp>
27 #include <util/version.h>
29 #include <signaldata/IndexStatSignal.hpp>
31 #include <signaldata/GetTabInfo.hpp>
32 #include <signaldata/DictTabInfo.hpp>
33 #include <signaldata/CreateTable.hpp>
34 #include <signaldata/CreateIndx.hpp>
35 #include <signaldata/CreateEvnt.hpp>
36 #include <signaldata/SumaImpl.hpp>
37 #include <signaldata/DropTable.hpp>
38 #include <signaldata/AlterTable.hpp>
39 #include <signaldata/DropIndx.hpp>
40 #include <signaldata/ListTables.hpp>
41 #include <signaldata/DropFilegroup.hpp>
42 #include <signaldata/CreateFilegroup.hpp>
43 #include <signaldata/WaitGCP.hpp>
44 #include <signaldata/SchemaTrans.hpp>
45 #include <signaldata/CreateHashMap.hpp>
46 #include <signaldata/ApiRegSignalData.hpp>
47 #include <signaldata/NodeFailRep.hpp>
50 #define INCOMPATIBLE_VERSION -2
52 #define DICT_WAITFOR_TIMEOUT (7*24*60*60*1000)
54 #define ERR_RETURN(a,b) \
56 DBUG_PRINT("exit", ("error %d return %d", (a).code, b));\
60 int ndb_dictionary_is_mysqld = 0;
63 is_ndb_blob_table(
const char*
name, Uint32* ptab_id, Uint32* pcol_no)
65 return DictTabInfo::isBlobTableName(name, ptab_id, pcol_no);
71 return is_ndb_blob_table(t->m_internalName.
c_str());
75 ignore_broken_blob_tables()
81 const char* v = NdbEnv_GetEnv(
"NDB_FORCE_IGNORE_BROKEN_BLOB",
84 return (v != NULL && *v != 0 && *v !=
'0' && *v !=
'n' && *v !=
'N');
95 DBUG_ENTER(
"NdbColumnImpl::NdbColumnImpl");
96 DBUG_PRINT(
"info", (
"this: %p",
this));
104 DBUG_ENTER(
"NdbColumnImpl::NdbColumnImpl");
105 DBUG_PRINT(
"info", (
"this: %p",
this));
113 DBUG_ENTER(
"NdbColumnImpl::operator=");
114 DBUG_PRINT(
"info", (
"this: %p &col: %p",
this, &col));
115 m_attrId = col.m_attrId;
118 m_precision = col.m_precision;
120 m_scale = col.m_scale;
121 m_length = col.m_length;
123 m_distributionKey = col.m_distributionKey;
124 m_nullable = col.m_nullable;
125 m_autoIncrement = col.m_autoIncrement;
126 m_autoIncrementInitialValue = col.m_autoIncrementInitialValue;
127 m_defaultValue.assign(col.m_defaultValue);
128 m_attrSize = col.m_attrSize;
129 m_arraySize = col.m_arraySize;
130 m_arrayType = col.m_arrayType;
131 m_storageType = col.m_storageType;
132 m_blobVersion = col.m_blobVersion;
133 m_dynamic = col.m_dynamic;
134 m_indexSourced = col.m_indexSourced;
135 m_keyInfoPos = col.m_keyInfoPos;
136 if (col.m_blobTable == NULL)
139 if (m_blobTable == NULL)
141 m_blobTable->assign(*col.m_blobTable);
143 m_column_no = col.m_column_no;
150 NdbColumnImpl::init(Type t)
174 m_arrayType = NDB_ARRAYTYPE_FIXED;
177 case Olddecimalunsigned:
179 case Decimalunsigned:
184 m_arrayType = NDB_ARRAYTYPE_FIXED;
191 m_arrayType = NDB_ARRAYTYPE_FIXED;
198 m_arrayType = NDB_ARRAYTYPE_SHORT_VAR;
205 m_arrayType = NDB_ARRAYTYPE_FIXED;
212 m_arrayType = NDB_ARRAYTYPE_SHORT_VAR;
220 m_arrayType = NDB_ARRAYTYPE_FIXED;
227 m_cs = m_type ==
Blob ? NULL : default_cs;
228 m_arrayType = NDB_ARRAYTYPE_MEDIUM_VAR;
229 m_blobVersion = NDB_BLOB_V2;
231 if (NdbEnv_GetEnv(
"NDB_DEFAULT_BLOB_V1", (
char *)0, 0)) {
233 m_arrayType = NDB_ARRAYTYPE_FIXED;
234 m_blobVersion = NDB_BLOB_V1;
245 m_arrayType = NDB_ARRAYTYPE_FIXED;
252 m_arrayType = NDB_ARRAYTYPE_FIXED;
259 m_arrayType = NDB_ARRAYTYPE_MEDIUM_VAR;
266 m_arrayType = NDB_ARRAYTYPE_MEDIUM_VAR;
275 m_distributionKey =
false;
280 m_autoIncrement =
false;
281 m_autoIncrementInitialValue = 1;
283 m_storageType = NDB_STORAGETYPE_MEMORY;
285 m_indexSourced=
false;
287 if(NdbEnv_GetEnv(
"NDB_DEFAULT_DISK", (
char *)0, 0))
288 m_storageType = NDB_STORAGETYPE_DISK;
292 NdbColumnImpl::~NdbColumnImpl()
294 DBUG_ENTER(
"NdbColumnImpl::~NdbColumnImpl");
295 DBUG_PRINT(
"info", (
"this: %p",
this));
296 if (m_blobTable != NULL)
305 DBUG_ENTER(
"NdbColumnImpl::equal");
306 DBUG_PRINT(
"info", (
"this: %p &col: %p",
this, &col));
311 if(strcmp(m_name.
c_str(), col.m_name.
c_str()) != 0){
314 if(m_type != col.m_type){
317 if(m_pk != col.m_pk){
320 if(m_nullable != col.m_nullable){
324 if (m_distributionKey != col.m_distributionKey) {
328 if (m_precision != col.m_precision ||
329 m_scale != col.m_scale ||
330 m_length != col.m_length ||
334 if (m_autoIncrement != col.m_autoIncrement){
337 if (m_defaultValue.length() != col.m_defaultValue.length())
340 if(memcmp(m_defaultValue.get_data(), col.m_defaultValue.get_data(), m_defaultValue.length()) != 0){
344 if (m_arrayType != col.m_arrayType || m_storageType != col.m_storageType){
347 if (m_blobVersion != col.m_blobVersion) {
350 if(m_dynamic != col.m_dynamic){
358 NdbColumnImpl::create_pseudo_columns()
360 NdbDictionary::Column::FRAGMENT=
361 NdbColumnImpl::create_pseudo(
"NDB$FRAGMENT");
362 NdbDictionary::Column::FRAGMENT_FIXED_MEMORY=
363 NdbColumnImpl::create_pseudo(
"NDB$FRAGMENT_FIXED_MEMORY");
364 NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY=
365 NdbColumnImpl::create_pseudo(
"NDB$FRAGMENT_VARSIZED_MEMORY");
366 NdbDictionary::Column::ROW_COUNT=
367 NdbColumnImpl::create_pseudo(
"NDB$ROW_COUNT");
368 NdbDictionary::Column::COMMIT_COUNT=
369 NdbColumnImpl::create_pseudo(
"NDB$COMMIT_COUNT");
370 NdbDictionary::Column::ROW_SIZE=
371 NdbColumnImpl::create_pseudo(
"NDB$ROW_SIZE");
372 NdbDictionary::Column::RANGE_NO=
373 NdbColumnImpl::create_pseudo(
"NDB$RANGE_NO");
374 NdbDictionary::Column::DISK_REF=
375 NdbColumnImpl::create_pseudo(
"NDB$DISK_REF");
376 NdbDictionary::Column::RECORDS_IN_RANGE=
377 NdbColumnImpl::create_pseudo(
"NDB$RECORDS_IN_RANGE");
378 NdbDictionary::Column::ROWID=
379 NdbColumnImpl::create_pseudo(
"NDB$ROWID");
380 NdbDictionary::Column::ROW_GCI=
381 NdbColumnImpl::create_pseudo(
"NDB$ROW_GCI");
382 NdbDictionary::Column::ROW_GCI64 =
383 NdbColumnImpl::create_pseudo(
"NDB$ROW_GCI64");
384 NdbDictionary::Column::ROW_AUTHOR =
385 NdbColumnImpl::create_pseudo(
"NDB$ROW_AUTHOR");
386 NdbDictionary::Column::ANY_VALUE=
387 NdbColumnImpl::create_pseudo(
"NDB$ANY_VALUE");
388 NdbDictionary::Column::COPY_ROWID=
389 NdbColumnImpl::create_pseudo(
"NDB$COPY_ROWID");
390 NdbDictionary::Column::OPTIMIZE=
391 NdbColumnImpl::create_pseudo(
"NDB$OPTIMIZE");
392 NdbDictionary::Column::FRAGMENT_EXTENT_SPACE =
393 NdbColumnImpl::create_pseudo(
"NDB$FRAGMENT_EXTENT_SPACE");
394 NdbDictionary::Column::FRAGMENT_FREE_EXTENT_SPACE =
395 NdbColumnImpl::create_pseudo(
"NDB$FRAGMENT_FREE_EXTENT_SPACE");
396 NdbDictionary::Column::LOCK_REF =
397 NdbColumnImpl::create_pseudo(
"NDB$LOCK_REF");
398 NdbDictionary::Column::OP_ID =
399 NdbColumnImpl::create_pseudo(
"NDB$OP_ID");
403 NdbColumnImpl::destory_pseudo_columns()
405 delete NdbDictionary::Column::FRAGMENT;
406 delete NdbDictionary::Column::FRAGMENT_FIXED_MEMORY;
407 delete NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY;
408 delete NdbDictionary::Column::ROW_COUNT;
409 delete NdbDictionary::Column::COMMIT_COUNT;
410 delete NdbDictionary::Column::ROW_SIZE;
411 delete NdbDictionary::Column::RANGE_NO;
412 delete NdbDictionary::Column::DISK_REF;
413 delete NdbDictionary::Column::RECORDS_IN_RANGE;
414 delete NdbDictionary::Column::ROWID;
415 delete NdbDictionary::Column::ROW_GCI;
416 delete NdbDictionary::Column::ROW_GCI64;
417 delete NdbDictionary::Column::ROW_AUTHOR;
418 delete NdbDictionary::Column::ANY_VALUE;
419 delete NdbDictionary::Column::OPTIMIZE;
420 NdbDictionary::Column::FRAGMENT= 0;
421 NdbDictionary::Column::FRAGMENT_FIXED_MEMORY= 0;
422 NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY= 0;
423 NdbDictionary::Column::ROW_COUNT= 0;
424 NdbDictionary::Column::COMMIT_COUNT= 0;
425 NdbDictionary::Column::ROW_SIZE= 0;
426 NdbDictionary::Column::RANGE_NO= 0;
427 NdbDictionary::Column::DISK_REF= 0;
428 NdbDictionary::Column::RECORDS_IN_RANGE= 0;
429 NdbDictionary::Column::ROWID= 0;
430 NdbDictionary::Column::ROW_GCI= 0;
431 NdbDictionary::Column::ROW_GCI64= 0;
432 NdbDictionary::Column::ROW_AUTHOR= 0;
433 NdbDictionary::Column::ANY_VALUE= 0;
434 NdbDictionary::Column::OPTIMIZE= 0;
436 delete NdbDictionary::Column::COPY_ROWID;
437 NdbDictionary::Column::COPY_ROWID = 0;
439 delete NdbDictionary::Column::FRAGMENT_EXTENT_SPACE;
440 NdbDictionary::Column::FRAGMENT_EXTENT_SPACE = 0;
442 delete NdbDictionary::Column::FRAGMENT_FREE_EXTENT_SPACE;
443 NdbDictionary::Column::FRAGMENT_FREE_EXTENT_SPACE = 0;
445 delete NdbDictionary::Column::LOCK_REF;
446 delete NdbDictionary::Column::OP_ID;
447 NdbDictionary::Column::LOCK_REF = 0;
448 NdbDictionary::Column::OP_ID = 0;
452 NdbColumnImpl::create_pseudo(
const char *
name){
455 if(!strcmp(name,
"NDB$FRAGMENT")){
457 col->m_impl.m_attrId = AttributeHeader::FRAGMENT;
458 col->m_impl.m_attrSize = 4;
459 col->m_impl.m_arraySize = 1;
460 }
else if(!strcmp(name,
"NDB$FRAGMENT_FIXED_MEMORY")){
462 col->m_impl.m_attrId = AttributeHeader::FRAGMENT_FIXED_MEMORY;
463 col->m_impl.m_attrSize = 8;
464 col->m_impl.m_arraySize = 1;
465 }
else if(!strcmp(name,
"NDB$FRAGMENT_VARSIZED_MEMORY")){
467 col->m_impl.m_attrId = AttributeHeader::FRAGMENT_VARSIZED_MEMORY;
468 col->m_impl.m_attrSize = 8;
469 col->m_impl.m_arraySize = 1;
470 }
else if(!strcmp(name,
"NDB$ROW_COUNT")){
472 col->m_impl.m_attrId = AttributeHeader::ROW_COUNT;
473 col->m_impl.m_attrSize = 8;
474 col->m_impl.m_arraySize = 1;
475 }
else if(!strcmp(name,
"NDB$COMMIT_COUNT")){
477 col->m_impl.m_attrId = AttributeHeader::COMMIT_COUNT;
478 col->m_impl.m_attrSize = 8;
479 col->m_impl.m_arraySize = 1;
480 }
else if(!strcmp(name,
"NDB$ROW_SIZE")){
482 col->m_impl.m_attrId = AttributeHeader::ROW_SIZE;
483 col->m_impl.m_attrSize = 4;
484 col->m_impl.m_arraySize = 1;
485 }
else if(!strcmp(name,
"NDB$RANGE_NO")){
487 col->m_impl.m_attrId = AttributeHeader::RANGE_NO;
488 col->m_impl.m_attrSize = 4;
489 col->m_impl.m_arraySize = 1;
490 }
else if(!strcmp(name,
"NDB$DISK_REF")){
492 col->m_impl.m_attrId = AttributeHeader::DISK_REF;
493 col->m_impl.m_attrSize = 8;
494 col->m_impl.m_arraySize = 1;
495 }
else if(!strcmp(name,
"NDB$RECORDS_IN_RANGE")){
497 col->m_impl.m_attrId = AttributeHeader::RECORDS_IN_RANGE;
498 col->m_impl.m_attrSize = 4;
499 col->m_impl.m_arraySize = 4;
500 }
else if(!strcmp(name,
"NDB$ROWID")){
502 col->m_impl.m_attrId = AttributeHeader::ROWID;
503 col->m_impl.m_attrSize = 4;
504 col->m_impl.m_arraySize = 2;
505 }
else if(!strcmp(name,
"NDB$ROW_GCI")){
507 col->m_impl.m_attrId = AttributeHeader::ROW_GCI;
508 col->m_impl.m_attrSize = 8;
509 col->m_impl.m_arraySize = 1;
510 col->m_impl.m_nullable =
true;
511 }
else if(!strcmp(name,
"NDB$ROW_GCI64")){
513 col->m_impl.m_attrId = AttributeHeader::ROW_GCI64;
514 col->m_impl.m_attrSize = 8;
515 col->m_impl.m_arraySize = 1;
516 col->m_impl.m_nullable =
true;
517 }
else if(!strcmp(name,
"NDB$ROW_AUTHOR")){
519 col->m_impl.m_attrId = AttributeHeader::ROW_AUTHOR;
520 col->m_impl.m_attrSize = 4;
521 col->m_impl.m_arraySize = 1;
522 col->m_impl.m_nullable =
true;
523 }
else if(!strcmp(name,
"NDB$ANY_VALUE")){
525 col->m_impl.m_attrId = AttributeHeader::ANY_VALUE;
526 col->m_impl.m_attrSize = 4;
527 col->m_impl.m_arraySize = 1;
528 }
else if(!strcmp(name,
"NDB$COPY_ROWID")){
530 col->m_impl.m_attrId = AttributeHeader::COPY_ROWID;
531 col->m_impl.m_attrSize = 4;
532 col->m_impl.m_arraySize = 2;
533 }
else if(!strcmp(name,
"NDB$OPTIMIZE")){
535 col->m_impl.m_attrId = AttributeHeader::OPTIMIZE;
536 col->m_impl.m_attrSize = 4;
537 col->m_impl.m_arraySize = 1;
538 }
else if(!strcmp(name,
"NDB$FRAGMENT_EXTENT_SPACE")){
540 col->m_impl.m_attrId = AttributeHeader::FRAGMENT_EXTENT_SPACE;
541 col->m_impl.m_attrSize = 4;
542 col->m_impl.m_arraySize = 2;
543 }
else if(!strcmp(name,
"NDB$FRAGMENT_FREE_EXTENT_SPACE")){
545 col->m_impl.m_attrId = AttributeHeader::FRAGMENT_FREE_EXTENT_SPACE;
546 col->m_impl.m_attrSize = 4;
547 col->m_impl.m_arraySize = 2;
548 }
else if (!strcmp(name,
"NDB$LOCK_REF")){
550 col->m_impl.m_attrId = AttributeHeader::LOCK_REF;
551 col->m_impl.m_attrSize = 4;
552 col->m_impl.m_arraySize = 3;
553 }
else if (!strcmp(name,
"NDB$OP_ID")){
555 col->m_impl.m_attrId = AttributeHeader::OP_ID;
556 col->m_impl.m_attrSize = 8;
557 col->m_impl.m_arraySize = 1;
562 col->m_impl.m_storageType = NDB_STORAGETYPE_MEMORY;
574 DBUG_ENTER(
"NdbTableImpl::NdbTableImpl");
575 DBUG_PRINT(
"info", (
"this: %p",
this));
584 DBUG_ENTER(
"NdbTableImpl::NdbTableImpl");
585 DBUG_PRINT(
"info", (
"this: %p",
this));
590 NdbTableImpl::~NdbTableImpl()
592 DBUG_ENTER(
"NdbTableImpl::~NdbTableImpl");
593 DBUG_PRINT(
"info", (
"this: %p",
this));
598 for (
unsigned i = 0;
i < m_columns.size();
i++)
607 free(const_cast<unsigned char *>(
m_pkMask));
615 NdbTableImpl::init(){
620 m_primaryTableId= RNIL;
621 m_internalName.
clear();
622 m_externalName.
clear();
627 m_fragmentType= NdbDictionary::Object::HashMapPartition;
629 m_hashpointerValue= 0;
632 m_default_no_part_flag = 1;
636 m_row_checksum =
true;
637 m_force_var_part =
false;
638 m_has_default_values =
false;
647 m_noOfDistributionKeys= 0;
650 m_noOfAutoIncColumns = 0;
656 m_tablespace_id = RNIL;
657 m_tablespace_version = ~0;
658 m_single_user_mode = 0;
659 m_hash_map_id = RNIL;
660 m_hash_map_version = ~0;
661 m_storageType = NDB_STORAGETYPE_DEFAULT;
662 m_extra_row_gci_bits = 0;
663 m_extra_row_author_bits = 0;
669 DBUG_ENTER(
"NdbTableImpl::equal");
670 if ((m_internalName.
c_str() == NULL) ||
671 (strcmp(m_internalName.
c_str(),
"") == 0) ||
672 (obj.m_internalName.
c_str() == NULL) ||
673 (strcmp(obj.m_internalName.
c_str(),
"") == 0))
685 if(strcmp(m_internalName.
c_str(), obj.m_internalName.
c_str()) != 0)
687 DBUG_PRINT(
"info",(
"m_internalName %s != %s",
688 m_internalName.
c_str(),obj.m_internalName.
c_str()));
692 if (m_frm.length() != obj.m_frm.length() ||
693 (memcmp(m_frm.get_data(), obj.m_frm.get_data(), m_frm.length())))
695 DBUG_PRINT(
"info",(
"m_frm not equal"));
698 if (!m_fd.
equal(obj.m_fd))
700 DBUG_PRINT(
"info",(
"m_fd not equal"));
703 if (!m_range.
equal(obj.m_range))
705 DBUG_PRINT(
"info",(
"m_range not equal"));
708 if(m_fragmentType != obj.m_fragmentType)
710 DBUG_PRINT(
"info",(
"m_fragmentType %d != %d",m_fragmentType,
711 obj.m_fragmentType));
714 if(m_columns.size() != obj.m_columns.size())
716 DBUG_PRINT(
"info",(
"m_columns.size %d != %d",m_columns.size(),
717 obj.m_columns.size()));
721 for(
unsigned i = 0;
i<obj.m_columns.size();
i++)
723 if(!m_columns[
i]->
equal(* obj.m_columns[
i]))
725 DBUG_PRINT(
"info",(
"m_columns [%d] != [%d]",
i,
i));
730 if(m_linear_flag != obj.m_linear_flag)
732 DBUG_PRINT(
"info",(
"m_linear_flag %d != %d",m_linear_flag,
737 if(m_max_rows != obj.m_max_rows)
739 DBUG_PRINT(
"info",(
"m_max_rows %d != %d",(int32)m_max_rows,
740 (int32)obj.m_max_rows));
744 if(m_default_no_part_flag != obj.m_default_no_part_flag)
746 DBUG_PRINT(
"info",(
"m_default_no_part_flag %d != %d",m_default_no_part_flag,
747 obj.m_default_no_part_flag));
751 if(m_logging != obj.m_logging)
753 DBUG_PRINT(
"info",(
"m_logging %d != %d",m_logging,obj.m_logging));
757 if(m_temporary != obj.m_temporary)
759 DBUG_PRINT(
"info",(
"m_temporary %d != %d",m_temporary,obj.m_temporary));
763 if(m_row_gci != obj.m_row_gci)
765 DBUG_PRINT(
"info",(
"m_row_gci %d != %d",m_row_gci,obj.m_row_gci));
769 if(m_row_checksum != obj.m_row_checksum)
771 DBUG_PRINT(
"info",(
"m_row_checksum %d != %d",m_row_checksum,
772 obj.m_row_checksum));
776 if(m_kvalue != obj.m_kvalue)
778 DBUG_PRINT(
"info",(
"m_kvalue %d != %d",m_kvalue,obj.m_kvalue));
782 if(m_minLoadFactor != obj.m_minLoadFactor)
784 DBUG_PRINT(
"info",(
"m_minLoadFactor %d != %d",m_minLoadFactor,
785 obj.m_minLoadFactor));
789 if(m_maxLoadFactor != obj.m_maxLoadFactor)
791 DBUG_PRINT(
"info",(
"m_maxLoadFactor %d != %d",m_maxLoadFactor,
792 obj.m_maxLoadFactor));
796 if(m_tablespace_id != obj.m_tablespace_id)
798 DBUG_PRINT(
"info",(
"m_tablespace_id %d != %d",m_tablespace_id,
799 obj.m_tablespace_id));
803 if(m_tablespace_version != obj.m_tablespace_version)
805 DBUG_PRINT(
"info",(
"m_tablespace_version %d != %d",m_tablespace_version,
806 obj.m_tablespace_version));
812 DBUG_PRINT(
"info",(
"m_id %d != %d",m_id,obj.m_id));
816 if(m_version != obj.m_version)
818 DBUG_PRINT(
"info",(
"m_version %d != %d",m_version,obj.m_version));
822 if(m_type != obj.m_type)
824 DBUG_PRINT(
"info",(
"m_type %d != %d",m_type,obj.m_type));
831 if(m_primaryTableId != obj.m_primaryTableId)
833 DBUG_PRINT(
"info",(
"m_primaryTableId %d != %d",m_primaryTableId,
834 obj.m_primaryTableId));
837 if (m_indexType != obj.m_indexType)
839 DBUG_PRINT(
"info",(
"m_indexType %d != %d",m_indexType,obj.m_indexType));
844 DBUG_PRINT(
"info",(
"m_primaryTable %s != %s",
850 if(m_single_user_mode != obj.m_single_user_mode)
852 DBUG_PRINT(
"info",(
"m_single_user_mode %d != %d",
853 (int32)m_single_user_mode,
854 (int32)obj.m_single_user_mode));
858 if (m_extra_row_gci_bits != obj.m_extra_row_gci_bits)
860 DBUG_PRINT(
"info",(
"m_extra_row_gci_bits %d != %d",
861 (int32)m_extra_row_gci_bits,
862 (int32)obj.m_extra_row_gci_bits));
866 if (m_extra_row_author_bits != obj.m_extra_row_author_bits)
868 DBUG_PRINT(
"info",(
"m_extra_row_author_bits %d != %d",
869 (int32)m_extra_row_author_bits,
870 (int32)obj.m_extra_row_author_bits));
880 DBUG_ENTER(
"NdbColumnImpl::assign");
881 DBUG_PRINT(
"info", (
"this: %p &org: %p",
this, &org));
882 m_primaryTableId = org.m_primaryTableId;
883 if (!m_internalName.
assign(org.m_internalName) ||
888 m_externalName.
assign(org.m_externalName);
889 m_frm.assign(org.m_frm.get_data(), org.m_frm.length());
890 m_fd.assign(org.m_fd);
891 m_range.assign(org.m_range);
893 m_fragmentType = org.m_fragmentType;
899 for(i = 0; i < m_columns.size(); i++)
904 for(i = 0; i < org.m_columns.size(); i++)
914 if (m_columns.push_back(col))
921 m_fragments = org.m_fragments;
923 m_linear_flag = org.m_linear_flag;
924 m_max_rows = org.m_max_rows;
925 m_default_no_part_flag = org.m_default_no_part_flag;
926 m_logging = org.m_logging;
927 m_temporary = org.m_temporary;
928 m_row_gci = org.m_row_gci;
929 m_row_checksum = org.m_row_checksum;
930 m_force_var_part = org.m_force_var_part;
931 m_has_default_values = org.m_has_default_values;
932 m_kvalue = org.m_kvalue;
933 m_minLoadFactor = org.m_minLoadFactor;
934 m_maxLoadFactor = org.m_maxLoadFactor;
935 m_keyLenInWords = org.m_keyLenInWords;
936 m_fragmentCount = org.m_fragmentCount;
938 m_single_user_mode = org.m_single_user_mode;
939 m_extra_row_gci_bits = org.m_extra_row_gci_bits;
940 m_extra_row_author_bits = org.m_extra_row_author_bits;
944 m_index = org.m_index;
947 m_indexType = org.m_indexType;
950 m_noOfDistributionKeys = org.m_noOfDistributionKeys;
951 m_noOfBlobs = org.m_noOfBlobs;
952 m_replicaCount = org.m_replicaCount;
954 m_noOfAutoIncColumns = org.m_noOfAutoIncColumns;
957 m_version = org.m_version;
958 m_status = org.m_status;
960 m_max_rows = org.m_max_rows;
961 m_min_rows = org.m_min_rows;
964 m_tablespace_id= org.m_tablespace_id;
965 m_tablespace_version = org.m_tablespace_version;
966 m_storageType = org.m_storageType;
973 return !m_externalName.
assign(name);
979 return m_externalName.
c_str();
983 NdbTableImpl::getDbName(
char buf[],
size_t len)
const
989 const char *ptr = m_internalName.
c_str();
992 while (ptr[pos] && ptr[pos] != table_name_separator)
1005 NdbTableImpl::getSchemaName(
char buf[],
size_t len)
const
1011 const char *ptr = m_internalName.
c_str();
1014 while (*ptr && *ptr != table_name_separator)
1018 if (*ptr == table_name_separator)
1022 while (ptr[pos] && ptr[pos] != table_name_separator)
1024 buf[pos] = ptr[pos];
1037 NdbTableImpl::setDbSchema(
const char * db,
const char * schema)
1039 m_internalName.
assfmt(
"%s%c%s%c%s",
1041 table_name_separator,
1043 table_name_separator,
1044 m_externalName.
c_str());
1049 NdbTableImpl::computeAggregates()
1052 m_keyLenInWords = 0;
1053 m_noOfDistributionKeys = 0;
1055 m_noOfDiskColumns = 0;
1057 for (i = 0; i < m_columns.size(); i++) {
1061 m_keyLenInWords += (col->m_attrSize * col->m_arraySize + 3) / 4;
1063 if (col->m_distributionKey)
1064 m_noOfDistributionKeys++;
1066 if (col->getBlobType())
1069 if (col->getStorageType() == NdbDictionary::Column::StorageTypeDisk)
1070 m_noOfDiskColumns++;
1072 col->m_keyInfoPos = ~0;
1074 if (col->m_autoIncrement)
1075 m_noOfAutoIncColumns++;
1079 m_noOfDistributionKeys = 0;
1082 if (m_noOfDistributionKeys == 0)
1088 col->m_distributionKey =
true;
1094 Uint32 keyInfoPos = 0;
1098 col->m_keyInfoPos = keyInfoPos++;
1109 computeAggregates();
1123 m_fragmentCount= count;
1128 return m_fragmentCount;
1133 return m_frm.assign(data, len);
1139 return m_frm.get_data();
1143 NdbTableImpl::getFrmLength()
const
1145 return m_frm.length();
1151 return m_fd.assign(data, cnt);
1157 return m_fd.getBase();
1161 NdbTableImpl::getFragmentDataLen()
const
1169 return m_range.assign(data, len);
1175 return m_range.getBase();
1179 NdbTableImpl::getRangeListDataLen()
const
1181 return m_range.size();
1186 Uint32* nodeIdArrayPtr,
1187 Uint32 arraySize)
const
1189 const Uint16 *shortNodeIds;
1190 Uint32 nodeCount =
get_nodes(fragmentId, &shortNodeIds);
1196 nodeIdArrayPtr[i] = (Uint32) shortNodeIds[
i];
1202 NdbTableImpl::updateMysqlName()
1205 if (m_internalName.
split(v,
"/") == 3)
1207 return !m_mysqlName.
assfmt(
"%s/%s",v[0].c_str(),v[2].c_str());
1209 return !m_mysqlName.
assign(
"");
1213 NdbTableImpl::buildColumnHash(){
1214 const Uint32
size = m_columns.size();
1216 for(i = 31; i >= 0; i--){
1217 if(((1 << i) & size) != 0){
1218 m_columnHashMask = (1 << (i + 1)) - 1;
1225 if (chains.fill(size, hashValues))
1229 for(i = 0; i< (int) size; i++){
1230 Uint32 hv = Hash(m_columns[i]->
getName()) & 0xFFFE;
1231 Uint32
bucket = hv & m_columnHashMask;
1232 bucket = (bucket < size ? bucket : bucket -
size);
1233 assert(bucket < size);
1234 if (hashValues.push_back(hv) ||
1235 chains[bucket].push_back(i))
1241 m_columnHash.clear();
1243 if (m_columnHash.fill((
unsigned)size-1, tmp))
1249 for(i = 0; i< (int) size; i++){
1250 Uint32 sz = chains[
i].size();
1252 Uint32 col = chains[
i][0];
1253 Uint32 hv = hashValues[col];
1254 Uint32 bucket = hv & m_columnHashMask;
1255 bucket = (bucket < size ? bucket : bucket -
size);
1256 m_columnHash[bucket] = (col << 16) | hv | 1;
1258 Uint32 col = chains[
i][0];
1259 Uint32 hv = hashValues[col];
1260 Uint32 bucket = hv & m_columnHashMask;
1261 bucket = (bucket < size ? bucket : bucket -
size);
1262 m_columnHash[bucket] = (sz << 16) | (((size - bucket) + pos) << 1);
1263 for(
size_t j = 0; j<sz; j++, pos++){
1264 Uint32 col = chains[
i][j];
1265 Uint32 hv = hashValues[col];
1266 if (m_columnHash.push_back((col << 16) | hv))
1274 if (m_columnHash.push_back(0))
1280 for(
size_t i = 0; i<m_columnHash.size(); i++){
1281 Uint32 tmp = m_columnHash[
i];
1283 if(i < size && (tmp & 1) == 1){
1285 }
else if(i >= size){
1288 ndbout_c(
"m_columnHash[%d] %s = %x",
1289 i, col > 0 ? m_columns[col]->
getName() :
"" , m_columnHash[i]);
1298 Uint32 pos = fragmentId * m_replicaCount;
1299 if (pos + m_replicaCount <= m_fragments.size())
1301 *nodes = m_fragments.getBase()+pos;
1302 return m_replicaCount;
1311 Uint32 colCnt = m_impl.m_columns.size();
1315 ret |= (m_impl.m_noOfDiskColumns) ? 2 : 0;
1316 ret |= (colCnt > m_impl.m_noOfDiskColumns) ? 4 : 0;
1321 const char * ptr =
reinterpret_cast<const char*
>(map);
1322 const char * end = ptr + len;
1326 Uint32 val = (Uint32)* ptr;
1328 for (Uint32 i = 0; i<8; i++)
1336 if (cols[no]->getStorageType() == NdbDictionary::Column::StorageTypeDisk)
1373 void NdbIndexImpl::init()
1382 NdbIndexImpl::~NdbIndexImpl(){
1383 for (
unsigned i = 0; i < m_columns.size(); i++)
1384 delete m_columns[i];
1389 return !m_externalName.
assign(name);
1395 return m_externalName.
c_str();
1401 return !m_tableName.
assign(table);
1407 return m_tableName.
c_str();
1411 NdbIndexImpl::getIndexTable()
const
1423 m_ndb(NULL), m_table(NULL),
1424 m_table_queue(NULL), m_table_queue_first(NULL), m_table_queue_end(NULL),
1425 m_trans(NULL), m_scan_op(NULL),
1430 NdbOptimizeTableHandleImpl::~NdbOptimizeTableHandleImpl()
1432 DBUG_ENTER(
"NdbOptimizeTableHandleImpl::~NdbOptimizeTableHandleImpl");
1437 int NdbOptimizeTableHandleImpl::start()
1439 int noRetries = 100;
1440 DBUG_ENTER(
"NdbOptimizeTableImpl::start");
1449 while (noRetries-- > 0)
1451 if (m_trans && (m_trans->
restart() != 0))
1494 m_state = NdbOptimizeTableHandleImpl::INITIALIZED;
1497 m_state = NdbOptimizeTableHandleImpl::FINISHED;
1501 DBUG_PRINT(
"info", (
"NdbOptimizeTableImpl::start aborted"));
1502 m_state = NdbOptimizeTableHandleImpl::ABORTED;
1508 DBUG_ENTER(
"NdbOptimizeTableHandleImpl::init");
1510 Uint32 sz = table.m_columns.size();
1511 bool found_varpart =
false;
1512 int blob_num = table.m_noOfBlobs;
1522 for (Uint32 i = 0; i < sz; i++) {
1524 if (col != 0 && col->m_storageType == NDB_STORAGETYPE_MEMORY &&
1525 (col->m_dynamic || col->m_arrayType != NDB_ARRAYTYPE_FIXED)) {
1526 found_varpart=
true;
1532 m_state = NdbOptimizeTableHandleImpl::FINISHED;
1540 m_table_queue_end =
new fifo_element_st(m_table, m_table_queue_end);
1541 m_table_queue = m_table_queue_first = m_table_queue_end;
1546 for (
int i = m_table->m_columns.size(); i > 0 && blob_num > 0;) {
1557 m_table_queue_end =
new fifo_element_st(blob_table, m_table_queue_end);
1563 DBUG_RETURN(start());
1568 int noRetries = 100;
1570 DBUG_ENTER(
"NdbOptimizeTableHandleImpl::next");
1572 if (m_state == NdbOptimizeTableHandleImpl::FINISHED)
1574 else if (m_state != NdbOptimizeTableHandleImpl::INITIALIZED)
1577 while (noRetries-- > 0)
1579 if ((done = check = m_scan_op->
nextResult(
true)) == 0)
1587 if (myUpdateOp == 0)
1596 Uint32 options = 0 | AttributeHeader::OPTIMIZE_MOVE_VARPART;
1597 myUpdateOp->setOptimize(options);
1603 }
while ((check = m_scan_op->
nextResult(
false)) == 0);
1614 DBUG_PRINT(
"info", (
"Done with table %s",
1615 m_table_queue->table->getName()));
1620 fifo_element_st *current = m_table_queue;
1621 m_table_queue = current->next;
1651 DBUG_PRINT(
"info", (
"Failed to restart transaction"));
1663 DBUG_PRINT(
"info", (
"NdbOptimizeTableHandleImpl::next aborted"));
1664 m_state = NdbOptimizeTableHandleImpl::ABORTED;
1670 DBUG_ENTER(
"NdbOptimizeTableHandleImpl::close");
1674 while(m_table_queue_first != NULL)
1676 fifo_element_st *
next = m_table_queue_first->next;
1677 delete m_table_queue_first;
1678 m_table_queue_first =
next;
1680 m_table_queue = m_table_queue_first = m_table_queue_end = NULL;
1686 m_state = NdbOptimizeTableHandleImpl::CLOSED;
1697 m_ndb(NULL), m_index(NULL),
1700 DBUG_ENTER(
"NdbOptimizeIndexHandleImpl::NdbOptimizeIndexHandleImpl");
1704 NdbOptimizeIndexHandleImpl::~NdbOptimizeIndexHandleImpl()
1706 DBUG_ENTER(
"NdbOptimizeIndexHandleImpl::~NdbOptimizeIndexHandleImpl");
1712 DBUG_ENTER(
"NdbOptimizeIndexHandleImpl::init");
1714 m_state = NdbOptimizeIndexHandleImpl::INITIALIZED;
1720 DBUG_RETURN(m_optimize_table_handle.m_impl.
init(ndb, *index.getIndexTable()));
1725 DBUG_ENTER(
"NdbOptimizeIndexHandleImpl::next");
1726 if (m_state != NdbOptimizeIndexHandleImpl::INITIALIZED)
1730 DBUG_RETURN(m_optimize_table_handle.m_impl.
next());
1735 DBUG_ENTER(
"NdbOptimizeIndexHandleImpl::close");
1736 m_state = NdbOptimizeIndexHandleImpl::CLOSED;
1739 DBUG_RETURN(m_optimize_table_handle.m_impl.
close());
1752 DBUG_ENTER(
"NdbEventImpl::NdbEventImpl");
1753 DBUG_PRINT(
"info", (
"this: %p",
this));
1762 DBUG_ENTER(
"NdbEventImpl::NdbEventImpl");
1763 DBUG_PRINT(
"info", (
"this: %p",
this));
1768 void NdbEventImpl::init()
1773 m_dur= NdbDictionary::Event::ED_UNDEFINED;
1774 m_mergeEvents =
false;
1776 m_rep= NdbDictionary::Event::ER_UPDATED;
1779 NdbEventImpl::~NdbEventImpl()
1781 DBUG_ENTER(
"NdbEventImpl::~NdbEventImpl");
1782 DBUG_PRINT(
"info", (
"this: %p",
this));
1783 for (
unsigned i = 0; i < m_columns.size(); i++)
1784 delete m_columns[i];
1792 return !m_name.
assign(name);
1797 return m_name.
c_str();
1803 setTable(&NdbTableImpl::getImpl(table));
1810 DBUG_ENTER(
"NdbEventImpl::setTable");
1811 DBUG_PRINT(
"info", (
"this: %p tableImpl: %p",
this, tableImpl));
1816 m_tableImpl->assign(*tableImpl);
1824 return m_tableImpl->m_facade;
1832 return !m_tableName.
assign(table);
1838 return m_tableName.
c_str();
1844 mi_type |= (unsigned)t;
1850 return (mi_type & (
unsigned)t) == (unsigned)t;
1879 return m_attrIds.size() + m_columns.size();
1885 if (m_columns.size())
1887 if (no < m_columns.size())
1889 return m_columns[no];
1892 else if (m_attrIds.size())
1894 if (no < m_attrIds.size())
1899 return tab->getColumn(m_attrIds[no]);
1913 NdbDictionaryImpl::NdbDictionaryImpl(
Ndb &ndb)
1916 m_receiver(m_tx, m_error, m_warn),
1920 m_local_table_data_size= 0;
1923 (
int)WarnUndobufferRoundUp == (
int)CreateFilegroupConf::WarnUndobufferRoundUp &&
1924 (
int)WarnUndofileRoundDown == (
int)CreateFileConf::WarnUndofileRoundDown &&
1925 (
int)WarnExtentRoundUp == (
int)CreateFilegroupConf::WarnExtentRoundUp &&
1926 (
int)WarnDatafileRoundDown == (
int)CreateFileConf::WarnDatafileRoundDown &&
1927 (
int)WarnDatafileRoundUp == (
int)CreateFileConf::WarnDatafileRoundUp
1932 NdbDictionaryImpl::NdbDictionaryImpl(
Ndb &ndb,
1936 m_receiver(m_tx, m_error, m_warn),
1940 m_local_table_data_size= 0;
1943 NdbDictionaryImpl::~NdbDictionaryImpl()
1949 m_globalHash->lock();
1950 m_globalHash->release(curr->theData->m_table_impl);
1951 Ndb_local_table_info::destroy(curr->theData);
1952 m_globalHash->unlock();
1954 curr = m_localHash.m_tableHash.getNext(curr);
1964 DBUG_ENTER(
"fetchGlobalTableImplRef");
1968 m_globalHash->lock();
1969 impl = m_globalHash->
get(obj.m_name.
c_str(), &error);
1970 m_globalHash->unlock();
1974 impl = m_receiver.getTable(obj.m_name,
1975 m_ndb.usingFullyQualifiedNames());
1977 m_error.
code = 4000;
1978 if (impl != 0 && (obj.init(
this, *impl)))
1983 m_globalHash->lock();
1984 m_globalHash->put(obj.m_name.
c_str(), impl);
1985 m_globalHash->unlock();
1996 int ret = getBlobTables(*impl);
2000 m_globalHash->lock();
2001 if ((old= m_globalHash->
get(impl->m_internalName.
c_str(), &error)))
2003 m_globalHash->alter_table_rep(old->m_internalName.
c_str(),
2008 m_globalHash->put(impl->m_internalName.
c_str(), impl);
2009 m_globalHash->unlock();
2011 Ndb_local_table_info::create(impl, m_local_table_data_size);
2013 m_localHash.put(impl->m_internalName.
c_str(), info);
2019 unsigned n= t.m_noOfBlobs;
2020 DBUG_ENTER(
"NdbDictionaryImpl::getBlobTables");
2023 for (
unsigned i = t.m_columns.size(); i > 0 && n > 0;) {
2030 char btname[NdbBlobImpl::BlobTableNameSize];
2032 BaseString btname_internal = m_ndb.internalize_table_name(btname);
2034 m_receiver.getTable(btname_internal, m_ndb.usingFullyQualifiedNames());
2037 if (ignore_broken_blob_tables())
2039 DBUG_PRINT(
"info", (
"Blob table %s not found, continuing", btname));
2048 assert(c.m_blobTable == NULL);
2052 const char* colName = c.m_blobVersion == 1 ?
"DATA" :
"NDB$DATA";
2055 assert(c.m_storageType == NDB_STORAGETYPE_MEMORY);
2056 c.m_storageType = bc->m_storageType;
2062 NdbDictionaryImpl::getBlobTable(
const NdbTableImpl& tab, uint col_no)
2064 if (col_no < tab.m_columns.size()) {
2071 m_error.
code = 4273;
2073 m_error.
code = 4249;
2075 m_error.
code = 4318;
2080 NdbDictionaryImpl::getBlobTable(uint tab_id, uint col_no)
2082 DBUG_ENTER(
"NdbDictionaryImpl::getBlobTable");
2083 DBUG_PRINT(
"enter", (
"tab_id: %u col_no %u", tab_id, col_no));
2086 m_ndb.usingFullyQualifiedNames());
2090 get_local_table_info(tab->m_internalName);
2094 NdbTableImpl* bt = getBlobTable(*info->m_table_impl, col_no);
2099 NdbDictionaryImpl::setTransporter(
class Ndb* ndb,
2102 m_globalHash = tf->m_globalDictCache;
2103 if(m_receiver.setTransporter(ndb)){
2116 m_ndb.internalize_index_name(table, index->
getName()));
2119 index_table= getTable(m_ndb.externalizeTableName(internalName.c_str()));
2125 index_table= getTable(m_ndb.externalizeTableName(internalName.c_str()));
2131 NdbDictInterface::setTransporter(
class Ndb* ndb)
2133 m_reference = ndb->getReference();
2134 m_impl = ndb->theImpl;
2140 NdbDictInterface::getTransporter()
const
2142 return m_impl->m_transporter_facade;
2145 NdbDictInterface::~NdbDictInterface()
2150 NdbDictInterface::execSignal(
void* dictImpl,
2156 const Uint32 gsn = signal->readSignalNumber();
2158 case GSN_GET_TABINFOREF:
2159 tmp->execGET_TABINFO_REF(signal, ptr);
2161 case GSN_GET_TABINFO_CONF:
2162 tmp->execGET_TABINFO_CONF(signal, ptr);
2164 case GSN_CREATE_TABLE_REF:
2165 tmp->execCREATE_TABLE_REF(signal, ptr);
2167 case GSN_CREATE_TABLE_CONF:
2168 tmp->execCREATE_TABLE_CONF(signal, ptr);
2170 case GSN_DROP_TABLE_REF:
2171 tmp->execDROP_TABLE_REF(signal, ptr);
2173 case GSN_DROP_TABLE_CONF:
2174 tmp->execDROP_TABLE_CONF(signal, ptr);
2176 case GSN_ALTER_TABLE_REF:
2177 tmp->execALTER_TABLE_REF(signal, ptr);
2179 case GSN_ALTER_TABLE_CONF:
2180 tmp->execALTER_TABLE_CONF(signal, ptr);
2182 case GSN_CREATE_INDX_REF:
2183 tmp->execCREATE_INDX_REF(signal, ptr);
2185 case GSN_CREATE_INDX_CONF:
2186 tmp->execCREATE_INDX_CONF(signal, ptr);
2188 case GSN_DROP_INDX_REF:
2189 tmp->execDROP_INDX_REF(signal, ptr);
2191 case GSN_DROP_INDX_CONF:
2192 tmp->execDROP_INDX_CONF(signal, ptr);
2194 case GSN_INDEX_STAT_CONF:
2195 tmp->execINDEX_STAT_CONF(signal, ptr);
2197 case GSN_INDEX_STAT_REF:
2198 tmp->execINDEX_STAT_REF(signal, ptr);
2200 case GSN_CREATE_EVNT_REF:
2201 tmp->execCREATE_EVNT_REF(signal, ptr);
2203 case GSN_CREATE_EVNT_CONF:
2204 tmp->execCREATE_EVNT_CONF(signal, ptr);
2206 case GSN_SUB_START_CONF:
2207 tmp->execSUB_START_CONF(signal, ptr);
2209 case GSN_SUB_START_REF:
2210 tmp->execSUB_START_REF(signal, ptr);
2212 case GSN_SUB_STOP_CONF:
2213 tmp->execSUB_STOP_CONF(signal, ptr);
2215 case GSN_SUB_STOP_REF:
2216 tmp->execSUB_STOP_REF(signal, ptr);
2218 case GSN_DROP_EVNT_REF:
2219 tmp->execDROP_EVNT_REF(signal, ptr);
2221 case GSN_DROP_EVNT_CONF:
2222 tmp->execDROP_EVNT_CONF(signal, ptr);
2224 case GSN_LIST_TABLES_CONF:
2225 tmp->execLIST_TABLES_CONF(signal, ptr);
2227 case GSN_CREATE_FILEGROUP_REF:
2228 tmp->execCREATE_FILEGROUP_REF(signal, ptr);
2230 case GSN_CREATE_FILEGROUP_CONF:
2231 tmp->execCREATE_FILEGROUP_CONF(signal, ptr);
2233 case GSN_CREATE_FILE_REF:
2234 tmp->execCREATE_FILE_REF(signal, ptr);
2236 case GSN_CREATE_FILE_CONF:
2237 tmp->execCREATE_FILE_CONF(signal, ptr);
2239 case GSN_DROP_FILEGROUP_REF:
2240 tmp->execDROP_FILEGROUP_REF(signal, ptr);
2242 case GSN_DROP_FILEGROUP_CONF:
2243 tmp->execDROP_FILEGROUP_CONF(signal, ptr);
2245 case GSN_DROP_FILE_REF:
2246 tmp->execDROP_FILE_REF(signal, ptr);
2248 case GSN_DROP_FILE_CONF:
2249 tmp->execDROP_FILE_CONF(signal, ptr);
2251 case GSN_SCHEMA_TRANS_BEGIN_CONF:
2252 tmp->execSCHEMA_TRANS_BEGIN_CONF(signal, ptr);
2254 case GSN_SCHEMA_TRANS_BEGIN_REF:
2255 tmp->execSCHEMA_TRANS_BEGIN_REF(signal, ptr);
2257 case GSN_SCHEMA_TRANS_END_CONF:
2258 tmp->execSCHEMA_TRANS_END_CONF(signal, ptr);
2260 case GSN_SCHEMA_TRANS_END_REF:
2261 tmp->execSCHEMA_TRANS_END_REF(signal, ptr);
2263 case GSN_SCHEMA_TRANS_END_REP:
2264 tmp->execSCHEMA_TRANS_END_REP(signal, ptr);
2266 case GSN_WAIT_GCP_CONF:
2267 tmp->execWAIT_GCP_CONF(signal, ptr);
2269 case GSN_WAIT_GCP_REF:
2270 tmp->execWAIT_GCP_REF(signal, ptr);
2272 case GSN_CREATE_HASH_MAP_REF:
2273 tmp->execCREATE_HASH_MAP_REF(signal, ptr);
2275 case GSN_CREATE_HASH_MAP_CONF:
2276 tmp->execCREATE_HASH_MAP_CONF(signal, ptr);
2278 case GSN_NODE_FAILREP:
2282 for (Uint32 i = NdbNodeBitmask::find_first(rep->theNodes);
2283 i != NdbNodeBitmask::NotFound;
2286 tmp->m_impl->theWaiter.nodeFail(i);
2296 NdbDictInterface::execNodeStatus(
void* dictImpl, Uint32 aNode, Uint32 ns_event)
2303 int node_specification,
2305 int timeout, Uint32 RETRIES,
2306 const int *errcodes,
int temporaryMask)
2308 DBUG_ENTER(
"NdbDictInterface::dictSignal");
2309 DBUG_PRINT(
"enter", (
"useMasterNodeId: %d", node_specification));
2314 for(Uint32 i = 0; i<RETRIES; i++)
2318 Uint32 t = sleep + 10 * (rand() % mod);
2320 ndbout_c(
"retry sleep %ums on error %u", t, m_error.
code);
2322 NdbSleep_MilliSleep(t);
2324 if (i == RETRIES / 2)
2328 if (i == 3*RETRIES/4)
2344 switch(node_specification){
2346 node = (m_impl->get_node_alive(m_masterNodeId) ? m_masterNodeId :
2347 (m_masterNodeId = getTransporter()->get_an_alive_node()));
2350 node = getTransporter()->get_an_alive_node();
2353 node = node_specification;
2355 DBUG_PRINT(
"info", (
"node %d", node));
2361 m_impl->sendFragmentedSignal(sig, node, ptr, secs):
2362 m_impl->sendSignal(sig, node));
2364 DBUG_PRINT(
"info", (
"dictSignal failed to send signal"));
2365 m_error.
code = 4007;
2369 m_impl->incClientStat(Ndb::WaitMetaRequestCount,1);
2371 int ret_val= poll_guard.wait_n_unlock(timeout, node, wst,
true);
2374 if(ret_val == 0 && m_error.
code == 0){
2384 m_error.
code = 4013;
2387 if(m_impl->theWaiter.get_state() == WST_WAIT_TIMEOUT)
2389 DBUG_PRINT(
"info", (
"dictSignal caught time-out"));
2390 m_error.
code = 4008;
2394 if ( temporaryMask == -1)
2396 const NdbError &error= getNdbError();
2402 else if ( (temporaryMask & m_error.
code) != 0 )
2406 DBUG_PRINT(
"info", (
"dictSignal caught error= %d", m_error.
code));
2408 if(m_error.
code && errcodes)
2411 for(j = 0; errcodes[j] ; j++){
2412 if(m_error.
code == errcodes[j]){
2433 NdbDictInterface::getTable(
int tableId,
bool fullyQualifiedNames)
2438 req->senderRef = m_reference;
2439 req->senderData = 0;
2441 GetTabInfoReq::RequestById | GetTabInfoReq::LongSignalConf;
2442 req->tableId = tableId;
2443 req->schemaTransId = m_tx.transId();
2444 tSignal.theReceiversBlockNumber = DBDICT;
2445 tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
2446 tSignal.theLength = GetTabInfoReq::SignalLength;
2448 return getTable(&tSignal, 0, 0, fullyQualifiedNames);
2460 NdbDictInterface::getTable(
const BaseString& name,
bool fullyQualifiedNames)
2465 const Uint32 namelen= name.
length() + 1;
2466 const Uint32 namelen_words= (namelen + 3) >> 2;
2468 req->senderRef= m_reference;
2471 GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
2472 req->tableNameLen= namelen;
2473 req->schemaTransId = m_tx.transId();
2474 tSignal.theReceiversBlockNumber= DBDICT;
2475 tSignal.theVerId_signalNumber= GSN_GET_TABINFOREQ;
2476 tSignal.theLength= GetTabInfoReq::SignalLength;
2480 if (m_buffer.grow(namelen_words*4+4) ||
2481 m_buffer.append(name.
c_str(), namelen))
2487 #ifndef IGNORE_VALGRIND_WARNINGS
2489 if (m_buffer.append(&pad, 4))
2497 ptr[0].p= (Uint32*)m_buffer.get_data();
2498 ptr[0].sz= namelen_words;
2500 return getTable(&tSignal, ptr, 1, fullyQualifiedNames);
2505 NdbDictInterface::getTable(
class NdbApiSignal * signal,
2507 Uint32 noOfSections,
bool fullyQualifiedNames)
2509 int errCodes[] = {GetTabInfoRef::Busy, 0 };
2510 int r =
dictSignal(signal, ptr, noOfSections,
2512 WAIT_GET_TAB_INFO_REQ,
2513 DICT_WAITFOR_TIMEOUT, 100, errCodes);
2520 (Uint32*)m_buffer.get_data(),
2521 m_buffer.length() / 4,
2522 fullyQualifiedNames);
2525 if (rt->buildColumnHash())
2527 m_error.
code = 4000;
2532 if (rt->m_fragmentType == NdbDictionary::Object::HashMapPartition)
2535 if (get_hashmap(tmp, rt->m_hash_map_id))
2540 for (Uint32 i = 0; i<tmp.m_map.size(); i++)
2542 assert(tmp.m_map[i] <= 255);
2543 rt->m_hash_map.push_back(tmp.m_map[i]);
2552 NdbDictInterface::execGET_TABINFO_CONF(
const NdbApiSignal * signal,
2556 const Uint32 i = GetTabInfoConf::DICT_TAB_INFO;
2557 if(signal->isFirstFragment()){
2558 m_fragmentId = signal->getFragmentId();
2559 if (m_buffer.grow(4 * conf->totalLen))
2565 if(m_fragmentId != signal->getFragmentId()){
2570 if (m_buffer.append(ptr[i].p, 4 * ptr[i].sz))
2575 if(!signal->isLastFragment()){
2579 m_impl->theWaiter.signal(NO_WAIT);
2583 NdbDictInterface::execGET_TABINFO_REF(
const NdbApiSignal * signal,
2589 if (likely(signal->getLength() == GetTabInfoRef::SignalLength))
2591 m_error.
code= ref->errorCode;
2596 assert (signal->getLength() == GetTabInfoRef::OriginalSignalLength);
2598 GetTabInfoRef::OriginalErrorOffset));
2600 m_impl->theWaiter.signal(NO_WAIT);
2607 Int32 kernelConstant;
2612 getApiConstant(Int32 kernelConstant,
const ApiKernelMapping map[], Uint32 def)
2615 while(map[i].kernelConstant != kernelConstant){
2616 if(map[i].kernelConstant == -1 &&
2617 map[i].apiConstant == -1){
2622 return map[
i].apiConstant;
2626 getKernelConstant(Int32 apiConstant,
const ApiKernelMapping map[], Uint32 def)
2629 while(map[i].apiConstant != apiConstant){
2630 if(map[i].kernelConstant == -1 &&
2631 map[i].apiConstant == -1){
2636 return map[
i].kernelConstant;
2641 fragmentTypeMapping[] = {
2646 { DictTabInfo::DistrKeyHash, NdbDictionary::Object::DistrKeyHash },
2647 { DictTabInfo::DistrKeyLin, NdbDictionary::Object::DistrKeyLin },
2648 { DictTabInfo::UserDefined, NdbDictionary::Object::UserDefined },
2649 { DictTabInfo::HashMapPartition, NdbDictionary::Object::HashMapPartition },
2655 objectTypeMapping[] = {
2668 { DictTabInfo::ReorgTrigger, NdbDictionary::Object::ReorgTrigger },
2674 objectStateMapping[] = {
2686 objectStoreMapping[] = {
2694 indexTypeMapping[] = {
2702 const Uint32 * data, Uint32 len,
2703 bool fullyQualifiedNames,
2709 DBUG_ENTER(
"NdbDictInterface::parseTableInfo");
2717 s = SimpleProperties::unpack(it, tableDesc,
2718 DictTabInfo::TableMapping,
2719 DictTabInfo::TableMappingSize,
2722 if(s != SimpleProperties::Break){
2723 NdbMem_Free((
void*)tableDesc);
2726 const char * internalName = tableDesc->TableName;
2727 const char * externalName = Ndb::externalizeTableName(internalName, fullyQualifiedNames);
2730 impl->m_id = tableDesc->TableId;
2731 impl->m_version = tableDesc->TableVersion;
2733 if (!impl->m_internalName.
assign(internalName) ||
2734 impl->updateMysqlName() ||
2735 !impl->m_externalName.
assign(externalName) ||
2736 impl->m_frm.assign(tableDesc->FrmData, tableDesc->FrmLen) ||
2737 impl->m_range.assign((Int32*)tableDesc->RangeListData,
2738 tableDesc->RangeListDataLen / 4))
2749 Uint32 cnt = tableDesc->FragmentDataLen / 2;
2750 for (Uint32 i = 0; i<cnt; i++)
2751 if (impl->m_fd.push_back((Uint32)tableDesc->FragmentData[i]))
2755 impl->m_fragmentCount = tableDesc->FragmentCount;
2768 getApiConstant(tableDesc->FragmentType,
2769 fragmentTypeMapping,
2772 if (impl->m_fragmentType == NdbDictionary::Object::HashMapPartition)
2774 impl->m_hash_map_id = tableDesc->HashMapObjectId;
2775 impl->m_hash_map_version = tableDesc->HashMapVersion;
2779 impl->m_hash_map_id = ~0;
2780 impl->m_hash_map_version = ~0;
2783 Uint64 max_rows = ((Uint64)tableDesc->MaxRowsHigh) << 32;
2784 max_rows += tableDesc->MaxRowsLow;
2785 impl->m_max_rows = max_rows;
2786 Uint64 min_rows = ((Uint64)tableDesc->MinRowsHigh) << 32;
2787 min_rows += tableDesc->MinRowsLow;
2788 impl->m_min_rows = min_rows;
2789 impl->m_default_no_part_flag = tableDesc->DefaultNoPartFlag;
2790 impl->m_linear_flag = tableDesc->LinearHashFlag;
2791 impl->m_logging = tableDesc->TableLoggedFlag;
2792 impl->m_temporary = tableDesc->TableTemporaryFlag;
2793 impl->m_row_gci = tableDesc->RowGCIFlag;
2794 impl->m_row_checksum = tableDesc->RowChecksumFlag;
2795 impl->m_force_var_part = tableDesc->ForceVarPartFlag;
2796 impl->m_kvalue = tableDesc->TableKValue;
2797 impl->m_minLoadFactor = tableDesc->MinLoadFactor;
2798 impl->m_maxLoadFactor = tableDesc->MaxLoadFactor;
2799 impl->m_single_user_mode = tableDesc->SingleUserMode;
2800 impl->m_storageType = tableDesc->TableStorageType;
2801 impl->m_extra_row_gci_bits = tableDesc->ExtraRowGCIBits;
2802 impl->m_extra_row_author_bits = tableDesc->ExtraRowAuthorBits;
2805 getApiConstant(tableDesc->TableType,
2809 bool columnsIndexSourced=
false;
2813 const char * externalPrimary =
2814 Ndb::externalizeTableName(tableDesc->PrimaryTable, fullyQualifiedNames);
2819 columnsIndexSourced=
true;
2823 for(i = 0; i < tableDesc->NoOfAttributes; i++) {
2825 s = SimpleProperties::unpack(it,
2827 DictTabInfo::AttributeMapping,
2828 DictTabInfo::AttributeMappingSize,
2830 if(s != SimpleProperties::Break){
2832 NdbMem_Free((
void*)tableDesc);
2837 col->m_attrId = attrDesc.AttributeId;
2838 col->
setName(attrDesc.AttributeName);
2841 if (! attrDesc.translateExtType()) {
2844 NdbMem_Free((
void*)tableDesc);
2848 col->m_precision = (attrDesc.AttributeExtPrecision & 0xFFFF);
2849 col->m_scale = attrDesc.AttributeExtScale;
2850 col->m_length = attrDesc.AttributeExtLength;
2852 unsigned cs_number = (attrDesc.AttributeExtPrecision >> 16);
2854 if (col->getCharType() != (cs_number != 0)) {
2857 NdbMem_Free((
void*)tableDesc);
2860 if (col->getCharType()) {
2861 col->m_cs = get_charset(cs_number, MYF(0));
2862 if (col->m_cs == NULL) {
2865 NdbMem_Free((
void*)tableDesc);
2870 col->m_attrSize = (1 << attrDesc.AttributeSize) / 8;
2871 col->m_arraySize = attrDesc.AttributeArraySize;
2872 col->m_arrayType = attrDesc.AttributeArrayType;
2873 if(attrDesc.AttributeSize == 0)
2875 col->m_attrSize = 4;
2876 col->m_arraySize = (attrDesc.AttributeArraySize + 31) >> 5;
2878 col->m_storageType = attrDesc.AttributeStorageType;
2879 col->m_dynamic = (attrDesc.AttributeDynamic != 0);
2880 col->m_indexSourced= columnsIndexSourced;
2882 if (col->getBlobType()) {
2883 if (unlikely(col->m_arrayType) == NDB_ARRAYTYPE_FIXED)
2884 col->m_blobVersion = NDB_BLOB_V1;
2885 else if (col->m_arrayType == NDB_ARRAYTYPE_MEDIUM_VAR)
2886 col->m_blobVersion = NDB_BLOB_V2;
2889 NdbMem_Free((
void*)tableDesc);
2894 col->m_pk = attrDesc.AttributeKeyFlag;
2895 col->m_distributionKey = (attrDesc.AttributeDKey != 0);
2896 col->m_nullable = attrDesc.AttributeNullableFlag;
2897 col->m_autoIncrement = (attrDesc.AttributeAutoIncrement != 0);
2898 col->m_autoIncrementInitialValue = ~0;
2900 if (attrDesc.AttributeDefaultValueLen)
2902 assert(attrDesc.AttributeDefaultValueLen >=
sizeof(Uint32));
2903 const char* defPtr = (
const char*) attrDesc.AttributeDefaultValue;
2904 Uint32 a = * (
const Uint32*) defPtr;
2906 Uint32 bytesize = ah.getByteSize();
2907 assert(attrDesc.AttributeDefaultValueLen >=
sizeof(Uint32) + bytesize);
2911 if (col->m_defaultValue.assign(defPtr +
sizeof(Uint32), bytesize))
2924 attrDesc.AttributeSize,
2925 attrDesc.AttributeArrayType,
2926 attrDesc.AttributeArraySize,
2927 (uchar*) col->m_defaultValue.get_data(),
2930 impl->m_has_default_values =
true;
2934 col->m_column_no = impl->m_columns.size();
2935 impl->m_columns.push_back(col);
2939 impl->computeAggregates();
2941 if(tableDesc->ReplicaDataLen > 0)
2943 Uint16 replicaCount = ntohs(tableDesc->ReplicaData[0]);
2944 Uint16 fragCount = ntohs(tableDesc->ReplicaData[1]);
2946 assert(replicaCount <= 256);
2948 impl->m_replicaCount = (Uint8)replicaCount;
2949 impl->m_fragmentCount = fragCount;
2950 DBUG_PRINT(
"info", (
"replicaCount=%x , fragCount=%x",replicaCount,fragCount));
2952 for(i = 0; i < (Uint32) fragCount;i++)
2955 for (Uint32 j = 0; j<(Uint32)replicaCount; j++)
2957 if (impl->m_fragments.push_back(ntohs(tableDesc->ReplicaData[pos++])))
2965 Uint32 topBit = (1 << 31);
2966 for(; topBit && !(fragCount & topBit); ){
2974 impl->m_fragmentCount = tableDesc->FragmentCount;
2975 impl->m_replicaCount = 0;
2977 impl->m_hashpointerValue = 0;
2980 impl->m_tablespace_id = tableDesc->TablespaceId;
2981 impl->m_tablespace_version = tableDesc->TablespaceVersion;
2985 NdbMem_Free((
void*)tableDesc);
2986 if (version < MAKE_VERSION(5,1,3))
2992 DBUG_ASSERT(impl->m_fragmentCount > 0);
3003 DBUG_ENTER(
"NdbDictionaryImpl::createTable");
3005 bool autoIncrement =
false;
3006 Uint64 initialValue = 0;
3007 for (Uint32 i = 0; i < t.m_columns.size(); i++) {
3010 if (c->m_autoIncrement) {
3011 if (autoIncrement) {
3012 m_error.
code = 4335;
3015 autoIncrement =
true;
3016 initialValue = c->m_autoIncrementInitialValue;
3019 if (c->m_pk && (! c->m_defaultValue.empty())) {
3029 Uint32* data = (Uint32*)m_receiver.m_buffer.get_data();
3031 t.m_version = data[1];
3032 objid.m_id = data[0];
3033 objid.m_version = data[1];
3037 m_receiver.getTable(t.m_internalName, m_ndb.usingFullyQualifiedNames());
3041 DBUG_PRINT(
"info", (
"table %s dropped by another thread",
3042 t.m_internalName.
c_str()));
3046 if (t.m_id != t2->m_id || t.m_version != t2->m_version) {
3047 DBUG_PRINT(
"info", (
"table %s re-created by another thread",
3048 t.m_internalName.
c_str()));
3056 if (autoIncrement) {
3060 if (m_ndb.setTupleIdInNdb(&t, range, initialValue,
false) == -1) {
3061 assert(m_ndb.theError.
code != 0);
3062 m_error.
code = m_ndb.theError.
code;
3070 if (t.m_noOfBlobs != 0) {
3074 for (i = 0; i < t.m_columns.size(); i++) {
3077 if (c->getBlobType()) {
3079 assert(c2->m_storageType == NDB_STORAGETYPE_MEMORY);
3080 c2->m_storageType = c->m_storageType;
3084 if (createBlobTables(*t2) != 0) {
3085 int save_code = m_error.
code;
3086 (void)dropTableGlobal(*t2);
3087 m_error.
code = save_code;
3099 NdbDictionaryImpl::optimizeTable(
const NdbTableImpl &t,
3102 DBUG_ENTER(
"NdbDictionaryImpl::optimizeTableGlobal(const NdbTableImpl)");
3103 DBUG_RETURN(h.
init(&m_ndb, t));
3107 NdbDictionaryImpl::optimizeIndex(
const NdbIndexImpl &index,
3110 DBUG_ENTER(
"NdbDictionaryImpl::optimizeIndexGlobal(const NdbIndexImpl)");
3111 DBUG_RETURN(h.
init(&m_ndb, index));
3115 NdbDictionaryImpl::createBlobTables(
const NdbTableImpl& t)
3117 DBUG_ENTER(
"NdbDictionaryImpl::createBlobTables");
3118 for (
unsigned i = 0; i < t.m_columns.size(); i++) {
3122 DBUG_PRINT(
"info", (
"col: %s array type: %u storage type: %u",
3123 c.m_name.
c_str(), c.m_arrayType, c.m_storageType));
3126 if (NdbBlob::getBlobTable(bt, &t, &c, error) == -1) {
3130 NdbDictionary::Column::StorageType
3131 d = NdbDictionary::Column::StorageTypeDisk;
3132 if (t.m_columns[i]->getStorageType() == d) {
3133 const char* colName = c.m_blobVersion == 1 ?
"DATA" :
"NDB$DATA";
3136 bc->setStorageType(d);
3139 if (createTable(bt, NdbDictObjectImpl::getImpl(objId)) != 0) {
3152 DBUG_ENTER(
"NdbDictInterface::createTable");
3154 if (impl.m_fragmentType == NdbDictionary::Object::HashMapPartition)
3156 if (impl.m_hash_map_id == RNIL && impl.m_hash_map_version == ~(Uint32)0)
3163 CreateHashMapReq::CreateDefault |
3164 CreateHashMapReq::CreateIfNotExists);
3172 syncInternalName(ndb, impl);
3181 DBUG_RETURN(sendCreateTable(impl, w));
3184 bool NdbDictionaryImpl::supportedAlterTable(
NdbTableImpl &old_impl,
3187 return m_receiver.supportedAlterTable(old_impl, impl);
3190 bool NdbDictInterface::supportedAlterTable(
const NdbTableImpl &old_impl,
3194 return (compChangeMask(old_impl, impl, change_mask) == 0);
3197 int NdbDictionaryImpl::alterTable(
NdbTableImpl &old_impl,
3200 return alterTableGlobal(old_impl, impl);
3203 int NdbDictionaryImpl::alterTableGlobal(
NdbTableImpl &old_impl,
3206 DBUG_ENTER(
"NdbDictionaryImpl::alterTableGlobal");
3208 Uint32 changeMask = 0;
3209 int ret = m_receiver.alterTable(m_ndb, old_impl, impl, changeMask);
3215 op.m_gsn = GSN_ALTER_TABLE_REQ;
3216 op.m_impl = &old_impl;
3217 if (m_tx.m_op.push_back(op) == -1) {
3218 m_error.
code = 4000;
3221 m_globalHash->lock();
3222 ret = m_globalHash->inc_ref_count(op.m_impl);
3223 m_globalHash->unlock();
3229 char db0[MAX_TAB_NAME_SIZE];
3230 char db1[MAX_TAB_NAME_SIZE];
3231 if (old_impl.getDbName(db0,
sizeof(db0)) != 0)
3236 if (impl.getDbName(db1,
sizeof(db0)) != 0)
3242 bool db_change = strcmp(db0, db1) != 0;
3243 if (old_impl.getSchemaName(db0,
sizeof(db0)) != 0)
3248 if (impl.getSchemaName(db1,
sizeof(db0)) != 0)
3254 bool schema_change = strcmp(db0, db1) != 0;
3255 if (db_change || schema_change)
3257 if (renameBlobTables(old_impl, impl) != 0)
3269 NdbDictionaryImpl::renameBlobTables(
const NdbTableImpl & old_tab,
3272 if (old_tab.m_noOfBlobs == 0)
3275 char db[MAX_TAB_NAME_SIZE];
3276 char schema[MAX_TAB_NAME_SIZE];
3277 new_tab.getDbName(db,
sizeof(db));
3278 new_tab.getSchemaName(schema,
sizeof(schema));
3280 for (
unsigned i = 0; i < old_tab.m_columns.size(); i++)
3293 new_bt.m_impl.setDbSchema(db, schema);
3295 Uint32 changeMask = 0;
3296 int ret = m_receiver.alterTable(m_ndb, bt.m_impl, new_bt.m_impl,changeMask);
3307 NdbDictInterface::alterTable(
Ndb & ndb,
3310 Uint32 & change_mask)
3314 DBUG_ENTER(
"NdbDictInterface::alterTable");
3316 syncInternalName(ndb, impl);
3319 ret= compChangeMask(old_impl, impl, change_mask);
3328 DBUG_RETURN(sendAlterTable(impl, change_mask, w));
3335 ndb.internalize_table_name(impl.m_externalName.
c_str()));
3336 impl.m_internalName.
assign(internalName);
3337 impl.updateMysqlName();
3346 NdbDictInterface::compChangeMask(
const NdbTableImpl &old_impl,
3348 Uint32 &change_mask)
3350 DBUG_ENTER(
"compChangeMask");
3353 Uint32 old_sz= old_impl.m_columns.size();
3354 Uint32 sz= impl.m_columns.size();
3357 DBUG_PRINT(
"info", (
"old_impl.m_internalName='%s' impl.m_internalName='%s'",
3358 old_impl.m_internalName.
c_str(),
3359 impl.m_internalName.
c_str()));
3360 if(impl.m_internalName != old_impl.m_internalName)
3362 bool old_blob = is_ndb_blob_table(old_impl.m_externalName.
c_str());
3363 bool new_blob = is_ndb_blob_table(impl.m_externalName.
c_str());
3364 if (unlikely(old_blob != new_blob))
3367 DBUG_PRINT(
"info", (
"Attempt to alter to/from Blob part table name"));
3368 goto invalid_alter_table;
3370 AlterTableReq::setNameFlag(change_mask,
true);
3372 if(!impl.m_frm.equal(old_impl.m_frm))
3373 AlterTableReq::setFrmFlag(change_mask,
true);
3374 if(!impl.m_fd.
equal(old_impl.m_fd))
3375 AlterTableReq::setFragDataFlag(change_mask,
true);
3376 if(!impl.m_range.
equal(old_impl.m_range))
3377 AlterTableReq::setRangeListFlag(change_mask,
true);
3380 if(impl.m_logging != old_impl.m_logging ||
3381 impl.m_temporary != old_impl.m_temporary ||
3382 impl.m_row_gci != old_impl.m_row_gci ||
3383 impl.m_row_checksum != old_impl.m_row_checksum ||
3384 impl.m_kvalue != old_impl.m_kvalue ||
3385 impl.m_minLoadFactor != old_impl.m_minLoadFactor ||
3386 impl.m_maxLoadFactor != old_impl.m_maxLoadFactor ||
3387 impl.m_primaryTableId != old_impl.m_primaryTableId ||
3388 impl.m_max_rows != old_impl.m_max_rows ||
3389 impl.m_min_rows != old_impl.m_min_rows ||
3390 impl.m_default_no_part_flag != old_impl.m_default_no_part_flag ||
3391 impl.m_linear_flag != old_impl.m_linear_flag ||
3392 impl.m_fragmentType != old_impl.m_fragmentType ||
3394 impl.m_tablespace_id != old_impl.m_tablespace_id ||
3395 impl.m_tablespace_version != old_impl.m_tablespace_version ||
3396 impl.m_id != old_impl.m_id ||
3397 impl.m_version != old_impl.m_version ||
3399 impl.m_extra_row_gci_bits != old_impl.m_extra_row_gci_bits ||
3400 impl.m_extra_row_author_bits != old_impl.m_extra_row_author_bits)
3402 DBUG_PRINT(
"info", (
"Old and new table not compatible"));
3403 goto invalid_alter_table;
3406 if (impl.m_fragmentCount != old_impl.m_fragmentCount)
3408 if (impl.m_fragmentType != NdbDictionary::Object::HashMapPartition)
3409 goto invalid_alter_table;
3410 AlterTableReq::setAddFragFlag(change_mask,
true);
3426 for(Uint32 i= 0; i<old_sz; i++)
3429 if(!col->
equal(*(old_impl.m_columns[i])))
3431 DBUG_PRINT(
"info", (
"Old and new column not equal"));
3432 goto invalid_alter_table;
3434 if(col->m_storageType == NDB_STORAGETYPE_MEMORY &&
3435 (col->m_dynamic || col->m_arrayType != NDB_ARRAYTYPE_FIXED))
3436 found_varpart=
true;
3443 DBUG_PRINT(
"info", (
"No old dynamic column found"));
3444 goto invalid_alter_table;
3447 for(Uint32 i=old_sz; i<sz; i++)
3450 if(!col->m_dynamic || !col->m_nullable ||
3451 col->m_storageType == NDB_STORAGETYPE_DISK ||
3453 col->m_distributionKey ||
3454 col->m_autoIncrement ||
3458 goto invalid_alter_table;
3461 AlterTableReq::setAddAttrFlag(change_mask,
true);
3466 invalid_alter_table:
3477 DBUG_ENTER(
"NdbDictInterface::serializeTableDesc");
3479 impl.computeAggregates();
3485 unsigned sz = impl.m_columns.size();
3486 if (sz > NDB_MAX_ATTRIBUTES_IN_TABLE){
3504 m_error.
code = 4000;
3509 "%s", impl.m_internalName.
c_str());
3512 for(i = 0; i<sz; i++) {
3515 m_error.
code = 4272;
3516 NdbMem_Free((
void*)tmpTab);
3519 if (col->m_distributionKey)
3524 m_error.
code = 4327;
3525 NdbMem_Free((
void*)tmpTab);
3532 impl.m_noOfDistributionKeys= distKeys;
3536 if (impl.m_frm.length() > MAX_FRM_DATA_SIZE){
3538 NdbMem_Free((
void*)tmpTab);
3545 tmpTab->FrmLen = impl.m_frm.length();
3546 memcpy(tmpTab->FrmData, impl.m_frm.get_data(), impl.m_frm.length());
3554 const Uint32* src = impl.m_fd.getBase();
3555 tmpTab->FragmentDataLen = 2*impl.m_fd.size();
3556 for (Uint32 i = 0; i<impl.m_fd.size(); i++)
3557 tmpTab->FragmentData[i] = (Uint16)src[
i];
3565 tmpTab->RangeListDataLen = 4*impl.m_range.size();
3566 memcpy(tmpTab->RangeListData, impl.m_range.getBase(),4*impl.m_range.size());
3569 tmpTab->FragmentCount= impl.m_fragmentCount;
3570 tmpTab->TableLoggedFlag = impl.m_logging;
3571 tmpTab->TableTemporaryFlag = impl.m_temporary;
3572 tmpTab->RowGCIFlag = impl.m_row_gci;
3573 tmpTab->RowChecksumFlag = impl.m_row_checksum;
3574 tmpTab->TableKValue = impl.m_kvalue;
3575 tmpTab->MinLoadFactor = impl.m_minLoadFactor;
3576 tmpTab->MaxLoadFactor = impl.m_maxLoadFactor;
3577 tmpTab->TableType = DictTabInfo::UserTable;
3578 tmpTab->PrimaryTableId = impl.m_primaryTableId;
3579 tmpTab->NoOfAttributes = sz;
3580 tmpTab->MaxRowsHigh = (Uint32)(impl.m_max_rows >> 32);
3581 tmpTab->MaxRowsLow = (Uint32)(impl.m_max_rows & 0xFFFFFFFF);
3582 tmpTab->MinRowsHigh = (Uint32)(impl.m_min_rows >> 32);
3583 tmpTab->MinRowsLow = (Uint32)(impl.m_min_rows & 0xFFFFFFFF);
3584 tmpTab->DefaultNoPartFlag = impl.m_default_no_part_flag;
3585 tmpTab->LinearHashFlag = impl.m_linear_flag;
3586 tmpTab->SingleUserMode = impl.m_single_user_mode;
3587 tmpTab->ForceVarPartFlag = impl.m_force_var_part;
3588 tmpTab->ExtraRowGCIBits = impl.m_extra_row_gci_bits;
3589 tmpTab->ExtraRowAuthorBits = impl.m_extra_row_author_bits;
3591 tmpTab->FragmentType = getKernelConstant(impl.m_fragmentType,
3592 fragmentTypeMapping,
3593 DictTabInfo::AllNodesSmallTable);
3594 tmpTab->TableVersion = rand();
3596 tmpTab->HashMapObjectId = impl.m_hash_map_id;
3597 tmpTab->HashMapVersion = impl.m_hash_map_version;
3598 tmpTab->TableStorageType = impl.m_storageType;
3602 if(impl.m_tablespace_version != ~(Uint32)0)
3604 tmpTab->TablespaceId = impl.m_tablespace_id;
3605 tmpTab->TablespaceVersion = impl.m_tablespace_version;
3607 else if(strlen(tablespace_name))
3611 tablespace_name) == 0)
3613 tmpTab->TablespaceId = tmp.m_id;
3614 tmpTab->TablespaceVersion = tmp.m_version;
3619 if (m_error.
code == 723)
3622 NdbMem_Free((
void*)tmpTab);
3628 for(i = 0; i<sz; i++)
3630 if(impl.m_columns[i]->m_storageType == NDB_STORAGETYPE_DISK)
3632 tablespace_name =
"DEFAULT-TS";
3640 s = SimpleProperties::pack(w,
3642 DictTabInfo::TableMapping,
3643 DictTabInfo::TableMappingSize,
true);
3645 if(s != SimpleProperties::Eof){
3648 NdbMem_Free((
void*)tmpTab);
3650 DBUG_PRINT(
"info",(
"impl.m_noOfDistributionKeys: %d impl.m_noOfKeys: %d distKeys: %d",
3651 impl.m_noOfDistributionKeys, impl.
m_noOfKeys, distKeys));
3654 impl.m_noOfDistributionKeys= distKeys;
3656 for(i = 0; i<sz; i++){
3661 DBUG_PRINT(
"info",(
"column: %s(%d) col->m_distributionKey: %d"
3662 " array type: %u storage type: %u",
3663 col->m_name.
c_str(),
i, col->m_distributionKey,
3664 col->m_arrayType, col->m_storageType));
3667 "%s", col->m_name.
c_str());
3668 tmpAttr.AttributeId = col->m_attrId;
3669 tmpAttr.AttributeKeyFlag = col->m_pk;
3670 tmpAttr.AttributeNullableFlag = col->m_nullable;
3671 tmpAttr.AttributeDKey = distKeys ? col->m_distributionKey : 0;
3673 tmpAttr.AttributeExtType = (Uint32)col->m_type;
3674 tmpAttr.AttributeExtPrecision = ((
unsigned)col->m_precision & 0xFFFF);
3675 tmpAttr.AttributeExtScale = col->m_scale;
3676 tmpAttr.AttributeExtLength = col->m_length;
3677 tmpAttr.AttributeArrayType = col->m_arrayType;
3680 tmpAttr.AttributeStorageType = NDB_STORAGETYPE_MEMORY;
3682 tmpAttr.AttributeStorageType = col->m_storageType;
3683 tmpAttr.AttributeDynamic = (col->m_dynamic ? 1 : 0);
3685 if (col->getBlobType()) {
3686 tmpAttr.AttributeArrayType = col->m_arrayType;
3687 tmpAttr.AttributeStorageType = NDB_STORAGETYPE_MEMORY;
3691 if (! tmpAttr.translateExtType()) {
3696 if (col->getCharType() != (col->m_cs != NULL)) {
3709 if (col->getCharType()) {
3710 tmpAttr.AttributeExtPrecision |= (col->m_cs->number << 16);
3713 tmpAttr.AttributeAutoIncrement = col->m_autoIncrement;
3716 Uint32 byteSize = col->m_defaultValue.length();
3717 assert(byteSize <= NDB_MAX_TUPLE_SIZE);
3721 if (unlikely(! ndb_native_default_support(ndb.getMinDbNodeVersion())))
3739 Uint32 a = htonl(ah);
3740 memcpy(tmpAttr.AttributeDefaultValue, &a,
sizeof(Uint32));
3741 memcpy(tmpAttr.AttributeDefaultValue +
sizeof(Uint32),
3742 col->m_defaultValue.get_data(), byteSize);
3743 Uint32 defValByteLen = ((col->m_defaultValue.length() + 3) / 4) * 4;
3744 tmpAttr.AttributeDefaultValueLen = defValByteLen +
sizeof(Uint32);
3750 tmpAttr.AttributeSize,
3751 tmpAttr.AttributeArrayType,
3752 tmpAttr.AttributeArraySize,
3753 tmpAttr.AttributeDefaultValue +
3758 s = SimpleProperties::pack(w,
3760 DictTabInfo::AttributeMapping,
3761 DictTabInfo::AttributeMappingSize,
true);
3762 w.add(DictTabInfo::AttributeEnd, 1);
3769 NdbDictInterface::sendAlterTable(
const NdbTableImpl &impl,
3774 ptr[0].p = (Uint32*)m_buffer.get_data();
3775 ptr[0].sz = m_buffer.length() / 4;
3777 tSignal.theReceiversBlockNumber = DBDICT;
3778 tSignal.theVerId_signalNumber = GSN_ALTER_TABLE_REQ;
3779 tSignal.theLength = AlterTableReq::SignalLength;
3783 req->clientRef = m_reference;
3784 req->clientData = 0;
3785 req->transId = m_tx.transId();
3786 req->transKey = m_tx.transKey();
3787 req->requestInfo = 0;
3788 req->requestInfo |= m_tx.requestFlags();
3789 req->tableId = impl.m_id;
3790 req->tableVersion = impl.m_version;
3791 req->changeMask = change_mask;
3793 int errCodes[] = { AlterTableRef::NotMaster, AlterTableRef::Busy, 0 };
3797 DICT_WAITFOR_TIMEOUT, 100,
3800 if(m_error.
code == AlterTableRef::InvalidTableVersion) {
3802 return(INCOMPATIBLE_VERSION);
3809 NdbDictInterface::sendCreateTable(
const NdbTableImpl &impl,
3813 ptr[0].p = (Uint32*)m_buffer.get_data();
3814 ptr[0].sz = m_buffer.length() / 4;
3816 tSignal.theReceiversBlockNumber = DBDICT;
3817 tSignal.theVerId_signalNumber = GSN_CREATE_TABLE_REQ;
3818 tSignal.theLength = CreateTableReq::SignalLength;
3821 req->clientRef = m_reference;
3822 req->clientData = 0;
3823 req->requestInfo = 0;
3824 req->requestInfo |= m_tx.requestFlags();
3825 req->transId = m_tx.transId();
3826 req->transKey = m_tx.transKey();
3828 int errCodes[]= { CreateTableRef::Busy, CreateTableRef::NotMaster, 0 };
3831 WAIT_CREATE_INDX_REQ,
3832 DICT_WAITFOR_TIMEOUT, 100,
3839 NdbDictInterface::execCREATE_TABLE_CONF(
const NdbApiSignal * signal,
3844 m_buffer.grow(4 * 2);
3845 Uint32* data = (Uint32*)m_buffer.get_data();
3846 data[0] = conf->tableId;
3847 data[1] = conf->tableVersion;
3848 m_impl->theWaiter.signal(NO_WAIT);
3852 NdbDictInterface::execCREATE_TABLE_REF(
const NdbApiSignal * sig,
3856 m_error.
code= ref->errorCode;
3857 m_masterNodeId = ref->masterNodeId;
3858 m_impl->theWaiter.signal(NO_WAIT);
3862 NdbDictInterface::execALTER_TABLE_CONF(
const NdbApiSignal * signal,
3865 m_impl->theWaiter.signal(NO_WAIT);
3869 NdbDictInterface::execALTER_TABLE_REF(
const NdbApiSignal * sig,
3873 m_error.
code= ref->errorCode;
3874 m_masterNodeId = ref->masterNodeId;
3875 m_impl->theWaiter.signal(NO_WAIT);
3884 DBUG_ENTER(
"NdbDictionaryImpl::dropTable");
3885 DBUG_PRINT(
"enter",(
"name: %s", name));
3894 if (ret == INCOMPATIBLE_VERSION) {
3895 const BaseString internalTableName(m_ndb.internalize_table_name(name));
3896 DBUG_PRINT(
"info",(
"INCOMPATIBLE_VERSION internal_name: %s", internalTableName.c_str()));
3897 m_localHash.drop(internalTableName.c_str());
3898 m_globalHash->lock();
3899 m_globalHash->release(tab, 1);
3900 m_globalHash->unlock();
3911 const char * name = impl.
getName();
3918 m_receiver.m_error.
code= 1228;
3923 if ((res = listIndexes(list, impl.m_id)) == -1){
3926 for (
unsigned i = 0; i < list.count; i++) {
3927 const List::Element& element = list.elements[
i];
3930 if ((res =
dropIndex(element.name, name)) != 0)
3936 if (impl.m_noOfBlobs != 0) {
3937 if (dropBlobTables(impl) != 0){
3942 int ret = m_receiver.dropTable(impl);
3943 if(ret == 0 || m_error.
code == 709 || m_error.
code == 723){
3944 const char * internalTableName = impl.m_internalName.
c_str();
3947 m_localHash.drop(internalTableName);
3948 m_globalHash->lock();
3949 m_globalHash->release(&impl, 1);
3950 m_globalHash->unlock();
3959 NdbDictionaryImpl::dropTableGlobal(
NdbTableImpl & impl)
3962 DBUG_ENTER(
"NdbDictionaryImpl::dropTableGlobal");
3967 if ((res = listIndexes(list, impl.m_id)) == -1){
3970 for (
unsigned i = 0; i < list.count; i++) {
3971 const List::Element& element = list.elements[
i];
3979 if ((res = dropIndexGlobal(*idx)) != 0)
3981 releaseIndexGlobal(*idx, 1);
3984 releaseIndexGlobal(*idx, 1);
3987 if (impl.m_noOfBlobs != 0) {
3988 if (dropBlobTables(impl) != 0){
3993 int ret = m_receiver.dropTable(impl);
3995 if(ret == 0 || m_error.
code == 709 || m_error.
code == 723)
4006 DBUG_ENTER(
"NdbDictionaryImpl::dropBlobTables");
4007 for (
unsigned i = 0; i < t.m_columns.size(); i++) {
4013 DBUG_PRINT(
"info", (
"col %s: blob table pointer is NULL",
4018 int ret = m_receiver.dropTable(*c.m_blobTable);
4020 DBUG_PRINT(
"info", (
"col %s: blob table %s: error %d",
4022 if (! (ret == 709 || ret == 723))
4034 tSignal.theReceiversBlockNumber = DBDICT;
4035 tSignal.theVerId_signalNumber = GSN_DROP_TABLE_REQ;
4036 tSignal.theLength = DropTableReq::SignalLength;
4039 req->clientRef = m_reference;
4040 req->clientData = 0;
4041 req->transId = m_tx.transId();
4042 req->transKey = m_tx.transKey();
4043 req->requestInfo = 0;
4044 req->requestInfo |= m_tx.requestFlags();
4045 req->tableId = impl.m_id;
4046 req->tableVersion = impl.m_version;
4049 { DropTableRef::NoDropTableRecordAvailable,
4050 DropTableRef::NotMaster,
4051 DropTableRef::Busy, 0 };
4055 DICT_WAITFOR_TIMEOUT, 100,
4057 if(m_error.
code == DropTableRef::InvalidTableVersion) {
4059 return INCOMPATIBLE_VERSION;
4065 NdbDictInterface::execDROP_TABLE_CONF(
const NdbApiSignal * signal,
4068 DBUG_ENTER(
"NdbDictInterface::execDROP_TABLE_CONF");
4071 m_impl->theWaiter.signal(NO_WAIT);
4076 NdbDictInterface::execDROP_TABLE_REF(
const NdbApiSignal * signal,
4079 DBUG_ENTER(
"NdbDictInterface::execDROP_TABLE_REF");
4081 m_error.
code= ref->errorCode;
4082 m_masterNodeId = ref->masterNodeId;
4083 m_impl->theWaiter.signal(NO_WAIT);
4088 NdbDictionaryImpl::invalidateObject(
NdbTableImpl & impl)
4090 const char * internalTableName = impl.m_internalName.
c_str();
4091 DBUG_ENTER(
"NdbDictionaryImpl::invalidateObject");
4092 DBUG_PRINT(
"enter", (
"internal_name: %s", internalTableName));
4094 m_localHash.drop(internalTableName);
4095 m_globalHash->lock();
4096 m_globalHash->release(&impl, 1);
4097 m_globalHash->unlock();
4102 NdbDictionaryImpl::removeCachedObject(
NdbTableImpl & impl)
4104 const char * internalTableName = impl.m_internalName.
c_str();
4105 DBUG_ENTER(
"NdbDictionaryImpl::removeCachedObject");
4106 DBUG_PRINT(
"enter", (
"internal_name: %s", internalTableName));
4108 m_localHash.drop(internalTableName);
4109 m_globalHash->lock();
4110 m_globalHash->release(&impl);
4111 m_globalHash->unlock();
4120 DBUG_ENTER(
"NdbDictInterface::create_index_obj_from_table");
4127 idx->m_version = tab->m_version;
4128 idx->m_status = tab->m_status;
4129 idx->m_id = tab->m_id;
4131 !idx->m_tableName.
assign(prim->m_externalName))
4138 idx->m_logging = tab->m_logging;
4139 idx->m_temporary = tab->m_temporary;
4141 const Uint32 distKeys = prim->m_noOfDistributionKeys;
4145 const Uint32 fullKeyCount = keyCount;
4149 for(i = 0; i+1<tab->m_columns.size(); i++){
4161 if (idx->m_columns.push_back(col))
4180 idx->m_key_ids.fill(key_id, fill);
4181 idx->m_key_ids[key_id] =
i;
4182 col->m_keyInfoPos = key_id;
4185 (primCol->m_distributionKey ||
4189 org->m_distributionKey = 1;
4194 org->m_distributionKey = 1;
4200 tab->m_noOfDistributionKeys = fullKeyCount;
4204 for(i = 0; i+1<tab->m_columns.size(); i++)
4205 tab->m_columns[i]->m_distributionKey = 0;
4212 DBUG_PRINT(
"exit", (
"m_id: %d m_version: %d", idx->m_id, idx->m_version));
4220 NdbDictionaryImpl::createIndex(
NdbIndexImpl &ix,
bool offline)
4225 m_error.
code = 4249;
4229 return m_receiver.createIndex(m_ndb, ix, * tab, offline);
4236 return m_receiver.createIndex(m_ndb, ix, tab, offline);
4240 NdbDictInterface::createIndex(
Ndb & ndb,
4249 const size_t len = strlen(impl.m_externalName.
c_str()) + 1;
4250 if(len > MAX_TAB_NAME_SIZE) {
4251 m_error.
code = 4241;
4255 ndb.internalize_index_name(&table, impl.
getName()));
4256 w.add(DictTabInfo::TableName, internalName.c_str());
4257 w.add(DictTabInfo::TableLoggedFlag, impl.m_logging);
4258 w.add(DictTabInfo::TableTemporaryFlag, impl.m_temporary);
4261 tSignal.theReceiversBlockNumber = DBDICT;
4262 tSignal.theVerId_signalNumber = GSN_CREATE_INDX_REQ;
4263 tSignal.theLength = CreateIndxReq::SignalLength;
4266 req->clientRef = m_reference;
4267 req->clientData = 0;
4268 req->transId = m_tx.transId();
4269 req->transKey = m_tx.transKey();
4270 req->requestInfo = offline ? CreateIndxReq::RF_BUILD_OFFLINE : 0;
4271 req->requestInfo |= m_tx.requestFlags();
4273 Uint32 it = getKernelConstant(impl.m_type,
4275 DictTabInfo::UndefTableType);
4277 if(it == DictTabInfo::UndefTableType){
4278 m_error.
code = 4250;
4281 req->indexType = it;
4283 req->tableId = table.m_id;
4284 req->tableVersion = table.m_version;
4287 attributeList.sz = impl.m_columns.size();
4288 for(i = 0; i<attributeList.sz; i++){
4290 table.getColumn(impl.m_columns[i]->m_name.c_str());
4292 m_error.
code = 4247;
4296 *impl.m_columns[
i] = *col;
4299 if ((it == DictTabInfo::UniqueHashIndex &&
4300 (err = NdbSqlUtil::check_column_for_hash_index(col->m_type, col->m_cs)))
4302 (it == DictTabInfo::OrderedIndex &&
4303 (err = NdbSqlUtil::check_column_for_ordered_index(col->m_type, col->m_cs))))
4309 attributeList.id[
i] = col->m_column_no;
4312 ptr[0].p = (Uint32*)&attributeList;
4313 ptr[0].sz = 1 + attributeList.sz;
4314 ptr[1].p = (Uint32*)m_buffer.get_data();
4315 ptr[1].sz = m_buffer.length() >> 2;
4317 int errCodes[] = { CreateIndxRef::Busy, CreateIndxRef::NotMaster, 0 };
4320 WAIT_CREATE_INDX_REQ,
4321 DICT_WAITFOR_TIMEOUT, 100,
4326 NdbDictInterface::execCREATE_INDX_CONF(
const NdbApiSignal * signal,
4329 m_impl->theWaiter.signal(NO_WAIT);
4333 NdbDictInterface::execCREATE_INDX_REF(
const NdbApiSignal * sig,
4337 m_error.
code = ref->errorCode;
4338 if (m_error.
code == ref->NotMaster)
4339 m_masterNodeId = ref->masterNodeId;
4340 m_impl->theWaiter.signal(NO_WAIT);
4346 NdbDictionaryImpl::updateIndexStat(
const NdbIndexImpl& index,
4349 Uint32 rt = IndexStatReq::RT_UPDATE_STAT;
4350 return m_receiver.doIndexStatReq(m_ndb, index, table, rt);
4354 NdbDictionaryImpl::updateIndexStat(Uint32 indexId,
4355 Uint32 indexVersion,
4358 Uint32 rt = IndexStatReq::RT_UPDATE_STAT;
4359 return m_receiver.doIndexStatReq(m_ndb, indexId, indexVersion, tableId, rt);
4363 NdbDictionaryImpl::deleteIndexStat(
const NdbIndexImpl& index,
4366 Uint32 rt = IndexStatReq::RT_DELETE_STAT;
4367 return m_receiver.doIndexStatReq(m_ndb, index, table, rt);
4371 NdbDictionaryImpl::deleteIndexStat(Uint32 indexId,
4372 Uint32 indexVersion,
4375 Uint32 rt = IndexStatReq::RT_DELETE_STAT;
4376 return m_receiver.doIndexStatReq(m_ndb, indexId, indexVersion, tableId, rt);
4380 NdbDictInterface::doIndexStatReq(
Ndb& ndb,
4385 return doIndexStatReq(ndb, index.m_id, index.m_version, table.m_id, rt);
4389 NdbDictInterface::doIndexStatReq(
Ndb& ndb,
4391 Uint32 indexVersion,
4396 tSignal.theReceiversBlockNumber = DBDICT;
4397 tSignal.theVerId_signalNumber = GSN_INDEX_STAT_REQ;
4398 tSignal.theLength = IndexStatReq::SignalLength;
4401 req->clientRef = m_reference;
4402 req->clientData = 0;
4403 req->transId = m_tx.transId();
4404 req->transKey = m_tx.transKey();
4405 req->requestInfo = requestType;
4406 req->requestFlag = 0;
4407 req->indexId = indexId;
4408 req->indexVersion = indexVersion;
4409 req->tableId = tableId;
4411 int errCodes[] = { IndexStatRef::Busy, IndexStatRef::NotMaster, 0 };
4414 WAIT_CREATE_INDX_REQ,
4415 DICT_WAITFOR_TIMEOUT, 100,
4420 NdbDictInterface::execINDEX_STAT_CONF(
const NdbApiSignal * signal,
4423 m_impl->theWaiter.signal(NO_WAIT);
4427 NdbDictInterface::execINDEX_STAT_REF(
const NdbApiSignal * signal,
4431 m_error.
code = ref->errorCode;
4432 if (m_error.
code == ref->NotMaster)
4433 m_masterNodeId = ref->masterNodeId;
4434 m_impl->theWaiter.signal(NO_WAIT);
4442 const char * tableName)
4447 m_error.
code = 4243;
4453 if (ret == INCOMPATIBLE_VERSION) {
4454 const BaseString internalIndexName((tableName)
4456 m_ndb.internalize_index_name(getTable(tableName), indexName)
4458 m_ndb.internalize_table_name(indexName));
4460 m_localHash.drop(internalIndexName.c_str());
4461 m_globalHash->lock();
4462 m_globalHash->release(idx->m_table, 1);
4463 m_globalHash->unlock();
4473 const char * indexName = impl.
getName();
4474 if (tableName || m_ndb.usingFullyQualifiedNames()) {
4482 const BaseString internalIndexName((tableName)
4484 m_ndb.internalize_index_name(getTable(tableName), indexName)
4486 m_ndb.internalize_table_name(indexName));
4492 int ret= dropIndexGlobal(impl);
4495 m_globalHash->lock();
4496 m_globalHash->release(impl.m_table, 1);
4497 m_globalHash->unlock();
4498 m_localHash.drop(internalIndexName.c_str());
4503 m_error.
code = 4243;
4508 NdbDictionaryImpl::dropIndexGlobal(
NdbIndexImpl & impl)
4510 DBUG_ENTER(
"NdbDictionaryImpl::dropIndexGlobal");
4511 int ret = m_receiver.dropIndex(impl, *impl.m_table);
4524 DBUG_ENTER(
"NdbDictInterface::dropIndex");
4525 DBUG_PRINT(
"enter", (
"indexId: %d indexVersion: %d",
4526 timpl.m_id, timpl.m_version));
4528 tSignal.theReceiversBlockNumber = DBDICT;
4529 tSignal.theVerId_signalNumber = GSN_DROP_INDX_REQ;
4530 tSignal.theLength = DropIndxReq::SignalLength;
4533 req->clientRef = m_reference;
4534 req->clientData = 0;
4535 req->transId = m_tx.transId();
4536 req->transKey = m_tx.transKey();
4537 req->requestInfo = 0;
4538 req->requestInfo |= m_tx.requestFlags();
4539 req->indexId = timpl.m_id;
4540 req->indexVersion = timpl.m_version;
4542 int errCodes[] = { DropIndxRef::Busy, DropIndxRef::NotMaster, 0 };
4546 DICT_WAITFOR_TIMEOUT, 100,
4548 if(m_error.
code == DropIndxRef::InvalidIndexVersion) {
4550 ERR_RETURN(m_error, INCOMPATIBLE_VERSION);
4552 ERR_RETURN(m_error, r);
4556 NdbDictInterface::execDROP_INDX_CONF(
const NdbApiSignal * signal,
4559 m_impl->theWaiter.signal(NO_WAIT);
4563 NdbDictInterface::execDROP_INDX_REF(
const NdbApiSignal * signal,
4567 m_error.
code = ref->errorCode;
4568 if (m_error.
code == ref->NotMaster)
4569 m_masterNodeId = ref->masterNodeId;
4570 m_impl->theWaiter.signal(NO_WAIT);
4580 DBUG_ENTER(
"NdbDictionaryImpl::createEvent");
4587 DBUG_PRINT(
"info",(
"NdbDictionaryImpl::createEvent: table not found: %s",
4594 DBUG_PRINT(
"info",(
"Table: id: %d version: %d", tab->m_id, tab->m_version));
4598 int attributeList_sz = evnt.m_attrIds.size();
4600 for (i = 0; i < attributeList_sz; i++) {
4601 NdbColumnImpl *col_impl = table.getColumn(evnt.m_attrIds[i]);
4603 evnt.m_facade->addColumn(*(col_impl->m_facade));
4605 ndbout_c(
"Attr id %u in table %s not found", evnt.m_attrIds[i],
4612 evnt.m_attrIds.clear();
4614 attributeList_sz = evnt.m_columns.size();
4616 DBUG_PRINT(
"info",(
"Event on tableId=%d, tableVersion=%d, event name %s, no of columns %d",
4617 table.m_id, table.m_version,
4618 evnt.m_name.
c_str(),
4619 evnt.m_columns.size()));
4622 evnt.m_attrListBitmask.
clear();
4624 for(i = 0; i<attributeList_sz; i++){
4626 table.getColumn(evnt.m_columns[i]->m_name.c_str());
4632 *evnt.m_columns[
i] = *col;
4638 evnt.m_attrListBitmask.
set(col->m_attrId);
4642 for(i = 1; i < attributeList_sz; i++) {
4645 while((j > 0) && (evnt.m_columns[j - 1]->m_attrId > temp->m_attrId)) {
4646 evnt.m_columns[j] = evnt.m_columns[j - 1];
4649 evnt.m_columns[j] =
temp;
4652 for(i = 1; i<attributeList_sz; i++) {
4653 if (evnt.m_columns[i-1]->m_attrId == evnt.m_columns[i]->m_attrId) {
4660 if (m_receiver.createEvent(m_ndb, evnt, 0 ) != 0)
4664 if (evnt.m_mergeEvents && createBlobEvents(evnt) != 0) {
4665 int save_code = m_error.
code;
4667 m_error.
code = save_code;
4674 NdbDictionaryImpl::createBlobEvents(
NdbEventImpl& evnt)
4676 DBUG_ENTER(
"NdbDictionaryImpl::createBlobEvents");
4678 Uint32 n = t.m_noOfBlobs;
4680 for (i = 0; i < evnt.m_columns.size() && n > 0; i++) {
4686 NdbBlob::getBlobEvent(blob_evnt, &evnt, &c);
4687 if (createEvent(blob_evnt) != 0)
4694 NdbDictInterface::createEvent(
class Ndb & ndb,
4698 DBUG_ENTER(
"NdbDictInterface::createEvent");
4699 DBUG_PRINT(
"enter",(
"getFlag=%d",getFlag));
4702 tSignal.theReceiversBlockNumber = DBDICT;
4703 tSignal.theVerId_signalNumber = GSN_CREATE_EVNT_REQ;
4705 tSignal.theLength = CreateEvntReq::SignalLengthGet;
4707 tSignal.theLength = CreateEvntReq::SignalLengthCreate;
4711 req->setUserRef(m_reference);
4712 req->setUserData(0);
4719 req->setRequestType(CreateEvntReq::RT_USER_GET);
4721 DBUG_PRINT(
"info",(
"tableId: %u tableVersion: %u",
4722 evnt.m_tableImpl->m_id,
4723 evnt.m_tableImpl->m_version));
4725 req->setRequestType(CreateEvntReq::RT_USER_CREATE);
4726 req->setTableId(evnt.m_tableImpl->m_id);
4727 req->setTableVersion(evnt.m_tableImpl->m_version);
4728 req->setAttrListBitmask(evnt.m_attrListBitmask);
4729 req->setEventType(evnt.mi_type);
4731 if (evnt.m_rep & NdbDictionary::Event::ER_ALL)
4732 req->setReportAll();
4733 if (evnt.m_rep & NdbDictionary::Event::ER_SUBSCRIBE)
4734 req->setReportSubscribe();
4735 if (evnt.m_rep & NdbDictionary::Event::ER_DDL)
4737 req->setReportDDL();
4741 req->clearReportDDL();
4743 ptr[1].p = evnt.m_attrListBitmask.rep.data;
4744 ptr[1].sz = evnt.m_attrListBitmask.getSizeInWords();
4750 const size_t len = strlen(evnt.m_name.
c_str()) + 1;
4751 if(len > MAX_TAB_NAME_SIZE) {
4753 ERR_RETURN(getNdbError(), -1);
4756 w.add(SimpleProperties::StringValue, evnt.m_name.
c_str());
4761 ndb.internalize_table_name(evnt.m_tableName.
c_str()));
4762 w.add(SimpleProperties::StringValue,
4763 internal_tabname.c_str());
4766 ptr[0].p = (Uint32*)m_buffer.get_data();
4767 ptr[0].sz = (m_buffer.length()+3) >> 2;
4771 WAIT_CREATE_INDX_REQ,
4772 DICT_WAITFOR_TIMEOUT, 100,
4776 ERR_RETURN(getNdbError(), ret);
4779 char *dataPtr = (
char *)m_buffer.get_data();
4780 unsigned int lenCreateEvntConf = *((
unsigned int *)dataPtr);
4781 dataPtr +=
sizeof(lenCreateEvntConf);
4783 dataPtr += lenCreateEvntConf;
4787 evnt.m_eventId = evntConf->getEventId();
4788 evnt.m_eventKey = evntConf->getEventKey();
4789 evnt.m_table_id = evntConf->getTableId();
4790 evnt.m_table_version = evntConf->getTableVersion();
4793 evnt.m_attrListBitmask = evntConf->getAttrListBitmask();
4794 evnt.mi_type = evntConf->getEventType();
4796 if (!m_tableData.empty())
4798 Uint32 len = m_tableData.length();
4799 assert((len & 3) == 0);
4801 if (len <= evnt.m_attrListBitmask.getSizeInWords())
4803 evnt.m_attrListBitmask.
clear();
4804 memcpy(evnt.m_attrListBitmask.rep.data, m_tableData.get_data(), 4*len);
4808 memcpy(evnt.m_attrListBitmask.rep.data, m_tableData.get_data(),
4809 4*evnt.m_attrListBitmask.getSizeInWords());
4813 if ((Uint32) evnt.m_tableImpl->m_id != evntConf->getTableId() ||
4814 evnt.m_tableImpl->m_version != evntConf->getTableVersion() ||
4816 evnt.mi_type != evntConf->getEventType()) {
4817 ndbout_c(
"ERROR*************");
4819 m_tableData.clear();
4820 ERR_RETURN(getNdbError(), 1);
4825 m_tableData.clear();
4835 return m_receiver.executeSubscribeEvent(m_ndb, ev_op, buckets);
4839 NdbDictInterface::executeSubscribeEvent(
class Ndb & ndb,
4843 DBUG_ENTER(
"NdbDictInterface::executeSubscribeEvent");
4845 tSignal.theReceiversBlockNumber = DBDICT;
4846 tSignal.theVerId_signalNumber = GSN_SUB_START_REQ;
4847 tSignal.theLength = SubStartReq::SignalLength;
4851 req->subscriptionId = ev_op.m_eventImpl->m_eventId;
4852 req->subscriptionKey = ev_op.m_eventImpl->m_eventKey;
4853 req->part = SubscriptionData::TableData;
4854 req->subscriberData = ev_op.m_oid;
4855 req->subscriberRef = m_reference;
4857 DBUG_PRINT(
"info",(
"GSN_SUB_START_REQ subscriptionId=%d,subscriptionKey=%d,"
4858 "subscriberData=%d",req->subscriptionId,
4859 req->subscriptionKey,req->subscriberData));
4861 int errCodes[] = { SubStartRef::Busy,
4862 SubStartRef::BusyWithNR,
4863 SubStartRef::NotMaster,
4867 WAIT_CREATE_INDX_REQ ,
4872 buckets = m_data.m_sub_start_conf.m_buckets;
4882 return m_receiver.stopSubscribeEvent(m_ndb, ev_op);
4886 NdbDictInterface::stopSubscribeEvent(
class Ndb & ndb,
4889 DBUG_ENTER(
"NdbDictInterface::stopSubscribeEvent");
4893 tSignal.theReceiversBlockNumber = DBDICT;
4894 tSignal.theVerId_signalNumber = GSN_SUB_STOP_REQ;
4895 tSignal.theLength = SubStopReq::SignalLength;
4899 req->subscriptionId = ev_op.m_eventImpl->m_eventId;
4900 req->subscriptionKey = ev_op.m_eventImpl->m_eventKey;
4901 req->subscriberData = ev_op.m_oid;
4902 req->part = (Uint32) SubscriptionData::TableData;
4903 req->subscriberRef = m_reference;
4904 req->requestInfo = 0;
4906 DBUG_PRINT(
"info",(
"GSN_SUB_STOP_REQ subscriptionId=%d,subscriptionKey=%d,"
4907 "subscriberData=%d",req->subscriptionId,
4908 req->subscriptionKey,req->subscriberData));
4910 int errCodes[] = { SubStartRef::Busy,
4911 SubStartRef::BusyWithNR,
4912 SubStartRef::NotMaster,
4916 WAIT_CREATE_INDX_REQ ,
4921 Uint32 *data = (Uint32*)m_buffer.get_data();
4922 ev_op.m_stop_gci = data[1] | (Uint64(data[0]) << 32);
4928 NdbDictionaryImpl::getEvent(
const char * eventName,
NdbTableImpl* tab)
4930 DBUG_ENTER(
"NdbDictionaryImpl::getEvent");
4931 DBUG_PRINT(
"enter",(
"eventName= %s", eventName));
4940 int ret = m_receiver.createEvent(m_ndb, *ev, 1 );
4954 DBUG_PRINT(
"error",(
"unable to find table %s", ev->
getTableName()));
4959 ((Uint32) tab->m_id != ev->m_table_id) ||
4960 (table_version_major(tab->m_version) !=
4961 table_version_major(ev->m_table_version)))
4963 DBUG_PRINT(
"info", (
"mismatch on verison in cache"));
4964 releaseTableGlobal(*tab, 1);
4968 DBUG_PRINT(
"error",(
"unable to find table %s", ev->
getTableName()));
4974 releaseTableGlobal(*tab, 0);
4984 unsigned attributeList_sz = mask.
count();
4986 DBUG_PRINT(
"info",(
"Table: id: %d version: %d",
4987 table.m_id, table.m_version));
4989 if ((Uint32) table.m_id != ev->m_table_id ||
4990 table_version_major(table.m_version) !=
4991 table_version_major(ev->m_table_version))
5001 DBUG_PRINT(
"error",(
"Invalid version, too many columns"));
5007 for(
unsigned id= 0; ev->m_columns.size() < attributeList_sz;
id++) {
5011 DBUG_PRINT(
"error",(
"Invalid version, column %d out of range",
id));
5019 DBUG_PRINT(
"info",(
"column %d %s",
id, col->
getName()));
5023 ev->m_columns.push_back(new_col);
5030 NdbDictionaryImpl::getBlobEvent(
const NdbEventImpl& ev, uint col_no)
5032 DBUG_ENTER(
"NdbDictionaryImpl::getBlobEvent");
5033 DBUG_PRINT(
"enter", (
"ev=%s col=%u", ev.m_name.
c_str(), col_no));
5036 assert(tab != NULL && col_no < tab->m_columns.size());
5038 assert(col != NULL && col->getBlobType() && col->getPartSize() != 0);
5040 assert(blob_tab != NULL);
5041 char bename[MAX_TAB_NAME_SIZE];
5045 DBUG_RETURN(blob_ev);
5049 NdbDictInterface::execCREATE_EVNT_CONF(
const NdbApiSignal * signal,
5052 DBUG_ENTER(
"NdbDictInterface::execCREATE_EVNT_CONF");
5055 m_tableData.clear();
5056 unsigned int len = signal->getLength() << 2;
5057 m_buffer.append((
char *)&len,
sizeof(len));
5060 if (signal->m_noOfSections > 0) {
5061 m_buffer.append((
char *)ptr[0].p, strlen((
char *)ptr[0].p)+1);
5063 if (signal->m_noOfSections > 1)
5065 m_tableData.append(ptr[1].p, 4 * ptr[1].sz);
5071 Uint32 subscriptionId = createEvntConf->getEventId();
5072 Uint32 subscriptionKey = createEvntConf->getEventKey();
5074 DBUG_PRINT(
"info",(
"nodeid=%d,subscriptionId=%d,subscriptionKey=%d",
5075 refToNode(signal->theSendersBlockRef),
5076 subscriptionId,subscriptionKey));
5077 m_impl->theWaiter.signal(NO_WAIT);
5082 NdbDictInterface::execCREATE_EVNT_REF(
const NdbApiSignal * signal,
5085 DBUG_ENTER(
"NdbDictInterface::execCREATE_EVNT_REF");
5089 m_error.
code= ref->getErrorCode();
5090 DBUG_PRINT(
"error",(
"error=%d,line=%d,node=%d",ref->getErrorCode(),
5091 ref->getErrorLine(),ref->getErrorNode()));
5092 if (m_error.
code == CreateEvntRef::NotMaster)
5093 m_masterNodeId = ref->getMasterNode();
5094 m_impl->theWaiter.signal(NO_WAIT);
5099 NdbDictInterface::execSUB_STOP_CONF(
const NdbApiSignal * signal,
5102 DBUG_ENTER(
"NdbDictInterface::execSUB_STOP_CONF");
5106 Uint32 subscriptionId = subStopConf->subscriptionId;
5107 Uint32 subscriptionKey = subStopConf->subscriptionKey;
5108 Uint32 subscriberData = subStopConf->subscriberData;
5110 DBUG_PRINT(
"info",(
"subscriptionId=%d,subscriptionKey=%d,subscriberData=%d",
5111 subscriptionId,subscriptionKey,subscriberData));
5115 if (SubStopConf::SignalLength >= SubStopConf::SignalLengthWithGci)
5117 gci_hi= subStopConf->gci_hi;
5118 gci_lo= subStopConf->gci_lo;
5121 m_buffer.grow(4 * 2);
5122 Uint32* data = (Uint32*)m_buffer.get_data();
5126 m_impl->theWaiter.signal(NO_WAIT);
5131 NdbDictInterface::execSUB_STOP_REF(
const NdbApiSignal * signal,
5134 DBUG_ENTER(
"NdbDictInterface::execSUB_STOP_REF");
5138 Uint32 subscriptionId = subStopRef->subscriptionId;
5139 Uint32 subscriptionKey = subStopRef->subscriptionKey;
5140 Uint32 subscriberData = subStopRef->subscriberData;
5141 m_error.
code= subStopRef->errorCode;
5143 DBUG_PRINT(
"error",(
"subscriptionId=%d,subscriptionKey=%d,subscriberData=%d,error=%d",
5144 subscriptionId,subscriptionKey,subscriberData,m_error.
code));
5145 if (m_error.
code == SubStopRef::NotMaster &&
5146 signal->getLength() >= SubStopRef::SL_MasterNode)
5148 m_masterNodeId = subStopRef->m_masterNodeId;
5150 m_impl->theWaiter.signal(NO_WAIT);
5155 NdbDictInterface::execSUB_START_CONF(
const NdbApiSignal * signal,
5158 DBUG_ENTER(
"NdbDictInterface::execSUB_START_CONF");
5162 Uint32 subscriptionId = subStartConf->subscriptionId;
5163 Uint32 subscriptionKey = subStartConf->subscriptionKey;
5164 SubscriptionData::Part part =
5165 (SubscriptionData::Part)subStartConf->part;
5166 Uint32 subscriberData = subStartConf->subscriberData;
5169 case SubscriptionData::MetaData: {
5170 DBUG_PRINT(
"error",(
"SubscriptionData::MetaData"));
5174 case SubscriptionData::TableData: {
5175 DBUG_PRINT(
"info",(
"SubscriptionData::TableData"));
5179 DBUG_PRINT(
"error",(
"wrong data"));
5185 if (signal->getLength() == SubStartConf::SignalLength)
5187 m_data.m_sub_start_conf.m_buckets = subStartConf->bucketCount;
5195 m_data.m_sub_start_conf.m_buckets = ~0;
5197 DBUG_PRINT(
"info",(
"subscriptionId=%d,subscriptionKey=%d,subscriberData=%d",
5198 subscriptionId,subscriptionKey,subscriberData));
5199 m_impl->theWaiter.signal(NO_WAIT);
5204 NdbDictInterface::execSUB_START_REF(
const NdbApiSignal * signal,
5207 DBUG_ENTER(
"NdbDictInterface::execSUB_START_REF");
5210 m_error.
code= subStartRef->errorCode;
5211 if (m_error.
code == SubStartRef::NotMaster)
5212 m_masterNodeId = subStartRef->m_masterNodeId;
5213 m_impl->theWaiter.signal(NO_WAIT);
5223 DBUG_ENTER(
"NdbDictionaryImpl::dropEvent");
5224 DBUG_PRINT(
"enter", (
"name:%s force: %d", eventName, force));
5229 evnt = getEvent(eventName);
5232 if (m_error.
code != 723 &&
5233 m_error.
code != 241)
5235 DBUG_PRINT(
"info", (
"no table err=%d", m_error.
code));
5238 DBUG_PRINT(
"info", (
"no table err=%d, drop by name alone", m_error.
code));
5254 if (dropBlobEvents(evnt) != 0)
5256 if (m_receiver.dropEvent(evnt) != 0)
5262 NdbDictionaryImpl::dropBlobEvents(
const NdbEventImpl& evnt)
5264 DBUG_ENTER(
"NdbDictionaryImpl::dropBlobEvents");
5265 if (evnt.m_tableImpl != 0) {
5267 Uint32 n = t.m_noOfBlobs;
5269 for (i = 0; i < evnt.m_columns.size() && n > 0; i++) {
5275 if (blob_evnt == NULL)
5283 DBUG_PRINT(
"info", (
"no table definition, listing events"));
5284 char bename[MAX_TAB_NAME_SIZE];
5287 sprintf(bename,
"NDB$BLOBEVENT_%s_%s", evnt.
getName(),
"%d");
5291 for (
unsigned i = 0; i < list.count; i++)
5297 if (sscanf(elt.
name, bename, &val) == 1)
5299 DBUG_PRINT(
"info", (
"found blob event %s, removing...", elt.
name));
5302 (void)m_receiver.dropEvent(*bevnt);
5306 DBUG_PRINT(
"info", (
"found event %s, skipping...", elt.
name));
5320 tSignal.theReceiversBlockNumber = DBDICT;
5321 tSignal.theVerId_signalNumber = GSN_DROP_EVNT_REQ;
5322 tSignal.theLength = DropEvntReq::SignalLength;
5326 req->setUserRef(m_reference);
5327 req->setUserData(0);
5331 w.add(SimpleProperties::StringValue, evnt.m_name.
c_str());
5334 ptr[0].p = (Uint32*)m_buffer.get_data();
5335 ptr[0].sz = (m_buffer.length()+3) >> 2;
5339 WAIT_CREATE_INDX_REQ,
5345 NdbDictInterface::execDROP_EVNT_CONF(
const NdbApiSignal * signal,
5348 DBUG_ENTER(
"NdbDictInterface::execDROP_EVNT_CONF");
5349 m_impl->theWaiter.signal(NO_WAIT);
5354 NdbDictInterface::execDROP_EVNT_REF(
const NdbApiSignal * signal,
5357 DBUG_ENTER(
"NdbDictInterface::execDROP_EVNT_REF");
5360 m_error.
code= ref->getErrorCode();
5362 DBUG_PRINT(
"info",(
"ErrorCode=%u Errorline=%u ErrorNode=%u",
5363 ref->getErrorCode(), ref->getErrorLine(), ref->getErrorNode()));
5364 if (m_error.
code == DropEvntRef::NotMaster)
5365 m_masterNodeId = ref->getMasterNode();
5366 m_impl->theWaiter.signal(NO_WAIT);
5370 static int scanEventTable(
Ndb* pNdb,
5374 int retryAttempt = 0;
5375 const int retryMax = 100;
5380 const Uint32 codeWords= 1;
5381 Uint32 codeSpace[ codeWords ];
5385 if ((
code.interpret_exit_last_row() != 0) ||
5386 (
code.finalise() != 0))
5388 return code.getNdbError().code;
5397 if (retryAttempt >= retryMax)
5399 ndbout <<
"ERROR: has retried this operation " << retryAttempt
5400 <<
" times, failing!" << endl;
5405 NdbSleep_MilliSleep(50);
5416 Uint64 row_count = 0;
5426 pOp->
getValue(NdbDictionary::Column::ROW_COUNT, (
char*)&tmp);
5448 if ((event_id = pOp->
getValue(6)) == 0 ||
5449 (event_name = pOp->
getValue(0u)) == 0)
5461 assert((row_count & 0xffffffff) == row_count);
5463 tmp_list.
count = (
unsigned int)row_count;
5471 if (rows < tmp_list.
count)
5478 Uint32 len = (Uint32)strlen(event_name->
aRef());
5479 el.
name =
new char[len+1];
5480 memcpy(el.
name, event_name->
aRef(), len);
5494 if (rows < tmp_list.
count)
5495 tmp_list.
count = rows;
5528 m_facade->getTableGlobal(
"NDB$EVENTS_0");
5534 error_code = scanEventTable(&m_ndb, pTab, list);
5535 m_facade->removeTableGlobal(*pTab, 0);
5543 m_error.
code = error_code;
5553 NdbDictionaryImpl::listObjects(
List& list,
5555 bool fullyQualified)
5572 req.setTableType(getKernelConstant(type, objectTypeMapping, 0));
5573 req.setListNames(
true);
5575 return m_receiver.listObjects(list, req, fullyQualified);
5576 ret = m_receiver.listObjects(list1, req, fullyQualified);
5579 list.count = list1.count + list2.count;
5583 for (i = 0; i < list1.count; i++)
5586 list.elements[
i] = el;
5589 for (i = 0; i < list2.count; i++)
5592 list.elements[i + list1.count] = el;
5599 NdbDictionaryImpl::listIndexes(
List& list, Uint32 indexId)
5603 req.setTableId(indexId);
5604 req.setTableType(0);
5605 req.setListNames(
true);
5606 req.setListIndexes(
true);
5607 return m_receiver.listObjects(list, req, m_ndb.usingFullyQualifiedNames());
5614 bool listTablesLongSignal =
false;
5618 req->senderRef = m_reference;
5619 req->senderData = 0;
5620 if (ltreq.getTableId() > 4096)
5627 listTablesLongSignal =
true;
5634 req->oldSetTableId(ltreq.getTableId());
5635 req->oldSetTableType(ltreq.getTableType());
5637 tSignal.theReceiversBlockNumber = DBDICT;
5638 tSignal.theVerId_signalNumber = GSN_LIST_TABLES_REQ;
5639 tSignal.theLength = ListTablesReq::SignalLength;
5640 if (listObjects(&tSignal, listTablesLongSignal) != 0)
5643 if (listTablesLongSignal)
5645 return unpackListTables(list, fullyQualifiedNames);
5649 return unpackOldListTables(list, fullyQualifiedNames);
5655 bool fullyQualifiedNames)
5658 Uint32* tableData = (Uint32*)m_tableData.get_data();
5659 Uint32* tableNames = (Uint32*)m_tableNames.get_data();
5660 const Uint32 listTablesDataSizeInWords = (
sizeof(
ListTablesData) + 3) / 4;
5661 list.
count = m_noOfTables;
5664 while (count < m_noOfTables)
5669 memcpy(ltd, tableData, 4 * listTablesDataSizeInWords);
5670 tableData += listTablesDataSizeInWords;
5671 element.
id = ltd->getTableId();
5673 getApiConstant(ltd->getTableType(), objectTypeMapping, 0);
5675 getApiConstant(ltd->getTableState(), objectStateMapping, 0);
5677 getApiConstant(ltd->getTableStore(), objectStoreMapping, 0);
5678 element.
temp = ltd->getTableTemp();
5683 if (!databaseName || !schemaName || !objectName)
5688 Uint32 size = tableNames[0];
5689 Uint32 wsize = (size + 3) / 4;
5693 char * indexName =
new char[
size];
5694 if (indexName == NULL)
5699 memcpy(indexName, (
char *) tableNames, size);
5700 if (!(databaseName = Ndb::getDatabaseFromInternalName(indexName)) ||
5701 !(schemaName = Ndb::getSchemaFromInternalName(indexName)))
5703 delete [] indexName;
5707 objectName =
BaseString(Ndb::externalizeIndexName(indexName,
5708 fullyQualifiedNames));
5709 delete [] indexName;
5712 char * tableName =
new char[
size];
5713 if (tableName == NULL)
5718 memcpy(tableName, (
char *) tableNames, size);
5719 if (!(databaseName = Ndb::getDatabaseFromInternalName(tableName)) ||
5720 !(schemaName = Ndb::getSchemaFromInternalName(tableName)))
5722 delete [] tableName;
5726 objectName =
BaseString(Ndb::externalizeTableName(tableName,
5727 fullyQualifiedNames));
5728 delete [] tableName;
5731 char * otherName =
new char[
size];
5732 if (otherName == NULL)
5737 memcpy(otherName, (
char *) tableNames, size);
5743 delete [] otherName;
5746 !(element.
schema =
new char[schemaName.
length() + 1]) ||
5747 !(element.
name =
new char[objectName.
length() + 1]))
5754 strcpy(element.
name, objectName.
c_str());
5756 tableNames += wsize;
5764 bool fullyQualifiedNames)
5767 const Uint32* data = (
const Uint32*)m_buffer.get_data();
5768 const unsigned length = m_buffer.length() / 4;
5771 unsigned pos, count;
5773 while (pos < length) {
5776 if (pos >= length) {
5780 Uint32 n = (data[pos++] + 3) >> 2;
5796 while (pos < length) {
5798 Uint32 d = data[pos++];
5799 element.
id = OldListTablesConf::getTableId(d);
5801 getApiConstant(OldListTablesConf::getTableType(d), objectTypeMapping, 0);
5803 getApiConstant(OldListTablesConf::getTableState(d), objectStateMapping, 0);
5805 getApiConstant(OldListTablesConf::getTableStore(d), objectStoreMapping, 0);
5806 element.
temp = OldListTablesConf::getTableTemp(d);
5808 Uint32 n = (data[pos++] + 3) >> 2;
5812 if (!databaseName || !schemaName || !objectName)
5819 char * indexName =
new char[n << 2];
5820 if (indexName == NULL)
5825 memcpy(indexName, &data[pos], n << 2);
5826 if (!(databaseName = Ndb::getDatabaseFromInternalName(indexName)) ||
5827 !(schemaName = Ndb::getSchemaFromInternalName(indexName)))
5829 delete [] indexName;
5833 objectName =
BaseString(Ndb::externalizeIndexName(indexName, fullyQualifiedNames));
5834 delete [] indexName;
5837 char * tableName =
new char[n << 2];
5838 if (tableName == NULL)
5843 memcpy(tableName, &data[pos], n << 2);
5844 if (!(databaseName = Ndb::getDatabaseFromInternalName(tableName)) ||
5845 !(schemaName = Ndb::getSchemaFromInternalName(tableName)))
5847 delete [] tableName;
5851 objectName =
BaseString(Ndb::externalizeTableName(tableName, fullyQualifiedNames));
5852 delete [] tableName;
5855 char * otherName =
new char[n << 2];
5856 if (otherName == NULL)
5861 memcpy(otherName, &data[pos], n << 2);
5867 delete [] otherName;
5870 !(element.
schema =
new char[schemaName.
length() + 1]) ||
5871 !(element.
name =
new char[objectName.
length() + 1]))
5878 strcpy(element.
name, objectName.
c_str());
5887 bool& listTablesLongSignal)
5889 const Uint32 RETRIES = 100;
5890 for (Uint32 i = 0; i < RETRIES; i++) {
5900 Uint16 aNodeId = getTransporter()->get_an_alive_node();
5905 NodeInfo info = m_impl->getNodeInfo(aNodeId).m_info;
5906 if (ndbd_LIST_TABLES_CONF_long_signal(info.
m_version))
5911 listTablesLongSignal =
true;
5913 else if (listTablesLongSignal)
5923 if (m_impl->sendSignal(signal, aNodeId) != 0) {
5926 m_impl->incClientStat(Ndb::WaitMetaRequestCount, 1);
5928 int ret_val= poll_guard.wait_n_unlock(DICT_WAITFOR_TIMEOUT,
5929 aNodeId, WAIT_LIST_TABLES_CONF,
5932 if (ret_val == 0 && m_error.
code == 0)
5942 NdbDictInterface::execLIST_TABLES_CONF(
const NdbApiSignal* signal,
5945 Uint16 nodeId = refToNode(signal->theSendersBlockRef);
5946 NodeInfo info = m_impl->getNodeInfo(nodeId).m_info;
5947 if (!ndbd_LIST_TABLES_CONF_long_signal(info.
m_version))
5952 NdbDictInterface::execOLD_LIST_TABLES_CONF(signal, ptr);
5956 if (signal->isFirstFragment())
5958 m_fragmentId = signal->getFragmentId();
5960 m_tableData.clear();
5961 m_tableNames.clear();
5965 if (m_fragmentId != signal->getFragmentId())
5976 m_noOfTables+= conf->noOfTables;
5979 Uint32 sigLen = signal->getLength() - 1;
5980 const Uint32 secs = signal->m_noOfSections;
5981 const Uint32 directMap[3] = {0,1,2};
5982 const Uint32 *
const secNos =
5985 : (
const Uint32 *) &directMap;
5987 for(Uint32 i = 0; i<secs; i++)
5989 Uint32 sectionNo = secNos[
i];
5990 switch (sectionNo) {
5991 case(ListTablesConf::TABLE_DATA):
5992 if (m_tableData.append(ptr[i].p, 4 * ptr[i].sz))
5998 case(ListTablesConf::TABLE_NAMES):
5999 if (m_tableNames.append(ptr[i].p, 4 * ptr[i].sz))
6011 if(!signal->isLastFragment()){
6015 m_impl->theWaiter.signal(NO_WAIT);
6020 NdbDictInterface::execOLD_LIST_TABLES_CONF(
const NdbApiSignal* signal,
6023 const unsigned off = OldListTablesConf::HeaderLength;
6024 const unsigned len = (signal->getLength() - off);
6025 if (m_buffer.append(signal->
getDataPtr() + off, len << 2))
6029 if (signal->getLength() < OldListTablesConf::SignalLength) {
6031 m_impl->theWaiter.signal(NO_WAIT);
6038 return m_receiver.forceGCPWait(type);
6042 NdbDictInterface::forceGCPWait(
int type)
6045 if (type == 0 || type == 2)
6048 req->senderRef = m_reference;
6049 req->senderData = 0;
6054 tSignal.theReceiversBlockNumber = DBDIH;
6055 tSignal.theVerId_signalNumber = GSN_WAIT_GCP_REQ;
6056 tSignal.theLength = WaitGCPReq::SignalLength;
6058 const Uint32 RETRIES = 100;
6059 for (Uint32 i = 0; i < RETRIES; i++)
6062 Uint16 aNodeId = getTransporter()->get_an_alive_node();
6067 if (m_impl->sendSignal(&tSignal, aNodeId) != 0)
6074 m_impl->incClientStat(Ndb::WaitMetaRequestCount, 1);
6075 int ret_val= pg.wait_n_unlock(DICT_WAITFOR_TIMEOUT,
6076 aNodeId, WAIT_LIST_TABLES_CONF);
6078 if (ret_val == 0 && m_error.
code == 0)
6088 tSignal.getDataPtrSend()[0] = 6099;
6089 tSignal.theReceiversBlockNumber = DBDIH;
6090 tSignal.theVerId_signalNumber = GSN_DUMP_STATE_ORD;
6091 tSignal.theLength = 1;
6093 const Uint32 RETRIES = 100;
6094 for (Uint32 i = 0; i < RETRIES; i++)
6097 Uint16 aNodeId = getTransporter()->get_an_alive_node();
6103 if (m_impl->sendSignal(&tSignal, aNodeId) != 0) {
6108 m_impl->do_forceSend();
6111 return m_error.
code == 0 ? 0 : -1;
6115 m_error.
code = 4003;
6123 int res = m_receiver.forceGCPWait(2);
6124 if (res == 0 && gci != 0)
6126 * gci = m_receiver.m_data.m_wait_gcp_conf.gci_hi;
6132 NdbDictInterface::execWAIT_GCP_CONF(
const NdbApiSignal* signal,
6137 m_data.m_wait_gcp_conf.gci_lo = conf->gci_lo;
6138 m_data.m_wait_gcp_conf.gci_hi = conf->gci_hi;
6139 m_impl->theWaiter.signal(NO_WAIT);
6143 NdbDictInterface::execWAIT_GCP_REF(
const NdbApiSignal* signal,
6147 m_error.
code = ref->errorCode;
6149 m_impl->theWaiter.signal(NO_WAIT);
6156 m_undo_buffer_size = 0;
6157 m_logfile_group_id = RNIL;
6158 m_logfile_group_version = ~0;
6161 NdbTablespaceImpl::NdbTablespaceImpl() :
6173 NdbTablespaceImpl::~NdbTablespaceImpl(){
6180 m_version = org.m_version;
6181 m_status = org.m_status;
6182 m_type = org.m_type;
6184 if (!m_name.
assign(org.m_name))
6186 m_grow_spec = org.m_grow_spec;
6187 m_extent_size = org.m_extent_size;
6188 m_undo_free_words = org.m_undo_free_words;
6189 m_logfile_group_id = org.m_logfile_group_id;
6190 m_logfile_group_version = org.m_logfile_group_version;
6191 if (!m_logfile_group_name.
assign(org.m_logfile_group_name))
6193 m_undo_free_words = org.m_undo_free_words;
6197 NdbLogfileGroupImpl::NdbLogfileGroupImpl() :
6209 NdbLogfileGroupImpl::~NdbLogfileGroupImpl(){
6216 m_version = org.m_version;
6217 m_status = org.m_status;
6218 m_type = org.m_type;
6220 if (!m_name.
assign(org.m_name))
6222 m_grow_spec = org.m_grow_spec;
6223 m_extent_size = org.m_extent_size;
6224 m_undo_free_words = org.m_undo_free_words;
6225 m_logfile_group_id = org.m_logfile_group_id;
6226 m_logfile_group_version = org.m_logfile_group_version;
6227 if (!m_logfile_group_name.
assign(org.m_logfile_group_name))
6229 m_undo_free_words = org.m_undo_free_words;
6238 m_filegroup_id = RNIL;
6239 m_filegroup_version = ~0;
6242 NdbDatafileImpl::NdbDatafileImpl() :
6254 NdbDatafileImpl::~NdbDatafileImpl(){
6261 m_version = org.m_version;
6262 m_status = org.m_status;
6263 m_type = org.m_type;
6265 m_size = org.m_size;
6266 m_free = org.m_free;
6267 m_filegroup_id = org.m_filegroup_id;
6268 m_filegroup_version = org.m_filegroup_version;
6269 if (!m_path.
assign(org.m_path) ||
6270 !m_filegroup_name.
assign(org.m_filegroup_name))
6275 NdbUndofileImpl::NdbUndofileImpl() :
6287 NdbUndofileImpl::~NdbUndofileImpl(){
6294 m_version = org.m_version;
6295 m_status = org.m_status;
6296 m_type = org.m_type;
6298 m_size = org.m_size;
6299 m_free = org.m_free;
6300 m_filegroup_id = org.m_filegroup_id;
6301 m_filegroup_version = org.m_filegroup_version;
6302 if (!m_path.
assign(org.m_path) ||
6303 !m_filegroup_name.
assign(org.m_filegroup_name))
6314 DBUG_ENTER(
"NdbDictionaryImpl::createDatafile");
6316 if(file.m_filegroup_version != ~(Uint32)0){
6317 tmp.m_id = file.m_filegroup_id;
6318 tmp.m_version = file.m_filegroup_version;
6319 DBUG_RETURN(m_receiver.create_file(file, tmp, force, obj));
6324 file.m_filegroup_name.
c_str()) == 0){
6325 DBUG_RETURN(m_receiver.create_file(file, tmp, force, obj));
6332 return m_receiver.drop_file(file);
6340 DBUG_ENTER(
"NdbDictionaryImpl::createUndofile");
6342 if(file.m_filegroup_version != ~(Uint32)0){
6343 tmp.m_id = file.m_filegroup_id;
6344 tmp.m_version = file.m_filegroup_version;
6345 DBUG_RETURN(m_receiver.create_file(file, tmp, force, obj));
6350 file.m_filegroup_name.
c_str()) == 0){
6351 DBUG_RETURN(m_receiver.create_file(file, tmp, force, obj));
6353 DBUG_PRINT(
"info", (
"Failed to find filegroup"));
6361 return m_receiver.drop_file(file);
6368 return m_receiver.create_filegroup(fg, obj);
6374 return m_receiver.drop_filegroup(fg);
6381 return m_receiver.create_filegroup(fg, obj);
6387 return m_receiver.drop_filegroup(fg);
6391 cmp_ndbrec_attr(
const void *a,
const void *b)
6395 if(r1->attrId < r2->attrId)
6397 else if(r1->attrId == r2->attrId)
6409 cmp_bitrange(
const void* a,
const void* b)
6415 if (brA.start < brB.start)
6417 else if (brA.start == brB.start)
6433 const Uint32 MaxRecordElements= (2* NDB_MAX_ATTRIBUTES_IN_TABLE) - 1;
6434 Uint32 numElements= 0;
6435 BitRange bitRanges[ MaxRecordElements ];
6437 if (length > NDB_MAX_ATTRIBUTES_IN_TABLE)
6446 for (Uint32 rs=0; rs < length; rs++)
6449 Uint64 elementByteOffset= recSpec[rs].offset;
6450 Uint64 elementByteLength= col->getSizeInBytes();
6461 elementByteLength=
sizeof(
NdbBlob*);
6465 (flags & NdbDictionary::RecMysqldBitfield))
6474 Uint32 fractionalBits= bitLength % 8;
6475 nullLength+= fractionalBits;
6476 elementByteLength= bitLength / 8;
6482 if (elementByteLength)
6484 bitRanges[numElements].start= 8 * elementByteOffset;
6485 bitRanges[numElements].end= (8 * (elementByteOffset + elementByteLength)) - 1;
6492 bitRanges[numElements].start=
6493 (8* recSpec[rs].nullbit_byte_offset) +
6494 recSpec[rs].nullbit_bit_in_byte;
6495 bitRanges[numElements].end= bitRanges[numElements].start +
6508 Uint64 endOfPreviousRange= bitRanges[0].end;
6511 for (Uint32 rangeNum= 1; rangeNum < numElements; rangeNum++)
6513 if (unlikely((bitRanges[rangeNum].start <= endOfPreviousRange)))
6519 endOfPreviousRange= bitRanges[rangeNum].end;
6538 ndb_set_record_specification(Uint32 storageOffset,
6540 Uint32& nullableColNum,
6544 spec->column= col->m_facade;
6546 spec->offset= storageOffset;
6548 const Uint32 sizeOfElement= col->getBlobType() ?
6550 spec->column->getSizeInBytes();
6554 spec->nullbit_byte_offset= (nullableColNum >> 3);
6555 spec->nullbit_bit_in_byte= (nullableColNum & 7);
6561 spec->nullbit_byte_offset= ~0;
6562 spec->nullbit_bit_in_byte= ~0;
6565 return storageOffset + sizeOfElement;
6582 NdbDictionaryImpl::createDefaultNdbRecord(
NdbTableImpl *tableOrIndex,
6587 DBUG_ENTER(
"NdbDictionaryImpl::createNdbRecords()");
6591 Uint32 numCols= tableOrIndex->m_columns.size();
6593 Uint32 baseTabCols= numCols;
6594 unsigned char* pkMask= NULL;
6595 bool isIndex=
false;
6597 if (baseTableForIndex != NULL)
6604 baseTabCols= baseTableForIndex->m_columns.size();
6621 Uint32 nullableCols= 0;
6623 for (i=0; i<numCols; i++)
6635 Uint32 baseTableColNum=
6636 tableOrIndex->m_index->m_columns[
i]->m_keyInfoPos;
6637 col= baseTableForIndex->m_columns[baseTableColNum];
6641 col= tableOrIndex->m_columns[
i];
6644 if (col->m_nullable)
6649 Uint32
offset= (nullableCols+7) / 8;
6652 Uint32 bitMaskBytes= (baseTabCols + 7) / 8;
6653 pkMask= (
unsigned char*) calloc(1, bitMaskBytes);
6662 Uint32 nullableColNum= 0;
6665 for (i= 0; i < numCols; i++)
6682 Uint32 baseTableColNum=
6683 tableOrIndex->m_index->m_columns[
i]->m_keyInfoPos;
6684 col= baseTableForIndex->m_columns[baseTableColNum];
6689 assert( baseTableColNum < baseTabCols);
6690 pkMask[ baseTableColNum >> 3 ] |= ( 1 << ( baseTableColNum & 7 ));
6694 col= tableOrIndex->m_columns[
i];
6699 pkMask[ i >> 3 ] |= ( 1 << (i & 7));
6706 if (col->getBlobType() && col->
getPartSize() != 0)
6708 if (likely(col->m_blobTable != NULL))
6710 int res= createDefaultNdbRecord(col->m_blobTable, NULL);
6719 if (!ignore_broken_blob_tables())
6723 m_error.
code = 4263;
6731 offset= ndb_set_record_specification(offset,
6761 NdbDictionaryImpl::initialiseColumnData(
bool isIndex,
6767 const NdbColumnImpl *col= &NdbColumnImpl::getImpl(*(recSpec->column));
6775 if (col->m_attrId & AttributeHeader::PSEUDO)
6782 if (col->m_indexSourced)
6790 recCol->attrId= col->m_attrId;
6791 recCol->column_no= col->m_column_no;
6792 recCol->index_attrId= ~0;
6793 recCol->offset= recSpec->offset;
6794 recCol->maxSize= col->m_attrSize*col->m_arraySize;
6796 if (recCol->offset+recCol->maxSize > rec->m_row_size)
6797 rec->m_row_size= recCol->offset+recCol->maxSize;
6799 rec->m_max_transid_ai_bytes+= (recCol->maxSize+7) & ~3;
6800 recCol->charset_info= col->m_cs;
6803 if (!isIndex && col->m_pk)
6804 recCol->flags|= NdbRecord::IsKey;
6806 if (col->m_storageType == NDB_STORAGETYPE_DISK)
6807 recCol->flags|= NdbRecord::IsDisk;
6808 if (col->m_nullable)
6810 recCol->flags|= NdbRecord::IsNullable;
6811 recCol->nullbit_byte_offset= recSpec->nullbit_byte_offset;
6812 recCol->nullbit_bit_in_byte= recSpec->nullbit_bit_in_byte;
6814 const Uint32 nullbit_byte= recSpec->nullbit_byte_offset +
6815 (recSpec->nullbit_bit_in_byte >> 3);
6816 if (nullbit_byte >= rec->m_row_size)
6817 rec->m_row_size= nullbit_byte + 1;
6819 if (col->m_arrayType==NDB_ARRAYTYPE_SHORT_VAR)
6821 recCol->flags|= NdbRecord::IsVar1ByteLen;
6822 if (flags & NdbDictionary::RecMysqldShrinkVarchar)
6823 recCol->flags|= NdbRecord::IsMysqldShrinkVarchar;
6825 else if (col->m_arrayType==NDB_ARRAYTYPE_MEDIUM_VAR)
6827 recCol->flags|= NdbRecord::IsVar2ByteLen;
6831 recCol->bitCount= col->m_length;
6832 if (flags & NdbDictionary::RecMysqldBitfield)
6834 recCol->flags|= NdbRecord::IsMysqldBitfield;
6835 if (!(col->m_nullable))
6841 recCol->nullbit_byte_offset= recSpec->nullbit_byte_offset;
6842 recCol->nullbit_bit_in_byte= recSpec->nullbit_bit_in_byte;
6847 recCol->bitCount= 0;
6848 if (col->m_distributionKey)
6849 recCol->flags|= NdbRecord::IsDistributionKey;
6850 if (col->getBlobType())
6852 recCol->flags|= NdbRecord::IsBlob;
6853 rec->flags|= NdbRecord::RecHasBlob;
6877 Uint32 numKeys, tableNumKeys, numIndexDistrKeys, min_distkey_prefix_length;
6892 if (!validateRecordSpec(recSpec, length, flags))
6904 assert(table->m_index);
6906 tableNumKeys= table->m_columns.size() - 1;
6911 for (i= 0; i<table->m_columns.size(); i++)
6913 if (table->m_columns[i]->m_pk)
6917 Uint32 tableNumDistKeys;
6918 if (isIndex || table->m_noOfDistributionKeys != 0)
6919 tableNumDistKeys= table->m_noOfDistributionKeys;
6923 int max_attrId = -1;
6924 for (i = 0; i < length; i++)
6926 Uint32 attrId = recSpec[
i].column->getAttrId();
6927 if ((
int)attrId > max_attrId)
6928 max_attrId = (int)attrId;
6930 Uint32 attrId_indexes_length = (Uint32)(max_attrId + 1);
6940 const Uint32 ndbRecBytes=
sizeof(
NdbRecord);
6942 const Uint32 tableKeyMapBytes= tableNumKeys*
sizeof(Uint32);
6943 const Uint32 tableDistKeyMapBytes= tableNumDistKeys*
sizeof(Uint32);
6944 const Uint32 attrIdMapBytes= attrId_indexes_length*
sizeof(int);
6945 rec= (
NdbRecord *)calloc(1, ndbRecBytes +
6948 tableDistKeyMapBytes +
6955 Uint32 *key_indexes= (Uint32 *)((
unsigned char *)rec +
6958 Uint32 *distkey_indexes= (Uint32 *)((
unsigned char *)rec +
6962 int *attrId_indexes = (
int *)((
unsigned char *)rec +
6966 tableDistKeyMapBytes);
6967 for (i = 0; i < attrId_indexes_length; i++)
6968 attrId_indexes[i] = -1;
6971 rec->tableId= table->m_id;
6972 rec->tableVersion= table->m_version;
6974 rec->noOfColumns= length;
6975 rec->m_no_of_distribution_keys= tableNumDistKeys;
6978 for (i= 0; i<table->m_columns.size(); i++)
6980 if (table->m_columns[i]->getBlobType())
6982 rec->flags|= NdbRecord::RecTableHasBlob;
6988 rec->m_max_transid_ai_bytes= 0;
6989 for (i= 0; i<length; i++)
6996 if (initialiseColumnData(isIndex,
7010 if (table->m_columns[i]->m_distributionKey)
7011 recCol->flags|= NdbRecord::IsDistributionKey;
7013 recCol->flags&= ~
NdbRecord::IsDistributionKey;
7020 sizeof(rec->columns[0]),
7036 min_distkey_prefix_length= 0;
7037 numIndexDistrKeys= 0;
7038 for (i= 0; i<rec->noOfColumns; i++)
7041 if (i > 0 && oldAttrId==recCol->attrId)
7046 oldAttrId= recCol->attrId;
7048 assert(recCol->attrId < attrId_indexes_length);
7049 attrId_indexes[recCol->attrId] =
i;
7053 Uint32 colNo= recCol->column_no;
7055 if (colNo < table->m_index->m_key_ids.size() &&
7056 (key_idx= table->m_index->m_key_ids[colNo]) != -1)
7058 assert((Uint32)key_idx < tableNumKeys);
7059 recCol->flags|= NdbRecord::IsKey;
7060 key_indexes[key_idx]=
i;
7061 recCol->index_attrId= table->m_columns[key_idx]->m_attrId;
7064 if (recCol->flags & NdbRecord::IsDistributionKey)
7066 if (min_distkey_prefix_length <= (Uint32)key_idx)
7067 min_distkey_prefix_length= key_idx+1;
7068 if (numIndexDistrKeys < tableNumDistKeys)
7069 distkey_indexes[numIndexDistrKeys++]=
i;
7075 if (recCol->flags & NdbRecord::IsKey)
7077 key_indexes[numKeys]=
i;
7080 if (recCol->flags & NdbRecord::IsDistributionKey)
7082 if (numIndexDistrKeys < tableNumDistKeys)
7083 distkey_indexes[numIndexDistrKeys++]=
i;
7088 rec->flags|= NdbRecord::RecIsDefaultRec;
7090 rec->key_indexes= key_indexes;
7091 rec->key_index_length= tableNumKeys;
7092 rec->m_min_distkey_prefix_length= min_distkey_prefix_length;
7093 rec->distkey_indexes= distkey_indexes;
7094 rec->distkey_index_length= numIndexDistrKeys;
7095 rec->m_attrId_indexes = attrId_indexes;
7096 rec->m_attrId_indexes_length = attrId_indexes_length;
7102 if (numKeys == tableNumKeys)
7104 rec->flags|= NdbRecord::RecHasAllKeys;
7105 if (rec->noOfColumns == tableNumKeys)
7106 rec->flags|= NdbRecord::RecIsKeyRecord;
7109 rec->flags|= NdbRecord::RecIsIndex;
7110 rec->m_keyLenInWords= table->m_keyLenInWords;
7112 if (table->m_fragmentType == NdbDictionary::Object::UserDefined)
7113 rec->flags |= NdbRecord::RecHasUserDefinedPartitioning;
7124 NdbRecord::copyMask(Uint32 *dst,
const unsigned char *src)
const
7131 for (i= 0; i<noOfColumns; i++)
7133 Uint32 attrId= columns[
i].attrId;
7135 assert(!(attrId & AttributeHeader::PSEUDO));
7137 if (src[attrId>>3] & (1 << (attrId&7)))
7143 for (i= 0; i<noOfColumns; i++)
7145 Uint32 attrId= columns[
i].attrId;
7147 assert(!(attrId & AttributeHeader::PSEUDO));
7155 NdbRecord::Attr::get_mysqld_bitfield(
const char *src_row,
char *dst_buffer)
const
7157 assert(flags & IsMysqldBitfield);
7159 Uint32 remaining_bits= bitCount;
7160 Uint32 fractional_bitcount= remaining_bits % 8;
7163 if (fractional_bitcount > 0)
7165 Uint32 fractional_shift= nullbit_bit_in_byte + ((flags & IsNullable) != 0);
7166 Uint32 fractional_bits= (
unsigned char)(src_row[nullbit_byte_offset]);
7167 if (fractional_shift + fractional_bitcount > 8)
7168 fractional_bits|= (
unsigned char)(src_row[nullbit_byte_offset+1]) << 8;
7170 (fractional_bits >> fractional_shift) & ((1 << fractional_bitcount) - 1);
7171 bits= fractional_bits;
7177 assert(remaining_bits <= 64);
7178 const unsigned char *src_ptr= (
const unsigned char *)&src_row[offset];
7179 while (remaining_bits >= 8)
7181 bits= (bits << 8) | (*src_ptr++);
7185 Uint32 small_bits= (Uint32)bits;
7186 memcpy(dst_buffer, &small_bits, 4);
7189 small_bits= (Uint32)(bits >> 32);
7190 memcpy(dst_buffer+4, &small_bits, 4);
7195 NdbRecord::Attr::put_mysqld_bitfield(
char *dst_row,
const char *src_buffer)
const
7197 assert(flags & IsMysqldBitfield);
7198 char *dst_ptr= &dst_row[
offset];
7201 memcpy(&small_bits, src_buffer, 4);
7205 memcpy(&small_bits, src_buffer+4, 4);
7206 bits|= ((Uint64)small_bits) << 32;
7210 Uint32 remaining_bits= bitCount;
7211 assert(remaining_bits <= 64);
7212 dst_ptr+= remaining_bits/8;
7213 while (remaining_bits >= 8)
7215 *--dst_ptr= (char)(bits & 0xff);
7221 if (remaining_bits > 0)
7223 Uint32 shift= nullbit_bit_in_byte + ((flags & IsNullable) != 0);
7224 Uint32 mask= ((1 << remaining_bits) - 1) << shift;
7225 bits= (bits << shift) & mask;
7226 dst_row[nullbit_byte_offset]=
7227 Uint8((dst_row[nullbit_byte_offset] & ~mask) | bits);
7228 if (shift + remaining_bits > 8)
7232 dst_row[nullbit_byte_offset+1]=
7233 Uint8((dst_row[nullbit_byte_offset+1] & ~mask) | bits);
7238 void NdbDictionaryImpl::releaseRecord_impl(
NdbRecord *rec)
7245 if (!(rec->flags & NdbRecord::RecIsDefaultRec))
7250 if (rec->flags & NdbRecord::RecIsIndex)
7251 releaseIndexGlobal(*rec->table->m_index,
7254 releaseTableGlobal(*rec->table,
7262 NdbDictionary::RecordType
7265 if (record->flags & NdbRecord::RecIsIndex)
7266 return NdbDictionary::IndexAccess;
7268 return NdbDictionary::TableAccess;
7272 NdbDictionaryImpl::getRecordTableName(
const NdbRecord* record)
7274 if (!(record->flags & NdbRecord::RecIsIndex))
7276 return record->table->m_externalName.
c_str();
7283 NdbDictionaryImpl::getRecordIndexName(
const NdbRecord* record)
7285 if (record->flags & NdbRecord::RecIsIndex)
7287 assert(record->table->m_index != NULL);
7288 assert(record->table->m_index->m_facade != NULL);
7290 return record->table->m_index->m_externalName.
c_str();
7297 NdbDictionaryImpl::getNextAttrIdFrom(
const NdbRecord* record,
7301 for (Uint32 i= startAttrId; i < record->m_attrId_indexes_length; i++)
7313 NdbDictionaryImpl::getOffset(
const NdbRecord* record,
7317 if (attrId < record->m_attrId_indexes_length)
7321 if (attrIdIndex != -1)
7323 assert(attrIdIndex < (
int) record->noOfColumns);
7325 offset= record->columns[attrIdIndex].offset;
7335 NdbDictionaryImpl::getNullBitOffset(
const NdbRecord* record,
7337 Uint32& nullbit_byte_offset,
7338 Uint32& nullbit_bit_in_byte)
7340 if (attrId < record->m_attrId_indexes_length)
7344 if (attrIdIndex != -1)
7346 assert(attrIdIndex < (
int) record->noOfColumns);
7350 nullbit_byte_offset= attr.nullbit_byte_offset;
7351 nullbit_bit_in_byte= attr.nullbit_bit_in_byte;
7361 NdbDictionaryImpl::getValuePtr(
const NdbRecord* record,
7365 if (attrId < record->m_attrId_indexes_length)
7369 if (attrIdIndex != -1)
7371 assert(attrIdIndex < (
int) record->noOfColumns);
7373 return row + (record->columns[attrIdIndex].offset);
7382 NdbDictionaryImpl::getValuePtr(
const NdbRecord* record,
7386 if (attrId < record->m_attrId_indexes_length)
7390 if (attrIdIndex != -1)
7392 assert(attrIdIndex < (
int)record->noOfColumns);
7394 return row + (record->columns[attrIdIndex].offset);
7403 NdbDictionaryImpl::isNull(
const NdbRecord* record,
7407 if (attrId < record->m_attrId_indexes_length)
7411 if (attrIdIndex != -1)
7413 assert(attrIdIndex < (
int)record->noOfColumns);
7414 return record->columns[attrIdIndex].is_null(row);
7423 NdbDictionaryImpl::setNull(
const NdbRecord* record,
7428 if (attrId < record->m_attrId_indexes_length)
7432 if (attrIdIndex != -1)
7434 assert(attrIdIndex < (
int)record->noOfColumns);
7437 if (attr.flags & NdbRecord::IsNullable)
7440 *(row + attr.nullbit_byte_offset) |=
7441 (1 << attr.nullbit_bit_in_byte);
7443 *(row + attr.nullbit_byte_offset) &=
7444 ~(1 << attr.nullbit_bit_in_byte);
7456 NdbDictionaryImpl::getRecordRowLength(
const NdbRecord* record)
7458 return record->m_row_size;
7464 NdbDictInterface::create_file(
const NdbFileImpl & file,
7469 DBUG_ENTER(
"NdbDictInterface::create_file");
7473 f.FileType = file.m_type;
7474 f.FilegroupId = group.m_id;
7475 f.FilegroupVersion = group.m_version;
7476 f.FileSizeHi = (Uint32)(file.m_size >> 32);
7477 f.FileSizeLo = (Uint32)(file.m_size & 0xFFFFFFFF);
7480 s = SimpleProperties::pack(w,
7482 DictFilegroupInfo::FileMapping,
7483 DictFilegroupInfo::FileMappingSize,
true);
7485 if(s != SimpleProperties::Eof){
7490 tSignal.theReceiversBlockNumber = DBDICT;
7491 tSignal.theVerId_signalNumber = GSN_CREATE_FILE_REQ;
7492 tSignal.theLength = CreateFileReq::SignalLength;
7495 req->senderRef = m_reference;
7496 req->senderData = 0;
7497 req->objType = file.m_type;
7498 req->requestInfo = 0;
7500 req->requestInfo |= CreateFileReq::ForceCreateFile;
7501 req->requestInfo |= m_tx.requestFlags();
7502 req->transId = m_tx.transId();
7503 req->transKey = m_tx.transKey();
7506 ptr[0].p = (Uint32*)m_buffer.get_data();
7507 ptr[0].sz = m_buffer.length() / 4;
7509 int err[] = { CreateFileRef::Busy, CreateFileRef::NotMaster, 0};
7514 int ret = dictSignal(&tSignal, ptr, 1,
7516 WAIT_CREATE_INDX_REQ,
7522 Uint32* data = (Uint32*)m_buffer.get_data();
7525 obj->m_id = data[0];
7526 obj->m_version = data[1];
7529 DBUG_PRINT(
"info", (
"warning flags: 0x%x", m_warn));
7536 NdbDictInterface::execCREATE_FILE_CONF(
const NdbApiSignal * signal,
7541 m_buffer.grow(4 * 3);
7542 Uint32* data = (Uint32*)m_buffer.get_data();
7543 data[0] = conf->fileId;
7544 data[1] = conf->fileVersion;
7545 data[2] = conf->warningFlags;
7547 m_impl->theWaiter.signal(NO_WAIT);
7551 NdbDictInterface::execCREATE_FILE_REF(
const NdbApiSignal * signal,
7556 m_error.code = ref->errorCode;
7557 m_masterNodeId = ref->masterNodeId;
7558 m_impl->theWaiter.signal(NO_WAIT);
7562 NdbDictInterface::drop_file(
const NdbFileImpl & file)
7564 DBUG_ENTER(
"NdbDictInterface::drop_file");
7566 tSignal.theReceiversBlockNumber = DBDICT;
7567 tSignal.theVerId_signalNumber = GSN_DROP_FILE_REQ;
7568 tSignal.theLength = DropFileReq::SignalLength;
7571 req->senderRef = m_reference;
7572 req->senderData = 0;
7573 req->file_id = file.m_id;
7574 req->file_version = file.m_version;
7575 req->requestInfo = 0;
7576 req->requestInfo |= m_tx.requestFlags();
7577 req->transId = m_tx.transId();
7578 req->transKey = m_tx.transKey();
7580 int err[] = { DropFileRef::Busy, DropFileRef::NotMaster, 0};
7581 DBUG_RETURN(dictSignal(&tSignal, 0, 0,
7583 WAIT_CREATE_INDX_REQ,
7584 DICT_WAITFOR_TIMEOUT, 100,
7589 NdbDictInterface::execDROP_FILE_CONF(
const NdbApiSignal * signal,
7592 m_impl->theWaiter.signal(NO_WAIT);
7596 NdbDictInterface::execDROP_FILE_REF(
const NdbApiSignal * signal,
7601 m_error.code = ref->errorCode;
7602 m_masterNodeId = ref->masterNodeId;
7603 m_impl->theWaiter.signal(NO_WAIT);
7610 DBUG_ENTER(
"NdbDictInterface::create_filegroup");
7614 "%s", group.m_name.
c_str());
7615 switch(group.m_type){
7620 fg.TS_ExtentSize = group.m_extent_size;
7622 if(group.m_logfile_group_version != ~(Uint32)0)
7624 fg.TS_LogfileGroupId = group.m_logfile_group_id;
7625 fg.TS_LogfileGroupVersion = group.m_logfile_group_version;
7631 group.m_logfile_group_name.
c_str()) == 0)
7633 fg.TS_LogfileGroupId = tmp.m_id;
7634 fg.TS_LogfileGroupVersion = tmp.m_version;
7644 fg.LF_UndoBufferSize = group.m_undo_buffer_size;
7654 s = SimpleProperties::pack(w,
7656 DictFilegroupInfo::Mapping,
7657 DictFilegroupInfo::MappingSize,
true);
7659 if(s != SimpleProperties::Eof){
7664 tSignal.theReceiversBlockNumber = DBDICT;
7665 tSignal.theVerId_signalNumber = GSN_CREATE_FILEGROUP_REQ;
7666 tSignal.theLength = CreateFilegroupReq::SignalLength;
7670 req->senderRef = m_reference;
7671 req->senderData = 0;
7672 req->objType = fg.FilegroupType;
7673 req->requestInfo = 0;
7674 req->requestInfo |= m_tx.requestFlags();
7675 req->transId = m_tx.transId();
7676 req->transKey = m_tx.transKey();
7679 ptr[0].p = (Uint32*)m_buffer.get_data();
7680 ptr[0].sz = m_buffer.length() / 4;
7682 int err[] = { CreateFilegroupRef::Busy, CreateFilegroupRef::NotMaster, 0};
7683 int ret = dictSignal(&tSignal, ptr, 1,
7685 WAIT_CREATE_INDX_REQ,
7686 DICT_WAITFOR_TIMEOUT, 100,
7691 Uint32* data = (Uint32*)m_buffer.get_data();
7694 obj->m_id = data[0];
7695 obj->m_version = data[1];
7698 DBUG_PRINT(
"info", (
"warning flags: 0x%x", m_warn));
7705 NdbDictInterface::execCREATE_FILEGROUP_CONF(
const NdbApiSignal * signal,
7710 m_buffer.grow(4 * 3);
7711 Uint32* data = (Uint32*)m_buffer.get_data();
7712 data[0] = conf->filegroupId;
7713 data[1] = conf->filegroupVersion;
7714 data[2] = conf->warningFlags;
7715 m_impl->theWaiter.signal(NO_WAIT);
7719 NdbDictInterface::execCREATE_FILEGROUP_REF(
const NdbApiSignal * signal,
7724 m_error.code = ref->errorCode;
7725 m_masterNodeId = ref->masterNodeId;
7726 m_impl->theWaiter.signal(NO_WAIT);
7732 DBUG_ENTER(
"NdbDictInterface::drop_filegroup");
7734 tSignal.theReceiversBlockNumber = DBDICT;
7735 tSignal.theVerId_signalNumber = GSN_DROP_FILEGROUP_REQ;
7736 tSignal.theLength = DropFilegroupReq::SignalLength;
7739 req->senderRef = m_reference;
7740 req->senderData = 0;
7741 req->filegroup_id = group.m_id;
7742 req->filegroup_version = group.m_version;
7743 req->requestInfo = 0;
7744 req->requestInfo |= m_tx.requestFlags();
7745 req->transId = m_tx.transId();
7746 req->transKey = m_tx.transKey();
7748 int err[] = { DropFilegroupRef::Busy, DropFilegroupRef::NotMaster, 0};
7749 DBUG_RETURN(dictSignal(&tSignal, 0, 0,
7751 WAIT_CREATE_INDX_REQ,
7752 DICT_WAITFOR_TIMEOUT, 100,
7757 NdbDictInterface::execDROP_FILEGROUP_CONF(
const NdbApiSignal * signal,
7760 m_impl->theWaiter.signal(NO_WAIT);
7764 NdbDictInterface::execDROP_FILEGROUP_REF(
const NdbApiSignal * signal,
7769 m_error.code = ref->errorCode;
7770 m_masterNodeId = ref->masterNodeId;
7771 m_impl->theWaiter.signal(NO_WAIT);
7779 DBUG_ENTER(
"NdbDictInterface::get_filegroup");
7783 Uint32 strLen = (Uint32)strlen(name) + 1;
7785 req->senderRef = m_reference;
7786 req->senderData = 0;
7788 GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
7789 req->tableNameLen = strLen;
7790 req->schemaTransId = m_tx.transId();
7791 tSignal.theReceiversBlockNumber = DBDICT;
7792 tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
7793 tSignal.theLength = GetTabInfoReq::SignalLength;
7796 ptr[0].p = (Uint32*)name;
7797 ptr[0].sz = (strLen + 3)/4;
7799 #ifndef IGNORE_VALGRIND_WARNINGS
7804 m_buffer.append(name, strLen);
7805 m_buffer.append(&pad, 4);
7806 ptr[0].p = (Uint32*)m_buffer.get_data();
7810 int r = dictSignal(&tSignal, ptr, 1,
7812 WAIT_GET_TAB_INFO_REQ,
7813 DICT_WAITFOR_TIMEOUT, 100);
7819 DBUG_PRINT(
"info", (
"get_filegroup failed dictSignal"));
7823 m_error.code = parseFilegroupInfo(dst,
7824 (Uint32*)m_buffer.get_data(),
7825 m_buffer.length() / 4);
7829 DBUG_PRINT(
"info", (
"get_filegroup failed parseFilegroupInfo %d",
7831 DBUG_RETURN(m_error.code);
7837 get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
7839 dst.m_logfile_group_id);
7840 if (!dst.m_logfile_group_name.
assign(tmp.getName()))
7841 DBUG_RETURN(m_error.code = 4000);
7844 if(dst.m_type == type)
7848 DBUG_PRINT(
"info", (
"get_filegroup failed no such filegroup"));
7849 DBUG_RETURN(m_error.code = GetTabInfoRef::TableNotDefined);
7854 const Uint32 * data, Uint32 len)
7861 status = SimpleProperties::unpack(it, &fg,
7862 DictFilegroupInfo::Mapping,
7863 DictFilegroupInfo::MappingSize,
7866 if(status != SimpleProperties::Eof){
7867 return CreateFilegroupRef::InvalidFormat;
7870 dst.m_id = fg.FilegroupId;
7871 dst.m_version = fg.FilegroupVersion;
7875 if (!dst.m_name.
assign(fg.FilegroupName))
7877 dst.m_extent_size = fg.TS_ExtentSize;
7878 dst.m_undo_buffer_size = fg.LF_UndoBufferSize;
7879 dst.m_logfile_group_id = fg.TS_LogfileGroupId;
7880 dst.m_logfile_group_version = fg.TS_LogfileGroupVersion;
7881 dst.m_undo_free_words= ((Uint64)fg.LF_UndoFreeWordsHi << 32)
7882 | (fg.LF_UndoFreeWordsLo);
7891 DBUG_ENTER(
"NdbDictInterface::get_filegroup");
7895 req->senderRef = m_reference;
7896 req->senderData = 0;
7898 GetTabInfoReq::RequestById | GetTabInfoReq::LongSignalConf;
7900 req->schemaTransId = m_tx.transId();
7901 tSignal.theReceiversBlockNumber = DBDICT;
7902 tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
7903 tSignal.theLength = GetTabInfoReq::SignalLength;
7905 int r = dictSignal(&tSignal, NULL, 1,
7907 WAIT_GET_TAB_INFO_REQ,
7908 DICT_WAITFOR_TIMEOUT, 100);
7911 DBUG_PRINT(
"info", (
"get_filegroup failed dictSignal"));
7915 m_error.code = parseFilegroupInfo(dst,
7916 (Uint32*)m_buffer.get_data(),
7917 m_buffer.length() / 4);
7921 DBUG_PRINT(
"info", (
"get_filegroup failed parseFilegroupInfo %d",
7923 DBUG_RETURN(m_error.code);
7926 if(dst.m_type == type)
7930 DBUG_PRINT(
"info", (
"get_filegroup failed no such filegroup"));
7931 DBUG_RETURN(m_error.code = GetTabInfoRef::TableNotDefined);
7939 DBUG_ENTER(
"NdbDictInterface::get_file");
7943 Uint32 strLen = (Uint32)strlen(name) + 1;
7945 req->senderRef = m_reference;
7946 req->senderData = 0;
7948 GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
7949 req->tableNameLen = strLen;
7950 req->schemaTransId = m_tx.transId();
7951 tSignal.theReceiversBlockNumber = DBDICT;
7952 tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
7953 tSignal.theLength = GetTabInfoReq::SignalLength;
7956 ptr[0].p = (Uint32*)name;
7957 ptr[0].sz = (strLen + 3)/4;
7959 #ifndef IGNORE_VALGRIND_WARNINGS
7964 m_buffer.append(name, strLen);
7965 m_buffer.append(&pad, 4);
7966 ptr[0].p = (Uint32*)m_buffer.get_data();
7970 int r = dictSignal(&tSignal, ptr, 1,
7972 WAIT_GET_TAB_INFO_REQ,
7973 DICT_WAITFOR_TIMEOUT, 100);
7976 DBUG_PRINT(
"info", (
"get_file failed dictSignal"));
7980 m_error.code = parseFileInfo(dst,
7981 (Uint32*)m_buffer.get_data(),
7982 m_buffer.length() / 4);
7986 DBUG_PRINT(
"info", (
"get_file failed parseFileInfo %d",
7988 DBUG_RETURN(m_error.code);
7994 get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
7996 dst.m_filegroup_id);
7997 if (!dst.m_filegroup_name.
assign(tmp.getName()))
7998 DBUG_RETURN(m_error.code = 4000);
8003 get_filegroup(NdbTablespaceImpl::getImpl(tmp),
8005 dst.m_filegroup_id);
8006 if (!dst.m_filegroup_name.
assign(tmp.getName()))
8007 DBUG_RETURN(m_error.code = 4000);
8008 dst.m_free *= tmp.getExtentSize();
8011 dst.m_filegroup_name.
assign(
"Not Yet Implemented");
8013 if(dst.m_type == type)
8017 DBUG_PRINT(
"info", (
"get_file failed no such file"));
8018 DBUG_RETURN(m_error.code = GetTabInfoRef::TableNotDefined);
8023 const Uint32 * data, Uint32 len)
8029 status = SimpleProperties::unpack(it, &f,
8030 DictFilegroupInfo::FileMapping,
8031 DictFilegroupInfo::FileMappingSize,
8034 if(status != SimpleProperties::Eof){
8035 return CreateFilegroupRef::InvalidFormat;
8040 dst.m_version = f.FileVersion;
8042 dst.m_size= ((Uint64)f.FileSizeHi << 32) | (f.FileSizeLo);
8043 if (!dst.m_path.
assign(f.FileName))
8046 dst.m_filegroup_id= f.FilegroupId;
8047 dst.m_filegroup_version= f.FilegroupVersion;
8048 dst.m_free= f.FileFreeExtents;
8068 NdbHashMapImpl::~NdbHashMapImpl()
8076 m_version = org.m_version;
8077 m_status = org.m_status;
8079 m_name.
assign(org.m_name);
8080 m_map.assign(org.m_map);
8092 Uint32 strLen = (Uint32)strlen(name) + 1;
8094 req->senderRef = m_reference;
8095 req->senderData = 0;
8097 GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
8098 req->tableNameLen = strLen;
8099 req->schemaTransId = m_tx.transId();
8100 tSignal.theReceiversBlockNumber = DBDICT;
8101 tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
8102 tSignal.theLength = GetTabInfoReq::SignalLength;
8105 ptr[0].p = (Uint32*)name;
8106 ptr[0].sz = (strLen + 3)/4;
8108 #ifndef IGNORE_VALGRIND_WARNINGS
8113 m_buffer.append(name, strLen);
8114 m_buffer.append(&pad, 4);
8115 ptr[0].p = (Uint32*)m_buffer.get_data();
8121 WAIT_GET_TAB_INFO_REQ,
8122 DICT_WAITFOR_TIMEOUT, 100);
8132 (Uint32*)m_buffer.get_data(),
8133 m_buffer.length() / 4);
8135 return m_error.
code;
8145 req->senderRef = m_reference;
8146 req->senderData = 0;
8148 GetTabInfoReq::RequestById | GetTabInfoReq::LongSignalConf;
8150 req->schemaTransId = m_tx.transId();
8151 tSignal.theReceiversBlockNumber = DBDICT;
8152 tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
8153 tSignal.theLength = GetTabInfoReq::SignalLength;
8157 WAIT_GET_TAB_INFO_REQ,
8158 DICT_WAITFOR_TIMEOUT, 100);
8168 (Uint32*)m_buffer.get_data(),
8169 m_buffer.length() / 4);
8171 return m_error.
code;
8176 const Uint32 * data, Uint32 len)
8182 status = SimpleProperties::unpack(it, &hm,
8184 DictHashMapInfo::MappingSize,
8187 if(status != SimpleProperties::Eof){
8188 return CreateFilegroupRef::InvalidFormat;
8191 dst.m_name.
assign(hm.HashMapName);
8192 dst.m_id= hm.HashMapObjectId;
8193 dst.m_version = hm.HashMapVersion;
8199 hm.HashMapBuckets /=
sizeof(Uint16);
8202 for (Uint32 i = 0; i<hm.HashMapBuckets; i++)
8204 dst.m_map.push_back(hm.HashMapValues[i]);
8217 "%s", src.getName());
8218 hm.HashMapBuckets = src.getMapLen();
8219 for (Uint32 i = 0; i<hm.HashMapBuckets; i++)
8221 hm.HashMapValues[
i] = NdbHashMapImpl::getImpl(src).m_map[
i];
8228 hm.HashMapBuckets *=
sizeof(Uint16);
8231 s = SimpleProperties::pack(w,
8234 DictHashMapInfo::MappingSize,
true);
8236 if(s != SimpleProperties::Eof)
8242 tSignal.theReceiversBlockNumber = DBDICT;
8243 tSignal.theVerId_signalNumber = GSN_CREATE_HASH_MAP_REQ;
8244 tSignal.theLength = CreateHashMapReq::SignalLength;
8247 req->clientRef = m_reference;
8248 req->clientData = 0;
8249 req->requestInfo =
flags;
8250 req->requestInfo |= m_tx.requestFlags();
8251 req->transId = m_tx.transId();
8252 req->transKey = m_tx.transKey();
8257 ptr[0].p = (Uint32*)m_buffer.get_data();
8258 ptr[0].sz = m_buffer.length() / 4;
8260 int err[]= { CreateTableRef::Busy, CreateTableRef::NotMaster, 0 };
8267 if (flags & CreateHashMapReq::CreateDefault)
8273 WAIT_CREATE_INDX_REQ,
8277 if (ret == 0 && obj)
8279 Uint32* data = (Uint32*)m_buffer.get_data();
8280 obj->m_id = data[0];
8281 obj->m_version = data[1];
8288 NdbDictInterface::execCREATE_HASH_MAP_REF(
const NdbApiSignal * signal,
8293 m_error.
code = ref->errorCode;
8294 m_masterNodeId = ref->masterNodeId;
8295 m_impl->theWaiter.signal(NO_WAIT);
8300 NdbDictInterface::execCREATE_HASH_MAP_CONF(
const NdbApiSignal * signal,
8305 m_buffer.grow(4 * 2);
8306 Uint32* data = (Uint32*)m_buffer.get_data();
8307 data[0] = conf->objectId;
8308 data[1] = conf->objectVersion;
8310 m_impl->theWaiter.signal(NO_WAIT);
8319 DBUG_ENTER(
"beginSchemaTrans");
8320 if (m_tx.m_state == NdbDictInterface::Tx::Started) {
8321 m_error.
code = 4410;
8324 if (!m_receiver.checkAllNodeVersionsMin(NDBD_SCHEMA_TRANS_VERSION))
8328 m_error.
code = 4411;
8332 m_tx.m_transId = rand();
8333 m_tx.m_state = NdbDictInterface::Tx::Started;
8334 m_tx.m_error.
code = 0;
8335 if (m_tx.m_transId == 0)
8337 int ret = m_receiver.beginSchemaTrans(retry711);
8339 m_tx.m_state = NdbDictInterface::Tx::NotStarted;
8342 DBUG_PRINT(
"info", (
"transId: %x transKey: %x",
8343 m_tx.m_transId, m_tx.m_transKey));
8350 DBUG_ENTER(
"endSchemaTrans");
8351 if (m_tx.m_state == NdbDictInterface::Tx::NotStarted) {
8358 if (m_tx.m_state != NdbDictInterface::Tx::Started)
8361 DBUG_PRINT(
"info", (
"endSchemaTrans: state %u, flags 0x%x\n", m_tx.m_state, flags));
8362 if (m_tx.m_state == NdbDictInterface::Tx::Aborted &&
8363 flags & NdbDictionary::Dictionary::SchemaTransAbort)
8365 m_tx.m_error.
code = 0;
8371 DBUG_PRINT(
"info", (
"transId: %x transKey: %x",
8372 m_tx.m_transId, m_tx.m_transKey));
8373 int ret = m_receiver.endSchemaTrans(flags);
8374 if (ret == -1 || m_tx.m_error.
code != 0) {
8375 DBUG_PRINT(
"info", (
"endSchemaTrans: state %u, flags 0x%x\n", m_tx.m_state, flags));
8376 if (m_tx.m_state == NdbDictInterface::Tx::Committed &&
8377 !(flags & NdbDictionary::Dictionary::SchemaTransAbort))
8380 if (m_tx.m_state == NdbDictInterface::Tx::Aborted &&
8381 flags & NdbDictionary::Dictionary::SchemaTransAbort)
8383 m_error.
code = m_tx.m_error.
code = 0;
8384 m_tx.m_state = NdbDictInterface::Tx::NotStarted;
8387 if (m_tx.m_error.
code != 0)
8389 m_tx.m_state = NdbDictInterface::Tx::NotStarted;
8395 for (i = 0; i < m_tx.m_op.size(); i++) {
8397 if (op.m_gsn == GSN_ALTER_TABLE_REQ)
8400 m_globalHash->lock();
8401 int ret = m_globalHash->dec_ref_count(op.m_impl);
8402 m_globalHash->unlock();
8407 m_tx.m_state = NdbDictInterface::Tx::NotStarted;
8413 NdbDictInterface::checkAllNodeVersionsMin(Uint32 minNdbVersion)
const
8415 for (Uint32 nodeId = 1; nodeId < MAX_NODES; nodeId++)
8417 if (m_impl->getIsDbNode(nodeId) &&
8418 m_impl->getIsNodeSendable(nodeId) &&
8419 (m_impl->getNodeNdbVersion(nodeId) <
8434 NdbDictInterface::beginSchemaTrans(
bool retry711)
8436 assert(m_tx.m_op.size() == 0);
8441 tSignal.theReceiversBlockNumber = DBDICT;
8442 tSignal.theVerId_signalNumber = GSN_SCHEMA_TRANS_BEGIN_REQ;
8443 tSignal.theLength = SchemaTransBeginReq::SignalLength;
8445 req->clientRef = m_reference;
8446 req->transId = m_tx.m_transId;
8447 req->requestInfo = 0;
8450 SchemaTransBeginRef::NotMaster,
8451 SchemaTransBeginRef::Busy,
8452 retry711 ? SchemaTransBeginRef::BusyWithNR : 0,
8462 DICT_WAITFOR_TIMEOUT,
8471 NdbDictInterface::endSchemaTrans(Uint32 flags)
8477 tSignal.theReceiversBlockNumber = DBDICT;
8478 tSignal.theVerId_signalNumber = GSN_SCHEMA_TRANS_END_REQ;
8479 tSignal.theLength = SchemaTransEndReq::SignalLength;
8481 req->clientRef = m_reference;
8482 req->transId = m_tx.m_transId;
8483 req->requestInfo = 0;
8484 req->transKey = m_tx.m_transKey;
8488 SchemaTransBeginRef::NotMaster,
8497 DICT_WAITFOR_TIMEOUT,
8506 NdbDictInterface::execSCHEMA_TRANS_BEGIN_CONF(
const NdbApiSignal * signal,
8511 assert(m_tx.m_transId == conf->transId);
8512 m_tx.m_transKey = conf->transKey;
8513 m_impl->theWaiter.signal(NO_WAIT);
8517 NdbDictInterface::execSCHEMA_TRANS_BEGIN_REF(
const NdbApiSignal * signal,
8522 m_error.
code = ref->errorCode;
8523 m_masterNodeId = ref->masterNodeId;
8524 m_impl->theWaiter.signal(NO_WAIT);
8528 NdbDictInterface::execSCHEMA_TRANS_END_CONF(
const NdbApiSignal * signal,
8533 assert(m_tx.m_transId == conf->transId);
8534 m_impl->theWaiter.signal(NO_WAIT);
8538 NdbDictInterface::execSCHEMA_TRANS_END_REF(
const NdbApiSignal * signal,
8543 m_error.
code = ref->errorCode;
8544 m_tx.m_error.
code = ref->errorCode;
8545 m_masterNodeId = ref->masterNodeId;
8546 m_impl->theWaiter.signal(NO_WAIT);
8550 NdbDictInterface::execSCHEMA_TRANS_END_REP(
const NdbApiSignal * signal,
8555 (rep->errorCode == 0) ?
8556 m_tx.m_state = Tx::Committed
8558 m_tx.m_state = Tx::Aborted;
8559 m_tx.m_error.
code = rep->errorCode;
8560 m_masterNodeId = rep->masterNodeId;
8561 m_impl->theWaiter.signal(NO_WAIT);