~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/page0zip.ic

Tags: innodb-plugin-1.0.2
InnoDB Plugin 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
                                can be stored locally on the page */
149
149
        ulint   rec_size,       /* in: length of the record in bytes */
150
150
        ulint   comp,           /* in: nonzero=compact format */
 
151
        ulint   n_fields,       /* in: number of fields in the record;
 
152
                                ignored if zip_size == 0 */
151
153
        ulint   zip_size)       /* in: compressed page size in bytes, or 0 */
152
154
{
153
155
        ut_ad(rec_size > comp ? REC_N_NEW_EXTRA_BYTES : REC_N_OLD_EXTRA_BYTES);
154
156
        ut_ad(ut_is_2pow(zip_size));
 
157
        ut_ad(comp || !zip_size);
155
158
 
156
159
#if UNIV_PAGE_SIZE > REC_MAX_DATA_SIZE
157
160
        if (UNIV_UNLIKELY(rec_size >= REC_MAX_DATA_SIZE)) {
159
162
        }
160
163
#endif
161
164
 
162
 
        if (UNIV_UNLIKELY(!comp)) {
163
 
                ut_ad(!zip_size);
164
 
                return(rec_size >= page_get_free_space_of_empty(FALSE) / 2);
165
 
        }
166
 
 
167
 
        /* If zip_size != 0, the record should fit on the compressed page.
168
 
        If not, the right-hand-side of the comparison will overwrap
169
 
        and the condition will not hold.  Thus, we do not need to test
170
 
        for zip_size != 0.  We subtract the size of the page header and
171
 
        assume that compressing the index information takes 50 bytes. */
172
 
        if (rec_size >= zip_size - (PAGE_DATA + 50)) {
173
 
                return(TRUE);
174
 
        }
175
 
 
176
 
        return(rec_size >= page_get_free_space_of_empty(TRUE) / 2);
 
165
        if (UNIV_UNLIKELY(zip_size)) {
 
166
                ut_ad(comp);
 
167
                /* On a compressed page, there is a two-byte entry in
 
168
                the dense page directory for every record.  But there
 
169
                is no record header.  There should be enough room for
 
170
                one record on an empty leaf page.  Subtract 1 byte for
 
171
                the encoded heap number.  Check also the available space
 
172
                on the uncompressed page. */
 
173
                return(rec_size - (REC_N_NEW_EXTRA_BYTES - 2)
 
174
                       >= (page_zip_empty_size(n_fields, zip_size) - 1)
 
175
                       || rec_size >= page_get_free_space_of_empty(TRUE) / 2);
 
176
        }
 
177
 
 
178
        return(rec_size >= page_get_free_space_of_empty(comp) / 2);
177
179
}
178
180
 
179
181
#ifdef UNIV_DEBUG