2005-10-27 13:48:10 +02: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 13:39:31 +02:00
|
|
|
#include "buf0types.h"
|
2006-02-10 16:06:17 +01:00
|
|
|
#include "dict0types.h"
|
2007-01-29 09:51:20 +01:00
|
|
|
#include "mem0mem.h"
|
2005-10-27 13:48:10 +02:00
|
|
|
|
2006-11-27 14:44:32 +01: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 15:12:09 +01:00
|
|
|
__attribute__((nonnull, pure));
|
2006-11-27 14:44:32 +01: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 10:14:38 +02: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 21:52:30 +02:00
|
|
|
ulint n_fields, /* in: number of fields in the record;
|
|
|
|
ignored if zip_size == 0 */
|
2006-08-17 10:14:38 +02:00
|
|
|
ulint zip_size) /* in: compressed page size in bytes, or 0 */
|
|
|
|
__attribute__((const));
|
|
|
|
|
2006-09-20 16:26:53 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Determine the guaranteed free space on an empty page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-09-20 16:26:53 +02: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 13:48:10 +02: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 09:51:20 +01:00
|
|
|
Configure the zlib allocator to use the given memory heap. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2007-01-29 09:51:20 +01:00
|
|
|
void
|
|
|
|
page_zip_set_alloc(
|
|
|
|
/*===============*/
|
|
|
|
void* stream, /* in/out: zlib stream */
|
|
|
|
mem_heap_t* heap); /* in: memory heap to use */
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-10-27 13:48:10 +02:00
|
|
|
Compress a page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2005-10-27 13:48:10 +02:00
|
|
|
ibool
|
|
|
|
page_zip_compress(
|
|
|
|
/*==============*/
|
|
|
|
/* out: TRUE on success, FALSE on failure;
|
|
|
|
page_zip will be left intact on failure. */
|
2006-02-10 16:06:17 +01:00
|
|
|
page_zip_des_t* page_zip,/* in: size; out: data, n_blobs,
|
2006-11-30 15:09:29 +01:00
|
|
|
m_start, m_end, m_nonempty */
|
2006-02-10 16:06:17 +01:00
|
|
|
const page_t* page, /* in: uncompressed page */
|
2006-05-16 16:17:43 +02:00
|
|
|
dict_index_t* index, /* in: index of the B-tree node */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction, or NULL */
|
2007-11-09 10:41:21 +01:00
|
|
|
__attribute__((nonnull(1,2,3)));
|
2005-10-27 13:48:10 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
2005-11-25 13:34:38 +01: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 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2005-10-27 13:48:10 +02:00
|
|
|
ibool
|
|
|
|
page_zip_decompress(
|
|
|
|
/*================*/
|
|
|
|
/* out: TRUE on success, FALSE on failure */
|
2008-05-14 17:43:19 +02:00
|
|
|
page_zip_des_t* page_zip,/* in: data, ssize;
|
2006-11-30 15:09:29 +01:00
|
|
|
out: m_start, m_end, m_nonempty, n_blobs */
|
2006-04-10 21:48:37 +02:00
|
|
|
page_t* page) /* out: uncompressed page, may be trashed */
|
2007-11-09 10:41:21 +01:00
|
|
|
__attribute__((nonnull));
|
2005-10-27 13:48:10 +02: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 14:57:54 +01:00
|
|
|
#endif /* UNIV_DEBUG */
|
2005-10-27 13:48:10 +02:00
|
|
|
|
2006-06-20 21:35:59 +02:00
|
|
|
#ifdef UNIV_ZIP_DEBUG
|
2005-10-27 13:48:10 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Check that the compressed and decompressed pages match. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2005-10-27 13:48:10 +02:00
|
|
|
ibool
|
2008-10-11 21:37:21 +02:00
|
|
|
page_zip_validate_low(
|
|
|
|
/*==================*/
|
|
|
|
/* out: TRUE if valid, FALSE if not */
|
|
|
|
const page_zip_des_t* page_zip,/* in: compressed page */
|
|
|
|
const page_t* page, /* in: uncompressed page */
|
|
|
|
ibool sloppy) /* in: FALSE=strict,
|
|
|
|
TRUE=ignore the MIN_REC_FLAG */
|
|
|
|
__attribute__((nonnull));
|
|
|
|
/**************************************************************************
|
|
|
|
Check that the compressed and decompressed pages match. */
|
|
|
|
UNIV_INTERN
|
|
|
|
ibool
|
2005-10-27 13:48:10 +02:00
|
|
|
page_zip_validate(
|
|
|
|
/*==============*/
|
|
|
|
const page_zip_des_t* page_zip,/* in: compressed page */
|
2006-02-10 16:06:17 +01:00
|
|
|
const page_t* page) /* in: uncompressed page */
|
|
|
|
__attribute__((nonnull));
|
2006-06-20 21:35:59 +02:00
|
|
|
#endif /* UNIV_ZIP_DEBUG */
|
2005-10-27 13:48:10 +02:00
|
|
|
|
2006-07-03 21:12:21 +02: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 21:32:06 +01:00
|
|
|
Determine how big record can be inserted without recompressing the page. */
|
|
|
|
UNIV_INLINE
|
|
|
|
lint
|
|
|
|
page_zip_max_ins_size(
|
|
|
|
/*==================*/
|
2007-10-12 13:16:20 +02: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 21:32:06 +01:00
|
|
|
const page_zip_des_t* page_zip,/* in: compressed page */
|
|
|
|
ibool is_clust)/* in: TRUE if clustered index */
|
2007-11-09 10:41:21 +01: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 21:32:06 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
Determine if enough space is available in the modification log. */
|
2006-07-03 21:12:21 +02: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 15:51:44 +01:00
|
|
|
ibool is_clust,/* in: TRUE if clustered index */
|
2006-07-03 21:12:21 +02:00
|
|
|
ulint length, /* in: combined size of the record */
|
|
|
|
ulint create) /* in: nonzero=add the record to
|
|
|
|
the heap */
|
2007-11-09 10:41:21 +01:00
|
|
|
__attribute__((nonnull, pure));
|
2006-07-03 21:12:21 +02:00
|
|
|
|
2005-10-27 13:48:10 +02:00
|
|
|
/**************************************************************************
|
2006-08-14 10:25:46 +02: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 13:48:10 +02:00
|
|
|
/**************************************************************************
|
2006-02-10 16:06:17 +01:00
|
|
|
Write an entire record on the compressed page. The data must already
|
|
|
|
have been written to the uncompressed page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-02-10 16:06:17 +01: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 22:00:05 +01:00
|
|
|
dict_index_t* index, /* in: the index the record belongs to */
|
2006-03-13 16:02:16 +01:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
|
|
|
ulint create) /* in: nonzero=insert, zero=update */
|
2006-02-10 16:06:17 +01:00
|
|
|
__attribute__((nonnull));
|
2005-10-27 13:48:10 +02:00
|
|
|
|
2006-04-07 14:56:22 +02:00
|
|
|
/***************************************************************
|
|
|
|
Parses a log record of writing a BLOB pointer of a record. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-04-07 14:56:22 +02: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 13:48:10 +02:00
|
|
|
/**************************************************************************
|
2006-04-07 14:56:22 +02:00
|
|
|
Write a BLOB pointer of a record on the leaf page of a clustered index.
|
2006-02-10 16:06:17 +01:00
|
|
|
The information must already have been updated on the uncompressed page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2005-10-27 13:48:10 +02:00
|
|
|
void
|
2006-02-10 16:06:17 +01:00
|
|
|
page_zip_write_blob_ptr(
|
|
|
|
/*====================*/
|
2005-10-27 13:48:10 +02:00
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
2006-02-10 16:06:17 +01: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 13:04:08 +02:00
|
|
|
/***************************************************************
|
|
|
|
Parses a log record of writing the node pointer of a record. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-04-07 13:04:08 +02: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 16:06:17 +01:00
|
|
|
/**************************************************************************
|
|
|
|
Write the node pointer of a record on a non-leaf compressed page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-02-10 16:06:17 +01: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 18:26:02 +01:00
|
|
|
Write the trx_id and roll_ptr of a record on a B-tree leaf node page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-02-10 16:06:17 +01:00
|
|
|
void
|
2006-03-09 18:26:02 +01:00
|
|
|
page_zip_write_trx_id_and_roll_ptr(
|
|
|
|
/*===============================*/
|
2006-02-10 16:06:17 +01:00
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
|
|
|
byte* rec, /* in/out: record */
|
2006-03-09 18:26:02 +01: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 16:06:17 +01:00
|
|
|
dulint trx_id, /* in: transaction identifier */
|
2006-03-09 18:26:02 +01:00
|
|
|
dulint roll_ptr)/* in: roll_ptr */
|
|
|
|
__attribute__((nonnull));
|
2006-02-10 16:06:17 +01: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 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-02-10 16:06:17 +01: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 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-02-10 16:06:17 +01: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 21:30:55 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Insert a record to the dense page directory. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-08-18 21:30:55 +02: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 11:27:44 +02:00
|
|
|
byte* rec); /* in: record to insert */
|
2006-08-18 21:30:55 +02:00
|
|
|
|
2006-02-10 16:06:17 +01:00
|
|
|
/**************************************************************************
|
2006-03-14 15:38:45 +01:00
|
|
|
Shift the dense page directory and the array of BLOB pointers
|
|
|
|
when a record is deleted. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-02-10 16:06:17 +01:00
|
|
|
void
|
|
|
|
page_zip_dir_delete(
|
|
|
|
/*================*/
|
|
|
|
page_zip_des_t* page_zip,/* in/out: compressed page */
|
2006-03-16 15:02:22 +01: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 16:06:17 +01:00
|
|
|
const byte* free) /* in: previous start of the free list */
|
2006-03-16 15:02:22 +01:00
|
|
|
__attribute__((nonnull(1,2,3,4)));
|
2005-10-27 13:48:10 +02:00
|
|
|
|
2006-03-06 22:00:05 +01:00
|
|
|
/**************************************************************************
|
|
|
|
Add a slot to the dense page directory. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-03-06 22:00:05 +01:00
|
|
|
void
|
|
|
|
page_zip_dir_add_slot(
|
|
|
|
/*==================*/
|
2006-03-09 18:26:02 +01: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 22:00:05 +01:00
|
|
|
__attribute__((nonnull));
|
|
|
|
|
2006-04-07 13:44:14 +02:00
|
|
|
/***************************************************************
|
|
|
|
Parses a log record of writing to the header of a page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-04-07 13:44:14 +02: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 13:48:10 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Write data to the uncompressed header portion of a page. The data must
|
2006-02-10 16:06:17 +01: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 13:48:10 +02: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 14:02:40 +01:00
|
|
|
ulint length, /* in: length of the data */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction, or NULL */
|
|
|
|
__attribute__((nonnull(1,2)));
|
2005-10-27 13:48:10 +02:00
|
|
|
|
2006-05-11 20:23:10 +02:00
|
|
|
/**************************************************************************
|
2006-05-16 16:17:43 +02: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 13:07:21 +02: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 11:23:53 +02: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 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-05-16 16:17:43 +02: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 13:39:31 +02:00
|
|
|
buf_block_t* block, /* in/out: page with compressed page;
|
|
|
|
on the compressed page, in: size;
|
2006-11-30 15:09:29 +01:00
|
|
|
out: data, n_blobs,
|
|
|
|
m_start, m_end, m_nonempty */
|
2006-05-16 16:17:43 +02:00
|
|
|
dict_index_t* index, /* in: index of the B-tree node */
|
|
|
|
mtr_t* mtr) /* in: mini-transaction */
|
2007-11-09 10:41:21 +01:00
|
|
|
__attribute__((nonnull));
|
2006-05-16 16:17:43 +02:00
|
|
|
/**************************************************************************
|
2008-10-11 21:37:21 +02: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
|
branches/innodb+: Merge revisions 2774:2799 from branches/zip:
------------------------------------------------------------------------
r2781 | marko | 2008-10-13 13:40:57 +0300 (Mon, 13 Oct 2008) | 1 line
branches/zip: page_cur_delete_rec(): Call page_zip_validate_low().
------------------------------------------------------------------------
r2783 | vasil | 2008-10-13 18:34:34 +0300 (Mon, 13 Oct 2008) | 9 lines
branches/zip:
Remove mysql-test/patches/bug37312.diff because MySQL "fixed"
Bug#37312 by removing the test.
http://bugs.mysql.com/37312
http://lists.mysql.com/commits/54462
------------------------------------------------------------------------
r2784 | marko | 2008-10-13 21:35:30 +0300 (Mon, 13 Oct 2008) | 1 line
branches/zip: Add missing NULL check to the assertion added in r2781.
------------------------------------------------------------------------
r2785 | marko | 2008-10-13 22:29:12 +0300 (Mon, 13 Oct 2008) | 2 lines
branches/zip: page_cur_delete_rec(): Remove the bogus page_zip_validate_low()
assertion that was added in r2781 and explain why it was bogus.
------------------------------------------------------------------------
r2786 | calvin | 2008-10-14 19:14:47 +0300 (Tue, 14 Oct 2008) | 7 lines
branches/zip: fix Mantis issue #96 Problem compiling ha_innodb.cc
on 64-bit Windows
Change the definition of srv_replication_delay from ulint to ulong.
ulint is 64-bit on Win64.
Approved by: Heikki (on IM)
------------------------------------------------------------------------
r2787 | calvin | 2008-10-14 19:19:41 +0300 (Tue, 14 Oct 2008) | 7 lines
branches/zip: fix compiler warning
Change the definition of add_on from ulint to ullint, to eliminate
the warning in .\btr\btr0cur.c:
conversion from 'ullint' to 'ulint', possible loss of data
Approved by: Heikki (on IM)
------------------------------------------------------------------------
r2793 | marko | 2008-10-15 10:00:06 +0300 (Wed, 15 Oct 2008) | 2 lines
branches/zip: row_create_table_for_mysql(), row_create_index_for_mysql():
Note that the dictionary object will be freed.
------------------------------------------------------------------------
r2794 | marko | 2008-10-15 10:32:40 +0300 (Wed, 15 Oct 2008) | 9 lines
branches/zip: When invoking page_zip_copy_recs(), update the lock table
and the adaptive hash index. This should fix Issue #95 and Issue #87.
page_zip_copy_recs(): Copy PAGE_MAX_TRX_ID as well, to have similar behavior
to page_copy_rec_list_start() and page_copy_rec_list_end().
btr_root_raise_and_insert(), btr_page_split_and_insert(), btr_lift_page_up():
Update the lock table and the adaptive hash index.
------------------------------------------------------------------------
r2797 | marko | 2008-10-15 13:21:54 +0300 (Wed, 15 Oct 2008) | 3 lines
branches/zip: Introduce UNIV_ZIP_COPY for invoking page_zip_copy_recs()
more often in B-tree operations.
------------------------------------------------------------------------
r2799 | marko | 2008-10-15 14:27:42 +0300 (Wed, 15 Oct 2008) | 25 lines
branches/zip: When the server crashes while freeing an externally stored
column of a compressed table, the BTR_EXTERN_LEN field in the BLOB pointer
will be written as 0. Tolerate this in the functions that deal with
externally stored columns. This fixes Issue #80 and was posted at rb://26.
Note that the clustered index record is always deleted or purged last,
after any secondary index records referring to it have been deleted.
btr_free_externally_stored_field(): On an uncompressed table, zero out
the BTR_EXTERN_LEN, so that half-deleted BLOBs can be detected after
crash recovery.
btr_copy_externally_stored_field_prefix(): Return 0 if the BLOB has been
half-deleted.
row_upd_ext_fetch(): Assert that the externally stored column exists.
row_ext_cache_fill(): Allow btr_copy_externally_stored_field_prefix()
to return 0.
row_sel_sec_rec_is_for_blob(): Return FALSE if the BLOB has been half-deleted.
This is correct, because the clustered index record would have been deleted
or purged last, after any secondary index records referring to it had been
deleted.
------------------------------------------------------------------------
2008-10-15 14:09:17 +02:00
|
|
|
related to the storage of records. Also copy PAGE_MAX_TRX_ID.
|
|
|
|
NOTE: The caller must update the lock table and the adaptive hash index. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-05-11 20:23:10 +02:00
|
|
|
void
|
2008-10-11 21:37:21 +02:00
|
|
|
page_zip_copy_recs(
|
|
|
|
/*===============*/
|
2006-11-24 09:32:18 +01:00
|
|
|
page_zip_des_t* page_zip, /* out: copy of src_zip
|
|
|
|
(n_blobs, m_start, m_end,
|
2006-11-30 15:09:29 +01:00
|
|
|
m_nonempty, data[0..size-1]) */
|
2006-05-11 20:23:10 +02: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 09:58:10 +02:00
|
|
|
dict_index_t* index, /* in: index of the B-tree */
|
2006-05-11 20:23:10 +02:00
|
|
|
mtr_t* mtr) /* in: mini-transaction */
|
|
|
|
__attribute__((nonnull(1,2,3,4)));
|
|
|
|
|
2006-04-11 14:27:06 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Parses a log record of compressing an index page. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-04-11 14:27:06 +02: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 13:44:39 +02:00
|
|
|
/**************************************************************************
|
|
|
|
Calculate the compressed page checksum. */
|
2008-02-18 19:38:33 +01:00
|
|
|
UNIV_INTERN
|
2006-05-02 13:44:39 +02: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 13:48:10 +02:00
|
|
|
#ifdef UNIV_MATERIALIZE
|
|
|
|
# undef UNIV_INLINE
|
|
|
|
# define UNIV_INLINE UNIV_INLINE_ORIGINAL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
# include "page0zip.ic"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* page0zip_h */
|