[+/-]
Column
ConstructorColumn::getName()
Column::getNullable()
Column::getPrimaryKey()
Column::getColumnNo()
Column::equal()
Column::getType()
Column::getPrecision()
Column::getScale()
Column::getLength()
Column::getCharset()
Column::getInlineSize()
Column::getPartSize()
Column::getStripeSize()
Column::getSize()
Column::getPartitionKey()
Column::getArrayType()
Column::getStorageType()
Column::setName()
Column::setNullable()
Column::setPrimaryKey()
Column::setType()
Column::setPrecision()
Column::setScale()
Column::setLength()
Column::setCharset()
Column::setInlineSize
Column::setPartSize()
Column::setStripeSize()
Column::setPartitionKey()
Column::setArrayType()
Column::setStorageType()
Column::setDefaultValue()
Column::getDefaultValue()
Abstract
This section documents the public methods of the
Column
class.
The assignment (=
) operator is overloaded for
this class, so that it always performs a deep copy.
As with other database objects, Column
object
creation and attribute changes to existing columns done using
the NDB API are not visible from MySQL. For example, if you
change a column's datatype using
Column::setType()
, MySQL will regard the type
of column as being unchanged. The only exception to this rule
with regard to columns is that you can change the name of an
existing column using Column::setName()
.
Also remember that the NDB API handles column names in case-sensitive fashion.
Description.
You can create a new Column
or copy an
existing one using the class constructor.
A Column
created using the NDB API will
not be visible to a MySQL server.
The NDB API handles column names in case-sensitive fashion. For example, if you create a column named “myColumn”, you will not be able to access it later using “Mycolumn” for the name. You can reduce the possibility for error, by naming all columns consistently using only uppercase or only lowercase.
Signature.
You can create either a new instance of the
Column
class, or by copying an existing
Column
object. Both of these are shown
here.
Constructor for a new Column
:
Column
(
const char* name
= ""
)
Copy constructor:
Column
(
const Column& column
)
Parameters.
When creating a new instance of Column
, the
constructor takes a single argument, which is the name of the
new column to be created. The copy constructor also takes one
parameter — in this case, a reference to the
Column
instance to be copied.
Return value.
A Column
object.
Destructor.
The Column
class destructor takes no
arguments and None.
Description. This method returns the name of the column for which it is called.
The NDB API handles column names in case-sensitive fashion. For example, if you retrieve the name “myColumn” for a given column, attempting to access this column using “Mycolumn” for the name fails with an error such as Column is NULL or Table definition has undefined column. You can reduce the possibility for error, by naming all columns consistently using only uppercase or only lowercase.
Signature.
const char* getName ( void ) const
Parameters. None.
Return value. The name of the column.
Description.
This method is used to determine whether the column can be set
to NULL
.
Signature.
bool getNullable ( void ) const
Parameters. None.
Return value.
A Boolean value: true
if the column can be
set to NULL
, otherwise
false
.
Description. This method is used to determine whether the column is part of the table's primary key.
The NDB API handles column names in case-sensitive fashion; “myColumn” and “Mycolumn” are not considered to refer to the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase for column names by naming all columns consistently using only uppercase or only lowercase.
Signature.
bool getPrimaryKey ( void ) const
Parameters. None.
Return value.
A Boolean value: true
if the column is part
of the primary key of the table to which this column belongs,
otherwise false
.
Description. This method gets the number of a column — that is, its horizontal position within the table.
The NDB API handles column names in case-sensitive fashion, “myColumn” and “Mycolumn” are not considered to be the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase by naming all columns consistently using only uppercase or only lowercase.
Signature.
int getColumnNo ( void ) const
Parameters. None.
Return value. The column number as an integer.
Description.
This method is used to compare one Column
with another to determine whether the two
Column
objects are the same.
Signature.
bool equal
(
const Column& column
) const
Parameters.
equal()
takes a single parameter, a
reference to an instance of Column
.
Return value.
true
if the columns being compared are
equal, otherwise false
.
Description. This method gets the column's datatype.
The NDB API handles column names in case-sensitive fashion, “myColumn” and “Mycolumn” are not considered to be the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase by naming all columns consistently using only uppercase or only lowercase.
Signature.
Type getType ( void ) const
Parameters. None.
Return value.
The Type
(datatype) of the column. For a
list of possible values, see
Section 2.3.1.1.3, “Column::Type
”.
Description. This method gets the precision of a column.
This method is applicable to decimal columns only.
Signature.
int getPrecision ( void ) const
Parameters. None.
Return value.
The column's precision, as an integer. The precision is
defined as the number of significant digits; for more
information, see the discussion of the
DECIMAL
datatype in
Numeric Types, in the MySQL Manual.
Description. This method gets the scale used for a decimal column value.
This method is applicable to decimal columns only.
Signature.
int getScale ( void ) const
Parameters. None.
Return value.
The decimal column's scale, as an integer. The scale of a
decimal column represents the number of digits that can be
stored following the decimal point. It is possible for this
value to be 0
. For more information, see
the discussion of the DECIMAL
datatype in
Numeric Types, in the MySQL Manual.
Description. This method gets the length of a column. This is either the array length for the column or — for a variable length array — the maximum length.
The NDB API handles column names in case-sensitive fashion; “myColumn” and “Mycolumn” are not considered to refer to the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase for column names by naming all columns consistently using only uppercase or only lowercase.
Signature.
int getLength ( void ) const
Parameters. None.
Return value. The (maximum) array length of the column, as an integer.
Description. This gets the character set used by a text column.
This method is applicable only to columns whose
Type
value is Char
,
Varchar
, or Text
.
The NDB API handles column names in case-sensitive fashion; “myColumn” and “Mycolumn” are not considered to refer to the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase for column names by naming all columns consistently using only uppercase or only lowercase.
Signature.
CHARSET_INFO* getCharset ( void ) const
Parameters. None.
Return value.
A pointer to a CHARSET_INFO
structure
specifying both character set and collation. This is the same
as a MySQL MY_CHARSET_INFO
data structure;
for more information, see
mysql_get_character_set_info()
,in the MySQL
Manual.
Description. This method retrieves the inline size of a blob column — that is, the number of initial bytes to store in the table's blob attribute. This part is normally in main memory and can be indexed.
This method is applicable only to blob columns.
Signature.
int getInlineSize ( void ) const
Parameters. None.
Return value. The blob column's inline size, as an integer.
Description. This method is used to get the part size of a blob column — that is, the number of bytes that are stored in each tuple of the blob table.
This method is applicable to blob columns only.
Signature.
int getPartSize ( void ) const
Parameters. None.
Return value.
The column's part size, as an integer. In the case of a
Tinyblob
column, this value is
0
(that is, only inline bytes are stored).
Description. This method gets the stripe size of a blob column — that is, the number of consecutive parts to store in each node group.
Signature.
int getStripeSize ( void ) const
Parameters. None.
Return value. The column's stripe size, as an integer.
Description. This function is used to obtain the size of a column.
The NDB API handles column names in case-sensitive fashion; “myColumn” and “Mycolumn” are not considered to refer to the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase for column names by naming all columns consistently using only uppercase or only lowercase.
Signature.
int getSize ( void ) const
Parameters. None.
Return value. The column's size in bytes (an integer value).
Description. This method is used to check whether the column is part of the table's partitioning key.
A partitioning key is a set of
attributes used to distribute the tuples onto the
NDB
nodes. This key a hashing function
specific to the NDBCLUSTER
storage engine.
An example where this would be useful is an inventory tracking application involving multiple warehouses and regions, 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 to each fragment the full primary key will still be used with the hashing algorithm in such a case.
For more information about partitioning, partitioning schemes, and partitioning keys in MySQL 5.1, see Partitioning, in the MySQL Manual.
The only type of user-defined partitioning that is supported
for use with the NDBCLUSTER
storage engine
in MySQL 5.1 is key partitioning.
Signature.
bool getPartitionKey ( void ) const
Parameters. None.
Return value.
true
if the column is part of the
partitioning key for the table, otherwise
false
.
Description. This method gets the column's array type.
Signature.
ArrayType getArrayType ( void ) const
Parameters. None.
Return value.
An ArrayType
; see
Section 2.3.1.1.1, “The Column::ArrayType
Type” for possible values.
Description. This method obtains a column's storage type.
Signature.
StorageType getStorageType ( void ) const
Parameters. None.
Return value.
A StorageType
value; for more information
about this type, see Section 2.3.1.1.2, “The Column::StorageType
Type”.
Description. This method is used to set the name of a column.
setName()
is the only
Column
method whose result is visible from
a MySQL Server. MySQL cannot see any other changes made to
existing columns using the NDB API.
Signature.
void setName
(
const char* name
)
Parameters. This method takes a single argument — the new name for the column.
Return value. This method None.
Description. This method allows you to toggle the nullability of a column.
Changes made to columns using this method are not visible to MySQL.
Signature.
void setNullable
(
bool nullable
)
Parameters.
A Boolean value. Using true
makes it
possible to insert NULL
s into the column;
if nullable
is
false
, then this method performs the
equivalent of changing the column to NOT
NULL
in MySQL.
Return value. No return value.
Description. This method is used to make a column part of the table's primary key, or to remove it from the primary key.
Changes made to columns using this method are not visible to MySQL.
The NDB API handles column names in case-sensitive fashion; “myColumn” and “Mycolumn” are not considered to refer to the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase for column names by naming all columns consistently using only uppercase or only lowercase.
Signature.
void setPrimaryKey
(
bool primary
)
Parameters.
This method takes a single Boolean value. If it is
true
, then the column becomes part of the
table's primary key; if false
, then the
column is removed from the primary key.
Return value. No return value.
Description.
This method sets the Type
(datatype) of a
column.
setType()
resets all
column attributes to their (type dependent) default values; it
should be the first method that you call when changing the
attributes of a given column.
Changes made to columns using this method are not visible to MySQL.
The NDB API handles column names in case-sensitive fashion; “myColumn” and “Mycolumn” are not considered to refer to the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase for column names by naming all columns consistently using only uppercase or only lowercase.
Signature.
void setType
(
Type type
)
Parameters.
This method takes a single parameter — the new
Column::Type
for the column. The default is
Unsigned
. For a listing of all permitted
values, see Section 2.3.1.1.3, “Column::Type
”.
Return value. No return value.
Description. This method can be used to set the precision of a decimal column.
This method is applicable to decimal columns only.
Changes made to columns using this method are not visible to MySQL.
Signature.
void setPrecision
(
int precision
)
Parameters.
This method takes a single parameter — precision is an
integer, the value of the column's new precision. For
additional information about decimal precision and scale, see
Section 2.3.1.2.8, “Column::getPrecision()
”, and
Section 2.3.1.2.9, “Column::getScale()
”.
Return value. No return value.
Description. This method can be used to set the scale of a decimal column.
This method is applicable to decimal columns only.
Changes made to columns using this method are not visible to MySQL.
Signature.
void setScale
(
int scale
)
Parameters.
This method takes a single parameter — the integer
scale
is the new scale for the
decimal column. For additional information about decimal
precision and scale, see
Section 2.3.1.2.8, “Column::getPrecision()
”, and
Section 2.3.1.2.9, “Column::getScale()
”.
Return value. No return value.
Description. This method sets the length of a column. For a variable-length array, this is the maximum length; otherwise it is the array length.
Changes made to columns using this method are not visible to MySQL.
The NDB API handles column names in case-sensitive fashion; “myColumn” and “Mycolumn” are not considered to refer to the same column. It is recommended that you minimize the possibility of errors from using the wrong lettercase by naming all columns consistently using only uppercase or only lowercase.
Signature.
void setLength
(
int length
)
Parameters.
This method takes a single argument — the integer value
length
is the new length for the
column.
Return value. No return value.
Description.
This method can be used to set the character set and collation
of a Char
, Varchar
, or
Text
column.
This method is applicable to Char
,
Varchar
, and Text
columns only.
Changes made to columns using this method are not visible to MySQL.
Signature.
void setCharset
(
CHARSET_INFO* cs
)
Parameters.
This method takes one parameter. cs
is a pointer to a CHARSET_INFO
structure.
For additional information, see
Section 2.3.1.2.11, “Column::getCharset()
”.
Return value. No return value.
Description.
This method gets the inline size of a BLOB
column — that is, the number of initial bytes to store
in the table's blob attribute. This part is normally kept in
main memory, and can be indexed and interpreted.
This method is applicable to BLOB
columns
only.
Changes made to columns using this method are not visible to MySQL.
Signature.
void setInlineSize
(
int size
)
Parameters.
The integer size
is the new inline
size for the BLOB
column.
Return value. No return value.
Description.
This method sets the part size of a BLOB
column — that is, the number of bytes to store in each
tuple of the BLOB
table.
This method is applicable to BLOB
columns
only.
Changes made to columns using this method are not visible to MySQL.
Signature.
void setPartSize
(
int size
)
Parameters.
The integer size
is the number of
bytes to store in the BLOB
table. Using
zero for this value allows only inline bytes to be stored, in
effect making the column's type TINYBLOB
.
Return value. No return value.
Description.
This method sets the stripe size of a BLOB
column — that is, the number of consecutive parts to
store in each node group.
This method is applicable to BLOB
columns
only.
Changes made to columns using this method are not visible to MySQL.
Signature.
void setStripeSize
(
int size
)
Parameters.
This method takes a single argument. The integer
size
is the new stripe size for the
column.
Return value. No return value.
Description. This method makes it possible to add a column to the partitioning key of the table to which it belongs, or to remove the column from the table's partitioning key.
Changes made to columns using this method are not visible to MySQL.
For additional information, see
Section 2.3.1.2.16, “Column::getPartitionKey()
”.
Signature.
void setPartitionKey
(
bool enable
)
Parameters.
The single parameter enable
is a
Boolean value. Passing true
to this method
makes the column part of the table's partitioning key; if
enable
is false
,
then the column is removed from the partitioning key.
Return value. No return value.
Description. Sets the array type for the column.
Signature.
void setArrayType
(
ArrayType type
)
Parameters.
A Column::ArrayType
value. See
Section 2.3.1.1.1, “The Column::ArrayType
Type”, for more information.
Return value. None.
Description. Sets the storage type for the column.
Signature.
void setStorageType
(
StorageType type
)
Parameters.
A Column::StorageType
value. See
Section 2.3.1.1.2, “The Column::StorageType
Type”, for more
information.
Return value. None.
Description.
This method sets a column value to its default, if it has one;
otherwise it sets the column to NULL
.
This method was added in MySQL Cluster NDB 7.1.0.
To determine whether a table has any columns with default
values, use
Table::hasDefaultValues()
.
Signature.
int setDefaultValue ( const void*buf
, unsigned intlen
)
Parameters.
This method takes 2 arguments: a value pointer
buf
; and the length
len
of the data, as the number of
significant bytes. For fixed size types, this is the type
size. For variable length types, the leading 1 or 2 bytes
pointed to by buffer
also contain
size information as normal for the type.
Return value. 0 on success, 1 on failure..
Description. Gets a column's default value data.
This method was added in MySQL Cluster NDB 7.1.0.
To determine whether a table has any columns with default
values, use
Table::hasDefaultValues()
.
Signature.
const void* getDefaultValue
(
unsigned int* len
= 0
) const
Parameters.
len
holds either the length of the
default value data, or 0 in the event that the column is
nullable or has no default value.
Return value. The default value data.