InnoDB Plugin  1.0
page0zip.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2005, 2013, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2012, Facebook Inc.
5 
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17 
18 *****************************************************************************/
19 
20 /**************************************************/
27 #ifndef page0zip_h
28 #define page0zip_h
29 
30 #ifdef UNIV_MATERIALIZE
31 # undef UNIV_INLINE
32 # define UNIV_INLINE
33 #endif
34 
35 #include "mtr0types.h"
36 #include "page0types.h"
37 #include "buf0types.h"
38 #include "dict0types.h"
39 #include "srv0srv.h"
40 #include "trx0types.h"
41 #include "mem0mem.h"
42 
43 /* Compression level to be used by zlib. Settable by user. */
44 extern uint page_zip_level;
45 
46 /* Default compression level. */
47 #define DEFAULT_COMPRESSION_LEVEL 6
48 
49 /* Whether or not to log compressed page images to avoid possible
50 compression algorithm changes in zlib. */
51 extern my_bool page_zip_log_pages;
52 
53 /**********************************************************************/
56 UNIV_INLINE
57 ulint
59 /*==============*/
60  const page_zip_des_t* page_zip)
61  __attribute__((nonnull, pure));
62 /**********************************************************************/
64 UNIV_INLINE
65 void
67 /*==============*/
68  page_zip_des_t* page_zip,
69  ulint size);
71 #ifndef UNIV_HOTBACKUP
72 /**********************************************************************/
75 UNIV_INLINE
76 ibool
78 /*===================*/
79  ulint rec_size,
80  ulint comp,
81  ulint n_fields,
83  ulint zip_size)
84  __attribute__((const));
85 
86 /**********************************************************************/
89 UNIV_INTERN
90 ulint
92 /*================*/
93  ulint n_fields,
94  ulint zip_size)
95  __attribute__((const));
96 #endif /* !UNIV_HOTBACKUP */
97 
98 /**********************************************************************/
100 UNIV_INLINE
101 void
103 /*==============*/
104  page_zip_des_t* page_zip);
107 /**********************************************************************/
109 UNIV_INTERN
110 void
112 /*===============*/
113  void* stream,
114  mem_heap_t* heap);
116 /**********************************************************************/
120 UNIV_INTERN
121 ibool
123 /*==============*/
124  page_zip_des_t* page_zip,
126  const page_t* page,
127  dict_index_t* index,
128  ulint level,
129  mtr_t* mtr)
130  __attribute__((nonnull(1,2,3)));
131 
132 /**********************************************************************/
137 UNIV_INTERN
138 ibool
140 /*================*/
141  page_zip_des_t* page_zip,
143  page_t* page,
144  ibool all)
148  __attribute__((nonnull(1,2)));
149 
150 #ifdef UNIV_DEBUG
151 /**********************************************************************/
154 UNIV_INLINE
155 ibool
157 /*=====================*/
158  const page_zip_des_t* page_zip);
160 #endif /* UNIV_DEBUG */
161 
162 #ifdef UNIV_ZIP_DEBUG
163 /**********************************************************************/
166 UNIV_INTERN
167 ibool
168 page_zip_validate_low(
169 /*==================*/
170  const page_zip_des_t* page_zip,
171  const page_t* page,
172  const dict_index_t* index,
173  ibool sloppy)
175  __attribute__((nonnull(1,2)));
176 /**********************************************************************/
178 UNIV_INTERN
179 ibool
180 page_zip_validate(
181 /*==============*/
182  const page_zip_des_t* page_zip,
183  const page_t* page,
184  const dict_index_t* index)
185  __attribute__((nonnull(1,2)));
186 #endif /* UNIV_ZIP_DEBUG */
187 
188 /**********************************************************************/
192 UNIV_INLINE
193 lint
195 /*==================*/
196  const page_zip_des_t* page_zip,
197  ibool is_clust)
198  __attribute__((nonnull, pure));
199 
200 /**********************************************************************/
203 UNIV_INLINE
204 ibool
206 /*===============*/
207  const page_zip_des_t* page_zip,
208  ibool is_clust,
209  ulint length,
210  ulint create)
212  __attribute__((nonnull, pure));
213 
214 /**********************************************************************/
217 UNIV_INLINE
218 void
220 /*==================*/
221  page_zip_des_t* page_zip,
222  const byte* str,
223  ulint length,
224  mtr_t* mtr)
225  __attribute__((nonnull(1,2)));
226 
227 /**********************************************************************/
230 UNIV_INTERN
231 void
233 /*===============*/
234  page_zip_des_t* page_zip,
235  const byte* rec,
236  dict_index_t* index,
237  const ulint* offsets,
238  ulint create)
239  __attribute__((nonnull));
240 
241 /***********************************************************/
244 UNIV_INTERN
245 byte*
247 /*==========================*/
248  byte* ptr,
249  byte* end_ptr,
250  page_t* page,
251  page_zip_des_t* page_zip);
253 /**********************************************************************/
256 UNIV_INTERN
257 void
259 /*====================*/
260  page_zip_des_t* page_zip,
261  const byte* rec,
263  dict_index_t* index,
264  const ulint* offsets,
265  ulint n,
266  mtr_t* mtr)
268  __attribute__((nonnull(1,2,3,4)));
269 
270 /***********************************************************/
273 UNIV_INTERN
274 byte*
276 /*==========================*/
277  byte* ptr,
278  byte* end_ptr,
279  page_t* page,
280  page_zip_des_t* page_zip);
282 /**********************************************************************/
284 UNIV_INTERN
285 void
287 /*====================*/
288  page_zip_des_t* page_zip,
289  byte* rec,
290  ulint size,
291  ulint ptr,
292  mtr_t* mtr)
293  __attribute__((nonnull(1,2)));
294 
295 /**********************************************************************/
297 UNIV_INTERN
298 void
300 /*===============================*/
301  page_zip_des_t* page_zip,
302  byte* rec,
303  const ulint* offsets,
304  ulint trx_id_col,
305  trx_id_t trx_id,
306  roll_ptr_t roll_ptr)
307  __attribute__((nonnull));
308 
309 /**********************************************************************/
312 UNIV_INTERN
313 void
315 /*=====================*/
316  page_zip_des_t* page_zip,
317  const byte* rec,
318  ulint flag)
319  __attribute__((nonnull));
320 
321 /**********************************************************************/
324 UNIV_INTERN
325 void
327 /*===================*/
328  page_zip_des_t* page_zip,
329  const byte* rec,
330  ulint flag)
331  __attribute__((nonnull));
332 
333 /**********************************************************************/
335 UNIV_INTERN
336 void
338 /*================*/
339  page_zip_des_t* page_zip,
340  const byte* prev_rec,
341  const byte* free_rec,
343  byte* rec);
345 /**********************************************************************/
348 UNIV_INTERN
349 void
351 /*================*/
352  page_zip_des_t* page_zip,
353  byte* rec,
354  const dict_index_t* index,
355  const ulint* offsets,
356  const byte* free)
358  __attribute__((nonnull(1,2,3,4)));
359 
360 /**********************************************************************/
362 UNIV_INTERN
363 void
365 /*==================*/
366  page_zip_des_t* page_zip,
367  ulint is_clustered)
369  __attribute__((nonnull));
370 
371 /***********************************************************/
374 UNIV_INTERN
375 byte*
377 /*========================*/
378  byte* ptr,
379  byte* end_ptr,
380  page_t* page,
381  page_zip_des_t* page_zip);
383 /**********************************************************************/
389 UNIV_INLINE
390 void
392 /*==================*/
393  page_zip_des_t* page_zip,
394  const byte* str,
395  ulint length,
396  mtr_t* mtr)
397  __attribute__((nonnull(1,2)));
398 
399 /**********************************************************************/
410 UNIV_INTERN
411 ibool
413 /*================*/
414  buf_block_t* block,
418  dict_index_t* index,
419  mtr_t* mtr)
420  __attribute__((nonnull));
421 #ifndef UNIV_HOTBACKUP
422 /**********************************************************************/
427 UNIV_INTERN
428 void
430 /*===============*/
431  page_zip_des_t* page_zip,
434  page_t* page,
435  const page_zip_des_t* src_zip,
436  const page_t* src,
437  dict_index_t* index,
438  mtr_t* mtr)
439  __attribute__((nonnull));
440 #endif /* !UNIV_HOTBACKUP */
441 
442 /**********************************************************************/
445 UNIV_INTERN
446 byte*
448 /*====================*/
449  byte* ptr,
450  byte* end_ptr,
451  page_t* page,
452  page_zip_des_t* page_zip)
453  __attribute__((nonnull(1,2)));
454 
455 /**********************************************************************/
458 UNIV_INTERN
459 ulint
461 /*===================*/
462  const void* data,
463  ulint size,
465  __attribute__((nonnull));
466 
467 /**********************************************************************/
471 UNIV_INTERN
472 ibool
474 /*=====================*/
475  const void* data,
476  ulint size);
477 /**********************************************************************/
479 UNIV_INLINE
480 void
482 /*================================*/
483  ulint level,
484  const page_t* page,
485  dict_index_t* index,
486  mtr_t* mtr);
487 /**********************************************************************/
490 UNIV_INLINE
491 byte*
493 /*============================*/
494  byte* ptr,
495  byte* end_ptr,
496  page_t* page,
497  page_zip_des_t* page_zip,
498  dict_index_t* index)
499  __attribute__((nonnull(1,2)));
500 
501 /**********************************************************************/
504 UNIV_INLINE
505 void
507 /*===========================*/
508 
509 #ifndef UNIV_HOTBACKUP
510 
516 # define PAGE_ZIP_MATCH(ptr, page_zip) \
517  (((page_zip)->m_external \
518  && (page_align(ptr) + UNIV_PAGE_SIZE == (page_zip)->data)) \
519  || buf_frame_get_page_zip(ptr) == (page_zip))
520 #else /* !UNIV_HOTBACKUP */
521 
525 # define PAGE_ZIP_MATCH(ptr, page_zip) \
526  (page_align(ptr) + UNIV_PAGE_SIZE == (page_zip)->data)
527 #endif /* !UNIV_HOTBACKUP */
528 
529 #ifdef UNIV_MATERIALIZE
530 # undef UNIV_INLINE
531 # define UNIV_INLINE UNIV_INLINE_ORIGINAL
532 #endif
533 
534 #ifndef UNIV_NONINL
535 # include "page0zip.ic"
536 #endif
537 
538 #endif /* page0zip_h */