⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbdict.hpp

📁 mysql-5.0.22.tar.gz源码包
💻 HPP
📖 第 1 页 / 共 5 页
字号:
/* 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 DBDICT_H#define DBDICT_H/** * Dict : Dictionary Block */#include <ndb_limits.h>#include <trigger_definitions.h>#include <pc.hpp>#include <ArrayList.hpp>#include <DLHashTable.hpp>#include <CArray.hpp>#include <KeyTable2.hpp>#include <SimulatedBlock.hpp>#include <SimpleProperties.hpp>#include <SignalCounter.hpp>#include <Bitmask.hpp>#include <AttributeList.hpp>#include <signaldata/GetTableId.hpp>#include <signaldata/GetTabInfo.hpp>#include <signaldata/DictTabInfo.hpp>#include <signaldata/CreateTable.hpp>#include <signaldata/CreateTab.hpp>#include <signaldata/DropTable.hpp>#include <signaldata/AlterTable.hpp>#include <signaldata/AlterTab.hpp>#include <signaldata/CreateIndx.hpp>#include <signaldata/DropIndx.hpp>#include <signaldata/AlterIndx.hpp>#include <signaldata/BuildIndx.hpp>#include <signaldata/UtilPrepare.hpp>#include <signaldata/CreateEvnt.hpp>#include <signaldata/CreateTrig.hpp>#include <signaldata/DropTrig.hpp>#include <signaldata/AlterTrig.hpp>#include "SchemaFile.hpp"#include <blocks/mutexes.hpp>#include <SafeCounter.hpp>#include <RequestTracker.hpp>#ifdef DBDICT_C// Debug Macros/*--------------------------------------------------------------*/// Constants for CONTINUEB/*--------------------------------------------------------------*/#define ZPACK_TABLE_INTO_PAGES 0#define ZSEND_GET_TAB_RESPONSE 3/*--------------------------------------------------------------*/// Other constants in alphabetical order/*--------------------------------------------------------------*/#define ZNOMOREPHASES 255/*--------------------------------------------------------------*/// Schema file defines/*--------------------------------------------------------------*/#define ZSCHEMA_WORDS 4/*--------------------------------------------------------------*/// Page constants/*--------------------------------------------------------------*/#define ZBAT_SCHEMA_FILE 0 //Variable number of page for NDBFS#define ZBAT_TABLE_FILE 1 //Variable number of page for NDBFS#define ZPAGE_HEADER_SIZE 32#define ZPOS_PAGE_SIZE 16#define ZPOS_CHECKSUM 17#define ZPOS_VERSION 18#define ZPOS_PAGE_HEADER_SIZE 19/*--------------------------------------------------------------*/// Size constants/*--------------------------------------------------------------*/#define ZFS_CONNECT_SIZE 4#define ZSIZE_OF_PAGES_IN_WORDS 8192#define ZLOG_SIZE_OF_PAGES_IN_WORDS 13#define ZMAX_PAGES_OF_TABLE_DEFINITION 8#define ZNUMBER_OF_PAGES (ZMAX_PAGES_OF_TABLE_DEFINITION + 1)#define ZNO_OF_FRAGRECORD 5/*--------------------------------------------------------------*/// Error codes/*--------------------------------------------------------------*/#define ZNODE_FAILURE_ERROR 704#endif/** * Systable NDB$EVENTS_0 */#define EVENT_SYSTEM_TABLE_NAME "sys/def/NDB$EVENTS_0"#define EVENT_SYSTEM_TABLE_LENGTH 6struct sysTab_NDBEVENTS_0 {  char   NAME[MAX_TAB_NAME_SIZE];  Uint32 EVENT_TYPE;  char   TABLE_NAME[MAX_TAB_NAME_SIZE];  Uint32 ATTRIBUTE_MASK[MAXNROFATTRIBUTESINWORDS];  Uint32 SUBID;  Uint32 SUBKEY;};/** *  DICT - This blocks handles all metadata */class Dbdict: public SimulatedBlock {public:  /*   *   2.3 RECORD AND FILESIZES   */  /**   * Shared table / index record.  Most of this is permanent data stored   * on disk.  Index trigger ids are volatile.   */  struct TableRecord : public MetaData::Table {    /****************************************************     *    Support variables for table handling     ****************************************************/    /*     Active page which is sent to disk */    Uint32 activePage;    /**    File pointer received from disk   */    Uint32 filePtr[2];    /**    Pointer to first attribute in table */    Uint32 firstAttribute;    /*    Pointer to first page of table description */    Uint32 firstPage;    /**    Pointer to last attribute in table */    Uint32 lastAttribute;#ifdef HAVE_TABLE_REORG        /*    Second table used by this table (for table reorg) */    Uint32 secondTable;#endif    /*    Next record in Pool */    Uint32 nextPool;    /*    Next record in hash table */    Uint32 nextHash;    /*    Previous record in Pool */    Uint32 prevPool;    /*    Previous record in hash table */    Uint32 prevHash;    enum TabState {      NOT_DEFINED = 0,      REORG_TABLE_PREPARED = 1,      DEFINING = 2,      CHECKED = 3,      DEFINED = 4,      PREPARE_DROPPING = 5,      DROPPING = 6,      BACKUP_ONGOING = 7    };    TabState tabState;    /*    State when returning from TC_SCHVERREQ */    enum TabReturnState {      TRS_IDLE = 0,      ADD_TABLE = 1,      SLAVE_SYSTEM_RESTART = 2,      MASTER_SYSTEM_RESTART = 3    };    TabReturnState tabReturnState;    /**    Number of words */    Uint32 packedSize;    /**   Index state (volatile data) */    enum IndexState {      IS_UNDEFINED = 0,         // initial      IS_OFFLINE = 1,           // index table created      IS_BUILDING = 2,          // building (local state)      IS_DROPPING = 3,          // dropping (local state)      IS_ONLINE = 4,            // online      IS_BROKEN = 9             // build or drop aborted    };    IndexState indexState;    /**   Trigger ids of index (volatile data) */    Uint32 insertTriggerId;    Uint32 updateTriggerId;    Uint32 deleteTriggerId;    Uint32 customTriggerId;     // ordered index    Uint32 buildTriggerId;      // temp during build    /**  Index state in other blocks on this node */    enum IndexLocal {      IL_CREATED_TC = 1 << 0    // created in TC    };    Uint32 indexLocal;        Uint32 noOfNullBits;        inline bool equal(TableRecord & rec) const {      return strcmp(tableName, rec.tableName) == 0;    }    inline Uint32 hashValue() const {      Uint32 h = 0;      for (const char* p = tableName; *p != 0; p++)        h = (h << 5) + h + (*p);      return h;    }    /**  frm data for this table */    /** TODO Could preferrably be made dynamic size */    Uint32 frmLen;    char frmData[MAX_FRM_DATA_SIZE];    Uint32 fragmentCount;  };  typedef Ptr<TableRecord> TableRecordPtr;  ArrayPool<TableRecord> c_tableRecordPool;  DLHashTable<TableRecord> c_tableRecordHash;  /**   * Table attributes.  Permanent data.   *   * Indexes have an attribute list which duplicates primary table   * attributes.  This is wrong but convenient.   */  struct AttributeRecord : public MetaData::Attribute {    union {        /** Pointer to the next attribute used by ArrayPool */    Uint32 nextPool;    /** Pointer to the next attribute used by DLHash */    Uint32 nextHash;    };    /** Pointer to the previous attribute used by DLHash */    Uint32 prevHash;    /** Pointer to the next attribute in table */    Uint32 nextAttrInTable;    inline bool equal(AttributeRecord & rec) const {      return strcmp(attributeName, rec.attributeName) == 0;    }    inline Uint32 hashValue() const {      Uint32 h = 0;      for (const char* p = attributeName; *p != 0; p++)        h = (h << 5) + h + (*p);      return h;    }  };  typedef Ptr<AttributeRecord> AttributeRecordPtr;  ArrayPool<AttributeRecord> c_attributeRecordPool;  DLHashTable<AttributeRecord> c_attributeRecordHash;  /**   * Triggers.  This is volatile data not saved on disk.  Setting a   * trigger online creates the trigger in TC (if index) and LQH-TUP.   */  struct TriggerRecord {    /** Trigger state */    enum TriggerState {       TS_NOT_DEFINED = 0,      TS_DEFINING = 1,      TS_OFFLINE  = 2,   // created globally in DICT      TS_BUILDING = 3,      TS_DROPPING = 4,      TS_ONLINE = 5      // activated globally    };    TriggerState triggerState;    /** Trigger state in other blocks on this node */    enum IndexLocal {      TL_CREATED_TC = 1 << 0,   // created in TC      TL_CREATED_LQH = 1 << 1   // created in LQH-TUP    };    Uint32 triggerLocal;    /** Trigger name, used by DICT to identify the trigger */     char triggerName[MAX_TAB_NAME_SIZE];    /** Trigger id, used by TRIX, TC, LQH, and TUP to identify the trigger */    Uint32 triggerId;    /** Table id, the table the trigger is defined on */    Uint32 tableId;    /** Trigger type, defines what the trigger is used for */    TriggerType::Value triggerType;        /** Trigger action time, defines when the trigger should fire */    TriggerActionTime::Value triggerActionTime;        /** Trigger event, defines what events the trigger should monitor */    TriggerEvent::Value triggerEvent;        /** Monitor all replicas */    bool monitorReplicas;    /** Monitor all, the trigger monitors changes of all attributes in table */    bool monitorAllAttributes;        /**     * Attribute mask, defines what attributes are to be monitored.     * Can be seen as a compact representation of SQL column name list.     */    AttributeMask attributeMask;    /** Index id, only used by secondary_index triggers */    Uint32 indexId;    union {    /** Pointer to the next attribute used by ArrayPool */    Uint32 nextPool;    /** Next record in hash table */    Uint32 nextHash;    };        /** Previous record in hash table */    Uint32 prevHash;    /** Equal function, used by DLHashTable */    inline bool equal(TriggerRecord & rec) const {       return strcmp(triggerName, rec.triggerName) == 0;    }        /** Hash value function, used by DLHashTable */    inline Uint32 hashValue() const {      Uint32 h = 0;      for (const char* p = triggerName; *p != 0; p++)        h = (h << 5) + h + (*p);      return h;    }  };    Uint32 c_maxNoOfTriggers;  typedef Ptr<TriggerRecord> TriggerRecordPtr;  ArrayPool<TriggerRecord> c_triggerRecordPool;  DLHashTable<TriggerRecord> c_triggerRecordHash;  /**   * Information for each FS connection.   ****************************************************************************/  struct FsConnectRecord {    enum FsState {      IDLE = 0,      OPEN_WRITE_SCHEMA = 1,      WRITE_SCHEMA = 2,      CLOSE_WRITE_SCHEMA = 3,      OPEN_READ_SCHEMA1 = 4,      OPEN_READ_SCHEMA2 = 5,      READ_SCHEMA1 = 6,      READ_SCHEMA2 = 7,      CLOSE_READ_SCHEMA = 8,      OPEN_READ_TAB_FILE1 = 9,      OPEN_READ_TAB_FILE2 = 10,      READ_TAB_FILE1 = 11,      READ_TAB_FILE2 = 12,      CLOSE_READ_TAB_FILE = 13,      OPEN_WRITE_TAB_FILE = 14,      WRITE_TAB_FILE = 15,      CLOSE_WRITE_TAB_FILE = 16    };    /** File Pointer for this file system connection */    Uint32 filePtr;    /** Reference of owner record */    Uint32 ownerPtr;    /** State of file system connection */    FsState fsState;    /** Used by Array Pool for free list handling */    Uint32 nextPool;  };    typedef Ptr<FsConnectRecord> FsConnectRecordPtr;  ArrayPool<FsConnectRecord> c_fsConnectRecordPool;  /**   * This record stores all the information about a node and all its attributes   ****************************************************************************/  struct NodeRecord {    enum NodeState {      API_NODE = 0,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -