This section provides information about the
NdbDictionary class, which stores
meta-information about NDB database objects, such
as tables, columns, and indexes.
While the preferred method of database object creation and deletion
is through the MySQL Server, NdbDictionary also
permits the developer to perform these tasks through the NDB API.
- Parent class
None
- Child classes
-
For the numeric equivalents to enumerations of
NdbDictionarysubclasses, see the file/storage/ndb/include/ndbapi/NdbDictionary.hppin the NDB Cluster source tree. - Description
-
This is a data dictionary class that supports enquiries about tables, columns, and indexes. It also provides ways to define these database objects and to remove them. Both sorts of functionality are supplied using inner classes that model these objects. These include the following inner classes:
Tablefor working with tablesColumnfor creating table columnsIndexfor working with secondary indexesDictionaryfor creating database objects and making schema enquiriesEventfor working with events in the cluster.
Additional
Objectsubclasses model the tablespaces, log file groups, data files, and undo files required for working with NDB Cluster Disk Data table, as well as with foreign key constraints.Tables and indexes created using
NdbDictionarycannot be viewed from the MySQL Server.Dropping indexes through the NDB API that were created originally from an NDB Cluster causes inconsistencies. It is possible that a table from which one or more indexes have been dropped using the NDB API will no longer be usable by MySQL following such operations. In this event, the table must be dropped, and then re-created using MySQL to make it accessible to MySQL once more.
- Methods
-
NdbDictionaryitself has no public instance methods, only static methods that are used for working withNdbRecordobjects. Operations not usingNdbRecordare accomplished by means ofNdbDictionarysubclass instance methods. The following table lists the public methods ofNdbDictionaryand the purpose or use of each method:Table 2.37 NdbDictionary class methods and descriptions
Name Description getEmptyBitmask()Returns an empty column presence bitmask which can be used with NdbRecordgetFirstAttrId()Get the first attribute ID specified by a given NdbRecordobjectgetRecordIndexName()Gets the name of the index object referred to by an NdbRecord getRecordRowLength()Get the number of bytes needed to store one row of data using a given NdbRecordgetRecordTableName()Gets the name of the table object referred to by an NdbRecord getRecordType()Gets the RecordType of an NdbRecord getValuePtr()Returns a pointer to the beginning of stored data specified by attribute ID, using NdbRecordisNull()Show whether the null bit for a column is true or false setNull()Set a column's null bit
- Types
-
NdbDictionary defines two data structures, listed here:
Abstract
This section provides information about the
AutoGrowSpecification data structure.
- Parent class
- Description
The
AutoGrowSpecificationis a data structure defined in theNdbDictionaryclass, and is used as a parameter to or return value of some of the methods of theTablespaceandLogfileGroupclasses.- Members
-
AutoGrowSpecificationhas the members shown in the following table:Table 2.38 NdbDictionary::AutoGrowSpecification data structure member names and descriptions
Name Description min_free??? max_size??? file_size??? filename_pattern???
- Description
Get the first attribute ID specified by an
NdbRecordobject. Returnsfalseif no attribute ID is specified.- Signature
static bool getFirstAttrId ( const NdbRecord* record, Uint32& firstAttrId )- Parameters
A pointer to an
NdbRecordand a reference to the attribute (firstAttrID).- Return value
Boolean
false, when no attribute ID can be obtained.
- Description
Get the next attribute ID specified by an
NdbRecordobject following the attribute ID passed in. Returnsfalsewhen there are no more attribute IDs to be returned.- Signature
static bool getNextAttrId ( const NdbRecord* record, Uint32& attrId )- Parameters
A pointer to an
NdbRecordand a reference to an attribute ID.- Return value
Boolean
false, when no attribute ID can be obtained.
- Description
Get the offset of the given attribute ID's null bit from the start of the
NdbRecordrow. Returnsfalseif the attribute ID is not present.- Signature
static bool getNullBitOffset ( const NdbRecord* record, Uint32 attrId, Uint32& bytes, Uint32& bit )- Parameters
An
NdbRecordrecordin which to get the null bit offset of the given attribute ID (attrId). The offset is expressed as a number of bytes (bytes) plus a number of bits within the last byte (bit).- Return value
Boolean
false, if the attribute with the given ID is not present.
- Description
Get the offset of the given attribute ID's storage from the start of the
NdbRecordrow. Returnsfalseif the attribute id is not present- Signature
static bool getOffset ( const NdbRecord* record, Uint32 attrId, Uint32& offset )- Parameters
The
offsetof the given attribute ID's storage from the start of theNdbRecordrow.- Return value
Boolean
false, if no attribute ID can be found.
- Description
Get the name of the
Indexobject that theNdbRecordrefers to.- Signature
static const char* getRecordIndexName ( const NdbRecord* record )- Parameters
A pointer to the
NdbRecordfor which to get the name.- Return value
The name, if any. Otherwise, or if the
NdbRecordobject is not of theIndexAccesstype, this method returns null.
- Description
Return the name of the table object that the
NdbRecordrefers to. This method returns null if the record is not aTableAccess.- Signature
static const char* getRecordTableName ( const NdbRecord* record )- Parameters
The
record(NdbRecordobject) for which to get the table name.- Return value
The name of the table, or null if the
NdbRecordobject' type is notTableAccess.
- Description
Returns a pointer to the beginning of stored data specified by attribute ID, by looking up the offset of the column stored in the NdbRecord object and returning the sum of the row position and the offset.
- Signature
-
This method provides both row-const and non-row-const versions:
static const char* getValuePtr ( const NdbRecord* record, const char* row, Uint32 attrId ) static char* getValuePtr ( const NdbRecord* record, char* row, Uint32 attrId ) - Parameters
A pointer to an
NdbRecordobject describing the row format, a pointer to the start of the row data (constin the const version of this method), and the attribute ID of the column,- Return value
A pointer to the start of the attribute in the row. This is null if the attribute is not part of the
NdbRecorddefinition.
- Description
Indicate whether the null bit for the given column is set to
trueorfalse. The location of the null bit in relation to the row pointer is obtained from the passedNdbRecordobject. If the column is not nullable, or if the column is not part of theNdbRecorddefinition, the method returnsfalse.- Signature
static bool isNull ( const NdbRecord* record, const char* row, Uint32 attrId )- Parameters
A pointer to an
NdbRecordobject describing the row format, a pointer to the start of the row data, and the attribute ID of the column to check.- Return value
Boolean
trueif the attribute ID exists in thisNdbRecord, is nullable, and this row's null bit is set; otherwise, Booleanfalse.
This section provides information about the
RecordSpecification structure.
- Parent class
- Description
This structure is used to specify columns and range offsets when creating
NdbRecordobjects.- Members
-
The elements making up this structure are shown in the following table:
Table 2.39 NdbDictionary::RecordSpecification attributes, with types and descriptions
Name Type Description columnColumnThe column described by this entry (the column's maximum size defines the field size for the row). Even when creating an NdbRecordfor an index, this must point to a column obtained from the underlying table, and not from the index itself.offsetUint32The offset of data from the beginning of a row. For reading blobs, the blob handle ( NdbBlob), rather than the actual blob data, is written into the row. This means that there must be at leastsizeof(NdbBlob*)must be available in the row.nullbit_byte_offsetUint32The offset from the beginning of the row of the byte containing the NULLbit.nullbit_bit_in_byteUint32NULLbit (0-7).nullbit_byte_offsetandnullbit_bit_in_byteare not used for non-nullable columns.For more information, see Section 2.3.22, “The NdbRecord Interface”.
- Description
Set the null bit for the given column to the supplied value. The offset for the null bit is obtained from the passed
NdbRecordobject. If the attribute ID is not part of theNdbRecord, or if it is not nullable, this method returns an error (-1).- Signature
static int setNull ( const NdbRecord* record, char* row, Uint32 attrId, bool value )- Parameters
A pointer to the
record(NdbRecordobject) describing the row format; a pointer to the start of therowdata; the attribute ID of the column (attrId); and thevalueto set the null bit to (trueorfalse).- Return value
Returns 0 on success; returns -1 if the
attrIdis not part of therecord, or is not nullable.