mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 22:34:18 +01:00
06299dddd4
inserted, uncommitted clustered index records when determining if a secondary index record that contains a column prefix of an externally stored column is referencing the clustered index record. field_ref_zero[]: A BLOB pointer full of zero, for use in comparisons. btr_copy_externally_stored_field_prefix(): Assert that the BLOB pointer is set. row_ext_lookup_ith(), row_ext_lookup(), row_ext_lookup_low(): Document that field_ref_zero is returned when the BLOB cannot be fetched. row_ext_lookup_low(): Return field_ref_zero and *len = 0 when the BLOB pointer is unset. row_build_index_entry(): Return NULL when a needed BLOB pointer cannot be dereferenced (row_ext_lookup returns field_ref_zero). Check the return value for NULL in callers. row_vers_impl_x_locked_off_kernel(): Avoid comparisons when row_build_index_entry() returns NULL. row_vers_old_has_index_entry(): Ignore records for which row_build_index_entry() returns NULL. The entry should never be NULL in rollback, but it may be NULL in purge. row_merge_buf_add(): Assert that row_ext_lookup() does not return field_ref_zero. The table will be locked during index creation.
124 lines
3.6 KiB
Text
124 lines
3.6 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);
|
|
|
|
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);
|
|
}
|