MySQL 8.3.0
Source Code Documentation
zipdecompress.cc File Reference

Page Decompression interface. More...

#include <stdarg.h>
#include <sys/types.h>
#include <zlib.h>
#include "btr0btr.h"
#include "mem0mem.h"
#include "page/zipdecompress.h"
#include "page0page.h"
#include "rem0rec.h"
#include "rem0wrec.h"

Macros

#define page_zip_fail(fmt_args)   page_zip_fail_func fmt_args
 Wrapper for page_zip_fail_func() More...
 

Functions

int page_zip_fail_func (const char *fmt,...)
 NOTE: The functions in this file should only use functions from other files in library. More...
 
static void * page_zip_zalloc (void *opaque, uInt items, uInt size)
 Allocate memory for zlib. More...
 
static void page_zip_free (void *opaque, void *address)
 Deallocate memory for zlib. More...
 
static void page_zip_fields_free (dict_index_t *index)
 Deallocate the index information initialized by page_zip_fields_decode(). More...
 
void page_zip_set_alloc (void *stream, mem_heap_t *heap)
 Configure the zlib allocator to use the given memory heap. More...
 
static bool page_zip_dir_decode (const page_zip_des_t *page_zip, page_t *page, rec_t **recs, ulint n_dense)
 Populate the sparse page directory from the dense directory. More...
 
static dict_index_tpage_zip_fields_decode (const byte *buf, const byte *end, ulint *trx_id_col, bool is_spatial)
 Read the index information for the compressed page. More...
 
static const bytepage_zip_apply_log_ext (const dict_index_t *index, rec_t *rec, const ulint *offsets, ulint trx_id_col, const byte *data, const byte *end)
 Apply the modification log to a record containing externally stored columns. More...
 
static const bytepage_zip_apply_log (const byte *data, ulint size, rec_t **recs, ulint n_dense, ulint trx_id_col, ulint heap_status, dict_index_t *index, ulint *offsets)
 Apply the modification log to an uncompressed page. More...
 
static bool page_zip_decompress_heap_no (z_stream *d_stream, rec_t *rec, ulint &heap_status)
 Set the heap_no in a record, and skip the fixed-size record header that is not included in the d_stream. More...
 
static bool page_zip_decompress_node_ptrs (page_zip_des_t *page_zip, z_stream *d_stream, rec_t **recs, ulint n_dense, dict_index_t *index, ulint *offsets, mem_heap_t *heap)
 Decompress the records of a node pointer page. More...
 
static bool page_zip_decompress_sec (page_zip_des_t *page_zip, z_stream *d_stream, rec_t **recs, ulint n_dense, dict_index_t *index, ulint *offsets)
 Decompress the records of a leaf node of a secondary index. More...
 
static bool page_zip_set_extra_bytes (const page_zip_des_t *page_zip, page_t *page, ulint info_bits)
 Initialize the REC_N_NEW_EXTRA_BYTES of each record. More...
 
static bool page_zip_decompress_clust_ext (z_stream *d_stream, const dict_index_t *index, rec_t *rec, const ulint *offsets, ulint trx_id_col)
 Decompress a record of a leaf node of a clustered index that contains externally stored columns. More...
 
static bool page_zip_decompress_clust (page_zip_des_t *page_zip, z_stream *d_stream, rec_t **recs, ulint n_dense, dict_index_t *index, ulint trx_id_col, ulint *offsets, mem_heap_t *heap)
 Compress the records of a leaf node of a clustered index. More...
 
bool page_zip_decompress_low (page_zip_des_t *page_zip, page_t *page, bool all)
 Decompress a page. More...
 

Detailed Description

Page Decompression interface.

Created June 2005 by Marko Makela

Macro Definition Documentation

◆ page_zip_fail

#define page_zip_fail (   fmt_args)    page_zip_fail_func fmt_args

Wrapper for page_zip_fail_func()

Parameters
fmt_argsin: printf(3) format string and arguments

Function Documentation

◆ page_zip_apply_log()

static const byte * page_zip_apply_log ( const byte data,
ulint  size,
rec_t **  recs,
ulint  n_dense,
ulint  trx_id_col,
ulint  heap_status,
dict_index_t index,
ulint offsets 
)
static

Apply the modification log to an uncompressed page.

Do not copy the fields that are stored separately.

Returns
pointer to end of modification log, or NULL on failure
Parameters
datain: modification log
sizein: maximum length of the log, in bytes
recsin: dense page directory, sorted by address (indexed by heap_no - PAGE_HEAP_NO_USER_LOW)
n_densein: size of recs[]
trx_id_colin: column number of trx_id in the index, or ULINT_UNDEFINED if none
heap_statusin: heap_no and status bits for the next record to uncompress
indexin: index of the page
offsetsin/out: work area for rec_get_offsets_reverse()

◆ page_zip_apply_log_ext()

static const byte * page_zip_apply_log_ext ( const dict_index_t index,
rec_t rec,
const ulint offsets,
ulint  trx_id_col,
const byte data,
const byte end 
)
static

Apply the modification log to a record containing externally stored columns.

Do not copy the fields that are stored separately.

Parameters
[in]indexindex
[in,out]recrecord
[in]offsetsrec_get_offsets(rec)
[in]trx_id_colposition of of DB_TRX_ID
[in]datamodification log
[in]endend of modification log
Returns
pointer to modification log, or NULL on failure

◆ page_zip_decompress_clust()

static bool page_zip_decompress_clust ( page_zip_des_t page_zip,
z_stream *  d_stream,
rec_t **  recs,
ulint  n_dense,
dict_index_t index,
ulint  trx_id_col,
ulint offsets,
mem_heap_t heap 
)
static

Compress the records of a leaf node of a clustered index.

