~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

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