📄 ndbdictionaryimpl.hpp
字号:
/* Copyright (C) 2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#ifndef NdbDictionaryImpl_H#define NdbDictionaryImpl_H#include <ndb_types.h>#include <kernel_types.h>#include <NdbError.hpp>#include <BaseString.hpp>#include <Vector.hpp>#include <UtilBuffer.hpp>#include <NdbDictionary.hpp>#include <Bitmask.hpp>#include <AttributeList.hpp>#include <Ndb.hpp>#include "NdbWaiter.hpp"#include "DictCache.hpp"class NdbDictObjectImpl {public: Uint32 m_version; NdbDictionary::Object::Status m_status; bool change();protected: NdbDictObjectImpl() : m_status(NdbDictionary::Object::New) { }};/** * Column */class NdbColumnImpl : public NdbDictionary::Column {public: NdbColumnImpl(); NdbColumnImpl(NdbDictionary::Column &); // This is not a copy constructor ~NdbColumnImpl(); NdbColumnImpl& operator=(const NdbColumnImpl&); void init(Type t = Unsigned); int m_attrId; BaseString m_name; NdbDictionary::Column::Type m_type; int m_precision; int m_scale; int m_length; CHARSET_INFO * m_cs; // not const in MySQL bool m_pk; bool m_distributionKey; bool m_nullable; bool m_autoIncrement; Uint64 m_autoIncrementInitialValue; BaseString m_defaultValue; NdbTableImpl * m_blobTable; /** * Internal types and sizes, and aggregates */ Uint32 m_attrSize; // element size (size when arraySize==1) Uint32 m_arraySize; // length or length+2 for Var* types Uint32 m_keyInfoPos; // TODO: use bits in attr desc 2 bool getInterpretableType() const ; bool getCharType() const; bool getStringType() const; bool getBlobType() const; /** * Equality/assign */ bool equal(const NdbColumnImpl&) const; static NdbColumnImpl & getImpl(NdbDictionary::Column & t); static const NdbColumnImpl & getImpl(const NdbDictionary::Column & t); NdbDictionary::Column * m_facade; static NdbDictionary::Column * create_psuedo(const char *);};class NdbTableImpl : public NdbDictionary::Table, public NdbDictObjectImpl {public: NdbTableImpl(); NdbTableImpl(NdbDictionary::Table &); ~NdbTableImpl(); void init(); void setName(const char * name); const char * getName() const; Uint32 m_changeMask; Uint32 m_tableId; BaseString m_internalName; BaseString m_externalName; BaseString m_newExternalName; // Used for alter table UtilBuffer m_frm; NdbDictionary::Object::FragmentType m_fragmentType; /** * */ Uint32 m_columnHashMask; Vector<Uint32> m_columnHash; Vector<NdbColumnImpl *> m_columns; void buildColumnHash(); /** * Fragment info */ Uint32 m_hashValueMask; Uint32 m_hashpointerValue; Vector<Uint16> m_fragments; bool m_logging; int m_kvalue; int m_minLoadFactor; int m_maxLoadFactor; Uint16 m_keyLenInWords; Uint16 m_fragmentCount; NdbDictionaryImpl * m_dictionary; NdbIndexImpl * m_index; NdbColumnImpl * getColumn(unsigned attrId); NdbColumnImpl * getColumn(const char * name); const NdbColumnImpl * getColumn(unsigned attrId) const; const NdbColumnImpl * getColumn(const char * name) const; /** * Index only stuff */ BaseString m_primaryTable; NdbDictionary::Index::Type m_indexType; /** * Aggregates */ Uint8 m_noOfKeys; Uint8 m_noOfDistributionKeys; Uint8 m_noOfBlobs; Uint8 m_replicaCount; /** * Equality/assign */ bool equal(const NdbTableImpl&) const; void assign(const NdbTableImpl&); static NdbTableImpl & getImpl(NdbDictionary::Table & t); static NdbTableImpl & getImpl(const NdbDictionary::Table & t); NdbDictionary::Table * m_facade; /** * Return count */ Uint32 get_nodes(Uint32 hashValue, const Uint16** nodes) const ;};class NdbIndexImpl : public NdbDictionary::Index, public NdbDictObjectImpl {public: NdbIndexImpl(); NdbIndexImpl(NdbDictionary::Index &); ~NdbIndexImpl(); void init(); void setName(const char * name); const char * getName() const; void setTable(const char * table); const char * getTable() const; const NdbTableImpl * getIndexTable() const; Uint32 m_indexId; BaseString m_internalName; BaseString m_externalName; BaseString m_tableName; Vector<NdbColumnImpl *> m_columns; Vector<int> m_key_ids; NdbDictionary::Index::Type m_type; bool m_logging; NdbTableImpl * m_table; static NdbIndexImpl & getImpl(NdbDictionary::Index & t); static NdbIndexImpl & getImpl(const NdbDictionary::Index & t); NdbDictionary::Index * m_facade;};class NdbEventImpl : public NdbDictionary::Event, public NdbDictObjectImpl {public: NdbEventImpl(); NdbEventImpl(NdbDictionary::Event &); ~NdbEventImpl(); void init(); void setName(const char * name); const char * getName() const; void setTable(const NdbDictionary::Table& table); void setTable(const char * table); const char * getTableName() const; void addTableEvent(const NdbDictionary::Event::TableEvent t); void setDurability(NdbDictionary::Event::EventDurability d); NdbDictionary::Event::EventDurability getDurability() const; void addEventColumn(const NdbColumnImpl &c); int getNoOfEventColumns() const; void print() { ndbout_c("NdbEventImpl: id=%d, key=%d", m_eventId, m_eventKey); }; Uint32 m_eventId; Uint32 m_eventKey; Uint32 m_tableId; AttributeMask m_attrListBitmask; //BaseString m_internalName; BaseString m_externalName; Uint32 mi_type; NdbDictionary::Event::EventDurability m_dur; NdbTableImpl *m_tableImpl; BaseString m_tableName; Vector<NdbColumnImpl *> m_columns; Vector<unsigned> m_attrIds; int m_bufferId; NdbEventOperation *eventOp; static NdbEventImpl & getImpl(NdbDictionary::Event & t); static NdbEventImpl & getImpl(const NdbDictionary::Event & t); NdbDictionary::Event * m_facade;};class NdbDictInterface {public: NdbDictInterface(NdbError& err) : m_error(err) { m_reference = 0; m_masterNodeId = 0; m_transporter= NULL; } ~NdbDictInterface(); bool setTransporter(class Ndb * ndb, class TransporterFacade * tf); bool setTransporter(class TransporterFacade * tf); // To abstract the stuff thats made in all create/drop/lists below int dictSignal(NdbApiSignal* signal, LinearSectionPtr ptr[3], int noLPTR, const int useMasterNodeId, const Uint32 RETRIES, const WaitSignalType wst, const int theWait, const int *errcodes, const int noerrcodes, const int temporaryMask = 0); int createOrAlterTable(class Ndb & ndb, NdbTableImpl &, bool alter); int createTable(class Ndb & ndb, NdbTableImpl &); int createTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int alterTable(class Ndb & ndb, NdbTableImpl &); int alterTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int createIndex(class Ndb & ndb, NdbIndexImpl &, const NdbTableImpl &); int createIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int createEvent(class Ndb & ndb, NdbEventImpl &, int getFlag); int createEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3], int noLSP); int dropTable(const NdbTableImpl &); int dropTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int dropIndex(const NdbIndexImpl &, const NdbTableImpl &); int dropIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int dropEvent(const NdbEventImpl &); int dropEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3], int noLSP); int executeSubscribeEvent(class Ndb & ndb, NdbEventImpl &); int executeSubscribeEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int stopSubscribeEvent(class Ndb & ndb, NdbEventImpl &); int stopSubscribeEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3]); int listObjects(NdbDictionary::Dictionary::List& list, Uint32 requestData, bool fullyQualifiedNames); int listObjects(NdbApiSignal* signal); /* NdbTableImpl * getTable(int tableId, bool fullyQualifiedNames); */ NdbTableImpl * getTable(const BaseString& name, bool fullyQualifiedNames); NdbTableImpl * getTable(class NdbApiSignal * signal, LinearSectionPtr ptr[3], Uint32 noOfSections, bool fullyQualifiedNames); static int parseTableInfo(NdbTableImpl ** dst, const Uint32 * data, Uint32 len, bool fullyQualifiedNames); static int create_index_obj_from_table(NdbIndexImpl ** dst, NdbTableImpl* index_table, const NdbTableImpl* primary_table); NdbError & m_error;private: Uint32 m_reference; Uint32 m_masterNodeId; NdbWaiter m_waiter; class TransporterFacade * m_transporter; friend class Ndb; static void execSignal(void* dictImpl, class NdbApiSignal* signal, struct LinearSectionPtr ptr[3]); static void execNodeStatus(void* dictImpl, Uint32, bool alive, bool nfCompleted); void execGET_TABINFO_REF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execGET_TABINFO_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execCREATE_TABLE_REF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execCREATE_TABLE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execALTER_TABLE_REF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execALTER_TABLE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execCREATE_INDX_REF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execCREATE_INDX_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execDROP_INDX_REF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execDROP_INDX_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execCREATE_EVNT_REF(NdbApiSignal *, LinearSectionPtr ptr[3]); void execCREATE_EVNT_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -