MySQL 5.6.14 Source Code Document
|
Represents a column in an NDB Cluster table. More...
#include <NdbDictionary.hpp>
Public Types | |
enum | Type { Undefined = NDB_TYPE_UNDEFINED, Tinyint = NDB_TYPE_TINYINT, Tinyunsigned = NDB_TYPE_TINYUNSIGNED, Smallint = NDB_TYPE_SMALLINT, Smallunsigned = NDB_TYPE_SMALLUNSIGNED, Mediumint = NDB_TYPE_MEDIUMINT, Mediumunsigned = NDB_TYPE_MEDIUMUNSIGNED, Int = NDB_TYPE_INT, Unsigned = NDB_TYPE_UNSIGNED, Bigint = NDB_TYPE_BIGINT, Bigunsigned = NDB_TYPE_BIGUNSIGNED, Float = NDB_TYPE_FLOAT, Double = NDB_TYPE_DOUBLE, Olddecimal = NDB_TYPE_OLDDECIMAL, Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED, Decimal = NDB_TYPE_DECIMAL, Decimalunsigned = NDB_TYPE_DECIMALUNSIGNED, Char = NDB_TYPE_CHAR, Varchar = NDB_TYPE_VARCHAR, Binary = NDB_TYPE_BINARY, Varbinary = NDB_TYPE_VARBINARY, Datetime = NDB_TYPE_DATETIME, Date = NDB_TYPE_DATE, Blob = NDB_TYPE_BLOB, Text = NDB_TYPE_TEXT, Bit = NDB_TYPE_BIT, Longvarchar = NDB_TYPE_LONGVARCHAR, Longvarbinary = NDB_TYPE_LONGVARBINARY, Time = NDB_TYPE_TIME, Year = NDB_TYPE_YEAR, Timestamp = NDB_TYPE_TIMESTAMP } |
enum | ArrayType { ArrayTypeFixed = NDB_ARRAYTYPE_FIXED, ArrayTypeShortVar = NDB_ARRAYTYPE_SHORT_VAR, ArrayTypeMediumVar = NDB_ARRAYTYPE_MEDIUM_VAR } |
enum | StorageType { StorageTypeMemory = NDB_STORAGETYPE_MEMORY, StorageTypeDisk = NDB_STORAGETYPE_DISK, StorageTypeDefault = NDB_STORAGETYPE_DEFAULT } |
Public Member Functions | |
int | setDefaultValue (const char *) |
int | setDefaultValue (const void *buf, unsigned int len) |
const void * | getDefaultValue (unsigned int *len=0) const |
const Table * | getBlobTable () const |
void | setAutoIncrement (bool) |
bool | getAutoIncrement () const |
void | setAutoIncrementInitialValue (Uint64 val) |
int | getSizeInBytes () const |
int | getBlobVersion () const |
void | setBlobVersion (int blobVersion) |
int | isBindable (const Column &) const |
General | |
const char * | getName () const |
bool | getNullable () const |
bool | getPrimaryKey () const |
int | getColumnNo () const |
int | getAttrId () const |
bool | equal (const Column &column) const |
Get Type Specifiers | |
Type | getType () const |
int | getPrecision () const |
int | getScale () const |
int | getLength () const |
CHARSET_INFO * | getCharset () const |
int | getCharsetNumber () const |
int | getInlineSize () const |
int | getPartSize () const |
int | getStripeSize () const |
int | getSize () const |
bool | getPartitionKey () const |
bool | getDistributionKey () const |
ArrayType | getArrayType () const |
StorageType | getStorageType () const |
bool | getDynamic () const |
bool | getIndexSourced () const |
Column creation | |
These operations should normally not be performed in an NbdApi program as results will not be visable in the MySQL Server | |
Column (const char *name="") | |
Column (const Column &column) | |
~Column () | |
int | setName (const char *name) |
void | setNullable (bool) |
void | setPrimaryKey (bool) |
void | setType (Type type) |
void | setPrecision (int) |
void | setScale (int) |
void | setLength (int length) |
void | setCharset (CHARSET_INFO *cs) |
void | setInlineSize (int size) |
void | setPartSize (int size) |
void | setStripeSize (int size) |
void | setPartitionKey (bool enable) |
void | setDistributionKey (bool enable) |
void | setArrayType (ArrayType type) |
void | setStorageType (StorageType type) |
void | setDynamic (bool) |
Static Public Attributes | |
static const Column * | FRAGMENT = 0 |
static const Column * | FRAGMENT_FIXED_MEMORY = 0 |
static const Column * | FRAGMENT_VARSIZED_MEMORY = 0 |
static const Column * | ROW_COUNT = 0 |
static const Column * | COMMIT_COUNT = 0 |
static const Column * | ROW_SIZE = 0 |
static const Column * | RANGE_NO = 0 |
static const Column * | DISK_REF = 0 |
static const Column * | RECORDS_IN_RANGE = 0 |
static const Column * | ROWID = 0 |
static const Column * | ROW_GCI = 0 |
static const Column * | ROW_GCI64 = 0 |
static const Column * | ROW_AUTHOR = 0 |
static const Column * | ANY_VALUE = 0 |
static const Column * | COPY_ROWID = 0 |
static const Column * | LOCK_REF = 0 |
static const Column * | OP_ID = 0 |
static const Column * | OPTIMIZE = 0 |
static const Column * | FRAGMENT_EXTENT_SPACE = 0 |
static const Column * | FRAGMENT_FREE_EXTENT_SPACE = 0 |
Friends | |
class | NdbRecAttr |
class | NdbColumnImpl |
Represents a column in an NDB Cluster table.
Each column has a type. The type of a column is determined by a number of type specifiers. The type specifiers are:
Types in general correspond to MySQL types and their variants. Data formats are same as in MySQL. NDB API provides no support for constructing such formats. NDB kernel checks them however.
Definition at line 226 of file NdbDictionary.hpp.
The builtin column types
Undefined |
Undefined. |
Tinyint |
8 bit. 1 byte signed integer, can be used in array |
Tinyunsigned |
8 bit. 1 byte unsigned integer, can be used in array |
Smallint |
16 bit. 2 byte signed integer, can be used in array |
Smallunsigned |
16 bit. 2 byte unsigned integer, can be used in array |
Mediumint |
24 bit. 3 byte signed integer, can be used in array |
Mediumunsigned |
24 bit. 3 byte unsigned integer, can be used in array |
Int |
32 bit. 4 byte signed integer, can be used in array |
Unsigned |
32 bit. 4 byte unsigned integer, can be used in array |
Bigint |
64 bit. 8 byte signed integer, can be used in array |
Bigunsigned |
64 Bit. 8 byte signed integer, can be used in array |
Float |
32-bit float. 4 bytes float, can be used in array |
Double |
64-bit float. 8 byte float, can be used in array |
Olddecimal |
MySQL < 5.0 signed decimal, Precision, Scale. |
Decimal |
MySQL >= 5.0 signed decimal, Precision, Scale. |
Char |
Len. A fixed array of 1-byte chars. |
Varchar |
Length bytes: 1, Max: 255. |
Binary |
Len. |
Varbinary |
Length bytes: 1, Max: 255. |
Datetime |
Precision down to 1 sec (sizeof(Datetime) == 8 bytes ) |
Date |
Precision down to 1 day(sizeof(Date) == 4 bytes ) |
Blob |
Binary large object (see NdbBlob) |
Text |
Text blob. |
Bit |
Bit, length specifies no of bits. |
Longvarchar |
Length bytes: 2, little-endian. |
Longvarbinary |
Length bytes: 2, little-endian. |
Time |
Time without date. |
Year |
Year 1901-2155 (1 byte) |
Timestamp |
Unix time. |
Definition at line 231 of file NdbDictionary.hpp.
NdbDictionary::Column::Column | ( | const char * | name = "" | ) |
Constructor
name | Name of column |
Definition at line 162 of file NdbDictionary.cpp.
NdbDictionary::Column::Column | ( | const Column & | column | ) |
Copy constructor
column | Column to be copied |
Definition at line 168 of file NdbDictionary.cpp.
bool NdbDictionary::Column::equal | ( | const Column & | column | ) | const |
Check if column is equal to some other column
column | Column to compare with |
Definition at line 400 of file NdbDictionary.cpp.
CHARSET_INFO * NdbDictionary::Column::getCharset | ( | ) | const |
For Char or Varchar or Text, get MySQL CHARSET_INFO. This specifies both character set and collation. See get_charset() etc in MySQL. (The cs is not "const" in MySQL).
Definition at line 257 of file NdbDictionary.cpp.
int NdbDictionary::Column::getCharsetNumber | ( | ) | const |
Returns mysql's internal number for the column's character set.
Definition at line 263 of file NdbDictionary.cpp.
int NdbDictionary::Column::getColumnNo | ( | ) | const |
Get number of column (horizontal position within table)
Definition at line 390 of file NdbDictionary.cpp.
bool NdbDictionary::Column::getDynamic | ( | ) | const |
Get if the column is dynamic (NULL values not stored)
Definition at line 452 of file NdbDictionary.cpp.
bool NdbDictionary::Column::getIndexSourced | ( | ) | const |
Determine if the column is defined relative to an Index This affects the meaning of the attrId, column no and primary key,
Definition at line 457 of file NdbDictionary.cpp.
int NdbDictionary::Column::getInlineSize | ( | ) | const |
For blob, get "inline size" i.e. number of initial bytes to store in table's blob attribute.
Definition at line 269 of file NdbDictionary.cpp.
int NdbDictionary::Column::getLength | ( | ) | const |
Get length for column Array length for column or max length for variable length arrays.
Definition at line 240 of file NdbDictionary.cpp.
const char * NdbDictionary::Column::getName | ( | ) | const |
Get name of column
Definition at line 200 of file NdbDictionary.cpp.
bool NdbDictionary::Column::getNullable | ( | ) | const |
Get if the column is nullable or not
Definition at line 309 of file NdbDictionary.cpp.
bool NdbDictionary::Column::getPartitionKey | ( | ) | const |
Check if column is part of partition key
A partition key is a set of attributes which are used to distribute the tuples onto the NDB nodes. The partition key uses the NDB Cluster hashing function.
An example where this is useful is TPC-C where it might be good to use the warehouse id and district id as the partition key. This would place all data for a specific district and warehouse in the same database node.
Locally in the fragments the full primary key will still be used with the hashing algorithm.
Definition at line 329 of file NdbDictionary.cpp.
int NdbDictionary::Column::getPartSize | ( | ) | const |
For blob, get "part size" i.e. number of bytes to store in each tuple of the "blob table". Can be set to zero to omit parts and to allow only inline bytes ("tinyblob").
Definition at line 281 of file NdbDictionary.cpp.
int NdbDictionary::Column::getPrecision | ( | ) | const |
Get precision of column.
Definition at line 220 of file NdbDictionary.cpp.
bool NdbDictionary::Column::getPrimaryKey | ( | ) | const |
Check if column is part of primary key
Definition at line 319 of file NdbDictionary.cpp.
int NdbDictionary::Column::getScale | ( | ) | const |
Get scale of column.
Definition at line 230 of file NdbDictionary.cpp.
int NdbDictionary::Column::getSize | ( | ) | const |
Get size of element
Definition at line 299 of file NdbDictionary.cpp.
int NdbDictionary::Column::getStripeSize | ( | ) | const |
For blob, set or get "stripe size" i.e. number of consecutive parts to store in each node group.
Definition at line 293 of file NdbDictionary.cpp.
NdbDictionary::Column::Type NdbDictionary::Column::getType | ( | ) | const |
Get type of column
Definition at line 210 of file NdbDictionary.cpp.
int NdbDictionary::Column::isBindable | ( | const Column & | col | ) | const |
0 = yes -1 = no
Definition at line 462 of file NdbDictionary.cpp.
void NdbDictionary::Column::setCharset | ( | CHARSET_INFO * | cs | ) |
For Char or Varchar or Text, get MySQL CHARSET_INFO. This specifies both character set and collation. See get_charset() etc in MySQL. (The cs is not "const" in MySQL).
Definition at line 251 of file NdbDictionary.cpp.
int NdbDictionary::Column::setDefaultValue | ( | const char * | defaultValue | ) |
void NdbDictionary::Column::setDynamic | ( | bool | val | ) |
Set whether column is dynamic.
Definition at line 447 of file NdbDictionary.cpp.
void NdbDictionary::Column::setInlineSize | ( | int | size | ) |
For blob, set "inline size" i.e. number of initial bytes to store in table's blob attribute. This part is normally in main memory. It can not currently be indexed.
Definition at line 245 of file NdbDictionary.cpp.
void NdbDictionary::Column::setLength | ( | int | length | ) |
Set length for column Array length for column or max length for variable length arrays.
Definition at line 235 of file NdbDictionary.cpp.
int NdbDictionary::Column::setName | ( | const char * | name | ) |
Set name of column
name | Name of the column |
Definition at line 195 of file NdbDictionary.cpp.
void NdbDictionary::Column::setNullable | ( | bool | val | ) |
Set whether column is nullable or not
Definition at line 304 of file NdbDictionary.cpp.
void NdbDictionary::Column::setPartitionKey | ( | bool | enable | ) |
Set partition key
enable | If set to true, then the column will be part of the partition key. |
Definition at line 324 of file NdbDictionary.cpp.
void NdbDictionary::Column::setPartSize | ( | int | size | ) |
For blob, set "part size" i.e. number of bytes to store in each tuple of the "blob table". Can be set to zero to omit parts and to allow only inline bytes ("tinyblob").
Definition at line 275 of file NdbDictionary.cpp.
void NdbDictionary::Column::setPrecision | ( | int | val | ) |
Set precision of column.
Definition at line 215 of file NdbDictionary.cpp.
void NdbDictionary::Column::setPrimaryKey | ( | bool | val | ) |
Set that column is part of primary key
Definition at line 314 of file NdbDictionary.cpp.
void NdbDictionary::Column::setScale | ( | int | val | ) |
Set scale of column.
Definition at line 225 of file NdbDictionary.cpp.
void NdbDictionary::Column::setStripeSize | ( | int | size | ) |
For blob, set "stripe size" i.e. number of consecutive parts to store in a fragment, before moving to another (random) fragment.
Striping may improve performance for large blobs since blob part operations are done in parallel. Optimal stripe size depends on the transport e.g. tcp/ip.
Example: Given part size 2048 bytes, set stripe size 8. This assigns i/o in 16k chunks to each fragment.
Blobs V1 required non-zero stripe size. Blobs V2 (created in version >= 5.1.x) have following behaviour:
Default stripe size is zero, which means no striping and also that blob part data is stored in the same node group as the primary table row. This is done by giving blob parts table same partition key as the primary table.
Definition at line 287 of file NdbDictionary.cpp.
void NdbDictionary::Column::setType | ( | Type | type | ) |
Set type of column
type | Type of column |
Definition at line 205 of file NdbDictionary.cpp.