MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AttributeHeader.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 ATTRIBUTE_HEADER
19 #define ATTRIBUTE_HEADER
20 
26  friend class Dbtup;
27  friend class Backup;
28  friend class NdbOperation;
29  friend class DbUtil;
30  friend class Suma;
31 
32 public:
36  STATIC_CONST( PSEUDO = 0x8000 );
37  STATIC_CONST( FRAGMENT = 0xFFFE ); // Read fragment no
38  STATIC_CONST( ROW_COUNT = 0xFFFD ); // Read row count (committed)
39  STATIC_CONST( COMMIT_COUNT = 0xFFFC ); // Read commit count
40  STATIC_CONST( RANGE_NO = 0xFFFB ); // Read range no (when batched ranges)
41 
42  STATIC_CONST( ROW_SIZE = 0xFFFA );
43  STATIC_CONST( FRAGMENT_FIXED_MEMORY= 0xFFF9 );
44 
45  STATIC_CONST( RECORDS_IN_RANGE = 0xFFF8 );
46  STATIC_CONST( DISK_REF = 0xFFF7 );
47  STATIC_CONST( ROWID = 0xFFF6 );
48  STATIC_CONST( ROW_GCI = 0xFFF5 );
49  STATIC_CONST( FRAGMENT_VARSIZED_MEMORY = 0xFFF4 );
50  STATIC_CONST( READ_PACKED = 0xFFF3 );
51  STATIC_CONST( ANY_VALUE = 0xFFF2 );
52  STATIC_CONST( COPY_ROWID = 0xFFF1 );
53  STATIC_CONST( READ_ALL = 0xFFF0 );
54  STATIC_CONST( READ_LCP = 0xFFEF );
55  STATIC_CONST( LOCK_REF = 0xFFEE ); // Operation lock reference
56  STATIC_CONST( OP_ID = 0xFFED ); // Operation runtime identity
57 
58  // Extents * sizeof(Extent) allocated to fragment
59  STATIC_CONST( FRAGMENT_EXTENT_SPACE = 0xFFEC );
60 
61  // Free but allocated DD extent space
62  STATIC_CONST( FRAGMENT_FREE_EXTENT_SPACE = 0xFFEB );
63 
64  STATIC_CONST( FLUSH_AI = 0xFFEA );
65  STATIC_CONST( CORR_FACTOR32 = 0xFFE9 ); // excluding root-frag
66  STATIC_CONST( CORR_FACTOR64 = 0xFFE8 ); // including root-frag
67 
72  STATIC_CONST( ROW_GCI64 = 0xFFE7);
73 
77  STATIC_CONST( ROW_AUTHOR = 0xFFE6);
78 
82  STATIC_CONST( OPTIMIZE = 0xFFE0 ); //pseudo column id to optimize
83  STATIC_CONST( OPTIMIZE_OPTIONS_MASK = 0xFFFF ); //bitmask AND column value
84  STATIC_CONST( OPTIMIZE_MOVE_VARPART = 0x0001 ); //option to move varpart
85  STATIC_CONST( OPTIMIZE_MOVE_FIXPART = 0x0002 ); //option to move fixpart
86 
87  // index stats pseudo columns
88  STATIC_CONST( INDEX_STAT_KEY = 0xFFD0 );
89  STATIC_CONST( INDEX_STAT_VALUE = 0xFFD1 );
90 
91  // NOTE: in 5.1 ctors and init take size in bytes
92 
94  static void init(Uint32* aHeaderPtr, Uint32 anAttributeId, Uint32 aByteSize);
95 
97  Uint32 getHeaderSize() const; // In 32-bit words
98 
100  void insertHeader(Uint32*);
101 
103  AttributeHeader* getNext() const;
104 
106  Uint32* getDataPtr() const;
107 
109  Uint32 getAttributeId() const;
110  void setAttributeId(Uint32);
111  Uint32 getByteSize() const;
112  void setByteSize(Uint32);
113  Uint32 getDataSize() const; // In 32-bit words, rounded up
114  void setDataSize(Uint32); // Set size to multiple of word size
115  bool isNULL() const;
116  void setNULL();
117 
119  //void print(NdbOut&);
120  void print(FILE*);
121 
122  static Uint32 getByteSize(Uint32);
123  static Uint32 getDataSize(Uint32);
124  static Uint32 getAttributeId(Uint32 id);
125 
126 public:
127  AttributeHeader(Uint32 = 0);
128  AttributeHeader(Uint32 anAttributeId, Uint32 aByteSize);
129  ~AttributeHeader();
130 
131  Uint32 m_value;
132 };
133 
154 inline
155 void AttributeHeader::init(Uint32* aHeaderPtr, Uint32 anAttributeId,
156  Uint32 aByteSize)
157 {
158  AttributeHeader ah(anAttributeId, aByteSize);
159  *aHeaderPtr = ah.m_value;
160 }
161 
162 inline
163 AttributeHeader::AttributeHeader(Uint32 aHeader)
164 {
165  m_value = aHeader;
166 }
167 
168 inline
169 AttributeHeader::AttributeHeader(Uint32 anAttributeId, Uint32 aByteSize)
170 {
171  m_value = 0;
172  this->setAttributeId(anAttributeId);
173  this->setByteSize(aByteSize);
174 }
175 
176 inline
177 AttributeHeader::~AttributeHeader()
178 {}
179 
180 inline
182 {
183  // Should check 'e' bit here
184  return 1;
185 }
186 
187 inline
189 {
190  return (m_value & 0xFFFF0000) >> 16;
191 }
192 
193 inline
194 void AttributeHeader::setAttributeId(Uint32 anAttributeId)
195 {
196  m_value &= 0x0000FFFF; // Clear attribute id
197  m_value |= (anAttributeId << 16);
198 }
199 
200 inline
201 Uint32 AttributeHeader::getByteSize() const
202 {
203  return (m_value & 0xFFFF);
204 }
205 
206 inline
207 void AttributeHeader::setByteSize(Uint32 aByteSize)
208 {
209  m_value &= (~0xFFFF);
210  m_value |= aByteSize;
211 }
212 
213 inline
214 Uint32 AttributeHeader::getDataSize() const
215 {
216  return (((m_value & 0xFFFF) + 3) >> 2);
217 }
218 
219 inline
220 void AttributeHeader::setDataSize(Uint32 aDataSize)
221 {
222  m_value &= (~0xFFFF);
223  m_value |= (aDataSize << 2);
224 }
225 
226 inline
227 bool AttributeHeader::isNULL() const
228 {
229  return (getDataSize() == 0);
230 }
231 
232 inline
233 void AttributeHeader::setNULL()
234 {
235  setDataSize(0);
236 }
237 
238 inline
240 {
241  return (Uint32*)&m_value + getHeaderSize();
242 }
243 
244 inline
245 void AttributeHeader::insertHeader(Uint32* target)
246 {
247  *target = m_value;
248 }
249 
250 inline
253  return (AttributeHeader*)(getDataPtr() + getDataSize());
254 }
255 
256 inline
257 void
258 //AttributeHeader::print(NdbOut& output) {
259 AttributeHeader::print(FILE* output) {
260  fprintf(output, "AttributeId: H\'%.8x (D\'%d), DataSize: H\'%.8x (D\'%d), "
261  "isNULL: %d\n",
263  getDataSize(), getDataSize(),
264  isNULL());
265 }
266 
267 inline
268 Uint32
269 AttributeHeader::getByteSize(Uint32 m_value){
270  return (m_value & 0xFFFF);
271 }
272 
273 inline
274 Uint32
275 AttributeHeader::getDataSize(Uint32 m_value){
276  return (((m_value & 0xFFFF) + 3) >> 2);
277 }
278 
279 inline
280 Uint32
281 AttributeHeader::getAttributeId(Uint32 m_value)
282 {
283  return m_value >> 16;
284 }
285 
286 #endif
287 
288 
289 
290 
291 
292 
293