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 LIST_TABLES_HPP
26 #define LIST_TABLES_HPP
27 
28 #include <Bitmask.hpp>
29 #include "SignalData.hpp"
30 
31 #define JAM_FILE_ID 55
32 
33 
34 struct ListTablesData
35 {
36   Uint32 requestData;
37   Uint32 tableId;
38   Uint32 tableType;
39 
initListTablesData40   void init() {
41     requestData = 0;
42   }
43 
getTableIdListTablesData44   Uint32 getTableId() const {
45     return tableId;
46   }
47 
setTableIdListTablesData48   void setTableId(Uint32 val) {
49     tableId = val;
50   }
51 
getTableTypeListTablesData52   Uint32 getTableType() const {
53     return tableType;
54   }
55 
setTableTypeListTablesData56   void setTableType(Uint32 val) {
57     tableType = val;
58   }
59 
getTableStoreListTablesData60   Uint32 getTableStore() const {
61     return BitmaskImpl::getField(1, &requestData, 20, 3);
62   }
setTableStoreListTablesData63   void setTableStore(Uint32 val) {
64     BitmaskImpl::setField(1, &requestData, 20, 3, val);
65   }
getTableTempListTablesData66   Uint32 getTableTemp() const {
67     return BitmaskImpl::getField(1, &requestData, 23, 1);
68   }
setTableTempListTablesData69   void setTableTemp(Uint32 val) {
70     BitmaskImpl::setField(1, &requestData, 23, 1, val);
71   }
getTableStateListTablesData72   Uint32 getTableState() const {
73     return BitmaskImpl::getField(1, &requestData, 24, 4);
74   }
setTableStateListTablesData75   void setTableState(Uint32 val) {
76     BitmaskImpl::setField(1, &requestData, 24, 4, val);
77   }
getListNamesListTablesData78   Uint32 getListNames() const {
79     return BitmaskImpl::getField(1, &requestData, 28, 1);
80   }
setListNamesListTablesData81   void setListNames(Uint32 val) {
82     BitmaskImpl::setField(1, &requestData, 28, 1, val);
83   }
getListIndexesListTablesData84   Uint32 getListIndexes() const {
85     return BitmaskImpl::getField(1, &requestData, 29, 1);
86   }
setListIndexesListTablesData87   void setListIndexes(Uint32 val) {
88     BitmaskImpl::setField(1, &requestData, 29, 1, val);
89   }
getListDependentListTablesData90   Uint32 getListDependent() const {
91     return BitmaskImpl::getField(1, &requestData, 30, 1);
92   }
setListDependentListTablesData93   void setListDependent(Uint32 val) {
94     BitmaskImpl::setField(1, &requestData, 30, 1, val);
95   }
96 };
97 
98 /**
99  * DEPRECATED
100  * It is convenient to pack request/response data per table in one
101  * 32-bit word...
102  *
103  */
104 class OldListTablesData {
105 public:
getTableId(Uint32 data)106   static Uint32 getTableId(Uint32 data) {
107     return BitmaskImpl::getField(1, &data, 0, 12);
108   }
setTableId(Uint32 & data,Uint32 val)109   static void setTableId(Uint32& data, Uint32 val) {
110     BitmaskImpl::setField(1, &data, 0, 12, val);
111   }
getTableType(Uint32 data)112   static Uint32 getTableType(Uint32 data) {
113     return BitmaskImpl::getField(1, &data, 12, 8);
114   }
setTableType(Uint32 & data,Uint32 val)115   static void setTableType(Uint32& data, Uint32 val) {
116     BitmaskImpl::setField(1, &data, 12, 8, val);
117   }
getTableStore(Uint32 data)118   static Uint32 getTableStore(Uint32 data) {
119     return BitmaskImpl::getField(1, &data, 20, 3);
120   }
setTableStore(Uint32 & data,Uint32 val)121   static void setTableStore(Uint32& data, Uint32 val) {
122     BitmaskImpl::setField(1, &data, 20, 3, val);
123   }
getTableTemp(Uint32 data)124   static Uint32 getTableTemp(Uint32 data) {
125     return BitmaskImpl::getField(1, &data, 23, 1);
126   }
setTableTemp(Uint32 & data,Uint32 val)127   static void setTableTemp(Uint32& data, Uint32 val) {
128     BitmaskImpl::setField(1, &data, 23, 1, val);
129   }
getTableState(Uint32 data)130   static Uint32 getTableState(Uint32 data) {
131     return BitmaskImpl::getField(1, &data, 24, 4);
132   }
setTableState(Uint32 & data,Uint32 val)133   static void setTableState(Uint32& data, Uint32 val) {
134     BitmaskImpl::setField(1, &data, 24, 4, val);
135   }
getListNames(Uint32 data)136   static Uint32 getListNames(Uint32 data) {
137     return BitmaskImpl::getField(1, &data, 28, 1);
138   }
setListNames(Uint32 & data,Uint32 val)139   static void setListNames(Uint32& data, Uint32 val) {
140     BitmaskImpl::setField(1, &data, 28, 1, val);
141   }
getListIndexes(Uint32 data)142   static Uint32 getListIndexes(Uint32 data) {
143     return BitmaskImpl::getField(1, &data, 29, 1);
144   }
setListIndexes(Uint32 & data,Uint32 val)145   static void setListIndexes(Uint32& data, Uint32 val) {
146     BitmaskImpl::setField(1, &data, 29, 1, val);
147   }
148 };
149 
150 class ListTablesReq {
151   /**
152    * Sender(s)
153    */
154   friend class Backup;
155   friend class Table;
156   friend class Suma;
157 
158   /**
159    * Reciver(s)
160    */
161   friend class Dbdict;
162 
163 public:
164   STATIC_CONST( oldSignalLength = 3 );
165   STATIC_CONST( SignalLength = 5 );
166 
167 public:
168   Uint32 senderData;
169   Uint32 senderRef;
170   ListTablesData data;
171 
init()172   void init(){
173     data.init();
174   }
175 
getTableId() const176   Uint32 getTableId() const {
177     return data.getTableId();
178   }
setTableId(Uint32 val)179   void setTableId(Uint32 val) {
180     data.setTableId(val);
181   }
getTableType() const182   Uint32 getTableType() const {
183     return data.getTableType();
184   }
setTableType(Uint32 val)185   void setTableType(Uint32 val) {
186     data.setTableType(val);
187   }
getListNames() const188   Uint32 getListNames() const {
189     return data.getListNames();
190   }
setListNames(Uint32 val)191   void setListNames(Uint32 val) {
192     data.setListNames(val);
193   }
getListIndexes() const194   Uint32 getListIndexes() const {
195     return data.getListIndexes();
196   }
setListIndexes(Uint32 val)197   void setListIndexes(Uint32 val) {
198     data.setListIndexes(val);
199   }
getListDependent() const200   Uint32 getListDependent() const {
201     return data.getListDependent();
202   }
setListDependent(Uint32 val)203   void setListDependent(Uint32 val) {
204     data.setListDependent(val);
205   }
206 
207 
208   /* For backwards compatility */
oldGetTableId()209   Uint32 oldGetTableId() {
210     return OldListTablesData::getTableId(data.requestData);
211   }
oldSetTableId(Uint32 val)212   void oldSetTableId(Uint32 val) {
213     OldListTablesData::setTableId(data.requestData, val);
214   }
oldGetTableType() const215   Uint32 oldGetTableType() const {
216     return OldListTablesData::getTableType(data.requestData);
217   }
oldSetTableType(Uint32 val)218   void oldSetTableType(Uint32 val) {
219     OldListTablesData::setTableType(data.requestData, val);
220   }
221 };
222 
223 class ListTablesConf {
224   /**
225    * Sender(s)
226    */
227   friend class Dbdict;
228 
229   /**
230    * Reciver(s)
231    */
232   friend class Backup;
233   friend class Table;
234 
235 public:
236   STATIC_CONST( SignalLength = 2 );
237 
238 public:
239   Uint32 senderData;
240   Uint32 noOfTables;
241 
242   SECTION( TABLE_DATA = 0 );
243   SECTION( TABLE_NAMES = 1 );
244 };
245 
246 class OldListTablesConf {
247   /**
248    * Sender(s)
249    */
250   friend class Dbdict;
251 
252   /**
253    * Reciver(s)
254    */
255   friend class Backup;
256   friend class Table;
257 
258 public:
259   /**
260    * Note: last signal is indicated by having length < 25
261    */
262   STATIC_CONST( SignalLength = 25 );
263   STATIC_CONST( HeaderLength = 2  );
264   STATIC_CONST( DataLength   = 23 );
265 
266 public:
267   Uint32 senderData;
268   Uint32 counter;
269   Uint32 tableData[DataLength];
270 
getTableId(Uint32 data)271   static Uint32 getTableId(Uint32 data) {
272     return OldListTablesData::getTableId(data);
273   }
setTableId(unsigned pos,Uint32 val)274   void setTableId(unsigned pos, Uint32 val) {
275     OldListTablesData::setTableId(tableData[pos], val);
276   }
getTableType(Uint32 data)277   static Uint32 getTableType(Uint32 data) {
278     return OldListTablesData::getTableType(data);
279   }
setTableType(unsigned pos,Uint32 val)280   void setTableType(unsigned pos, Uint32 val) {
281     OldListTablesData::setTableType(tableData[pos], val);
282   }
getTableStore(Uint32 data)283   static Uint32 getTableStore(Uint32 data) {
284     return OldListTablesData::getTableStore(data);
285   }
setTableStore(unsigned pos,Uint32 val)286   void setTableStore(unsigned pos, Uint32 val) {
287     OldListTablesData::setTableStore(tableData[pos], val);
288   }
getTableState(Uint32 data)289   static Uint32 getTableState(Uint32 data) {
290     return OldListTablesData::getTableState(data);
291   }
setTableState(unsigned pos,Uint32 val)292   void setTableState(unsigned pos, Uint32 val) {
293     OldListTablesData::setTableState(tableData[pos], val);
294   }
getTableTemp(Uint32 data)295   static Uint32 getTableTemp(Uint32 data) {
296     return OldListTablesData::getTableTemp(data);
297   }
setTableTemp(unsigned pos,Uint32 val)298   void setTableTemp(unsigned pos, Uint32 val) {
299     OldListTablesData::setTableTemp(tableData[pos], val);
300   }
301 };
302 
303 
304 #undef JAM_FILE_ID
305 
306 #endif
307