641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
1 |
/*****************************************************************************
|
2 |
||
3 |
Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
|
|
4 |
||
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.
|
|
8 |
||
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.
|
|
12 |
||
13 |
You should have received a copy of the GNU General Public License along with
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
15 |
St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
641.2.2
by Monty Taylor
InnoDB Plugin 1.0.3 |
16 |
|
17 |
*****************************************************************************/
|
|
18 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
19 |
/**************************************************//**
|
20 |
@file row/row0ext.c
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
21 |
Caching of externally stored column prefixes
|
22 |
||
23 |
Created September 2006 Marko Makela
|
|
24 |
*******************************************************/
|
|
25 |
||
26 |
#include "row0ext.h" |
|
27 |
||
28 |
#ifdef UNIV_NONINL
|
|
29 |
#include "row0ext.ic" |
|
30 |
#endif
|
|
31 |
||
32 |
#include "btr0cur.h" |
|
33 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
34 |
/********************************************************************//**
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
35 |
Fills the column prefix cache of an externally stored column. */
|
36 |
static
|
|
37 |
void
|
|
38 |
row_ext_cache_fill( |
|
39 |
/*===============*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
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 */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
44 |
{
|
45 |
const byte* field = dfield_get_data(dfield); |
|
46 |
ulint f_len = dfield_get_len(dfield); |
|
47 |
byte* buf = ext->buf + i * REC_MAX_INDEX_COL_LEN; |
|
48 |
||
49 |
ut_ad(i < ext->n_ext); |
|
50 |
ut_ad(dfield_is_ext(dfield)); |
|
51 |
ut_a(f_len >= BTR_EXTERN_FIELD_REF_SIZE); |
|
52 |
||
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 */
|
|
57 |
ext->len[i] = 0; |
|
58 |
} else { |
|
59 |
/* Fetch at most REC_MAX_INDEX_COL_LEN of the column.
|
|
641.2.1
by Monty Taylor
InnoDB Plugin 1.0.2 |
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(). */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
65 |
ext->len[i] = btr_copy_externally_stored_field_prefix( |
66 |
buf, REC_MAX_INDEX_COL_LEN, zip_size, field, f_len); |
|
67 |
}
|
|
68 |
}
|
|
69 |
||
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
70 |
/********************************************************************//**
|
71 |
Creates a cache of column prefixes of externally stored columns.
|
|
72 |
@return own: column prefix cache */
|
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
73 |
UNIV_INTERN
|
74 |
row_ext_t* |
|
75 |
row_ext_create( |
|
76 |
/*===========*/
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
77 |
ulint n_ext, /*!< in: number of externally stored columns */ |
78 |
const ulint* ext, /*!< in: col_no's of externally stored columns |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
79 |
in the InnoDB table object, as reported by
|
80 |
dict_col_get_no(); NOT relative to the records
|
|
81 |
in the clustered index */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
82 |
const dtuple_t* tuple, /*!< in: data tuple containing the field |
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
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). */
|
|
641.2.3
by Monty Taylor
InnoDB Plugin 1.0.4 |
88 |
ulint zip_size,/*!< compressed page size in bytes, or 0 */ |
89 |
mem_heap_t* heap) /*!< in: heap where created */ |
|
641.1.2
by Monty Taylor
Imported 1.0.1 with clean - with no changes. |
90 |
{
|
91 |
ulint i; |
|
92 |
row_ext_t* ret = mem_heap_alloc(heap, (sizeof *ret) |
|
93 |
+ (n_ext - 1) * sizeof ret->len); |
|
94 |
||
95 |
ut_ad(ut_is_2pow(zip_size)); |
|
96 |
ut_ad(zip_size <= UNIV_PAGE_SIZE); |
|
97 |
||
98 |
ret->n_ext = n_ext; |
|
99 |
ret->ext = ext; |
|
100 |
ret->buf = mem_heap_alloc(heap, n_ext * REC_MAX_INDEX_COL_LEN); |
|
101 |
#ifdef UNIV_DEBUG
|
|
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); |
|
104 |
#endif
|
|
105 |
||
106 |
/* Fetch the BLOB prefixes */
|
|
107 |
for (i = 0; i < n_ext; i++) { |
|
108 |
const dfield_t* dfield; |
|
109 |
||
110 |
dfield = dtuple_get_nth_field(tuple, ext[i]); |
|
111 |
row_ext_cache_fill(ret, i, zip_size, dfield); |
|
112 |
}
|
|
113 |
||
114 |
return(ret); |
|
115 |
}
|