1
/******************************************************
2
Caching of externally stored column prefixes
6
Created September 2006 Marko Makela
7
*******************************************************/
17
/************************************************************************
18
Fills the column prefix cache of an externally stored column. */
23
row_ext_t* ext, /* in/out: column prefix cache */
24
ulint i, /* in: index of ext->ext[] */
25
ulint zip_size,/* compressed page size in bytes, or 0 */
26
const dfield_t* dfield) /* in: data field */
28
const byte* field = dfield_get_data(dfield);
29
ulint f_len = dfield_get_len(dfield);
30
byte* buf = ext->buf + i * REC_MAX_INDEX_COL_LEN;
32
ut_ad(i < ext->n_ext);
33
ut_ad(dfield_is_ext(dfield));
34
ut_a(f_len >= BTR_EXTERN_FIELD_REF_SIZE);
36
if (UNIV_UNLIKELY(!memcmp(field_ref_zero,
37
field + f_len - BTR_EXTERN_FIELD_REF_SIZE,
38
BTR_EXTERN_FIELD_REF_SIZE))) {
39
/* The BLOB pointer is not set: we cannot fetch it */
42
/* Fetch at most REC_MAX_INDEX_COL_LEN of the column.
43
The column must be non-empty. */
44
ext->len[i] = btr_copy_externally_stored_field_prefix(
45
buf, REC_MAX_INDEX_COL_LEN, zip_size, field, f_len);
50
/************************************************************************
51
Creates a cache of column prefixes of externally stored columns. */
56
/* out,own: column prefix cache */
57
ulint n_ext, /* in: number of externally stored columns */
58
const ulint* ext, /* in: col_no's of externally stored columns
59
in the InnoDB table object, as reported by
60
dict_col_get_no(); NOT relative to the records
61
in the clustered index */
62
const dtuple_t* tuple, /* in: data tuple containing the field
63
references of the externally stored
64
columns; must be indexed by col_no;
65
the clustered index record must be
66
covered by a lock or a page latch
67
to prevent deletion (rollback or purge). */
68
ulint zip_size,/* compressed page size in bytes, or 0 */
69
mem_heap_t* heap) /* in: heap where created */
72
row_ext_t* ret = mem_heap_alloc(heap, (sizeof *ret)
73
+ (n_ext - 1) * sizeof ret->len);
75
ut_ad(ut_is_2pow(zip_size));
76
ut_ad(zip_size <= UNIV_PAGE_SIZE);
80
ret->buf = mem_heap_alloc(heap, n_ext * REC_MAX_INDEX_COL_LEN);
82
memset(ret->buf, 0xaa, n_ext * REC_MAX_INDEX_COL_LEN);
83
UNIV_MEM_ALLOC(ret->buf, n_ext * REC_MAX_INDEX_COL_LEN);
86
/* Fetch the BLOB prefixes */
87
for (i = 0; i < n_ext; i++) {
88
const dfield_t* dfield;
90
dfield = dtuple_get_nth_field(tuple, ext[i]);
91
row_ext_cache_fill(ret, i, zip_size, dfield);