📄 ndbdictionary.hpp
字号:
#endif /** * Set index type of the index */ void setType(Type type); /** * Enable/Disable index storage on disk * * @param enable If enable is set to true, then logging becomes enabled * * @see NdbDictionary::Index::getLogging */ void setLogging(bool enable); #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED void setStoredIndex(bool x) { setLogging(x); } bool getStoredIndex() const { return getLogging(); }#endif /** @} *******************************************************************/ private:#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL friend class NdbIndexImpl;#endif class NdbIndexImpl & m_impl; Index(NdbIndexImpl&); }; /** * @brief Represents an Event in NDB Cluster * */ class Event : public Object { public: /** * Specifies the type of database operations an Event listens to */#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** TableEvent must match 1 << TriggerEvent */#endif enum TableEvent { TE_INSERT=1, ///< Insert event on table TE_DELETE=2, ///< Delete event on table TE_UPDATE=4, ///< Update event on table TE_ALL=7 ///< Any/all event on table (not relevant when ///< events are received) }; /** * Specifies the durability of an event * (future version may supply other types) */ enum EventDurability { ED_UNDEFINED#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL = 0#endif#if 0 // not supported ,ED_SESSION = 1, // Only this API can use it // and it's deleted after api has disconnected or ndb has restarted ED_TEMPORARY = 2 // All API's can use it, // But's its removed when ndb is restarted#endif ,ED_PERMANENT ///< All API's can use it. ///< It's still defined after a cluster system restart#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL = 3#endif }; /** * Constructor * @param name Name of event */ Event(const char *name); /** * Constructor * @param name Name of event * @param table Reference retrieved from NdbDictionary */ Event(const char *name, const NdbDictionary::Table& table); virtual ~Event(); /** * Set unique identifier for the event */ void setName(const char *name); /** * Get unique identifier for the event */ const char *getName() const; /** * Define table on which events should be detected * * @note calling this method will default to detection * of events on all columns. Calling subsequent * addEventColumn calls will override this. * * @param table reference retrieved from NdbDictionary */ void setTable(const NdbDictionary::Table& table); /** * Set table for which events should be detected * * @note preferred way is using setTable(const NdbDictionary::Table&) * or constructor with table object parameter */ void setTable(const char *tableName); /** * Get table name for events * * @return table name */ const char* getTableName() const; /** * Add type of event that should be detected */ void addTableEvent(const TableEvent te); /** * Set durability of the event */ void setDurability(EventDurability); /** * Get durability of the event */ EventDurability getDurability() const;#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL void addColumn(const Column &c);#endif /** * Add a column on which events should be detected * * @param attrId Column id * * @note errors will mot be detected until createEvent() is called */ void addEventColumn(unsigned attrId); /** * Add a column on which events should be detected * * @param columnName Column name * * @note errors will not be detected until createEvent() is called */ void addEventColumn(const char * columnName); /** * Add several columns on which events should be detected * * @param n Number of columns * @param columnNames Column names * * @note errors will mot be detected until * NdbDictionary::Dictionary::createEvent() is called */ void addEventColumns(int n, const char ** columnNames); /** * Get no of columns defined in an Event * * @return Number of columns, -1 on error */ int getNoOfEventColumns() const; /** * Get object status */ virtual Object::Status getObjectStatus() const; /** * Get object version */ virtual int getObjectVersion() const;#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL void print();#endif private:#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL friend class NdbEventImpl; friend class NdbEventOperationImpl;#endif class NdbEventImpl & m_impl; Event(NdbEventImpl&); }; /** * @class Dictionary * @brief Dictionary for defining and retreiving meta data */ class Dictionary { public: /** * @class List * @brief Structure for retrieving lists of object names */ struct List { /** * @struct Element * @brief Object to be stored in an NdbDictionary::Dictionary::List */ struct Element { unsigned id; ///< Id of object Object::Type type; ///< Type of object Object::State state; ///< State of object Object::Store store; ///< How object is stored char * database; ///< In what database the object resides char * schema; ///< What schema the object is defined in char * name; ///< Name of object Element() : id(0), type(Object::TypeUndefined), state(Object::StateUndefined), store(Object::StoreUndefined), database(0), schema(0), name(0) { } }; unsigned count; ///< Number of elements in list Element * elements; ///< Pointer to array of elements List() : count(0), elements(0) {} ~List() { if (elements != 0) { for (unsigned i = 0; i < count; i++) { delete[] elements[i].database; delete[] elements[i].schema; delete[] elements[i].name; elements[i].name = 0; } delete[] elements; count = 0; elements = 0; } } }; /** * @name General * @{ */ /** * Fetch list of all objects, optionally restricted to given type. * * @param list List of objects returned in the dictionary * @param type Restrict returned list to only contain objects of * this type * * @return -1 if error. * */ int listObjects(List & list, Object::Type type = Object::TypeUndefined); int listObjects(List & list, Object::Type type = Object::TypeUndefined) const; /** * Get the latest error * * @return Error object. */ 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) const; /** * 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) const; /** * 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); int listIndexes(List & list, const char * tableName) const; /** @} *******************************************************************/ /** * @name Events * @{ */ /** * Create event given defined Event instance * @param event Event to create * @return 0 if successful otherwise -1. */ int createEvent(const Event &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 Table creation * @{ * * These methods should normally not be used in an application as * the result will not be visible from the MySQL Server */ /** * Create defined table given defined Table instance * @param table Table to create * @return 0 if successful otherwise -1. */ int createTable(const Table &table); /** * Drop table given retrieved Table instance * @param table Table to drop * @return 0 if successful otherwise -1. */ int dropTable(Table & table); /** * Drop table given table name * @param name Name of table to drop * @return 0 if successful otherwise -1. */ int dropTable(const char * name); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Alter defined table given defined Table instance * @param table Table to alter * @return -2 (incompatible version) <br> * -1 general error <br> * 0 success */ int alterTable(const Table &table); /** * Invalidate cached table object * @param name Name of table to invalidate */ void invalidateTable(const char * name);#endif /** * Remove table from local cache */ void removeCachedTable(const char * table); /** * Remove index from local cache */ void removeCachedIndex(const char * index, const char * table); /** @} *******************************************************************/ /** * @name Index creation * @{ * * These methods should normally not be used in an application as * the result will not be visible from the MySQL Server * */ /** * Create index given defined Index instance * @param index Index to create * @return 0 if successful otherwise -1. */ int createIndex(const Index &index); /** * Drop index with given name * @param indexName Name of index to drop. * @param tableName Name of table that index belongs to. * @return 0 if successful otherwise -1. */ int dropIndex(const char * indexName, const char * tableName); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Invalidate cached index object */ void invalidateIndex(const char * indexName, const char * tableName);#endif /** @} *******************************************************************/ protected: Dictionary(Ndb & ndb); ~Dictionary(); private:#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL friend class NdbDictionaryImpl; friend class UtilTransactions; friend class NdbBlob;#endif class NdbDictionaryImpl & m_impl; Dictionary(NdbDictionaryImpl&); const Table * getIndexTable(const char * indexName, const char * tableName) const; public:#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL const Table * getTable(const char * name, void **data) const; void set_local_table_data_size(unsigned sz);#endif };};class NdbOut& operator <<(class NdbOut& out, const NdbDictionary::Column& col);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -