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 ACC_SCAN_HPP
26 #define ACC_SCAN_HPP
27
28 #include "SignalData.hpp"
29
30 /*
31 * Used by ACC and TUX scan.
32 */
33
34 class AccScanReq {
35 /**
36 * Sender(s)
37 */
38 friend class Dblqh;
39
40 /**
41 * Reciver(s)
42 */
43 friend class Dbacc;
44 friend class Dbtux;
45 friend class Dbtup;
46 public:
47 STATIC_CONST( SignalLength = 8 );
48
49 private:
50 Uint32 senderData;
51 Uint32 senderRef;
52 Uint32 tableId;
53 Uint32 fragmentNo;
54 Uint32 requestInfo;
55 Uint32 transId1;
56 Uint32 transId2;
57 union {
58 Uint32 savePointId;
59 Uint32 gci;
60 };
61 Uint32 maxPage;
62
63 /**
64 * Previously there where also a scan type
65 */
66 static Uint32 getLockMode(const Uint32 & requestInfo);
67 static Uint32 getReadCommittedFlag(const Uint32 & requestInfo);
68 static Uint32 getDescendingFlag(const Uint32 & requestInfo);
69
70 static void setLockMode(Uint32 & requestInfo, Uint32 lockMode);
71 static void setReadCommittedFlag(Uint32 & requestInfo, Uint32 readCommitted);
72 static void setDescendingFlag(Uint32 & requestInfo, Uint32 descending);
73
74 static Uint32 getNoDiskScanFlag(const Uint32 & requestInfo);
75 static void setNoDiskScanFlag(Uint32 & requestInfo, Uint32 nodisk);
76
77 static Uint32 getNRScanFlag(const Uint32 & requestInfo);
78 static void setNRScanFlag(Uint32 & requestInfo, Uint32 nr);
79
80 static Uint32 getLcpScanFlag(const Uint32 & requestInfo);
81 static void setLcpScanFlag(Uint32 & requestInfo, Uint32 nr);
82
83 static Uint32 getStatScanFlag(const Uint32 & requestInfo);
84 static void setStatScanFlag(Uint32 & requestInfo, Uint32 nr);
85 };
86
87 /**
88 * Request Info
89 *
90 * l = Lock Mode - 1 Bit 2
91 * h = Read Committed - 1 Bit 5
92 * z = Descending (TUX) - 1 Bit 6
93 * d = No disk scan - 1 Bit 7
94 * n = Node recovery scan - 1 Bit 8
95 * c = LCP scan - 1 Bit 9
96 * s = Statistics scan - 1 Bit 4
97 *
98 * 1111111111222222222233
99 * 01234567890123456789012345678901
100 * l shzdn
101 */
102 #define AS_LOCK_MODE_SHIFT (2)
103 #define AS_LOCK_MODE_MASK (1)
104 #define AS_READ_COMMITTED_SHIFT (5)
105 #define AS_DESCENDING_SHIFT (6)
106 #define AS_NO_DISK_SCAN (7)
107 #define AS_NR_SCAN (8)
108 #define AS_LCP_SCAN (9)
109 #define AS_STAT_SCAN (4)
110
111 inline
112 Uint32
getLockMode(const Uint32 & requestInfo)113 AccScanReq::getLockMode(const Uint32 & requestInfo){
114 return (requestInfo >> AS_LOCK_MODE_SHIFT) & AS_LOCK_MODE_MASK;
115 }
116
117 inline
118 Uint32
getReadCommittedFlag(const Uint32 & requestInfo)119 AccScanReq::getReadCommittedFlag(const Uint32 & requestInfo){
120 return (requestInfo >> AS_READ_COMMITTED_SHIFT) & 1;
121 }
122
123 inline
124 Uint32
getDescendingFlag(const Uint32 & requestInfo)125 AccScanReq::getDescendingFlag(const Uint32 & requestInfo){
126 return (requestInfo >> AS_DESCENDING_SHIFT) & 1;
127 }
128
129 inline
130 void
setLockMode(UintR & requestInfo,UintR val)131 AccScanReq::setLockMode(UintR & requestInfo, UintR val){
132 ASSERT_MAX(val, AS_LOCK_MODE_MASK, "AccScanReq::setLockMode");
133 requestInfo |= (val << AS_LOCK_MODE_SHIFT);
134 }
135
136 inline
137 void
setReadCommittedFlag(UintR & requestInfo,UintR val)138 AccScanReq::setReadCommittedFlag(UintR & requestInfo, UintR val){
139 ASSERT_BOOL(val, "AccScanReq::setReadCommittedFlag");
140 requestInfo |= (val << AS_READ_COMMITTED_SHIFT);
141 }
142
143 inline
144 void
setDescendingFlag(UintR & requestInfo,UintR val)145 AccScanReq::setDescendingFlag(UintR & requestInfo, UintR val){
146 ASSERT_BOOL(val, "AccScanReq::setDescendingFlag");
147 requestInfo |= (val << AS_DESCENDING_SHIFT);
148 }
149
150 inline
151 Uint32
getNoDiskScanFlag(const Uint32 & requestInfo)152 AccScanReq::getNoDiskScanFlag(const Uint32 & requestInfo){
153 return (requestInfo >> AS_NO_DISK_SCAN) & 1;
154 }
155
156 inline
157 void
setNoDiskScanFlag(UintR & requestInfo,UintR val)158 AccScanReq::setNoDiskScanFlag(UintR & requestInfo, UintR val){
159 ASSERT_BOOL(val, "AccScanReq::setNoDiskScanFlag");
160 requestInfo |= (val << AS_NO_DISK_SCAN);
161 }
162
163 inline
164 Uint32
getNRScanFlag(const Uint32 & requestInfo)165 AccScanReq::getNRScanFlag(const Uint32 & requestInfo){
166 return (requestInfo >> AS_NR_SCAN) & 1;
167 }
168
169 inline
170 void
setNRScanFlag(UintR & requestInfo,UintR val)171 AccScanReq::setNRScanFlag(UintR & requestInfo, UintR val){
172 ASSERT_BOOL(val, "AccScanReq::setNoDiskScanFlag");
173 requestInfo |= (val << AS_NR_SCAN);
174 }
175
176 inline
177 Uint32
getLcpScanFlag(const Uint32 & requestInfo)178 AccScanReq::getLcpScanFlag(const Uint32 & requestInfo){
179 return (requestInfo >> AS_LCP_SCAN) & 1;
180 }
181
182 inline
183 void
setLcpScanFlag(UintR & requestInfo,UintR val)184 AccScanReq::setLcpScanFlag(UintR & requestInfo, UintR val){
185 ASSERT_BOOL(val, "AccScanReq::setNoDiskScanFlag");
186 requestInfo |= (val << AS_LCP_SCAN);
187 }
188
189 inline
190 Uint32
getStatScanFlag(const Uint32 & requestInfo)191 AccScanReq::getStatScanFlag(const Uint32 & requestInfo){
192 return (requestInfo >> AS_STAT_SCAN) & 1;
193 }
194
195 inline
196 void
setStatScanFlag(UintR & requestInfo,UintR val)197 AccScanReq::setStatScanFlag(UintR & requestInfo, UintR val){
198 ASSERT_BOOL(val, "AccScanReq::setStatScanScanFlag");
199 requestInfo |= (val << AS_STAT_SCAN);
200 }
201
202 class AccScanConf {
203 /**
204 * Sender(s)
205 */
206 friend class Dbacc;
207 friend class Dbtux;
208 friend class Dbtup;
209
210 /**
211 * Reciver(s)
212 */
213 friend class Dblqh;
214
215 enum {
216 ZEMPTY_FRAGMENT = 0,
217 ZNOT_EMPTY_FRAGMENT = 1
218 };
219
220 public:
221 STATIC_CONST( SignalLength = 8 );
222
223 private:
224 Uint32 scanPtr;
225 Uint32 accPtr;
226 Uint32 unused1;
227 Uint32 unused2;
228 Uint32 unused3;
229 Uint32 unused4;
230 Uint32 unused5;
231 Uint32 flag;
232 };
233
234 class AccScanRef {
235 friend class Dbtux;
236 friend class Dblqh;
237
238 enum ErrorCode {
239 TuxNoFreeScanOp = 909,
240 TuxIndexNotOnline = 910,
241 TuxNoFreeStatOp = 911,
242 TuxInvalidLockMode = 912
243 };
244
245 public:
246 STATIC_CONST( SignalLength = 3 );
247
248 private:
249 Uint32 scanPtr;
250 Uint32 accPtr;
251 Uint32 errorCode;
252 };
253
254 class AccCheckScan {
255 friend class Dbacc;
256 friend class Dbtux;
257 friend class Dbtup;
258 friend class Dblqh;
259 enum {
260 ZCHECK_LCP_STOP = 0,
261 ZNOT_CHECK_LCP_STOP = 1
262 };
263 public:
264 STATIC_CONST( SignalLength = 2 );
265 private:
266 Uint32 accPtr; // scanptr.i in ACC or TUX
267 Uint32 checkLcpStop; // from enum
268 };
269
270 #endif
271