2005-10-27 11:48:10 +00:00
|
|
|
/******************************************************
|
|
|
|
Compressed page interface
|
|
|
|
|
|
|
|
(c) 2005 Innobase Oy
|
|
|
|
|
|
|
|
Created June 2005 by Marko Makela
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#ifndef page0zip_h
|
|
|
|
#define page0zip_h
|
|
|
|
|
|
|
|
#ifdef UNIV_MATERIALIZE
|
|
|
|
# undef UNIV_INLINE
|
|
|
|
# define UNIV_INLINE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "mtr0types.h"
|
|
|
|
#include "page0types.h"
|
2006-10-18 11:39:31 +00:00
|
|
|
#include "buf0types.h"
|
2006-02-10 15:06:17 +00:00
|
|
|
#include "dict0types.h"
|
2007-01-29 08:51:20 +00:00
|
|
|
#include "mem0mem.h"
|
2005-10-27 11:48:10 +00:00
|
|
|
|
2006-11-27 13:44:32 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Determine the size of a compressed page in bytes. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
page_zip_get_size(
|
|
|
|
/*==============*/
|
|
|
|
/* out: size in bytes */
|
|
|
|
const page_zip_des_t* page_zip) /* in: compressed page */
|
2006-11-27 14:12:09 +00:00
|
|
|
__attribute__((nonnull, pure));
|
2006-11-27 13:44:32 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Set the size of a compressed page in bytes. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
page_zip_set_size(
|
|
|
|
/*==============*/
|
|
|
|
page_zip_des_t* page_zip, /* in/out: compressed page */
|
|
|
|
ulint size); /* in: size in bytes */
|
|
|
|
|
2006-08-17 08:14:38 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Determine if a record is so big that it needs to be stored externally. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
page_zip_rec_needs_ext(
|
|
|
|
/*===================*/
|
|
|
|
/* out: FALSE if the entire record
|
|
|
|
can be stored locally on the page */
|
|
|
|
ulint rec_size, /* in: length of the record in bytes */
|
|
|
|
ulint comp, /* in: nonzero=compact format */
|
2008-09-17 06:23:52 +00:00
|
|
|
ulint n_fields, /* in: number of fields in the record;
|
|
|
|
ignored if zip_size == 0 */
|
2006-08-17 08:14:38 +00:00
|
|
|
ulint zip_size) /* in: compressed page size in bytes, or 0 */
|
|
|
|
__attribute__((const));
|
|
|
|
|
2006-09-20 14:26:53 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Determine the guaranteed free space on an empty page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-09-20 14:26:53 +00:00
|
|
|
ulint
|
|
|
|
page_zip_empty_size(
|
|
|
|
/*================*/
|
|
|
|
/* out: minimum payload size on the page */
|
|
|
|
ulint n_fields, /* in: number of columns in the index */
|
|
|
|
ulint zip_size) /* in: compressed page size in bytes */
|
|
|
|
__attribute__((const));
|
|
|
|
|
2005-10-27 11:48:10 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Initialize a compressed page descriptor. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
page_zip_des_init(
|
|
|
|
/*==============*/
|
|
|
|
page_zip_des_t* page_zip); /* in/out: compressed page
|
|
|
|
descriptor */
|
|
|
|
|
|
|
|
/**************************************************************************
|
2007-01-29 08:51:20 +00:00
|
|
|
Configure the zlib allocator to use the given memory heap. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2007-01-29 08:51:20 +00:00
|
|
|
void
|
|
|
|
page_zip_set_alloc(
|
|
|
|
/*===============*/
|
|
|
|
void* stream, /* in/out: zlib stream */
|
|
|
|
mem_heap_t* heap); /* in: memory heap to use */
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-10-27 11:48:10 +00:00
|
|
|
Compress a page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 11:48:10 +00:00
|
|
|
ibool
|
|
|
|
page_zip_compress(
|
|
|
|
/*==============*/
|
|
|
|
/* out: TRUE on success, FALSE on failure;
|
|
|
|
page_zip will be left intact on failure. */
|
2006-02-10 15:06:17 +00:00
|
|
|
page_zip_des_t* page_zip,/* in: size; out: data, n_blobs,
|
2006-11-30 14:09:29 +00:00
|
|
|
m_start, m_end, m_nonempty */
|
2006-02-10 15:06:17 +00:00
|
|
|
const page_t* page, /* in: uncompressed page */
|
2006-05-16 14:17:43 +00:00
|
|
|
dict_index_t* index, /* in: index of the B-tree node */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction, or NULL */
|
2007-11-09 09:41:21 +00:00
|
|
|
__attribute__((nonnull(1,2,3)));
|
2005-10-27 11:48:10 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
2005-11-25 12:34:38 +00:00
|
|
|
Decompress a page. This function should tolerate errors on the compressed
|
|
|
|
page. Instead of letting assertions fail, it will return FALSE if an
|
|
|
|
inconsistency is detected. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 11:48:10 +00:00
|
|
|
ibool
|
|
|
|
page_zip_decompress(
|
|
|
|
/*================*/
|
|
|
|
/* out: TRUE on success, FALSE on failure */
|
branches/zip: Rename the INFORMATION_SCHEMA tables
INNODB_ZIP and INNODB_ZIP_RESET to
INNODB_COMPRESSION and INNODB_COMPRESSION_RESET,
and remove the statistics of the buddy system.
This change was discussed with Ken. It makes the tables shorter
and easier to understand. The removed data will be represented in
the tables INNODB_COMPRESSION_BUDDY and INNODB_COMPRESSION_BUDDY_RESET
that will be added later.
i_s_innodb_zip, i_s_innodb_zip_reset, i_s_zip_fields_info[],
i_s_zip_fill_low(), i_s_zip_fill(), i_s_zip_reset_fill(),
i_s_zip_init(), i_s_zip_reset_init(): Replace "zip" with "compression".
i_s_compression_fields_info[]: Remove "used", "free",
"relocated", "relocated_usec". In "compressed_usec" and "decompressed_usec",
replace microseconds with seconds ("usec" with "sec").
page_zip_decompress(): Correct a typo in the function comment.
PAGE_ZIP_SSIZE_BITS, PAGE_ZIP_NUM_SSIZE: New constants.
page_zip_stat_t, page_zip_stat: Statistics of the compression, grouped
by page size.
page_zip_simple_validate(): Assert that page_zip->ssize is reasonable.
2008-03-28 09:28:54 +00:00
|
|
|
page_zip_des_t* page_zip,/* in: data, ssize;
|
2006-11-30 14:09:29 +00:00
|
|
|
out: m_start, m_end, m_nonempty, n_blobs */
|
2006-04-10 19:48:37 +00:00
|
|
|
page_t* page) /* out: uncompressed page, may be trashed */
|
2007-11-09 09:41:21 +00:00
|
|
|
__attribute__((nonnull));
|
2005-10-27 11:48:10 +00:00
|
|
|
|
|
|
|
#ifdef UNIV_DEBUG
|
|
|
|
/**************************************************************************
|
|
|
|
Validate a compressed page descriptor. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
page_zip_simple_validate(
|
|
|
|
/*=====================*/
|
|
|
|
/* out: TRUE if ok */
|
|
|
|
const page_zip_des_t* page_zip); /* in: compressed page
|
|
|
|
descriptor */
|
2005-11-30 13:57:54 +00:00
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 11:48:10 +00:00
|
|
|
|
2006-06-20 19:35:59 +00:00
|
|
|
#ifdef UNIV_ZIP_DEBUG
|
2005-10-27 11:48:10 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Check that the compressed and decompressed pages match. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 11:48:10 +00:00
|
|
|
ibool
|
|
|
|
page_zip_validate(
|
|
|
|
/*==============*/
|
|
|
|
const page_zip_des_t* page_zip,/* in: compressed page */
|
2006-02-10 15:06:17 +00:00
|
|
|
const page_t* page) /* in: uncompressed page */
|
|
|
|
__attribute__((nonnull));
|
2006-06-20 19:35:59 +00:00
|
|
|
#endif /* UNIV_ZIP_DEBUG */
|
2005-10-27 11:48:10 +00:00
|
|
|
|
2006-07-03 19:12:21 +00:00
|
|
|
/**************************************************************************
|
branches/zip: Enable the insert buffer on compressed tablespaces.
page_zip_max_ins_size(): New function.
btr_cur_optimistic_insert(), btr_cur_optimistic_delete(),
btr_page_split_and_insert(), btr_compress(): Do not update the
ibuf free bits for non-leaf pages or pages belonging to a clustered index.
The insert buffer only covers operations on leaf pages of secondary indexes.
For pages covered by the insert buffer, limit the max_ins_size to
page_zip_max_ins_size().
buf_page_get_gen(): Merge the insert buffer after decompressing the page.
buf_page_io_complete(): Relax the assertion about ibuf_count. For
compressed-only pages, the insert buffer merge takes place
in buf_page_get_gen().
ibuf_index_page_calc_free_bits(), ibuf_index_page_calc_free_from_bits(),
ibuf_index_page_calc_free(), ibuf_update_free_bits_if_full(),
ibuf_update_free_bits_low(), ibuf_update_free_bits_for_two_pages_low(),
ibuf_set_free_bits_low(): Add the parameter zip_size. Limit the maximum
insert size to page_zip_max_ins_size().
2007-02-19 20:32:06 +00:00
|
|
|
Determine how big record can be inserted without recompressing the page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
lint
|
|
|
|
page_zip_max_ins_size(
|
|
|
|
/*==================*/
|
2007-10-12 11:16:20 +00:00
|
|
|
/* out: a positive number
|
|
|
|
indicating the maximum size of
|
|
|
|
a record whose insertion is
|
|
|
|
guaranteed to succeed, or
|
|
|
|
zero or negative */
|
branches/zip: Enable the insert buffer on compressed tablespaces.
page_zip_max_ins_size(): New function.
btr_cur_optimistic_insert(), btr_cur_optimistic_delete(),
btr_page_split_and_insert(), btr_compress(): Do not update the
ibuf free bits for non-leaf pages or pages belonging to a clustered index.
The insert buffer only covers operations on leaf pages of secondary indexes.
For pages covered by the insert buffer, limit the max_ins_size to
page_zip_max_ins_size().
buf_page_get_gen(): Merge the insert buffer after decompressing the page.
buf_page_io_complete(): Relax the assertion about ibuf_count. For
compressed-only pages, the insert buffer merge takes place
in buf_page_get_gen().
ibuf_index_page_calc_free_bits(), ibuf_index_page_calc_free_from_bits(),
ibuf_index_page_calc_free(), ibuf_update_free_bits_if_full(),
ibuf_update_free_bits_low(), ibuf_update_free_bits_for_two_pages_low(),
ibuf_set_free_bits_low(): Add the parameter zip_size. Limit the maximum
insert size to page_zip_max_ins_size().
2007-02-19 20:32:06 +00:00
|
|
|
const page_zip_des_t* page_zip,/* in: compressed page */
|
|
|
|
ibool is_clust)/* in: TRUE if clustered index */
|
2007-11-09 09:41:21 +00:00
|
|
|
__attribute__((nonnull, pure));
|
branches/zip: Enable the insert buffer on compressed tablespaces.
page_zip_max_ins_size(): New function.
btr_cur_optimistic_insert(), btr_cur_optimistic_delete(),
btr_page_split_and_insert(), btr_compress(): Do not update the
ibuf free bits for non-leaf pages or pages belonging to a clustered index.
The insert buffer only covers operations on leaf pages of secondary indexes.
For pages covered by the insert buffer, limit the max_ins_size to
page_zip_max_ins_size().
buf_page_get_gen(): Merge the insert buffer after decompressing the page.
buf_page_io_complete(): Relax the assertion about ibuf_count. For
compressed-only pages, the insert buffer merge takes place
in buf_page_get_gen().
ibuf_index_page_calc_free_bits(), ibuf_index_page_calc_free_from_bits(),
ibuf_index_page_calc_free(), ibuf_update_free_bits_if_full(),
ibuf_update_free_bits_low(), ibuf_update_free_bits_for_two_pages_low(),
ibuf_set_free_bits_low(): Add the parameter zip_size. Limit the maximum
insert size to page_zip_max_ins_size().
2007-02-19 20:32:06 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Determine if enough space is available in the modification log. */
|
2006-07-03 19:12:21 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
ibool
|
|
|
|
page_zip_available(
|
|
|
|
/*===============*/
|
|
|
|
/* out: TRUE if page_zip_write_rec()
|
|
|
|
will succeed */
|
|
|
|
const page_zip_des_t* page_zip,/* in: compressed page */
|
2007-02-19 14:51:44 +00:00
|
|
|
ibool is_clust,/* in: TRUE if clustered index */
|
2006-07-03 19:12:21 +00:00
|
|
|
ulint length, /* in: combined size of the record */
|
|
|
|
ulint create) /* in: nonzero=add the record to
|
|
|
|
the heap */
|
2007-11-09 09:41:21 +00:00
|
|
|
__attribute__((nonnull, pure));
|
2006-07-03 19:12:21 +00:00
|
|
|
|
2005-10-27 11:48:10 +00:00
|
|
|
/**************************************************************************
|
2006-08-14 08:25:46 +00:00
|
|
|
Write data to the uncompressed header portion of a page. The data must
|
|
|
|
already have been written to the uncompressed page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
page_zip_write_header(
|
|
|
|
/*==================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
const byte* str, /* in: address on the uncompressed page */
|
|
|
|
ulint length, /* in: length of the data */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction, or NULL */
|
|
|
|
__attribute__((nonnull(1,2)));
|
|
|
|
|
2005-10-27 11:48:10 +00:00
|
|
|
/**************************************************************************
|
2006-02-10 15:06:17 +00:00
|
|
|
Write an entire record on the compressed page. The data must already
|
|
|
|
have been written to the uncompressed page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-02-10 15:06:17 +00:00
|
|
|
void
|
|
|
|
page_zip_write_rec(
|
|
|
|
/*===============*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
const byte* rec, /* in: record being written */
|
2006-03-06 21:00:05 +00:00
|
|
|
dict_index_t* index, /* in: the index the record belongs to */
|
2006-03-13 15:02:16 +00:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
|
|
|
ulint create) /* in: nonzero=insert, zero=update */
|
2006-02-10 15:06:17 +00:00
|
|
|
__attribute__((nonnull));
|
2005-10-27 11:48:10 +00:00
|
|
|
|
2006-04-07 12:56:22 +00:00
|
|
|
/***************************************************************
|
|
|
|
Parses a log record of writing a BLOB pointer of a record. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-04-07 12:56:22 +00:00
|
|
|
byte*
|
|
|
|
page_zip_parse_write_blob_ptr(
|
|
|
|
/*==========================*/
|
|
|
|
/* out: end of log record or NULL */
|
|
|
|
byte* ptr, /* in: redo log buffer */
|
|
|
|
byte* end_ptr,/* in: redo log buffer end */
|
|
|
|
page_t* page, /* in/out: uncompressed page */
|
|
|
|
page_zip_des_t* page_zip);/* in/out: compressed page */
|
|
|
|
|
2005-10-27 11:48:10 +00:00
|
|
|
/**************************************************************************
|
2006-04-07 12:56:22 +00:00
|
|
|
Write a BLOB pointer of a record on the leaf page of a clustered index.
|
2006-02-10 15:06:17 +00:00
|
|
|
The information must already have been updated on the uncompressed page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2005-10-27 11:48:10 +00:00
|
|
|
void
|
2006-02-10 15:06:17 +00:00
|
|
|
page_zip_write_blob_ptr(
|
|
|
|
/*====================*/
|
2005-10-27 11:48:10 +00:00
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
2006-02-10 15:06:17 +00:00
|
|
|
const byte* rec, /* in/out: record whose data is being
|
|
|
|
written */
|
|
|
|
dict_index_t* index, /* in: index of the page */
|
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
|
|
|
ulint n, /* in: column index */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction handle,
|
|
|
|
or NULL if no logging is needed */
|
|
|
|
__attribute__((nonnull(1,2,3,4)));
|
|
|
|
|
2006-04-07 11:04:08 +00:00
|
|
|
/***************************************************************
|
|
|
|
Parses a log record of writing the node pointer of a record. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-04-07 11:04:08 +00:00
|
|
|
byte*
|
|
|
|
page_zip_parse_write_node_ptr(
|
|
|
|
/*==========================*/
|
|
|
|
/* out: end of log record or NULL */
|
|
|
|
byte* ptr, /* in: redo log buffer */
|
|
|
|
byte* end_ptr,/* in: redo log buffer end */
|
|
|
|
page_t* page, /* in/out: uncompressed page */
|
|
|
|
page_zip_des_t* page_zip);/* in/out: compressed page */
|
|
|
|
|
2006-02-10 15:06:17 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Write the node pointer of a record on a non-leaf compressed page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-02-10 15:06:17 +00:00
|
|
|
void
|
|
|
|
page_zip_write_node_ptr(
|
|
|
|
/*====================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
byte* rec, /* in/out: record */
|
|
|
|
ulint size, /* in: data size of rec */
|
|
|
|
ulint ptr, /* in: node pointer */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction, or NULL */
|
|
|
|
__attribute__((nonnull(1,2)));
|
|
|
|
|
|
|
|
/**************************************************************************
|
2006-03-09 17:26:02 +00:00
|
|
|
Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-02-10 15:06:17 +00:00
|
|
|
void
|
2006-03-09 17:26:02 +00:00
|
|
|
page_zip_write_trx_id_and_roll_ptr(
|
|
|
|
/*===============================*/
|
2006-02-10 15:06:17 +00:00
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
byte* rec, /* in/out: record */
|
2006-03-09 17:26:02 +00:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
|
|
|
ulint trx_id_col,/* in: column number of TRX_ID in rec */
|
2006-02-10 15:06:17 +00:00
|
|
|
dulint trx_id, /* in: transaction identifier */
|
2006-03-09 17:26:02 +00:00
|
|
|
dulint roll_ptr)/* in: roll_ptr */
|
|
|
|
__attribute__((nonnull));
|
2006-02-10 15:06:17 +00:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Write the "deleted" flag of a record on a compressed page. The flag must
|
|
|
|
already have been written on the uncompressed page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-02-10 15:06:17 +00:00
|
|
|
void
|
|
|
|
page_zip_rec_set_deleted(
|
|
|
|
/*=====================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
const byte* rec, /* in: record on the uncompressed page */
|
|
|
|
ulint flag) /* in: the deleted flag (nonzero=TRUE) */
|
|
|
|
__attribute__((nonnull));
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Write the "owned" flag of a record on a compressed page. The n_owned field
|
|
|
|
must already have been written on the uncompressed page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-02-10 15:06:17 +00:00
|
|
|
void
|
|
|
|
page_zip_rec_set_owned(
|
|
|
|
/*===================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
const byte* rec, /* in: record on the uncompressed page */
|
|
|
|
ulint flag) /* in: the owned flag (nonzero=TRUE) */
|
|
|
|
__attribute__((nonnull));
|
|
|
|
|
2006-08-18 19:30:55 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Insert a record to the dense page directory. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-08-18 19:30:55 +00:00
|
|
|
void
|
|
|
|
page_zip_dir_insert(
|
|
|
|
/*================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
const byte* prev_rec,/* in: record after which to insert */
|
|
|
|
const byte* free_rec,/* in: record from which rec was
|
|
|
|
allocated, or NULL */
|
2006-08-21 09:27:44 +00:00
|
|
|
byte* rec); /* in: record to insert */
|
2006-08-18 19:30:55 +00:00
|
|
|
|
2006-02-10 15:06:17 +00:00
|
|
|
/**************************************************************************
|
2006-03-14 14:38:45 +00:00
|
|
|
Shift the dense page directory and the array of BLOB pointers
|
|
|
|
when a record is deleted. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-02-10 15:06:17 +00:00
|
|
|
void
|
|
|
|
page_zip_dir_delete(
|
|
|
|
/*================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
2006-03-16 14:02:22 +00:00
|
|
|
byte* rec, /* in: deleted record */
|
|
|
|
dict_index_t* index, /* in: index of rec */
|
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec) */
|
2006-02-10 15:06:17 +00:00
|
|
|
const byte* free) /* in: previous start of the free list */
|
2006-03-16 14:02:22 +00:00
|
|
|
__attribute__((nonnull(1,2,3,4)));
|
2005-10-27 11:48:10 +00:00
|
|
|
|
2006-03-06 21:00:05 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Add a slot to the dense page directory. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-03-06 21:00:05 +00:00
|
|
|
void
|
|
|
|
page_zip_dir_add_slot(
|
|
|
|
/*==================*/
|
2006-03-09 17:26:02 +00:00
|
|
|
page_zip_des_t* page_zip, /* in/out: compressed page */
|
|
|
|
ulint is_clustered) /* in: nonzero for clustered index,
|
|
|
|
zero for others */
|
2006-03-06 21:00:05 +00:00
|
|
|
__attribute__((nonnull));
|
|
|
|
|
2006-04-07 11:44:14 +00:00
|
|
|
/***************************************************************
|
|
|
|
Parses a log record of writing to the header of a page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-04-07 11:44:14 +00:00
|
|
|
byte*
|
|
|
|
page_zip_parse_write_header(
|
|
|
|
/*========================*/
|
|
|
|
/* out: end of log record or NULL */
|
|
|
|
byte* ptr, /* in: redo log buffer */
|
|
|
|
byte* end_ptr,/* in: redo log buffer end */
|
|
|
|
page_t* page, /* in/out: uncompressed page */
|
|
|
|
page_zip_des_t* page_zip);/* in/out: compressed page */
|
|
|
|
|
2005-10-27 11:48:10 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Write data to the uncompressed header portion of a page. The data must
|
2006-02-10 15:06:17 +00:00
|
|
|
already have been written to the uncompressed page.
|
|
|
|
However, the data portion of the uncompressed page may differ from
|
|
|
|
the compressed page when a record is being inserted in
|
|
|
|
page_cur_insert_rec_low(). */
|
2005-10-27 11:48:10 +00:00
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
page_zip_write_header(
|
|
|
|
/*==================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
const byte* str, /* in: address on the uncompressed page */
|
2006-02-22 13:02:40 +00:00
|
|
|
ulint length, /* in: length of the data */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction, or NULL */
|
|
|
|
__attribute__((nonnull(1,2)));
|
2005-10-27 11:48:10 +00:00
|
|
|
|
2006-05-11 18:23:10 +00:00
|
|
|
/**************************************************************************
|
2006-05-16 14:17:43 +00:00
|
|
|
Reorganize and compress a page. This is a low-level operation for
|
|
|
|
compressed pages, to be used when page_zip_compress() fails.
|
2006-06-19 11:07:21 +00:00
|
|
|
On success, a redo log entry MLOG_ZIP_PAGE_COMPRESS will be written.
|
branches/zip: Document and obey the rules for modifying the free bits in
the insert buffer bitmap.
ibuf_set_free_bits_func(): Never disable redo logging.
ibuf_update_free_bits_zip(): Remove.
btr_page_reorganize_low(), page_zip_reorganize(): Do not update the insert
buffer bitmap. Instead, document that callers will have to take care of it,
and adapt the callers.
btr_compress(): On error, reset the insert buffer free bits.
btr_cur_insert_if_possible(): Do not modify the insert buffer bitmap.
btr_compress(), btr_cur_optimistic_insert(): On compressed pages,
reset the insert buffer bitmap. Document why.
btr_cur_update_alloc_zip(): Document why it is necessary and sufficient
to reset the insert buffer free bits.
btr_cur_update_in_place(), btr_cur_optimistic_update(),
btr_cur_pessimistic_update(): Update the free bits in the same
mini-transaction. Document that the mini-transaction must be
committed before latching any further pages. Verify that this
is the case in all execution paths.
row_ins_sec_index_entry_by_modify(), row_ins_clust_index_entry_by_modify(),
row_undo_mod_clust_low(): Because these functions call
btr_cur_update_in_place(), btr_cur_optimistic_update(), or
btr_cur_pessimistic_update(), document that the mini-transaction must be
committed before latching any further pages. Verify that this is the case
in all execution paths.
2007-05-16 09:23:53 +00:00
|
|
|
The function btr_page_reorganize() should be preferred whenever possible.
|
|
|
|
IMPORTANT: if page_zip_reorganize() is invoked on a leaf page of a
|
|
|
|
non-clustered index, the caller must update the insert buffer free
|
|
|
|
bits in the same mini-transaction in such a way that the modification
|
|
|
|
will be redo-logged. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-05-16 14:17:43 +00:00
|
|
|
ibool
|
|
|
|
page_zip_reorganize(
|
|
|
|
/*================*/
|
|
|
|
/* out: TRUE on success, FALSE on failure;
|
|
|
|
page and page_zip will be left intact
|
|
|
|
on failure. */
|
2006-10-18 11:39:31 +00:00
|
|
|
buf_block_t* block, /* in/out: page with compressed page;
|
|
|
|
on the compressed page, in: size;
|
2006-11-30 14:09:29 +00:00
|
|
|
out: data, n_blobs,
|
|
|
|
m_start, m_end, m_nonempty */
|
2006-05-16 14:17:43 +00:00
|
|
|
dict_index_t* index, /* in: index of the B-tree node */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction */
|
2007-11-09 09:41:21 +00:00
|
|
|
__attribute__((nonnull));
|
2006-05-16 14:17:43 +00:00
|
|
|
/**************************************************************************
|
2008-09-25 12:17:52 +00:00
|
|
|
Copy the records of a page byte for byte. Do not copy the page header
|
|
|
|
or trailer, except those B-tree header fields that are directly
|
|
|
|
related to the storage of records. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-05-11 18:23:10 +00:00
|
|
|
void
|
2008-09-25 12:17:52 +00:00
|
|
|
page_zip_copy_recs(
|
|
|
|
/*===============*/
|
2006-11-24 08:32:18 +00:00
|
|
|
page_zip_des_t* page_zip, /* out: copy of src_zip
|
|
|
|
(n_blobs, m_start, m_end,
|
2006-11-30 14:09:29 +00:00
|
|
|
m_nonempty, data[0..size-1]) */
|
2006-05-11 18:23:10 +00:00
|
|
|
page_t* page, /* out: copy of src */
|
|
|
|
const page_zip_des_t* src_zip, /* in: compressed page */
|
|
|
|
const page_t* src, /* in: page */
|
2006-05-16 07:58:10 +00:00
|
|
|
dict_index_t* index, /* in: index of the B-tree */
|
2006-05-11 18:23:10 +00:00
|
|
|
mtr_t* mtr) /* in: mini-transaction */
|
|
|
|
__attribute__((nonnull(1,2,3,4)));
|
|
|
|
|
2006-04-11 12:27:06 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Parses a log record of compressing an index page. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-04-11 12:27:06 +00:00
|
|
|
byte*
|
|
|
|
page_zip_parse_compress(
|
|
|
|
/*====================*/
|
|
|
|
/* out: end of log record or NULL */
|
|
|
|
byte* ptr, /* in: buffer */
|
|
|
|
byte* end_ptr,/* in: buffer end */
|
|
|
|
page_t* page, /* out: uncompressed page */
|
|
|
|
page_zip_des_t* page_zip)/* out: compressed page */
|
|
|
|
__attribute__((nonnull(1,2)));
|
|
|
|
|
2006-05-02 11:44:39 +00:00
|
|
|
/**************************************************************************
|
|
|
|
Calculate the compressed page checksum. */
|
2008-02-18 18:38:33 +00:00
|
|
|
UNIV_INTERN
|
2006-05-02 11:44:39 +00:00
|
|
|
ulint
|
|
|
|
page_zip_calc_checksum(
|
|
|
|
/*===================*/
|
|
|
|
/* out: page checksum */
|
|
|
|
const void* data, /* in: compressed page */
|
|
|
|
ulint size) /* in: size of compressed page */
|
|
|
|
__attribute__((nonnull));
|
|
|
|
|
2005-10-27 11:48:10 +00:00
|
|
|
#ifdef UNIV_MATERIALIZE
|
|
|
|
# undef UNIV_INLINE
|
|
|
|
# define UNIV_INLINE UNIV_INLINE_ORIGINAL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
# include "page0zip.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* page0zip_h */
|