~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/row0ext.ic

  • Committer: Monty Taylor
  • Date: 2009-03-25 21:06:47 UTC
  • mto: This revision was merged to the branch mainline in revision 964.
  • Revision ID: mordred@inaugust.com-20090325210647-7j1tm98gvct3jxsu
Removed legacy_db_type.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/******************************************************
 
20
Caching of externally stored column prefixes
 
21
 
 
22
Created September 2006 Marko Makela
 
23
*******************************************************/
 
24
 
 
25
#include "rem0types.h"
 
26
#include "btr0types.h"
 
27
 
 
28
/************************************************************************
 
29
Looks up a column prefix of an externally stored column. */
 
30
UNIV_INLINE
 
31
const byte*
 
32
row_ext_lookup_ith(
 
33
/*===============*/
 
34
                                        /* out: column prefix, or NULL if
 
35
                                        the column is not stored externally,
 
36
                                        or pointer to field_ref_zero
 
37
                                        if the BLOB pointer is unset */
 
38
        const row_ext_t*        ext,    /* in/out: column prefix cache */
 
39
        ulint                   i,      /* in: index of ext->ext[] */
 
40
        ulint*                  len)    /* out: length of prefix, in bytes,
 
41
                                        at most REC_MAX_INDEX_COL_LEN */
 
42
{
 
43
        ut_ad(ext);
 
44
        ut_ad(len);
 
45
        ut_ad(i < ext->n_ext);
 
46
 
 
47
        *len = ext->len[i];
 
48
 
 
49
        if (UNIV_UNLIKELY(*len == 0)) {
 
50
                /* The BLOB could not be fetched to the cache. */
 
51
                return(field_ref_zero);
 
52
        } else {
 
53
                return(ext->buf + i * REC_MAX_INDEX_COL_LEN);
 
54
        }
 
55
}
 
56
 
 
57
/************************************************************************
 
58
Looks up a column prefix of an externally stored column. */
 
59
UNIV_INLINE
 
60
const byte*
 
61
row_ext_lookup(
 
62
/*===========*/
 
63
                                        /* out: column prefix, or NULL if
 
64
                                        the column is not stored externally,
 
65
                                        or pointer to field_ref_zero
 
66
                                        if the BLOB pointer is unset */
 
67
        const row_ext_t*        ext,    /* in: column prefix cache */
 
68
        ulint                   col,    /* in: column number in the InnoDB
 
69
                                        table object, as reported by
 
70
                                        dict_col_get_no(); NOT relative to the
 
71
                                        records in the clustered index */
 
72
        ulint*                  len)    /* out: length of prefix, in bytes,
 
73
                                        at most REC_MAX_INDEX_COL_LEN */
 
74
{
 
75
        ulint   i;
 
76
 
 
77
        ut_ad(ext);
 
78
        ut_ad(len);
 
79
 
 
80
        for (i = 0; i < ext->n_ext; i++) {
 
81
                if (col == ext->ext[i]) {
 
82
                        return(row_ext_lookup_ith(ext, i, len));
 
83
                }
 
84
        }
 
85
 
 
86
        return(NULL);
 
87
}