1 /*
2    Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License, version 2.0,
6    as published by the Free Software Foundation.
7 
8    This program is also distributed with certain software (including
9    but not limited to OpenSSL) that is licensed under separate terms,
10    as designated in a particular file or component or in included license
11    documentation.  The authors of MySQL hereby grant you an additional
12    permission to link the program and your derivative works with the
13    separately licensed software that they have included with MySQL.
14 
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License, version 2.0, for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
23 */
24 
25 #ifndef UTIL_PREPARE_REQ_HPP
26 #define UTIL_PREPARE_REQ_HPP
27 
28 #include "SignalData.hpp"
29 #include <SimpleProperties.hpp>
30 
31 #define JAM_FILE_ID 18
32 
33 
34 #ifdef NDB_WIN32
35 #ifdef NO_ERROR
36 #undef NO_ERROR
37 #endif
38 #endif
39 
40 /**
41  * UTIL_PREPARE_REQ, UTIL_PREPARE_CONF, UTIL_PREPARE_REF
42  */
43 
44 /**
45  * @class UtilPrepareReq
46  * @brief Prepare transaction in Util block
47  *
48  * Data format:
49  * - UTIL_PREPARE_REQ <NoOfOps> (<OperationType> <TableName> <AttrName>+)+
50  */
51 class UtilPrepareReq {
52   /**
53    * Sender(s) / Receiver(s)
54    */
55   friend class DbUtil;
56   friend class Trix;
57 
58   /**
59    * For printing
60    */
61   friend bool printUTIL_PREPARE_REQ(FILE * output,
62                                     const Uint32 * theData,
63                                     Uint32 len,
64                                     Uint16 receiverBlockNo);
65 
66 public:
67   enum OperationTypeValue {
68     Read               = 0,
69     Update             = 1,
70     Insert             = 2,
71     Delete             = 3,
72     Write	       = 4,
73     Probe              = 5  // check existance...
74   };
75 
76   enum KeyValue {
77     NoOfOperations     = 1,  ///< No of operations in transaction
78     OperationType      = 2,  ///
79     TableName          = 3,  ///< String
80     AttributeName      = 4,  ///< String
81     TableId	       = 5,
82     AttributeId	       = 6,
83     ScanTakeOverInd    = 7,
84     ReorgInd           = 8
85   };
86 
87   // Signal constants
88   STATIC_CONST( SignalLength = 3 );
89   STATIC_CONST( PROPERTIES_SECTION = 0 );
90   STATIC_CONST( NoOfSections = 1 );
91 
92   GET_SET_SENDERREF
93   GET_SET_SENDERDATA
94 private:
95   Uint32 senderData; // MUST be no 1!
96   Uint32 senderRef;
97   Uint32 schemaTransId;
98 };
99 
100 /**
101  * @class UtilPrepareConf
102  *
103  * Data format:
104  * - UTIL_PREPARE_CONF <UtilPrepareId>
105  */
106 
107 class UtilPrepareConf {
108   /**
109    * Sender(s) / Receiver(s)
110    */
111   friend class DbUtil;
112   friend class Trix;
113 
114   /**
115    * For printing
116    */
117   friend bool printUTIL_PREPARE_CONF(FILE * output,
118 				     const Uint32 * theData,
119 				     Uint32 len,
120 				     Uint16 receiverBlockNo);
121 
122 public:
123   STATIC_CONST( SignalLength = 2 );
124 
125   GET_SET_SENDERDATA
126   GET_SET_PREPAREID
127 private:
128   Uint32 senderData; // MUST be no 1!
129   Uint32 prepareId;
130 };
131 
132 
133 /**
134  * @class UtilPrepareRef
135  *
136  * Data format:
137  * - UTIL_PREPARE_REF
138  */
139 
140 class UtilPrepareRef {
141   /**
142    * Sender(s) / Receiver(s)
143    */
144   friend class Dbdict;
145   friend class DbUtil;
146   friend class Trix;
147 
148   /**
149    * For printing
150    */
151   friend bool printUTIL_PREPARE_REF(FILE * output,
152 				    const Uint32 * theData,
153 				    Uint32 len,
154 				    Uint16 receiverBlockNo);
155 
156 public:
157   enum ErrorCode {
158     NO_ERROR = 0,
159     PREPARE_SEIZE_ERROR = 1,
160     PREPARE_PAGES_SEIZE_ERROR = 2,
161     PREPARED_OPERATION_SEIZE_ERROR = 3,
162     DICT_TAB_INFO_ERROR = 4,
163     MISSING_PROPERTIES_SECTION = 5
164   };
165 
166   STATIC_CONST( SignalLength = 3 );
167 
168   GET_SET_SENDERDATA
169   GET_SET_ERRORCODE
170 private:
171   Uint32 senderData; // MUST be no 1!
172   Uint32 errorCode;
173   Uint32 dictErrCode; // If errorCode == DICT_TAB_INFO_ERROR
174 };
175 
176 
177 
178 #undef JAM_FILE_ID
179 
180 #endif
181