UtilPrepare.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:3k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef UTIL_PREPARE_REQ_HPP
  14. #define UTIL_PREPARE_REQ_HPP
  15. #include "SignalData.hpp"
  16. #include <SimpleProperties.hpp>
  17. #ifdef NDB_WIN32
  18. #ifdef NO_ERROR
  19. #undef NO_ERROR
  20. #endif
  21. #endif
  22. /**
  23.  * UTIL_PREPARE_REQ, UTIL_PREPARE_CONF, UTIL_PREPARE_REF
  24.  */
  25. /**
  26.  * @class UtilPrepareReq
  27.  * @brief Prepare transaction in Util block
  28.  *
  29.  * Data format:
  30.  * - UTIL_PREPARE_REQ <NoOfOps> (<OperationType> <TableName> <AttrName>+)+
  31.  */
  32. class UtilPrepareReq {
  33.   /**
  34.    * Sender(s) / Receiver(s)
  35.    */
  36.   friend class DbUtil;
  37.   friend class Trix;
  38.   /**
  39.    * For printing
  40.    */
  41.   friend bool printUTIL_PREPARE_REQ(FILE * output, 
  42.                                     const Uint32 * theData, 
  43.                                     Uint32 len, 
  44.                                     Uint16 receiverBlockNo);
  45. public:
  46.   enum OperationTypeValue {
  47.     Read               = 0,
  48.     Update             = 1,
  49.     Insert             = 2,
  50.     Delete             = 3,
  51.     Write        = 4
  52.   };
  53.   enum KeyValue {
  54.     NoOfOperations     = 1,  ///< No of operations in transaction
  55.     OperationType      = 2,  /// 
  56.     TableName          = 3,  ///< String
  57.     AttributeName      = 4,  ///< String
  58.     TableId        = 5,
  59.     AttributeId        = 6
  60.   };
  61.   // Signal constants
  62.   STATIC_CONST( SignalLength = 2 );
  63.   STATIC_CONST( PROPERTIES_SECTION = 0 );
  64.   STATIC_CONST( NoOfSections = 1 );
  65.   GET_SET_SENDERREF
  66.   GET_SET_SENDERDATA
  67. private:  
  68.   Uint32 senderData; // MUST be no 1!
  69.   Uint32 senderRef;
  70. };
  71. /**
  72.  * @class UtilPrepareConf
  73.  *
  74.  * Data format:
  75.  * - UTIL_PREPARE_CONF <UtilPrepareId> 
  76.  */
  77. class UtilPrepareConf {
  78.   /**
  79.    * Sender(s) / Receiver(s)
  80.    */
  81.   friend class DbUtil;
  82.   friend class Trix;
  83.   /**
  84.    * For printing
  85.    */
  86.   friend bool printUTIL_PREPARE_CONF(FILE * output, 
  87.      const Uint32 * theData, 
  88.      Uint32 len, 
  89.      Uint16 receiverBlockNo);
  90. public:
  91.   STATIC_CONST( SignalLength = 2 );
  92.   GET_SET_SENDERDATA
  93.   GET_SET_PREPAREID
  94. private:
  95.   Uint32 senderData; // MUST be no 1!
  96.   Uint32 prepareId; 
  97. };
  98. /**
  99.  * @class UtilPrepareRef
  100.  *
  101.  * Data format:
  102.  * - UTIL_PREPARE_REF 
  103.  */
  104. class UtilPrepareRef {
  105.   /**
  106.    * Sender(s) / Receiver(s)
  107.    */
  108.   friend class DbUtil;
  109.   friend class Trix;
  110.   /**
  111.    * For printing
  112.    */
  113.   friend bool printUTIL_PREPARE_REF(FILE * output, 
  114.     const Uint32 * theData, 
  115.     Uint32 len, 
  116.     Uint16 receiverBlockNo);
  117. public:
  118.   enum ErrorCode {
  119.     NO_ERROR = 0,
  120.     PREPARE_SEIZE_ERROR = 1,
  121.     PREPARE_PAGES_SEIZE_ERROR = 2,
  122.     PREPARED_OPERATION_SEIZE_ERROR = 3,
  123.     DICT_TAB_INFO_ERROR = 4,
  124.     MISSING_PROPERTIES_SECTION = 5
  125.   };
  126.   STATIC_CONST( SignalLength = 2 );
  127.   GET_SET_SENDERDATA
  128.   GET_SET_ERRORCODE
  129. private:
  130.   Uint32 senderData; // MUST be no 1!
  131.   Uint32 errorCode;
  132. };
  133. #endif