partly rewritten the Diciotnary docs to reflect the integration with MySQL

parent 61e8a8dd
...@@ -14,18 +14,6 @@ ...@@ -14,18 +14,6 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*****************************************************************************
* Name: NdbDictionary.hpp
* Include:
* Link:
* Author: Jonas Oreland
* Date: 2003-05-14
* Version: 0.1
* Description: Data dictionary support
* Documentation:
* Adjust: 2003-05-14 Jonas Oreland First version.
****************************************************************************/
#ifndef NdbDictionary_H #ifndef NdbDictionary_H
#define NdbDictionary_H #define NdbDictionary_H
...@@ -39,11 +27,15 @@ typedef struct charset_info_st CHARSET_INFO; ...@@ -39,11 +27,15 @@ typedef struct charset_info_st CHARSET_INFO;
* @class NdbDictionary * @class NdbDictionary
* @brief Data dictionary class * @brief Data dictionary class
* *
* This class supports all schema data definition and enquiry such as: * The preferred and supported way to create tables and indexes
* -# Creating tables (Dictionary::createTable) and table columns * in ndb is through the
* -# Dropping tables (Dictionary::dropTable) * MySQL Server (see MySQL reference Manual, section MySQL Cluster).
* -# Creating secondary indexes (Dictionary::createIndex) *
* -# Dropping secondary indexes (Dictionary::dropIndex) * Tables and indexes that are created directly through the
* NdbDictionary class
* can not be viewed from the MySQL Server.
*
* This class supports schema data enquiries such as:
* -# Enquiries about tables * -# Enquiries about tables
* (Dictionary::getTable, Table::getNoOfColumns, * (Dictionary::getTable, Table::getNoOfColumns,
* Table::getPrimaryKey, and Table::getNoOfPrimaryKeys) * Table::getPrimaryKey, and Table::getNoOfPrimaryKeys)
...@@ -51,7 +43,13 @@ typedef struct charset_info_st CHARSET_INFO; ...@@ -51,7 +43,13 @@ typedef struct charset_info_st CHARSET_INFO;
* (Dictionary::getIndex, Index::getNoOfColumns, * (Dictionary::getIndex, Index::getNoOfColumns,
* and Index::getColumn) * and Index::getColumn)
* *
* NdbDictionary has several help (inner) classes: * This class supports schema data definition such as:
* -# Creating tables (Dictionary::createTable) and table columns
* -# Dropping tables (Dictionary::dropTable)
* -# Creating secondary indexes (Dictionary::createIndex)
* -# Dropping secondary indexes (Dictionary::dropIndex)
*
* NdbDictionary has several help (inner) classes to support this:
* -# NdbDictionary::Table for creating tables * -# NdbDictionary::Table for creating tables
* -# NdbDictionary::Column for creating table columns * -# NdbDictionary::Column for creating table columns
* -# NdbDictionary::Index for creating secondary indexes * -# NdbDictionary::Index for creating secondary indexes
...@@ -195,23 +193,6 @@ public: ...@@ -195,23 +193,6 @@ public:
* @name General * @name General
* @{ * @{
*/ */
/**
* Constructor
* @param name Name of column
*/
Column(const char * name = "");
/**
* Copy constructor
* @param column Column to be copied
*/
Column(const Column& column);
~Column();
/**
* Set name of column
* @param name Name of the column
*/
void setName(const char * name);
/** /**
* Get name of column * Get name of column
...@@ -219,21 +200,11 @@ public: ...@@ -219,21 +200,11 @@ public:
*/ */
const char* getName() const; const char* getName() const;
/**
* Set whether column is nullable or not
*/
void setNullable(bool);
/** /**
* Get if the column is nullable or not * Get if the column is nullable or not
*/ */
bool getNullable() const; bool getNullable() const;
/**
* Set that column is part of primary key
*/
void setPrimaryKey(bool);
/** /**
* Check if column is part of primary key * Check if column is part of primary key
*/ */
...@@ -251,57 +222,30 @@ public: ...@@ -251,57 +222,30 @@ public:
*/ */
bool equal(const Column& column) const; bool equal(const Column& column) const;
/** @} *******************************************************************/ /** @} *******************************************************************/
/** /**
* @name Type Specifiers * @name Get Type Specifiers
* @{ * @{
*/ */
/**
* Set type of column
* @param type Type of column
*
* @note setType resets <em>all</em> column attributes
* to (type dependent) defaults and should be the first
* method to call. Default type is Unsigned.
*/
void setType(Type type);
/** /**
* Get type of column * Get type of column
*/ */
Type getType() const; Type getType() const;
/**
* Set precision of column.
* @note Only applicable for builtin type Decimal
*/
void setPrecision(int);
/** /**
* Get precision of column. * Get precision of column.
* @note Only applicable for builtin type Decimal * @note Only applicable for builtin type Decimal
*/ */
int getPrecision() const; int getPrecision() const;
/**
* Set scale of column.
* @note Only applicable for builtin type Decimal
*/
void setScale(int);
/** /**
* Get scale of column. * Get scale of column.
* @note Only applicable for builtin type Decimal * @note Only applicable for builtin type Decimal
*/ */
int getScale() const; int getScale() const;
/**
* Set length for column
* Array length for column or max length for variable length arrays.
*/
void setLength(int length);
/** /**
* Get length for column * Get length for column
* Array length for column or max length for variable length arrays. * Array length for column or max length for variable length arrays.
...@@ -309,34 +253,31 @@ public: ...@@ -309,34 +253,31 @@ public:
int getLength() const; int getLength() const;
/** /**
* For Char or Varchar or Text, set or get MySQL CHARSET_INFO. This * For Char or Varchar or Text, get MySQL CHARSET_INFO. This
* specifies both character set and collation. See get_charset() * specifies both character set and collation. See get_charset()
* etc in MySQL. (The cs is not "const" in MySQL). * etc in MySQL. (The cs is not "const" in MySQL).
*/ */
void setCharset(CHARSET_INFO* cs);
CHARSET_INFO* getCharset() const; CHARSET_INFO* getCharset() const;
/** /**
* For blob, set or get "inline size" i.e. number of initial bytes * For blob, get "inline size" i.e. number of initial bytes
* to store in table's blob attribute. This part is normally in * to store in table's blob attribute. This part is normally in
* main memory and can be indexed and interpreted. * main memory and can be indexed and interpreted.
*/ */
void setInlineSize(int size);
int getInlineSize() const; int getInlineSize() const;
/** /**
* For blob, set or get "part size" i.e. number of bytes to store in * 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 * each tuple of the "blob table". Can be set to zero to omit parts
* and to allow only inline bytes ("tinyblob"). * and to allow only inline bytes ("tinyblob").
*/ */
void setPartSize(int size);
int getPartSize() const; int getPartSize() const;
/** /**
* For blob, set or get "stripe size" i.e. number of consecutive * For blob, set or get "stripe size" i.e. number of consecutive
* <em>parts</em> to store in each node group. * <em>parts</em> to store in each node group.
*/ */
void setStripeSize(int size);
int getStripeSize() const; int getStripeSize() const;
/** /**
...@@ -345,7 +286,7 @@ public: ...@@ -345,7 +286,7 @@ public:
int getSize() const; int getSize() const;
/** /**
* Set distribution key * Check if column is part of distribution key
* *
* A <em>distribution key</em> is a set of attributes which are used * A <em>distribution key</em> is a set of attributes which are used
* to distribute the tuples onto the NDB nodes. * to distribute the tuples onto the NDB nodes.
...@@ -359,16 +300,115 @@ public: ...@@ -359,16 +300,115 @@ public:
* Locally in the fragments the full primary key * Locally in the fragments the full primary key
* will still be used with the hashing algorithm. * will still be used with the hashing algorithm.
* *
* @param enable If set to true, then the column will be part of * @return true then the column is part of
* the distribution key. * the distribution key.
*/ */
void setDistributionKey(bool enable); bool getDistributionKey() const;
/** @} *******************************************************************/
/** /**
* Check if column is part of distribution key * @name Column creation
* @see setDistributionKey * @{
*
* These operations should normally not be performed in an NbdApi program
* as results will not be visable in the MySQL Server
*
*/ */
bool getDistributionKey() const;
/**
* Constructor
* @param name Name of column
*/
Column(const char * name = "");
/**
* Copy constructor
* @param column Column to be copied
*/
Column(const Column& column);
~Column();
/**
* Set name of column
* @param name Name of the column
*/
void setName(const char * name);
/**
* Set whether column is nullable or not
*/
void setNullable(bool);
/**
* Set that column is part of primary key
*/
void setPrimaryKey(bool);
/**
* Set type of column
* @param type Type of column
*
* @note setType resets <em>all</em> column attributes
* to (type dependent) defaults and should be the first
* method to call. Default type is Unsigned.
*/
void setType(Type type);
/**
* Set precision of column.
* @note Only applicable for builtin type Decimal
*/
void setPrecision(int);
/**
* Set scale of column.
* @note Only applicable for builtin type Decimal
*/
void setScale(int);
/**
* Set length for column
* Array length for column or max length for variable length arrays.
*/
void setLength(int length);
/**
* 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).
*/
void setCharset(CHARSET_INFO* cs);
/**
* For blob, get "inline size" i.e. number of initial bytes
* to store in table's blob attribute. This part is normally in
* main memory and can be indexed and interpreted.
*/
void setInlineSize(int size);
/**
* 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").
*/
void setPartSize(int size);
/**
* For blob, get "stripe size" i.e. number of consecutive
* <em>parts</em> to store in each node group.
*/
void setStripeSize(int size);
/**
* Set distribution key
* @see getDistributionKey
*
* @param enable If set to true, then the column will be part of
* the distribution key.
*/
void setDistributionKey(bool enable);
/** @} *******************************************************************/ /** @} *******************************************************************/
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
...@@ -429,30 +469,6 @@ public: ...@@ -429,30 +469,6 @@ public:
* @name General * @name General
* @{ * @{
*/ */
/**
* Constructor
* @param name Name of table
*/
Table(const char * name = "");
/**
* Copy constructor
* @param table Table to be copied
*/
Table(const Table& table);
virtual ~Table();
/**
* Assignment operator, deep copy
* @param table Table to be copied
*/
Table& operator=(const Table&);
/**
* Name of table
* @param name Name of table
*/
void setName(const char * name);
/** /**
* Get table name * Get table name
...@@ -464,12 +480,6 @@ public: ...@@ -464,12 +480,6 @@ public:
*/ */
int getTableId() const; int getTableId() const;
/**
* Add a column definition to a table
* @note creates a copy
*/
void addColumn(const Column &);
/** /**
* Get column definition via name. * Get column definition via name.
* @return null if none existing name * @return null if none existing name
...@@ -511,30 +521,13 @@ public: ...@@ -511,30 +521,13 @@ public:
* The default value is true and indicates a normal table * The default value is true and indicates a normal table
* with full checkpointing and logging activated. * with full checkpointing and logging activated.
*/ */
void setLogging(bool);
/**
* @see NdbDictionary::Table::setLogging.
*/
bool getLogging() const; bool getLogging() const;
/**
* Set fragmentation type
*/
void setFragmentType(FragmentType);
/** /**
* Get fragmentation type * Get fragmentation type
*/ */
FragmentType getFragmentType() const; FragmentType getFragmentType() const;
/**
* Set KValue (Hash parameter.)
* Only allowed value is 6.
* Later implementations might add flexibility in this parameter.
*/
void setKValue(int kValue);
/** /**
* Get KValue (Hash parameter.) * Get KValue (Hash parameter.)
* Only allowed value is 6. * Only allowed value is 6.
...@@ -542,15 +535,6 @@ public: ...@@ -542,15 +535,6 @@ public:
*/ */
int getKValue() const; int getKValue() const;
/**
* Set MinLoadFactor (Hash parameter.)
* This value specifies the load factor when starting to shrink
* the hash table.
* It must be smaller than MaxLoadFactor.
* Both these factors are given in percentage.
*/
void setMinLoadFactor(int);
/** /**
* Get MinLoadFactor (Hash parameter.) * Get MinLoadFactor (Hash parameter.)
* This value specifies the load factor when starting to shrink * This value specifies the load factor when starting to shrink
...@@ -560,16 +544,6 @@ public: ...@@ -560,16 +544,6 @@ public:
*/ */
int getMinLoadFactor() const; int getMinLoadFactor() const;
/**
* Set MaxLoadFactor (Hash parameter.)
* This value specifies the load factor when starting to split
* the containers in the local hash tables.
* 100 is the maximum which will optimize memory usage.
* A lower figure will store less information in each container and thus
* find the key faster but consume more memory.
*/
void setMaxLoadFactor(int);
/** /**
* Get MaxLoadFactor (Hash parameter.) * Get MaxLoadFactor (Hash parameter.)
* This value specifies the load factor when starting to split * This value specifies the load factor when starting to split
...@@ -612,24 +586,92 @@ public: ...@@ -612,24 +586,92 @@ public:
const void* getFrmData() const; const void* getFrmData() const;
Uint32 getFrmLength() const; Uint32 getFrmLength() const;
/** /** @} *******************************************************************/
* Set frm file to store with this table
*/
void setFrm(const void* data, Uint32 len);
/** /**
* Set table object type * @name Table creation
* @{
*
* These methods should normally not be used in an application as
* the result is not accessible from the MySQL Server
*
*/ */
void setObjectType(Object::Type type);
/** /**
* Get table object type * Constructor
* @param name Name of table
*/ */
Object::Type getObjectType() const; Table(const char * name = "");
/** /**
* Get object status * Copy constructor
*/ * @param table Table to be copied
*/
Table(const Table& table);
virtual ~Table();
/**
* Assignment operator, deep copy
* @param table Table to be copied
*/
Table& operator=(const Table&);
/**
* Name of table
* @param name Name of table
*/
void setName(const char * name);
/**
* Add a column definition to a table
* @note creates a copy
*/
void addColumn(const Column &);
/**
* @see NdbDictionary::Table::getLogging.
*/
void setLogging(bool);
/**
* Set fragmentation type
*/
void setFragmentType(FragmentType);
/**
* Set KValue (Hash parameter.)
* Only allowed value is 6.
* Later implementations might add flexibility in this parameter.
*/
void setKValue(int kValue);
/**
* Set MinLoadFactor (Hash parameter.)
* This value specifies the load factor when starting to shrink
* the hash table.
* It must be smaller than MaxLoadFactor.
* Both these factors are given in percentage.
*/
void setMinLoadFactor(int);
/**
* Set MaxLoadFactor (Hash parameter.)
* This value specifies the load factor when starting to split
* the containers in the local hash tables.
* 100 is the maximum which will optimize memory usage.
* A lower figure will store less information in each container and thus
* find the key faster but consume more memory.
*/
void setMaxLoadFactor(int);
/**
* Get table object type
*/
Object::Type getObjectType() const;
/**
* Get object status
*/
virtual Object::Status getObjectStatus() const; virtual Object::Status getObjectStatus() const;
/** /**
...@@ -637,6 +679,16 @@ public: ...@@ -637,6 +679,16 @@ public:
*/ */
virtual int getObjectVersion() const; virtual int getObjectVersion() const;
/**
* Set frm file to store with this table
*/
void setFrm(const void* data, Uint32 len);
/**
* Set table object type
*/
void setObjectType(Object::Type type);
/** @} *******************************************************************/ /** @} *******************************************************************/
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
...@@ -661,28 +713,17 @@ public: ...@@ -661,28 +713,17 @@ public:
*/ */
class Index : public Object { class Index : public Object {
public: public:
/**
* Constructor
* @param name Name of index
*/
Index(const char * name = "");
virtual ~Index();
/** /**
* Set the name of an index * @name Getting Index properties
* @{
*/ */
void setName(const char * name);
/** /**
* Get the name of an index * Get the name of an index
*/ */
const char * getName() const; const char * getName() const;
/**
* Define the name of the table to be indexed
*/
void setTable(const char * name);
/** /**
* Get the name of the table being indexed * Get the name of the table being indexed
*/ */
...@@ -714,6 +755,69 @@ public: ...@@ -714,6 +755,69 @@ public:
const char * getIndexColumn(int no) const ; const char * getIndexColumn(int no) const ;
#endif #endif
/**
* Represents type of index
*/
enum Type {
Undefined = 0, ///< Undefined object type (initial value)
UniqueHashIndex = 3, ///< Unique un-ordered hash index
///< (only one currently supported)
OrderedIndex = 6 ///< Non-unique ordered index
};
/**
* Get index type of the index
*/
Type getType() const;
/**
* Check if index is set to be stored on disk
*
* @return if true then logging id enabled
*
* @note Non-logged indexes are rebuilt at system restart.
* @note Ordered index does not currently support logging.
*/
bool getLogging() const;
/**
* Get object status
*/
virtual Object::Status getObjectStatus() const;
/**
* Get object version
*/
virtual int getObjectVersion() const;
/** @} *******************************************************************/
/**
* @name Index creation
* @{
*
* These methods should normally not be used in an application as
* the result will not be visible from the MySQL Server
*
*/
/**
* Constructor
* @param name Name of index
*/
Index(const char * name = "");
virtual ~Index();
/**
* Set the name of an index
*/
void setName(const char * name);
/**
* Define the name of the table to be indexed
*/
void setTable(const char * name);
/** /**
* Add a column to the index definition * Add a column to the index definition
* Note that the order of columns will be in * Note that the order of columns will be in
...@@ -755,59 +859,26 @@ public: ...@@ -755,59 +859,26 @@ public:
void addIndexColumns(int noOfNames, const char ** names); void addIndexColumns(int noOfNames, const char ** names);
#endif #endif
/**
* Represents type of index
*/
enum Type {
Undefined = 0, ///< Undefined object type (initial value)
UniqueHashIndex = 3, ///< Unique un-ordered hash index
///< (only one currently supported)
OrderedIndex = 6 ///< Non-unique ordered index
};
/** /**
* Set index type of the index * Set index type of the index
*/ */
void setType(Type type); void setType(Type type);
/**
* Get index type of the index
*/
Type getType() const;
/** /**
* Enable/Disable index storage on disk * Enable/Disable index storage on disk
* *
* @param enable If enable is set to true, then logging becomes enabled * @param enable If enable is set to true, then logging becomes enabled
* *
* @see NdbDictionary::Table::setLogging * @see NdbDictionary::Index::getLogging
*
* @note Non-logged indexes are rebuilt at system restart.
* @note Ordered index does not currently support logging.
*/ */
void setLogging(bool enable); void setLogging(bool enable);
/**
* Check if index is set to be stored on disk
*
* @see NdbDictionary::Index::setLogging
*/
bool getLogging() const;
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
void setStoredIndex(bool x) { setLogging(x); } void setStoredIndex(bool x) { setLogging(x); }
bool getStoredIndex() const { return getLogging(); } bool getStoredIndex() const { return getLogging(); }
#endif #endif
/** /** @} *******************************************************************/
* Get object status
*/
virtual Object::Status getObjectStatus() const;
/**
* Get object version
*/
virtual int getObjectVersion() const;
private: private:
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
...@@ -941,9 +1012,71 @@ public: ...@@ -941,9 +1012,71 @@ public:
const struct NdbError & getNdbError() const; const struct NdbError & getNdbError() const;
/** @} *******************************************************************/ /** @} *******************************************************************/
/**
* @name Retrieving references to Tables and Indexes
* @{
*/
/**
* Get table with given name, NULL if undefined
* @param name Name of table to get
* @return table if successful otherwise NULL.
*/
const Table * getTable(const char * name);
/**
* Get index with given name, NULL if undefined
* @param indexName Name of index to get.
* @param tableName Name of table that index belongs to.
* @return index if successful, otherwise 0.
*/
const Index * getIndex(const char * indexName,
const char * tableName);
/**
* Fetch list of indexes of given table.
* @param list Reference to list where to store the listed indexes
* @param tableName Name of table that index belongs to.
* @return 0 if successful, otherwise -1
*/
int listIndexes(List & list, const char * tableName);
/** @} *******************************************************************/
/**
* @name Events
* @{
*/
/**
* Create event given defined Event instance
* @param Event to create
* @return 0 if successful otherwise -1.
*/
int createEvent(const Event &);
/**
* Drop event with given name
* @param eventName Name of event to drop.
* @return 0 if successful otherwise -1.
*/
int dropEvent(const char * eventName);
/**
* Get event with given name.
* @param eventName Name of event to get.
* @return an Event if successful, otherwise NULL.
*/
const Event * getEvent(const char * eventName);
/** @} *******************************************************************/
/** /**
* @name Tables * @name Table creation
* @{ * @{
*
* These methods should normally not be used in an application as
* the result will not be visible from the MySQL Server
*/ */
/** /**
...@@ -976,13 +1109,6 @@ public: ...@@ -976,13 +1109,6 @@ public:
*/ */
int alterTable(const Table &); int alterTable(const Table &);
/**
* Get table with given name, NULL if undefined
* @param name Name of table to get
* @return table if successful otherwise NULL.
*/
const Table * getTable(const char * name);
/** /**
* Get table with given name for alteration. * Get table with given name for alteration.
* @param name Name of table to alter * @param name Name of table to alter
...@@ -1007,8 +1133,12 @@ public: ...@@ -1007,8 +1133,12 @@ public:
/** @} *******************************************************************/ /** @} *******************************************************************/
/** /**
* @name Indexes * @name Index creation
* @{ * @{
*
* These methods should normally not be used in an application as
* the result will not be visible from the MySQL Server
*
*/ */
/** /**
...@@ -1027,15 +1157,6 @@ public: ...@@ -1027,15 +1157,6 @@ public:
int dropIndex(const char * indexName, int dropIndex(const char * indexName,
const char * tableName); const char * tableName);
/**
* Get index with given name, NULL if undefined
* @param indexName Name of index to get.
* @param tableName Name of table that index belongs to.
* @return index if successful, otherwise 0.
*/
const Index * getIndex(const char * indexName,
const char * tableName);
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/** /**
* Invalidate cached index object * Invalidate cached index object
...@@ -1044,41 +1165,6 @@ public: ...@@ -1044,41 +1165,6 @@ public:
const char * tableName); const char * tableName);
#endif #endif
/**
* Fetch list of indexes of given table.
* @param list Reference to list where to store the listed indexes
* @param tableName Name of table that index belongs to.
* @return 0 if successful, otherwise -1
*/
int listIndexes(List & list, const char * tableName);
/** @} *******************************************************************/
/**
* @name Events
* @{
*/
/**
* Create event given defined Event instance
* @param Event to create
* @return 0 if successful otherwise -1.
*/
int createEvent(const Event &);
/**
* Drop event with given name
* @param eventName Name of event to drop.
* @return 0 if successful otherwise -1.
*/
int dropEvent(const char * eventName);
/**
* Get event with given name.
* @param eventName Name of event to get.
* @return an Event if successful, otherwise NULL.
*/
const Event * getEvent(const char * eventName);
/** @} *******************************************************************/ /** @} *******************************************************************/
protected: protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment