18 #include <signaldata/DictTabInfo.hpp>
19 #include <ndb_limits.h>
24 DictTabInfo::TableMapping[] = {
25 DTIMAPS(Table, TableName, TableName, 0, MAX_TAB_NAME_SIZE),
26 DTIMAP(Table, TableId, TableId),
27 DTIMAPS(Table, PrimaryTable, PrimaryTable, 0, MAX_TAB_NAME_SIZE),
28 DTIMAP(Table, PrimaryTableId, PrimaryTableId),
29 DTIMAP2(Table, TableLoggedFlag, TableLoggedFlag, 0, 1),
30 DTIMAP2(Table, TableTemporaryFlag, TableTemporaryFlag, 0, 1),
31 DTIMAP2(Table, ForceVarPartFlag, ForceVarPartFlag, 0, 1),
32 DTIMAP2(Table, TableKValue, TableKValue, 6, 6),
33 DTIMAP2(Table, MinLoadFactor, MinLoadFactor, 0, 90),
34 DTIMAP2(Table, MaxLoadFactor, MaxLoadFactor, 25, 110),
35 DTIMAP2(Table, FragmentTypeVal, FragmentType, 0, 3),
36 DTIMAP2(Table, TableTypeVal, TableType, 1, 3),
37 DTIMAP(Table, NoOfKeyAttr, NoOfKeyAttr),
38 DTIMAP2(Table, NoOfAttributes, NoOfAttributes, 1, MAX_ATTRIBUTES_IN_TABLE),
39 DTIMAP(Table, NoOfNullable, NoOfNullable),
40 DTIMAP2(Table, NoOfVariable, NoOfVariable, 0, 0),
41 DTIMAP(Table, KeyLength, KeyLength),
42 DTIMAP(Table, TableVersion, TableVersion),
43 DTIMAP(Table, IndexState, IndexState),
44 DTIMAP(Table, InsertTriggerId, InsertTriggerId),
45 DTIMAP(Table, UpdateTriggerId, UpdateTriggerId),
46 DTIMAP(Table, DeleteTriggerId, DeleteTriggerId),
47 DTIMAP(Table, CustomTriggerId, CustomTriggerId),
48 DTIMAP2(Table, FrmLen, FrmLen, 0, MAX_FRM_DATA_SIZE),
49 DTIMAPB(Table, FrmData, FrmData, 0, MAX_FRM_DATA_SIZE, FrmLen),
50 DTIMAP2(Table, FragmentCount, FragmentCount, 0, MAX_NDB_PARTITIONS),
51 DTIMAP2(Table, ReplicaDataLen, ReplicaDataLen, 0, 2*MAX_FRAGMENT_DATA_BYTES),
52 DTIMAPB(Table, ReplicaData, ReplicaData, 0, 2*MAX_FRAGMENT_DATA_BYTES, ReplicaDataLen),
53 DTIMAP2(Table, FragmentDataLen, FragmentDataLen, 0, 6*MAX_NDB_PARTITIONS),
54 DTIMAPB(Table, FragmentData, FragmentData, 0, 6*MAX_NDB_PARTITIONS, FragmentDataLen),
55 DTIMAP2(Table, TablespaceDataLen, TablespaceDataLen, 0, 8*MAX_NDB_PARTITIONS),
56 DTIMAPB(Table, TablespaceData, TablespaceData, 0, 8*MAX_NDB_PARTITIONS, TablespaceDataLen),
57 DTIMAP2(Table, RangeListDataLen, RangeListDataLen, 0, 8*MAX_NDB_PARTITIONS),
58 DTIMAPB(Table, RangeListData, RangeListData, 0, 8*MAX_NDB_PARTITIONS, RangeListDataLen),
59 DTIMAP(Table, TablespaceId, TablespaceId),
60 DTIMAP(Table, TablespaceVersion, TablespaceVersion),
61 DTIMAP(Table, MaxRowsLow, MaxRowsLow),
62 DTIMAP(Table, MaxRowsHigh, MaxRowsHigh),
63 DTIMAP(Table, DefaultNoPartFlag, DefaultNoPartFlag),
64 DTIMAP(Table, LinearHashFlag, LinearHashFlag),
65 DTIMAP(Table, TablespaceVersion, TablespaceVersion),
66 DTIMAP(Table, RowGCIFlag, RowGCIFlag),
67 DTIMAP(Table, RowChecksumFlag, RowChecksumFlag),
68 DTIMAP(Table, MaxRowsLow, MaxRowsLow),
69 DTIMAP(Table, MaxRowsHigh, MaxRowsHigh),
70 DTIMAP(Table, MinRowsLow, MinRowsLow),
71 DTIMAP(Table, MinRowsHigh, MinRowsHigh),
72 DTIMAP(Table, SingleUserMode, SingleUserMode),
73 DTIMAP(Table, HashMapObjectId, HashMapObjectId),
74 DTIMAP(Table, HashMapVersion, HashMapVersion),
75 DTIMAP(Table, TableStorageType, TableStorageType),
76 DTIMAP(Table, ExtraRowGCIBits, ExtraRowGCIBits),
77 DTIMAP(Table, ExtraRowAuthorBits, ExtraRowAuthorBits),
78 DTIBREAK(AttributeName)
82 const Uint32 DictTabInfo::TableMappingSize =
88 DictTabInfo::AttributeMapping[] = {
89 DTIMAPS(Attribute, AttributeName, AttributeName, 0, MAX_ATTR_NAME_SIZE),
90 DTIMAP(Attribute, AttributeId, AttributeId),
91 DTIMAP(Attribute, AttributeType, AttributeType),
92 DTIMAP2(Attribute, AttributeSize, AttributeSize, 3, 7),
93 DTIMAP2(Attribute, AttributeArraySize, AttributeArraySize, 0, 65535),
94 DTIMAP2(Attribute, AttributeArrayType, AttributeArrayType, 0, 3),
95 DTIMAP2(Attribute, AttributeKeyFlag, AttributeKeyFlag, 0, 1),
96 DTIMAP2(Attribute, AttributeNullableFlag, AttributeNullableFlag, 0, 1),
97 DTIMAP2(Attribute, AttributeDKey, AttributeDKey, 0, 1),
98 DTIMAP2(Attribute, AttributeStorageType, AttributeStorageType, 0, 1),
99 DTIMAP2(Attribute, AttributeDynamic, AttributeDynamic, 0, 1),
100 DTIMAP(Attribute, AttributeExtType, AttributeExtType),
101 DTIMAP(Attribute, AttributeExtPrecision, AttributeExtPrecision),
102 DTIMAP(Attribute, AttributeExtScale, AttributeExtScale),
103 DTIMAP(Attribute, AttributeExtLength, AttributeExtLength),
104 DTIMAP2(Attribute, AttributeAutoIncrement, AttributeAutoIncrement, 0, 1),
106 DTIMAP2(Attribute, AttributeDefaultValueLen, AttributeDefaultValueLen,
107 0, MAX_ATTR_DEFAULT_VALUE_SIZE),
108 DTIMAPB(Attribute, AttributeDefaultValue, AttributeDefaultValue,
109 0, MAX_ATTR_DEFAULT_VALUE_SIZE, AttributeDefaultValueLen),
111 DTIBREAK(AttributeEnd)
115 const Uint32 DictTabInfo::AttributeMappingSize =
116 sizeof(DictTabInfo::AttributeMapping) /
119 bool printDICTTABINFO(FILE * output,
const Uint32 * theData,
120 Uint32 len, Uint16 receiverBlockNo)
124 fprintf(output,
"Signal data: ");
127 fprintf(output,
"H\'%.8x ", theData[i++]);
128 fprintf(output,
"\n");
133 DictTabInfo::Table::init(){
134 memset(TableName, 0,
sizeof(TableName));
136 memset(PrimaryTable, 0,
sizeof(PrimaryTable));
137 PrimaryTableId = RNIL;
139 TableTemporaryFlag = 0;
140 ForceVarPartFlag = 0;
149 FragmentType = DictTabInfo::HashMapPartition;
150 TableType = DictTabInfo::UndefTableType;
153 InsertTriggerId = RNIL;
154 UpdateTriggerId = RNIL;
155 DeleteTriggerId = RNIL;
156 CustomTriggerId = RNIL;
160 RangeListDataLen = 0;
161 TablespaceDataLen = 0;
162 memset(FrmData, 0,
sizeof(FrmData));
163 memset(FragmentData, 0,
sizeof(FragmentData));
164 memset(ReplicaData, 0,
sizeof(ReplicaData));
165 memset(RangeListData, 0,
sizeof(RangeListData));
166 memset(TablespaceData, 0,
sizeof(TablespaceData));
169 TablespaceVersion = ~0;
172 DefaultNoPartFlag = 1;
176 RowChecksumFlag = ~0;
185 HashMapObjectId = RNIL;
186 HashMapVersion = RNIL;
188 TableStorageType = NDB_STORAGETYPE_DEFAULT;
191 ExtraRowAuthorBits = 0;
195 DictTabInfo::Attribute::init(){
196 memset(AttributeName, 0,
sizeof(AttributeName));
197 AttributeId = 0xFFFF;
199 AttributeSize = DictTabInfo::a32Bit;
200 AttributeArraySize = 1;
201 AttributeArrayType = NDB_ARRAYTYPE_FIXED;
202 AttributeKeyFlag = 0;
203 AttributeNullableFlag = 0;
205 AttributeExtType = DictTabInfo::ExtUnsigned,
206 AttributeExtPrecision = 0,
207 AttributeExtScale = 0,
208 AttributeExtLength = 0,
209 AttributeAutoIncrement =
false;
210 AttributeStorageType = 0;
211 AttributeDynamic = 0;
212 AttributeDefaultValueLen = 0;
213 memset(AttributeDefaultValue, 0,
sizeof(AttributeDefaultValue));
219 DictFilegroupInfo::Mapping[] = {
220 DFGIMAPS(Filegroup, FilegroupName, FilegroupName, 0, MAX_TAB_NAME_SIZE),
221 DFGIMAP2(Filegroup, FilegroupType, FilegroupType, 0, 1),
222 DFGIMAP(Filegroup, FilegroupId, FilegroupId),
223 DFGIMAP(Filegroup, FilegroupVersion, FilegroupVersion),
225 DFGIMAP(Filegroup, TS_ExtentSize, TS_ExtentSize),
226 DFGIMAP(Filegroup, TS_LogfileGroupId, TS_LogfileGroupId),
227 DFGIMAP(Filegroup, TS_LogfileGroupVersion, TS_LogfileGroupVersion),
228 DFGIMAP(Filegroup, TS_GrowLimit, TS_DataGrow.GrowLimit),
229 DFGIMAP(Filegroup, TS_GrowSizeHi, TS_DataGrow.GrowSizeHi),
230 DFGIMAP(Filegroup, TS_GrowSizeLo, TS_DataGrow.GrowSizeLo),
231 DFGIMAPS(Filegroup, TS_GrowPattern, TS_DataGrow.GrowPattern, 0, PATH_MAX),
232 DFGIMAP(Filegroup, TS_GrowMaxSize, TS_DataGrow.GrowMaxSize),
234 DFGIMAP(Filegroup, LF_UndoBufferSize, LF_UndoBufferSize),
235 DFGIMAP(Filegroup, LF_UndoGrowLimit, LF_UndoGrow.GrowLimit),
236 DFGIMAP(Filegroup, LF_UndoGrowSizeHi, LF_UndoGrow.GrowSizeHi),
237 DFGIMAP(Filegroup, LF_UndoGrowSizeLo, LF_UndoGrow.GrowSizeLo),
238 DFGIMAPS(Filegroup, LF_UndoGrowPattern, LF_UndoGrow.GrowPattern, 0,PATH_MAX),
239 DFGIMAP(Filegroup, LF_UndoGrowMaxSize, LF_UndoGrow.GrowMaxSize),
240 DFGIMAP(Filegroup, LF_UndoFreeWordsHi, LF_UndoFreeWordsHi),
241 DFGIMAP(Filegroup, LF_UndoFreeWordsLo, LF_UndoFreeWordsLo),
247 const Uint32 DictFilegroupInfo::MappingSize =
253 DictFilegroupInfo::FileMapping[] = {
254 DFGIMAPS(File, FileName, FileName, 0, PATH_MAX),
255 DFGIMAP2(File, FileType, FileType, 0, 1),
256 DFGIMAP(File, FileId, FileId),
257 DFGIMAP(File, FileVersion, FileVersion),
258 DFGIMAP(File, FileFGroupId, FilegroupId),
259 DFGIMAP(File, FileFGroupVersion, FilegroupVersion),
260 DFGIMAP(File, FileSizeHi, FileSizeHi),
261 DFGIMAP(File, FileSizeLo, FileSizeLo),
262 DFGIMAP(File, FileFreeExtents, FileFreeExtents),
267 const Uint32 DictFilegroupInfo::FileMappingSize =
268 sizeof(DictFilegroupInfo::FileMapping) /
272 DictFilegroupInfo::Filegroup::init(){
273 memset(FilegroupName, 0,
sizeof(FilegroupName));
276 FilegroupVersion = ~0;
279 TS_LogfileGroupId = ~0;
280 TS_LogfileGroupVersion = ~0;
281 TS_DataGrow.GrowLimit = 0;
282 TS_DataGrow.GrowSizeHi = 0;
283 TS_DataGrow.GrowSizeLo = 0;
284 memset(TS_DataGrow.GrowPattern, 0,
sizeof(TS_DataGrow.GrowPattern));
285 TS_DataGrow.GrowMaxSize = 0;
286 LF_UndoFreeWordsHi= 0;
287 LF_UndoFreeWordsLo= 0;
291 DictFilegroupInfo::File::init(){
292 memset(FileName, 0,
sizeof(FileName));
297 FilegroupVersion = ~0;
306 DictTabInfo::isBlobTableName(
const char*
name, Uint32* ptab_id, Uint32* pcol_no)
308 const char*
const prefix =
"NDB$BLOB_";
309 const char* s = strrchr(name, table_name_separator);
310 s = (s == NULL ? name : s + 1);
311 if (strncmp(s, prefix, strlen(prefix)) != 0)
315 for (i = 0, n = 0;
'0' <= s[
i] && s[
i] <=
'9'; i++)
316 n = 10 * n + (s[i] -
'0');
317 if (i == 0 || s[i] !=
'_')
319 const uint tab_id =
n;
321 for (i = 0, n = 0;
'0' <= s[
i] && s[
i] <=
'9'; i++)
322 n = 10 * n + (s[i] -
'0');
323 if (i == 0 || s[i] != 0)
325 const uint col_no =
n;
339 DHMIMAPS(
HashMap, HashMapName, HashMapName, 0, MAX_TAB_NAME_SIZE),
340 DHMIMAP2(
HashMap, HashMapBuckets, HashMapBuckets, 0, 256),
341 DTIMAP(
HashMap, HashMapObjectId, HashMapObjectId),
342 DTIMAP(
HashMap, HashMapVersion, HashMapVersion),
347 DHMIMAPB(
HashMap, HashMapValues, HashMapValues, 0, 256*2, HashMapBuckets)
351 const Uint32 DictHashMapInfo::MappingSize =
356 DictHashMapInfo::HashMap::init()
358 bzero(
this,
sizeof(*
this));