📄 dicttabinfo.hpp
字号:
/* Copyright (C) 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef DICT_TAB_INFO_HPP#define DICT_TAB_INFO_HPP#include "SignalData.hpp"#include <AttributeDescriptor.hpp>#include <SimpleProperties.hpp>#include <ndb_limits.h>#include <trigger_definitions.h>#include <NdbSqlUtil.hpp>#ifndef my_decimal_h// sql/my_decimal.h requires many more sql/*.h new to ndb// for now, copy the bit we need TODO proper fix#define DECIMAL_MAX_LENGTH ((8 * 9) - 8)#ifndef NOT_FIXED_DEC#define NOT_FIXED_DEC 31#endifC_MODE_STARTextern int decimal_bin_size(int, int);C_MODE_ENDinline int my_decimal_get_binary_size(uint precision, uint scale){ return decimal_bin_size((int)precision, (int)scale);}#endif#define DTIMAP(x, y, z) \ { DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 }#define DTIMAP2(x, y, z, u, v) \ { DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, u, v, 0 }#define DTIMAPS(x, y, z, u, v) \ { DictTabInfo::y, offsetof(x, z), SimpleProperties::StringValue, u, v, 0 }#define DTIMAPB(x, y, z, u, v, l) \ { DictTabInfo::y, offsetof(x, z), SimpleProperties::BinaryValue, u, v, \ offsetof(x, l) }#define DTIBREAK(x) \ { DictTabInfo::x, 0, SimpleProperties::InvalidValue, 0, 0, 0 }class DictTabInfo { /** * Sender(s) / Reciver(s) */ // Blocks friend class Backup; friend class Dbdict; friend class Ndbcntr; friend class Trix; friend class DbUtil; // API friend class NdbSchemaOp; /** * For printing */ friend bool printDICTTABINFO(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo);public: enum RequestType { CreateTableFromAPI = 1, AddTableFromDict = 2, // Between DICT's CopyTable = 3, // Between DICT's ReadTableFromDiskSR = 4, // Local in DICT GetTabInfoConf = 5, AlterTableFromAPI = 6 }; enum KeyValues { TableName = 1, // String, Mandatory TableId = 2, //Mandatory between DICT's otherwise not allowed TableVersion = 3, //Mandatory between DICT's otherwise not allowed TableLoggedFlag = 4, //Default Logged NoOfKeyAttr = 5, //Default 1 NoOfAttributes = 6, //Mandatory NoOfNullable = 7, //Deafult 0 NoOfVariable = 8, //Default 0 TableKValue = 9, //Default 6 MinLoadFactor = 10, //Default 70 MaxLoadFactor = 11, //Default 80 KeyLength = 12, //Default 1 (No of words in primary key) FragmentTypeVal = 13, //Default AllNodesSmallTable TableTypeVal = 18, //Default TableType::UserTable PrimaryTable = 19, //Mandatory for index otherwise RNIL PrimaryTableId = 20, //ditto IndexState = 21, InsertTriggerId = 22, UpdateTriggerId = 23, DeleteTriggerId = 24, CustomTriggerId = 25, FrmLen = 26, FrmData = 27, FragmentCount = 128, // No of fragments in table (!fragment replicas) FragmentDataLen = 129, FragmentData = 130, // CREATE_FRAGMENTATION reply TableEnd = 999, AttributeName = 1000, // String, Mandatory AttributeId = 1001, //Mandatory between DICT's otherwise not allowed AttributeType = 1002, //for osu 4.1->5.0.x AttributeSize = 1003, //Default DictTabInfo::a32Bit AttributeArraySize = 1005, //Default 1 AttributeKeyFlag = 1006, //Default noKey AttributeStorage = 1007, //Default MainMemory AttributeNullableFlag = 1008, //Default NotNullable AttributeDKey = 1010, //Default NotDKey AttributeExtType = 1013, //Default ExtUnsigned AttributeExtPrecision = 1014, //Default 0 AttributeExtScale = 1015, //Default 0 AttributeExtLength = 1016, //Default 0 AttributeAutoIncrement = 1017, //Default false AttributeDefaultValue = 1018, //Default value (printable string) AttributeEnd = 1999 // }; // ---------------------------------------------------------------------- // Part of the protocol is that we only transfer parameters which do not // have a default value. Thus the default values are part of the protocol. // ---------------------------------------------------------------------- // FragmentType constants enum FragmentType { AllNodesSmallTable = 0, AllNodesMediumTable = 1, AllNodesLargeTable = 2, SingleFragment = 3 }; // TableType constants + objects enum TableType { UndefTableType = 0, SystemTable = 1, UserTable = 2, UniqueHashIndex = 3, HashIndex = 4, UniqueOrderedIndex = 5, OrderedIndex = 6, // constant 10 hardcoded in Dbdict.cpp HashIndexTrigger = 10 + TriggerType::SECONDARY_INDEX, SubscriptionTrigger = 10 + TriggerType::SUBSCRIPTION, ReadOnlyConstraint = 10 + TriggerType::READ_ONLY_CONSTRAINT, IndexTrigger = 10 + TriggerType::ORDERED_INDEX }; static inline bool isTable(int tableType) { return tableType == SystemTable || tableType == UserTable; } static inline bool isIndex(int tableType) { return tableType == UniqueHashIndex || tableType == HashIndex || tableType == UniqueOrderedIndex || tableType == OrderedIndex; } static inline bool isUniqueIndex(int tableType) { return tableType == UniqueHashIndex || tableType == UniqueOrderedIndex; } static inline bool isNonUniqueIndex(int tableType) { return tableType == HashIndex || tableType == OrderedIndex; } static inline bool isHashIndex(int tableType) { return tableType == UniqueHashIndex || tableType == HashIndex; } static inline bool isOrderedIndex(int tableType) { return tableType == UniqueOrderedIndex || tableType == OrderedIndex; } // Object state for translating from/to API enum ObjectState { StateUndefined = 0, StateOffline = 1, StateBuilding = 2, StateDropping = 3, StateOnline = 4, StateBackup = 5, StateBroken = 9 }; // Object store for translating from/to API enum ObjectStore { StoreUndefined = 0, StoreTemporary = 1, StorePermanent = 2 }; // AttributeSize constants STATIC_CONST( aBit = 0 ); STATIC_CONST( an8Bit = 3 ); STATIC_CONST( a16Bit = 4 ); STATIC_CONST( a32Bit = 5 ); STATIC_CONST( a64Bit = 6 ); STATIC_CONST( a128Bit = 7 ); // Table data interpretation struct Table { char TableName[MAX_TAB_NAME_SIZE]; Uint32 TableId; char PrimaryTable[MAX_TAB_NAME_SIZE]; // Only used when "index" Uint32 PrimaryTableId; Uint32 TableLoggedFlag; Uint32 NoOfKeyAttr; Uint32 NoOfAttributes; Uint32 NoOfNullable; Uint32 NoOfVariable; Uint32 TableKValue; Uint32 MinLoadFactor; Uint32 MaxLoadFactor; Uint32 KeyLength; Uint32 FragmentType; Uint32 TableStorage; Uint32 TableType; Uint32 TableVersion; Uint32 IndexState; Uint32 InsertTriggerId; Uint32 UpdateTriggerId; Uint32 DeleteTriggerId;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -