mariadb/include/row0ext.ic
marko cf7d5b774f branches/zip: trx_undo_rec_get_partial_row(): Set up the row_ext cache
only for those externally stored columns that occur in the ordering columns
of indexes.  Prefetch the prefixes of those columns, because the clustered
index record and the BLOBs may have been deleted by the time when the
purge thread needs to read the BLOB prefixes.

row_ext_create(): Add the debug assertion ut_ad(ut_is_2pow(zip_size)).
2007-11-29 10:07:47 +00:00

126 lines
3.7 KiB
Text

/******************************************************
Caching of externally stored column prefixes
(c) 2006 Innobase Oy
Created September 2006 Marko Makela
*******************************************************/
#include "rem0types.h"
/************************************************************************
Looks up and caches a column prefix of an externally stored column. */
byte*
row_ext_lookup_low(
/*===============*/
/* out: column prefix, or
pointer to field_ref_zero
if the BLOB pointer is unset */
row_ext_t* ext, /* in/out: column prefix cache */
ulint i, /* in: index of ext->ext[] */
const byte* field, /* in: locally stored part of the column */
ulint f_len, /* in: length of field, in bytes */
ulint* len); /* out: length of prefix, in bytes,
at most REC_MAX_INDEX_COL_LEN */
/************************************************************************
Creates a cache of column prefixes of externally stored columns. */
UNIV_INLINE
row_ext_t*
row_ext_create(
/*===========*/
/* out,own: column prefix cache */
ulint n_ext, /* in: number of externally stored columns */
const ulint* ext, /* in: col_no's of externally stored columns
in the InnoDB table object, as reported by
dict_col_get_no(); NOT relative to the records
in the clustered index */
ulint zip_size,/* compressed page size, or 0 */
mem_heap_t* heap) /* in: heap where created */
{
row_ext_t* ret = mem_heap_alloc(heap, (sizeof *ret)
+ (n_ext - 1) * sizeof ret->len);
ut_ad(ut_is_2pow(zip_size));
ret->n_ext = n_ext;
ret->ext = ext;
ret->zip_size = zip_size;
ret->buf = mem_heap_alloc(heap, n_ext * REC_MAX_INDEX_COL_LEN);
#ifdef UNIV_DEBUG
memset(ret->buf, 0xaa, n_ext * REC_MAX_INDEX_COL_LEN);
UNIV_MEM_ALLOC(ret->buf, n_ext * REC_MAX_INDEX_COL_LEN);
#endif
memset(ret->len, 0, n_ext * sizeof *ret->len);
return(ret);
}
/************************************************************************
Looks up a column prefix of an externally stored column. */
UNIV_INLINE
byte*
row_ext_lookup_ith(
/*===============*/
/* out: column prefix, or NULL if
the column is not stored externally,
or pointer to field_ref_zero
if the BLOB pointer is unset */
row_ext_t* ext, /* in/out: column prefix cache */
ulint i, /* in: index of ext->ext[] */
const byte* field, /* in: locally stored part of the column */
ulint f_len, /* in: length of field, in bytes */
ulint* len) /* out: length of prefix, in bytes,
at most REC_MAX_INDEX_COL_LEN */
{
ut_ad(ext);
ut_ad(field);
ut_ad(len);
ut_ad(i < ext->n_ext);
/* Return from the cache if found */
if (ext->len[i]) {
*len = ext->len[i];
ut_ad(*len > f_len);
return(ext->buf + i * REC_MAX_INDEX_COL_LEN);
}
/* Update the cache */
return(row_ext_lookup_low(ext, i, field, f_len, len));
}
/************************************************************************
Looks up a column prefix of an externally stored column. */
UNIV_INLINE
byte*
row_ext_lookup(
/*===========*/
/* out: column prefix, or NULL if
the column is not stored externally,
or pointer to field_ref_zero
if the BLOB pointer is unset */
row_ext_t* ext, /* in/out: column prefix cache */
ulint col, /* in: column number in the InnoDB
table object, as reported by
dict_col_get_no(); NOT relative to the
records in the clustered index */
const byte* field, /* in: locally stored part of the column */
ulint f_len, /* in: length of field, in bytes */
ulint* len) /* out: length of prefix, in bytes,
at most REC_MAX_INDEX_COL_LEN */
{
ulint i;
ut_ad(ext);
ut_ad(field);
ut_ad(len);
for (i = 0; i < ext->n_ext; i++) {
if (col == ext->ext[i]) {
return(row_ext_lookup_ith(ext, i, field, f_len, len));
}
}
return(NULL);
}