📄 ndbschemaop.hpp
字号:
int aMemoryType = 1, bool aStoredTable = true); /** * This is the old function declaration, don't use. * * @deprecated do not use! */#ifndef NDB_WIN32 inline int createTable( const char* aTableName, Uint32 aTableSize, KeyType aTupleKey, int aNrOfPages, FragmentType aFragmentType, int aKValue, int aMinLoadFactor, int aMaxLoadFactor, int aMemoryType, int aStoredTable){ return createTable(aTableName, aTableSize, aTupleKey, aNrOfPages, aFragmentType, aKValue, aMinLoadFactor, aMaxLoadFactor, aMemoryType, (aStoredTable == 1 ? true : false)); }#endif /** * Add a new attribute to a database table. * * Attributes can only be added to a table in the same transaction * as the transaction creating the table. * * @note The NdbSchemaCon transaction should be closed with * Ndb::closeSchemaTransaction, even if this method fails. * * Example creating an unsigned int attribute belonging to the primary key * of the table it is created in: * @code * MySchemaOp->createAttribute("Attr1", // Attribute name * TupleKey, // Belongs to primary key * 32, // 32 bits * 1, // Not an array attribute * UnSigned, // Unsigned type * ); * @endcode * * Example creating a string attribute belonging to the primary key * of the table it is created in: * @code * MySchemaOp->createAttribute("Attr1", // Attribute name * TupleKey, // Belongs to primary key * 8, // Each character is 8 bits * 12, // Max 12 chars in string * String, // Attribute if of type string * ); * @endcode * * A <em>distribution key</em> is a set of attributes which are used * to distribute the tuples onto the NDB nodes. * A <em>distribution group</em> is a part (currently 16 bits) * of an attribute used to distribute the tuples onto the NDB nodes. * The distribution key uses the NDB Cluster hashing function, * while the distribution group uses a simpler function. * * @param aAttrName Attribute name. Should not be NULL. * @param aTupleKey This parameter specifies whether the * attribute is part of the primary key or not. * Floats are not allowed in the primary key. * <br> * Legal values: NoKey, TupleKey * @param aAttrSize Specifies the size of the elements of the * attribute. (An attribute can consist * of an array of elements.) * <br> * Legal values: 8, 16, 32, 64 and 128 bits. * @param aArraySize Size of array. * <br> * Legal values: * 0 = variable-sized array, * 1 = no array, and * 2- = fixed size array. * <br> * <em> * Variable-sized array attributes are * not yet supported. * </em> * <br> * There is no upper limit of the array size * for a single attribute. * @param aAttrType The attribute type. * This is only of interest if calculations are * made within NDB. * <br> * Legal values: UnSigned, Signed, Float, String * @param aStorageMode Main memory based or disk based attribute.<br> * Legal values: MMBased, DiskBased * <br> * <em> * Disk-based attributes are not yet supported. * </em> * @param nullable Set to true if NULL is a correct value for * the attribute. * <br> * Legal values: true, false * @param aStType Obsolete since wl-2066 * @param aDistributionKey Sometimes it is preferable to use a subset * of the primary key as the distribution key. * An example is TPC-C where it might be * good to use the warehouse id and district id * as the distribution key. * <br> * Locally in the fragments the full primary key * will still be used with the hashing algorithm. * Set to 1 if this attribute is part of the * distribution key. * All distribution key attributes must be * defined before * any other attributes are defined. * @param aDistributionGroup In other applications it is desirable to use * only a part of an attribute to create the * distribution key. * This is applicable for some telecom * applications. * <br> * In these situations one must provide how many * bits of the attribute that is to * be used as the distribution hash value. * <br> * This provides some control to the * application of the distribution. * It still needs to be part of a primary key * the attribute and must be defined as the * first attribute. * @param aDistributionGroupNoOfBits * Number of bits to use of the * distribution group attribute in the * distribution hash value. * <br> * Currently, only 16 bits is supported. It will * always be the last 16 bits in the attribute * which is used for the distribution group. * @param aAutoIncrement Set to autoincrement attribute. * @param aDefaultValue Set a default value of attribute. * * @return Returns 0 when successful and returns -1 otherwise. ****************************************************************************/ int createAttribute(const char* aAttrName, KeyType aTupleKey = NoKey, int aAttrSize = 32, int aArraySize = 1, AttrType aAttrType = UnSigned, StorageMode aStorageMode = MMBased, bool nullable = false, int aStType= 0, // obsolete int aDistributionKey = 0, int aDistributionGroup = 0, int aDistributionGroupNoOfBits = 16, bool aAutoIncrement = false, const char* aDefaultValue = 0); /** * @deprecated do not use! */ int createAttribute(const char* aAttrName, KeyType aTupleKey, int aAttrSize, int aArraySize, AttrType aAttrType, StorageMode aStorageMode, NullAttributeType aNullAttr, int aStType, // obsolete int aDistributionKey = 0, int aDistributionGroup = 0, int aDistributionGroupNoOfBits = 16){ return createAttribute(aAttrName, aTupleKey, aAttrSize, aArraySize, aAttrType, aStorageMode, aNullAttr == NullAttribute, aStType, aDistributionKey, aDistributionGroup, aDistributionGroupNoOfBits); } const NdbError & getNdbError() const;protected:/***************************************************************************** * These are the methods used to create and delete the NdbOperation objects. ****************************************************************************/ NdbSchemaOp(Ndb* aNdb); ~NdbSchemaOp(); /****************************************************************************** * These methods are service routines used by the other NDBAPI classes. *****************************************************************************/ void release(); // Release all memory connected // to the operations object. /**************************************************************************** * The methods below is the execution part of the NdbSchemaOp class. *****************************************************************************/ int sendRec(); int sendSignals(Uint32 aNodeId, bool HaveMutex); int init(NdbSchemaCon* aSchemaCon); /************************************************************************** * These are the private variables that are defined in the operation * objects. **************************************************************************/ Ndb* theNdb; // Point back to the Ndb object. NdbSchemaCon* theSchemaCon; // Point back to the connection object. class NdbDictionary::Table * m_currentTable;};/** * Get old attribute type from new type * * NOTE! attrType is deprecated, use getType instead! * * @return Type of attribute: { Signed, UnSigned, Float,a String } */inline AttrType convertColumnTypeToAttrType(NdbDictionary::Column::Type _type){ switch(_type){ case NdbDictionary::Column::Bigint: case NdbDictionary::Column::Int: return Signed; case NdbDictionary::Column::Bigunsigned: case NdbDictionary::Column::Unsigned: return UnSigned; case NdbDictionary::Column::Float: case NdbDictionary::Column::Olddecimal: case NdbDictionary::Column::Olddecimalunsigned: case NdbDictionary::Column::Decimal: case NdbDictionary::Column::Decimalunsigned: case NdbDictionary::Column::Double: return Float; case NdbDictionary::Column::Char: case NdbDictionary::Column::Varchar: case NdbDictionary::Column::Binary: case NdbDictionary::Column::Varbinary: return String; default: return NoAttrTypeDef; }}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -