mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innodb_plugin / include / page0types.h
blob68d0726e9998e98da4152dafc5b2221c4ab6da9e
1 /*****************************************************************************
3 Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 *****************************************************************************/
19 /**************************************************//**
20 @file include/page0types.h
21 Index page routines
23 Created 2/2/1994 Heikki Tuuri
24 *******************************************************/
26 #ifndef page0types_h
27 #define page0types_h
29 #include "univ.i"
30 #include "dict0types.h"
31 #include "mtr0types.h"
33 /** Eliminates a name collision on HP-UX */
34 #define page_t ib_page_t
35 /** Type of the index page */
36 typedef byte page_t;
37 /** Index page cursor */
38 typedef struct page_cur_struct page_cur_t;
40 /** Compressed index page */
41 typedef byte page_zip_t;
42 /** Compressed page descriptor */
43 typedef struct page_zip_des_struct page_zip_des_t;
45 /* The following definitions would better belong to page0zip.h,
46 but we cannot include page0zip.h from rem0rec.ic, because
47 page0*.h includes rem0rec.h and may include rem0rec.ic. */
49 /** Number of bits needed for representing different compressed page sizes */
50 #define PAGE_ZIP_SSIZE_BITS 3
52 /** log2 of smallest compressed page size */
53 #define PAGE_ZIP_MIN_SIZE_SHIFT 10
54 /** Smallest compressed page size */
55 #define PAGE_ZIP_MIN_SIZE (1 << PAGE_ZIP_MIN_SIZE_SHIFT)
57 /** Number of supported compressed page sizes */
58 #define PAGE_ZIP_NUM_SSIZE (UNIV_PAGE_SIZE_SHIFT - PAGE_ZIP_MIN_SIZE_SHIFT + 2)
59 #if PAGE_ZIP_NUM_SSIZE > (1 << PAGE_ZIP_SSIZE_BITS)
60 # error "PAGE_ZIP_NUM_SSIZE > (1 << PAGE_ZIP_SSIZE_BITS)"
61 #endif
63 /** Compressed page descriptor */
64 struct page_zip_des_struct
66 page_zip_t* data; /*!< compressed page data */
68 #ifdef UNIV_DEBUG
69 unsigned m_start:16; /*!< start offset of modification log */
70 #endif /* UNIV_DEBUG */
71 unsigned m_end:16; /*!< end offset of modification log */
72 unsigned m_nonempty:1; /*!< TRUE if the modification log
73 is not empty */
74 unsigned n_blobs:12; /*!< number of externally stored
75 columns on the page; the maximum
76 is 744 on a 16 KiB page */
77 unsigned ssize:PAGE_ZIP_SSIZE_BITS;
78 /*!< 0 or compressed page size;
79 the size in bytes is
80 PAGE_ZIP_MIN_SIZE << (ssize - 1). */
83 /** Compression statistics for a given page size */
84 struct page_zip_stat_struct {
85 /** Number of page compressions */
86 ulint compressed;
87 /** Number of successful page compressions */
88 ulint compressed_ok;
89 /** Number of page decompressions */
90 ulint decompressed;
91 /** Duration of page compressions in microseconds */
92 ib_uint64_t compressed_usec;
93 /** Duration of page decompressions in microseconds */
94 ib_uint64_t decompressed_usec;
97 /** Compression statistics */
98 typedef struct page_zip_stat_struct page_zip_stat_t;
100 /** Statistics on compression, indexed by page_zip_des_struct::ssize - 1 */
101 extern page_zip_stat_t page_zip_stat[PAGE_ZIP_NUM_SSIZE - 1];
103 /**********************************************************************//**
104 Write the "deleted" flag of a record on a compressed page. The flag must
105 already have been written on the uncompressed page. */
106 UNIV_INTERN
107 void
108 page_zip_rec_set_deleted(
109 /*=====================*/
110 page_zip_des_t* page_zip,/*!< in/out: compressed page */
111 const byte* rec, /*!< in: record on the uncompressed page */
112 ulint flag) /*!< in: the deleted flag (nonzero=TRUE) */
113 __attribute__((nonnull));
115 /**********************************************************************//**
116 Write the "owned" flag of a record on a compressed page. The n_owned field
117 must already have been written on the uncompressed page. */
118 UNIV_INTERN
119 void
120 page_zip_rec_set_owned(
121 /*===================*/
122 page_zip_des_t* page_zip,/*!< in/out: compressed page */
123 const byte* rec, /*!< in: record on the uncompressed page */
124 ulint flag) /*!< in: the owned flag (nonzero=TRUE) */
125 __attribute__((nonnull));
127 /**********************************************************************//**
128 Shift the dense page directory when a record is deleted. */
129 UNIV_INTERN
130 void
131 page_zip_dir_delete(
132 /*================*/
133 page_zip_des_t* page_zip,/*!< in/out: compressed page */
134 byte* rec, /*!< in: deleted record */
135 dict_index_t* index, /*!< in: index of rec */
136 const ulint* offsets,/*!< in: rec_get_offsets(rec) */
137 const byte* free) /*!< in: previous start of the free list */
138 __attribute__((nonnull(1,2,3,4)));
140 /**********************************************************************//**
141 Add a slot to the dense page directory. */
142 UNIV_INTERN
143 void
144 page_zip_dir_add_slot(
145 /*==================*/
146 page_zip_des_t* page_zip, /*!< in/out: compressed page */
147 ulint is_clustered) /*!< in: nonzero for clustered index,
148 zero for others */
149 __attribute__((nonnull));
150 #endif