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, 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 struct ListTablesData
32 {
33   Uint32 requestData;
34   Uint32 tableId;
35   Uint32 tableType;
36 
initListTablesData37   void init() {
38     requestData = 0;
39   }
40 
getTableIdListTablesData41   Uint32 getTableId() const {
42     return tableId;
43   }
44 
setTableIdListTablesData45   void setTableId(Uint32 val) {
46     tableId = val;
47   }
48 
getTableTypeListTablesData49   Uint32 getTableType() const {
50     return tableType;
51   }
52 
setTableTypeListTablesData53   void setTableType(Uint32 val) {
54     tableType = val;
55   }
56 
getTableStoreListTablesData57   Uint32 getTableStore() const {
58     return BitmaskImpl::getField(1, &requestData, 20, 3);
59   }
setTableStoreListTablesData60   void setTableStore(Uint32 val) {
61     BitmaskImpl::setField(1, &requestData, 20, 3, val);
62   }
getTableTempListTablesData63   Uint32 getTableTemp() const {
64     return BitmaskImpl::getField(1, &requestData, 23, 1);
65   }
setTableTempListTablesData66   void setTableTemp(Uint32 val) {
67     BitmaskImpl::setField(1, &requestData, 23, 1, val);
68   }
getTableStateListTablesData69   Uint32 getTableState() const {
70     return BitmaskImpl::getField(1, &requestData, 24, 4);
71   }
setTableStateListTablesData72   void setTableState(Uint32 val) {
73     BitmaskImpl::setField(1, &requestData, 24, 4, val);
74   }
getListNamesListTablesData75   Uint32 getListNames() const {
76     return BitmaskImpl::getField(1, &requestData, 28, 1);
77   }
setListNamesListTablesData78   void setListNames(Uint32 val) {
79     BitmaskImpl::setField(1, &requestData, 28, 1, val);
80   }
getListIndexesListTablesData81   Uint32 getListIndexes() const {
82     return BitmaskImpl::getField(1, &requestData, 29, 1);
83   }
setListIndexesListTablesData84   void setListIndexes(Uint32 val) {
85     BitmaskImpl::setField(1, &requestData, 29, 1, val);
86   }
87 };
88 
89 /**
90  * DEPRECATED
91  * It is convenient to pack request/response data per table in one
92  * 32-bit word...
93  *
94  */
95 class OldListTablesData {
96 public:
getTableId(Uint32 data)97   static Uint32 getTableId(Uint32 data) {
98     return BitmaskImpl::getField(1, &data, 0, 12);
99   }
setTableId(Uint32 & data,Uint32 val)100   static void setTableId(Uint32& data, Uint32 val) {
101     BitmaskImpl::setField(1, &data, 0, 12, val);
102   }
getTableType(Uint32 data)103   static Uint32 getTableType(Uint32 data) {
104     return BitmaskImpl::getField(1, &data, 12, 8);
105   }
setTableType(Uint32 & data,Uint32 val)106   static void setTableType(Uint32& data, Uint32 val) {
107     BitmaskImpl::setField(1, &data, 12, 8, val);
108   }
getTableStore(Uint32 data)109   static Uint32 getTableStore(Uint32 data) {
110     return BitmaskImpl::getField(1, &data, 20, 3);
111   }
setTableStore(Uint32 & data,Uint32 val)112   static void setTableStore(Uint32& data, Uint32 val) {
113     BitmaskImpl::setField(1, &data, 20, 3, val);
114   }
getTableTemp(Uint32 data)115   static Uint32 getTableTemp(Uint32 data) {
116     return BitmaskImpl::getField(1, &data, 23, 1);
117   }
setTableTemp(Uint32 & data,Uint32 val)118   static void setTableTemp(Uint32& data, Uint32 val) {
119     BitmaskImpl::setField(1, &data, 23, 1, val);
120   }
getTableState(Uint32 data)121   static Uint32 getTableState(Uint32 data) {
122     return BitmaskImpl::getField(1, &data, 24, 4);
123   }
setTableState(Uint32 & data,Uint32 val)124   static void setTableState(Uint32& data, Uint32 val) {
125     BitmaskImpl::setField(1, &data, 24, 4, val);
126   }
getListNames(Uint32 data)127   static Uint32 getListNames(Uint32 data) {
128     return BitmaskImpl::getField(1, &data, 28, 1);
129   }
setListNames(Uint32 & data,Uint32 val)130   static void setListNames(Uint32& data, Uint32 val) {
131     BitmaskImpl::setField(1, &data, 28, 1, val);
132   }
getListIndexes(Uint32 data)133   static Uint32 getListIndexes(Uint32 data) {
134     return BitmaskImpl::getField(1, &data, 29, 1);
135   }
setListIndexes(Uint32 & data,Uint32 val)136   static void setListIndexes(Uint32& data, Uint32 val) {
137     BitmaskImpl::setField(1, &data, 29, 1, val);
138   }
139 };
140 
141 class ListTablesReq {
142   /**
143    * Sender(s)
144    */
145   friend class Backup;
146   friend class Table;
147   friend class Suma;
148 
149   /**
150    * Reciver(s)
151    */
152   friend class Dbdict;
153 
154 public:
155   STATIC_CONST( oldSignalLength = 3 );
156   STATIC_CONST( SignalLength = 5 );
157 
158 public:
159   Uint32 senderData;
160   Uint32 senderRef;
161   ListTablesData data;
162 
init()163   void init(){
164     data.init();
165   }
166 
getTableId() const167   Uint32 getTableId() const {
168     return data.getTableId();
169   }
setTableId(Uint32 val)170   void setTableId(Uint32 val) {
171     data.setTableId(val);
172   }
getTableType() const173   Uint32 getTableType() const {
174     return data.getTableType();
175   }
setTableType(Uint32 val)176   void setTableType(Uint32 val) {
177     data.setTableType(val);
178   }
getListNames() const179   Uint32 getListNames() const {
180     return data.getListNames();
181   }
setListNames(Uint32 val)182   void setListNames(Uint32 val) {
183     data.setListNames(val);
184   }
getListIndexes() const185   Uint32 getListIndexes() const {
186     return data.getListIndexes();
187   }
setListIndexes(Uint32 val)188   void setListIndexes(Uint32 val) {
189     data.setListIndexes(val);
190   }
191 
192 
193   /* For backwards compatility */
oldGetTableId()194   Uint32 oldGetTableId() {
195     return OldListTablesData::getTableId(data.requestData);
196   }
oldSetTableId(Uint32 val)197   void oldSetTableId(Uint32 val) {
198     OldListTablesData::setTableId(data.requestData, val);
199   }
oldGetTableType() const200   Uint32 oldGetTableType() const {
201     return OldListTablesData::getTableType(data.requestData);
202   }
oldSetTableType(Uint32 val)203   void oldSetTableType(Uint32 val) {
204     OldListTablesData::setTableType(data.requestData, val);
205   }
206 };
207 
208 class ListTablesConf {
209   /**
210    * Sender(s)
211    */
212   friend class Dbdict;
213 
214   /**
215    * Reciver(s)
216    */
217   friend class Backup;
218   friend class Table;
219 
220 public:
221   STATIC_CONST( SignalLength = 2 );
222 
223 public:
224   Uint32 senderData;
225   Uint32 noOfTables;
226 
227   SECTION( TABLE_DATA = 0 );
228   SECTION( TABLE_NAMES = 1 );
229 };
230 
231 class OldListTablesConf {
232   /**
233    * Sender(s)
234    */
235   friend class Dbdict;
236 
237   /**
238    * Reciver(s)
239    */
240   friend class Backup;
241   friend class Table;
242 
243 public:
244   /**
245    * Note: last signal is indicated by having length < 25
246    */
247   STATIC_CONST( SignalLength = 25 );
248   STATIC_CONST( HeaderLength = 2  );
249   STATIC_CONST( DataLength   = 23 );
250 
251 public:
252   Uint32 senderData;
253   Uint32 counter;
254   Uint32 tableData[DataLength];
255 
getTableId(Uint32 data)256   static Uint32 getTableId(Uint32 data) {
257     return OldListTablesData::getTableId(data);
258   }
setTableId(unsigned pos,Uint32 val)259   void setTableId(unsigned pos, Uint32 val) {
260     OldListTablesData::setTableId(tableData[pos], val);
261   }
getTableType(Uint32 data)262   static Uint32 getTableType(Uint32 data) {
263     return OldListTablesData::getTableType(data);
264   }
setTableType(unsigned pos,Uint32 val)265   void setTableType(unsigned pos, Uint32 val) {
266     OldListTablesData::setTableType(tableData[pos], val);
267   }
getTableStore(Uint32 data)268   static Uint32 getTableStore(Uint32 data) {
269     return OldListTablesData::getTableStore(data);
270   }
setTableStore(unsigned pos,Uint32 val)271   void setTableStore(unsigned pos, Uint32 val) {
272     OldListTablesData::setTableStore(tableData[pos], val);
273   }
getTableState(Uint32 data)274   static Uint32 getTableState(Uint32 data) {
275     return OldListTablesData::getTableState(data);
276   }
setTableState(unsigned pos,Uint32 val)277   void setTableState(unsigned pos, Uint32 val) {
278     OldListTablesData::setTableState(tableData[pos], val);
279   }
getTableTemp(Uint32 data)280   static Uint32 getTableTemp(Uint32 data) {
281     return OldListTablesData::getTableTemp(data);
282   }
setTableTemp(unsigned pos,Uint32 val)283   void setTableTemp(unsigned pos, Uint32 val) {
284     OldListTablesData::setTableTemp(tableData[pos], val);
285   }
286 };
287 
288 #endif
289