~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/buf0rea.h

  • Committer: Jay Pipes
  • Date: 2009-09-15 21:01:42 UTC
  • mto: (1126.2.5 merge)
  • mto: This revision was merged to the branch mainline in revision 1128.
  • Revision ID: jpipes@serialcoder-20090915210142-x8mwiqn1q0vzjspp
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1995, 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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/buf0rea.h
21
 
The database buffer read
22
 
 
23
 
Created 11/5/1995 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef buf0rea_h
27
 
#define buf0rea_h
28
 
 
29
 
#include "univ.i"
30
 
#include "buf0types.h"
31
 
 
32
 
/********************************************************************//**
33
 
High-level function which reads a page asynchronously from a file to the
34
 
buffer buf_pool if it is not already there. Sets the io_fix flag and sets
35
 
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
36
 
released by the i/o-handler thread.
37
 
@return TRUE if page has been read in, FALSE in case of failure */
38
 
UNIV_INTERN
39
 
ibool
40
 
buf_read_page(
41
 
/*==========*/
42
 
        ulint   space,  /*!< in: space id */
43
 
        ulint   zip_size,/*!< in: compressed page size in bytes, or 0 */
44
 
        ulint   offset);/*!< in: page number */
45
 
/********************************************************************//**
46
 
Applies linear read-ahead if in the buf_pool the page is a border page of
47
 
a linear read-ahead area and all the pages in the area have been accessed.
48
 
Does not read any page if the read-ahead mechanism is not activated. Note
49
 
that the the algorithm looks at the 'natural' adjacent successor and
50
 
predecessor of the page, which on the leaf level of a B-tree are the next
51
 
and previous page in the chain of leaves. To know these, the page specified
52
 
in (space, offset) must already be present in the buf_pool. Thus, the
53
 
natural way to use this function is to call it when a page in the buf_pool
54
 
is accessed the first time, calling this function just after it has been
55
 
bufferfixed.
56
 
NOTE 1: as this function looks at the natural predecessor and successor
57
 
fields on the page, what happens, if these are not initialized to any
58
 
sensible value? No problem, before applying read-ahead we check that the
59
 
area to read is within the span of the space, if not, read-ahead is not
60
 
applied. An uninitialized value may result in a useless read operation, but
61
 
only very improbably.
62
 
NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this
63
 
function must be written such that it cannot end up waiting for these
64
 
latches!
65
 
NOTE 3: the calling thread must want access to the page given: this rule is
66
 
set to prevent unintended read-aheads performed by ibuf routines, a situation
67
 
which could result in a deadlock if the OS does not support asynchronous io.
68
 
@return number of page read requests issued */
69
 
UNIV_INTERN
70
 
ulint
71
 
buf_read_ahead_linear(
72
 
/*==================*/
73
 
        ulint   space,  /*!< in: space id */
74
 
        ulint   zip_size,/*!< in: compressed page size in bytes, or 0 */
75
 
        ulint   offset);/*!< in: page number of a page; NOTE: the current thread
76
 
                        must want access to this page (see NOTE 3 above) */
77
 
/********************************************************************//**
78
 
Issues read requests for pages which the ibuf module wants to read in, in
79
 
order to contract the insert buffer tree. Technically, this function is like
80
 
a read-ahead function. */
81
 
UNIV_INTERN
82
 
void
83
 
buf_read_ibuf_merge_pages(
84
 
/*======================*/
85
 
        ibool           sync,           /*!< in: TRUE if the caller
86
 
                                        wants this function to wait
87
 
                                        for the highest address page
88
 
                                        to get read in, before this
89
 
                                        function returns */
90
 
        const ulint*    space_ids,      /*!< in: array of space ids */
91
 
        const ib_int64_t* space_versions,/*!< in: the spaces must have
92
 
                                        this version number
93
 
                                        (timestamp), otherwise we
94
 
                                        discard the read; we use this
95
 
                                        to cancel reads if DISCARD +
96
 
                                        IMPORT may have changed the
97
 
                                        tablespace size */
98
 
        const ulint*    page_nos,       /*!< in: array of page numbers
99
 
                                        to read, with the highest page
100
 
                                        number the last in the
101
 
                                        array */
102
 
        ulint           n_stored);      /*!< in: number of elements
103
 
                                        in the arrays */
104
 
/********************************************************************//**
105
 
Issues read requests for pages which recovery wants to read in. */
106
 
UNIV_INTERN
107
 
void
108
 
buf_read_recv_pages(
109
 
/*================*/
110
 
        ibool           sync,           /*!< in: TRUE if the caller
111
 
                                        wants this function to wait
112
 
                                        for the highest address page
113
 
                                        to get read in, before this
114
 
                                        function returns */
115
 
        ulint           space,          /*!< in: space id */
116
 
        ulint           zip_size,       /*!< in: compressed page size in
117
 
                                        bytes, or 0 */
118
 
        const ulint*    page_nos,       /*!< in: array of page numbers
119
 
                                        to read, with the highest page
120
 
                                        number the last in the
121
 
                                        array */
122
 
        ulint           n_stored);      /*!< in: number of page numbers
123
 
                                        in the array */
124
 
 
125
 
/** The size in pages of the area which the read-ahead algorithms read if
126
 
invoked */
127
 
#define BUF_READ_AHEAD_AREA(b)                                  \
128
 
        ut_min(64, ut_2_power_up((b)->curr_size / 32))
129
 
 
130
 
/** @name Modes used in read-ahead @{ */
131
 
/** read only pages belonging to the insert buffer tree */
132
 
#define BUF_READ_IBUF_PAGES_ONLY        131
133
 
/** read any page */
134
 
#define BUF_READ_ANY_PAGE               132
135
 
/* @} */
136
 
 
137
 
#endif