2.3.2.2 Column Methods

2.3.2.2.1 Column Constructor
2.3.2.2.2 Column::equal()
2.3.2.2.3 Column::getArrayType()
2.3.2.2.4 Column::getCharset()
2.3.2.2.5 Column::getColumnNo()
2.3.2.2.6 Column::getDefaultValue()
2.3.2.2.7 Column::getInlineSize()
2.3.2.2.8 Column::getLength()
2.3.2.2.9 Column::getName()
2.3.2.2.10 Column::getNullable()
2.3.2.2.11 Column::getPartitionKey()
2.3.2.2.12 Column::getPartSize()
2.3.2.2.13 Column::getPrecision()
2.3.2.2.14 Column::getPrimaryKey()
2.3.2.2.15 Column::getScale()
2.3.2.2.16 Column::getSize()
2.3.2.2.17 Column::getStorageType()
2.3.2.2.18 Column::getStripeSize()
2.3.2.2.19 Column::getType()
2.3.2.2.20 Column::setArrayType()
2.3.2.2.21 Column::setCharset()
2.3.2.2.22 Column::setDefaultValue()
2.3.2.2.23 Column::setInlineSize
2.3.2.2.24 Column::setLength()
2.3.2.2.25 Column::setName()
2.3.2.2.26 Column::setNullable()
2.3.2.2.27 Column::setPartitionKey()
2.3.2.2.28 Column::setPartSize()
2.3.2.2.29 Column::setPrecision()
2.3.2.2.30 Column::setPrimaryKey()
2.3.2.2.31 Column::setScale()
2.3.2.2.32 Column::setStripeSize()
2.3.2.2.33 Column::setStorageType()
2.3.2.2.34 Column::setType()

Abstract

This section documents the public methods of the Column class.

Note

The assignment (=) operator is overloaded for this class, so that it always performs a deep copy.

Warning

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 data type 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.

2.3.2.2.1 Column Constructor

Description.  You can create a new Column or copy an existing one using the class constructor.

Warning

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.

2.3.2.2.2 Column::equal()

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.

2.3.2.2.3 Column::getArrayType()

Description.  This method gets the column's array type.

Signature. 

ArrayType getArrayType
    (
      void
    ) const

Parameters.  None.

Return value.  An ArrayType; see Section 2.3.2.1.1, “The Column::ArrayType Type” for possible values.

2.3.2.2.4 Column::getCharset()

Description.  This gets the character set used by a text column.

Note

This method is applicable only to columns whose Type value is Char, Varchar, or Text.

Important

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.

2.3.2.2.5 Column::getColumnNo()

Description.  This method gets the sequence number of a column within its containing table or index. If the column is part of an index (such as when returned by getColumn()), it is mapped to its position within that index, and not within the table containing the index.

Important

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.

2.3.2.2.6 Column::getDefaultValue()

Description.  Gets a column's default value data.

This method was added in MySQL Cluster NDB 7.0.15 and MySQL Cluster NDB 7.1.4.

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.

2.3.2.2.7 Column::getInlineSize()

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.

Note

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.

2.3.2.2.8 Column::getLength()

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.

Important

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.

2.3.2.2.9 Column::getName()

Description.  This method returns the name of the column for which it is called.

Important

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.

2.3.2.2.10 Column::getNullable()

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.

2.3.2.2.11 Column::getPartitionKey()

Description.  This method is used to check whether the column is part of the table's partitioning key.

Note

A partitioning key is a set of attributes used to distribute the tuples onto the data nodes. This key a hashing function specific to the NDB 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, see Partitioning, in the MySQL Manual.

Important

The only type of user-defined partitioning that is supported for use with the NDB storage engine is key partitioning, including linear 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.

2.3.2.2.12 Column::getPartSize()

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.

Note

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).

2.3.2.2.13 Column::getPrecision()

Description.  This method gets the precision of a column.

Note

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 data type in Numeric Types, in the MySQL Manual.

2.3.2.2.14 Column::getPrimaryKey()

Description.  This method is used to determine whether the column is part of the table's primary key.

Important

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.

2.3.2.2.15 Column::getScale()

Description.  This method gets the scale used for a decimal column value.

Note

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 data type in Numeric Types, in the MySQL Manual.

2.3.2.2.16 Column::getSize()

Description.  This function is used to obtain the size of a column.

Important

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).

2.3.2.2.17 Column::getStorageType()

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.2.1.2, “The Column::StorageType Type”.

2.3.2.2.18 Column::getStripeSize()

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.

2.3.2.2.19 Column::getType()

Description.  This method gets the column's data type.

Important

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 (data type) of the column. For a list of possible values, see Section 2.3.2.1.3, “Column::Type.

2.3.2.2.20 Column::setArrayType()

Description.  Sets the array type for the column.

Signature. 

void setArrayType
    (
      ArrayType type
    )

Parameters.  A Column::ArrayType value. See Section 2.3.2.1.1, “The Column::ArrayType Type”, for more information.

Return value.  None.

2.3.2.2.21 Column::setCharset()

Description.  This method can be used to set the character set and collation of a Char, Varchar, or Text column.

Important

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.2.2.4, “Column::getCharset()”.

Return value.  None.

2.3.2.2.22 Column::setDefaultValue()

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.0.15 and MySQL Cluster NDB 7.1.4.

To determine whether a table has any columns with default values, use Table::hasDefaultValues().

Signature. 

int setDefaultValue
    (
      const void* buf, 
      unsigned int len
    )

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..

2.3.2.2.23 Column::setInlineSize

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.

Important

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.  None.

2.3.2.2.24 Column::setLength()

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.

Important

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.  None.

2.3.2.2.25 Column::setName()

Description.  This method is used to set the name of a column.

Important

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.

2.3.2.2.26 Column::setNullable()

Description.  This method toggles the nullability of a column.

Important

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 NULLs into the column; if nullable is false, then this method performs the equivalent of changing the column to NOT NULL in MySQL.

Return value.  None.

2.3.2.2.27 Column::setPartitionKey()

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.

Important

Changes made to columns using this method are not visible to MySQL.

For additional information, see Section 2.3.2.2.11, “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.  None.

2.3.2.2.28 Column::setPartSize()

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.

Important

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 means only inline bytes can be stored, in effect making the column's type TINYBLOB.

Return value.  None.

2.3.2.2.29 Column::setPrecision()

Description.  This method can be used to set the precision of a decimal column.

Important

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.2.2.13, “Column::getPrecision()”, and Section 2.3.2.2.15, “Column::getScale()”.

Return value.  None.

2.3.2.2.30 Column::setPrimaryKey()

Description.  This method is used to make a column part of the table's primary key, or to remove it from the primary key.

Important

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.  None.

2.3.2.2.31 Column::setScale()

Description.  This method can be used to set the scale of a decimal column.

Important

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.2.2.13, “Column::getPrecision()”, and Section 2.3.2.2.15, “Column::getScale()”.

Return value.  None.

2.3.2.2.32 Column::setStripeSize()

Description.  This method sets the stripe size of a BLOB column—that is, the number of consecutive parts to store in each node group.

Important

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.  None.

2.3.2.2.33 Column::setStorageType()

Description.  Sets the storage type for the column.

Signature. 

void setStorageType
    (
      StorageType type
    )

Parameters.  A Column::StorageType value. See Section 2.3.2.1.2, “The Column::StorageType Type”, for more information.

Return value.  None.

2.3.2.2.34 Column::setType()

Description.  This method sets the Type (data type) of a column.

Important

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.2.1.3, “Column::Type.

Return value.  None.