1
/*****************************************************************************
3
Copyright (C) 2006, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/**************************************************//**
21
Caching of externally stored column prefixes
23
Created September 2006 Marko Makela
24
*******************************************************/
34
/********************************************************************//**
35
Fills the column prefix cache of an externally stored column. */
40
row_ext_t* ext, /*!< in/out: column prefix cache */
41
ulint i, /*!< in: index of ext->ext[] */
42
ulint zip_size,/*!< compressed page size in bytes, or 0 */
43
const dfield_t* dfield) /*!< in: data field */
45
const byte* field = static_cast<const byte *>(dfield_get_data(dfield));
46
ulint f_len = dfield_get_len(dfield);
47
byte* buf = ext->buf + i * REC_MAX_INDEX_COL_LEN;
49
ut_ad(i < ext->n_ext);
50
ut_ad(dfield_is_ext(dfield));
51
ut_a(f_len >= BTR_EXTERN_FIELD_REF_SIZE);
53
if (UNIV_UNLIKELY(!memcmp(field_ref_zero,
54
field + f_len - BTR_EXTERN_FIELD_REF_SIZE,
55
BTR_EXTERN_FIELD_REF_SIZE))) {
56
/* The BLOB pointer is not set: we cannot fetch it */
59
/* Fetch at most REC_MAX_INDEX_COL_LEN of the column.
60
The column should be non-empty. However,
61
trx_rollback_or_clean_all_recovered() may try to
62
access a half-deleted BLOB if the server previously
63
crashed during the execution of
64
btr_free_externally_stored_field(). */
65
ext->len[i] = btr_copy_externally_stored_field_prefix(
66
buf, REC_MAX_INDEX_COL_LEN, zip_size, field, f_len);
70
/********************************************************************//**
71
Creates a cache of column prefixes of externally stored columns.
72
@return own: column prefix cache */
77
ulint n_ext, /*!< in: number of externally stored columns */
78
const ulint* ext, /*!< in: col_no's of externally stored columns
79
in the InnoDB table object, as reported by
80
dict_col_get_no(); NOT relative to the records
81
in the clustered index */
82
const dtuple_t* tuple, /*!< in: data tuple containing the field
83
references of the externally stored
84
columns; must be indexed by col_no;
85
the clustered index record must be
86
covered by a lock or a page latch
87
to prevent deletion (rollback or purge). */
88
ulint zip_size,/*!< compressed page size in bytes, or 0 */
89
mem_heap_t* heap) /*!< in: heap where created */
92
row_ext_t* ret = static_cast<row_ext_t *>(mem_heap_alloc(heap, (sizeof *ret)
93
+ (n_ext - 1) * sizeof ret->len));
95
ut_ad(ut_is_2pow(zip_size));
96
ut_ad(zip_size <= UNIV_PAGE_SIZE);
100
ret->buf = static_cast<byte *>(mem_heap_alloc(heap, n_ext * REC_MAX_INDEX_COL_LEN));
102
memset(ret->buf, 0xaa, n_ext * REC_MAX_INDEX_COL_LEN);
103
UNIV_MEM_ALLOC(ret->buf, n_ext * REC_MAX_INDEX_COL_LEN);
106
/* Fetch the BLOB prefixes */
107
for (i = 0; i < n_ext; i++) {
108
const dfield_t* dfield;
110
dfield = dtuple_get_nth_field(tuple, ext[i]);
111
row_ext_cache_fill(ret, i, zip_size, dfield);