Returns
true on success, false on failure
Parameters
page_zipin/out: compressed page
d_streamin/out: compressed page stream
recsin: dense page directory sorted by address
n_densein: size of recs[]
indexin: the index of the page
trx_id_colindex of the trx_id column
offsetsin/out: temporary offsets
heapin: temporary memory heap

◆ page_zip_decompress_clust_ext()

static bool page_zip_decompress_clust_ext ( z_stream *  d_stream,
const dict_index_t index,
rec_t rec,
const ulint offsets,
ulint  trx_id_col 
)
static

Decompress a record of a leaf node of a clustered index that contains externally stored columns.

Parameters
[in,out]d_streamcompressed page stream
[in]indexindex
[in,out]recrecord
[in]offsetsrec_get_offsets(rec)
[in]trx_id_colposition of of DB_TRX_ID
Returns
true on success

◆ page_zip_decompress_heap_no()

static bool page_zip_decompress_heap_no ( z_stream *  d_stream,
rec_t rec,
ulint heap_status 
)
static

Set the heap_no in a record, and skip the fixed-size record header that is not included in the d_stream.

Returns
true on success, false if d_stream does not end at rec
Parameters
d_streamin/out: compressed page stream
recin/out: record
heap_statusin/out: heap_no and status bits

◆ page_zip_decompress_low()

bool page_zip_decompress_low ( page_zip_des_t page_zip,
page_t page,
bool  all 
)

Decompress a page.

NOTE: The functions in this file should only use functions from other files in library.

This function should tolerate errors on the compressed page. Instead of letting assertions fail, it will return false if an inconsistency is detected.

Returns
true on success, false on failure

< dense page directory, sorted by address

Parameters
page_zipin: data, ssize; out: m_start, m_end, m_nonempty, n_blobs
pageout: uncompressed page, may be trashed
allin: true=decompress the whole page; false=verify but do not copy some page header fields that should not change after page creation

◆ page_zip_decompress_node_ptrs()

static bool page_zip_decompress_node_ptrs ( page_zip_des_t page_zip,
z_stream *  d_stream,
rec_t **  recs,
ulint  n_dense,
dict_index_t index,
ulint offsets,
mem_heap_t heap 
)
static

Decompress the records of a node pointer page.

Returns
true on success, false on failure
Parameters
page_zipin/out: compressed page
d_streamin/out: compressed page stream
recsin: dense page directory sorted by address
n_densein: size of recs[]
indexin: the index of the page
offsetsin/out: temporary offsets
heapin: temporary memory heap

◆ page_zip_decompress_sec()

static bool page_zip_decompress_sec ( page_zip_des_t page_zip,
z_stream *  d_stream,
rec_t **  recs,
ulint  n_dense,
dict_index_t index,
ulint offsets 
)
static

Decompress the records of a leaf node of a secondary index.

Returns
true on success, false on failure
Parameters
page_zipin/out: compressed page
d_streamin/out: compressed page stream
recsin: dense page directory sorted by address
n_densein: size of recs[]
indexin: the index of the page
offsetsin/out: temporary offsets

◆ page_zip_dir_decode()

static bool page_zip_dir_decode ( const page_zip_des_t page_zip,
page_t page,
rec_t **  recs,
ulint  n_dense 
)
static

Populate the sparse page directory from the dense directory.

Returns
true on success, false on failure
Parameters
page_zipin: dense page directory on compressed page
pagein: compact page with valid header; out: trailer and sparse page directory filled in
recsout: dense page directory sorted by ascending address (and heap_no)
n_densein: number of user records, and size of recs[]

◆ page_zip_fail_func()

int page_zip_fail_func ( const char *  fmt,
  ... 
)

NOTE: The functions in this file should only use functions from other files in library.

The code in this file is used to make a library for external tools. Report a failure to decompress or compress.

Returns
number of characters printed
Parameters
fmtin: printf(3) format string
...in: arguments corresponding to fmt

◆ page_zip_fields_decode()

static dict_index_t * page_zip_fields_decode ( const byte buf,
const byte end,
ulint trx_id_col,
bool  is_spatial 
)
static

Read the index information for the compressed page.

Parameters
[in]bufindex information
[in]endend of buf
[in]trx_id_colNULL for non-leaf pages; for leaf pages, pointer to where to store the position of the trx_id column
[in]is_spatialis spatial index or not
Returns
own: dummy index describing the page, or NULL on error

◆ page_zip_fields_free()

static void page_zip_fields_free ( dict_index_t index)
static

Deallocate the index information initialized by page_zip_fields_decode().

Parameters
indexin: dummy index to be freed

◆ page_zip_free()

static void page_zip_free ( void *  opaque,
void *  address 
)
static

Deallocate memory for zlib.

Parameters
opaquein: memory heap
addressin: object to free

◆ page_zip_set_alloc()

void page_zip_set_alloc ( void *  stream,
mem_heap_t heap 
)

Configure the zlib allocator to use the given memory heap.

Parameters
[in,out]streamzlib stream
[in]heapMemory heap to use

◆ page_zip_set_extra_bytes()

static bool page_zip_set_extra_bytes ( const page_zip_des_t page_zip,
page_t page,
ulint  info_bits 
)
static

Initialize the REC_N_NEW_EXTRA_BYTES of each record.

Returns
true on success, false on failure
Parameters
page_zipin: compressed page
pagein/out: uncompressed page
info_bitsin: REC_INFO_MIN_REC_FLAG or 0

◆ page_zip_zalloc()

static void * page_zip_zalloc ( void *  opaque,
uInt  items,
uInt  size 
)
static

Allocate memory for zlib.

Parameters
opaquein/out: memory heap
itemsin: number of items to allocate
sizein: size of an item in bytes