MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlterTable.hpp
1 /*
2  Copyright (c) 2003, 2010, 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 as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef ALTER_TABLE_HPP
19 #define ALTER_TABLE_HPP
20 
21 #include "SignalData.hpp"
22 
23 struct AlterTableReq {
24  STATIC_CONST( SignalLength = 8 );
25 
26  Uint32 clientRef;
27  Uint32 clientData;
28  Uint32 transId;
29  Uint32 transKey;
30  Uint32 requestInfo;
31  Uint32 tableId;
32  Uint32 tableVersion;
33  Uint32 changeMask;
34 
35  SECTION( DICT_TAB_INFO = 0 );
36 
41 /*
42  n = Changed name
43  f = Changed frm
44  d = Changed fragment data
45  r = Changed range or list array
46  t = Changed tablespace name array
47  s = Changed tablespace id array
48  a = Add attribute
49  f = Add fragment(s)
50  r = Reorg fragment(s)
51 
52  1111111111222222222233
53  01234567890123456789012345678901
54  nfdrtsafr-----------------------
55 */
56 #define NAME_SHIFT (0)
57 #define FRM_SHIFT (1)
58 #define FRAG_DATA_SHIFT (2)
59 #define RANGE_LIST_SHIFT (3)
60 #define TS_NAME_SHIFT (4)
61 #define TS_SHIFT (5)
62 #define ADD_ATTR_SHIFT (6)
63 #define ADD_FRAG_SHIFT (7)
64 #define REORG_FRAG_SHIFT (8)
65 #define REORG_COMMIT_SHIFT (9)
66 #define REORG_COMPLETE_SHIFT (10)
67 #define REORG_SUMA_ENABLE (11)
68 #define REORG_SUMA_FILTER (12)
69 
73  static Uint8 getNameFlag(const UintR & changeMask);
74  static void setNameFlag(UintR & changeMask, Uint32 nameFlg);
75  static Uint8 getFrmFlag(const UintR & changeMask);
76  static void setFrmFlag(UintR & changeMask, Uint32 frmFlg);
77  static Uint8 getFragDataFlag(const UintR & changeMask);
78  static void setFragDataFlag(UintR & changeMask, Uint32 fragFlg);
79  static Uint8 getRangeListFlag(const UintR & changeMask);
80  static void setRangeListFlag(UintR & changeMask, Uint32 rangeFlg);
81  static Uint8 getTsNameFlag(const UintR & changeMask);
82  static void setTsNameFlag(UintR & changeMask, Uint32 tsNameFlg);
83  static Uint8 getTsFlag(const UintR & changeMask);
84  static void setTsFlag(UintR & changeMask, Uint32 tsFlg);
85  static Uint8 getAddAttrFlag(const UintR & changeMask);
86  static void setAddAttrFlag(UintR & changeMask, Uint32 tsFlg);
87  static Uint8 getAddFragFlag(const UintR & changeMask);
88  static void setAddFragFlag(UintR & changeMask, Uint32 tsFlg);
89  static Uint8 getReorgFragFlag(const UintR & changeMask);
90  static void setReorgFragFlag(UintR & changeMask, Uint32 tsFlg);
91  static Uint8 getReorgCommitFlag(const UintR & changeMask);
92  static void setReorgCommitFlag(UintR & changeMask, Uint32 tsFlg);
93  static Uint8 getReorgCompleteFlag(const UintR & changeMask);
94  static void setReorgCompleteFlag(UintR & changeMask, Uint32 tsFlg);
95  static Uint8 getReorgSumaEnableFlag(const UintR & changeMask);
96  static void setReorgSumaEnableFlag(UintR & changeMask, Uint32 tsFlg);
97  static Uint8 getReorgSumaFilterFlag(const UintR & changeMask);
98  static void setReorgSumaFilterFlag(UintR & changeMask, Uint32 tsFlg);
99 
100  static bool getReorgSubOp(const UintR & changeMask){
101  return
102  getReorgCommitFlag(changeMask) ||
103  getReorgCompleteFlag(changeMask) ||
104  getReorgSumaEnableFlag(changeMask) ||
105  getReorgSumaFilterFlag(changeMask);
106  }
107 };
108 
109 inline
110 Uint8
111 AlterTableReq::getTsFlag(const UintR & changeMask){
112  return (Uint8)((changeMask >> TS_SHIFT) & 1);
113 }
114 
115 inline
116 void
117 AlterTableReq::setTsFlag(UintR & changeMask, Uint32 tsFlg){
118  changeMask |= (tsFlg << TS_SHIFT);
119 }
120 
121 inline
122 Uint8
123 AlterTableReq::getNameFlag(const UintR & changeMask){
124  return (Uint8)((changeMask >> NAME_SHIFT) & 1);
125 }
126 
127 inline
128 void
129 AlterTableReq::setNameFlag(UintR & changeMask, Uint32 nameFlg){
130  changeMask |= (nameFlg << NAME_SHIFT);
131 }
132 
133 inline
134 Uint8
135 AlterTableReq::getFrmFlag(const UintR & changeMask){
136  return (Uint8)((changeMask >> FRM_SHIFT) & 1);
137 }
138 
139 inline
140 void
141 AlterTableReq::setFrmFlag(UintR & changeMask, Uint32 frmFlg){
142  changeMask |= (frmFlg << FRM_SHIFT);
143 }
144 
145 inline
146 Uint8
147 AlterTableReq::getFragDataFlag(const UintR & changeMask){
148  return (Uint8)((changeMask >> FRAG_DATA_SHIFT) & 1);
149 }
150 
151 inline
152 void
153 AlterTableReq::setFragDataFlag(UintR & changeMask, Uint32 fragDataFlg){
154  changeMask |= (fragDataFlg << FRAG_DATA_SHIFT);
155 }
156 
157 inline
158 Uint8
159 AlterTableReq::getRangeListFlag(const UintR & changeMask){
160  return (Uint8)((changeMask >> RANGE_LIST_SHIFT) & 1);
161 }
162 
163 inline
164 void
165 AlterTableReq::setRangeListFlag(UintR & changeMask, Uint32 rangeFlg){
166  changeMask |= (rangeFlg << RANGE_LIST_SHIFT);
167 }
168 
169 inline
170 Uint8
171 AlterTableReq::getTsNameFlag(const UintR & changeMask){
172  return (Uint8)((changeMask >> TS_NAME_SHIFT) & 1);
173 }
174 
175 inline
176 void
177 AlterTableReq::setTsNameFlag(UintR & changeMask, Uint32 tsNameFlg){
178  changeMask |= (tsNameFlg << TS_NAME_SHIFT);
179 }
180 
181 inline
182 Uint8
183 AlterTableReq::getAddAttrFlag(const UintR & changeMask){
184  return (Uint8)((changeMask >> ADD_ATTR_SHIFT) & 1);
185 }
186 
187 inline
188 void
189 AlterTableReq::setAddAttrFlag(UintR & changeMask, Uint32 addAttrFlg){
190  changeMask |= (addAttrFlg << ADD_ATTR_SHIFT);
191 }
192 
193 inline
194 Uint8
195 AlterTableReq::getAddFragFlag(const UintR & changeMask){
196  return (Uint8)((changeMask >> ADD_FRAG_SHIFT) & 1);
197 }
198 
199 inline
200 void
201 AlterTableReq::setAddFragFlag(UintR & changeMask, Uint32 addAttrFlg){
202  changeMask |= (addAttrFlg << ADD_FRAG_SHIFT);
203 }
204 
205 inline
206 Uint8
207 AlterTableReq::getReorgFragFlag(const UintR & changeMask){
208  return (Uint8)((changeMask >> REORG_FRAG_SHIFT) & 1);
209 }
210 
211 inline
212 void
213 AlterTableReq::setReorgFragFlag(UintR & changeMask, Uint32 reorgAttrFlg){
214  changeMask |= (reorgAttrFlg << REORG_FRAG_SHIFT);
215 }
216 
217 inline
218 Uint8
219 AlterTableReq::getReorgCommitFlag(const UintR & changeMask){
220  return (Uint8)((changeMask >> REORG_COMMIT_SHIFT) & 1);
221 }
222 
223 inline
224 void
225 AlterTableReq::setReorgCommitFlag(UintR & changeMask, Uint32 reorgAttrFlg){
226  changeMask |= (reorgAttrFlg << REORG_COMMIT_SHIFT);
227 }
228 
229 
230 inline
231 Uint8
232 AlterTableReq::getReorgCompleteFlag(const UintR & changeMask){
233  return (Uint8)((changeMask >> REORG_COMPLETE_SHIFT) & 1);
234 }
235 
236 inline
237 void
238 AlterTableReq::setReorgCompleteFlag(UintR & changeMask, Uint32 reorgAttrFlg){
239  changeMask |= (reorgAttrFlg << REORG_COMPLETE_SHIFT);
240 }
241 
242 inline
243 Uint8
244 AlterTableReq::getReorgSumaEnableFlag(const UintR & changeMask){
245  return (Uint8)((changeMask >> REORG_SUMA_ENABLE) & 1);
246 }
247 
248 inline
249 void
250 AlterTableReq::setReorgSumaEnableFlag(UintR & changeMask, Uint32 reorgAttrFlg){
251  changeMask |= (reorgAttrFlg << REORG_SUMA_ENABLE);
252 }
253 
254 inline
255 Uint8
256 AlterTableReq::getReorgSumaFilterFlag(const UintR & changeMask){
257  return (Uint8)((changeMask >> REORG_SUMA_FILTER) & 1);
258 }
259 
260 inline
261 void
262 AlterTableReq::setReorgSumaFilterFlag(UintR & changeMask, Uint32 reorgAttrFlg){
263  changeMask |= (reorgAttrFlg << REORG_SUMA_FILTER);
264 }
265 
267  STATIC_CONST( SignalLength = 6 );
268 
269  Uint32 senderRef;
270  union {
271  Uint32 clientData;
272  Uint32 senderData;
273  };
274  Uint32 transId;
275  Uint32 tableId;
276  Uint32 tableVersion;
277  Uint32 newTableVersion;
278 };
279 
281  STATIC_CONST( SignalLength = 9 );
282 
283  enum ErrorCode {
284  NoError = 0,
285  InvalidTableVersion = 241,
286  DropInProgress = 283,
287  Busy = 701,
288  BusyWithNR = 711,
289  NotMaster = 702,
290  InvalidFormat = 703,
291  AttributeNameTooLong = 704,
292  TableNameTooLong = 705,
293  Inconsistency = 706,
294  NoMoreTableRecords = 707,
295  NoMoreAttributeRecords = 708,
296  NoSuchTable = 709,
297  AttributeNameTwice = 720,
298  TableAlreadyExist = 721,
299  ArraySizeTooBig = 737,
300  RecordTooBig = 738,
301  InvalidPrimaryKeySize = 739,
302  NullablePrimaryKey = 740,
303  UnsupportedChange = 741,
304  BackupInProgress = 762,
305  IncompatibleVersions = 763,
306  SingleUser = 299,
307  TableDefinitionTooBig = 793
308  };
309 
310  Uint32 senderRef;
311  union {
312  Uint32 clientData;
313  Uint32 senderData;
314  };
315  Uint32 transId;
316  Uint32 errorCode;
317  Uint32 errorLine;
318  Uint32 errorNodeId;
319  Uint32 masterNodeId;
320  Uint32 errorStatus;
321  Uint32 errorKey;
322 };
323 
328 {
329  friend bool printALTER_TABLE_REP(FILE*, const Uint32*, Uint32, Uint16);
330 
331  STATIC_CONST( SignalLength = 3 );
332 
333  enum Change_type
334  {
335  CT_ALTERED = 0x1,
336  CT_DROPPED = 0x2
337  };
338 
339  Uint32 tableId;
340  Uint32 tableVersion;
341  Uint32 changeType;
342 
343  SECTION( TABLE_NAME = 0 );
344 };
345 
346 #endif