~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

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
#pragma once
 
27
#ifndef buf0rea_h
 
28
#define buf0rea_h
 
29
 
 
30
#include "univ.i"
 
31
#include "buf0types.h"
 
32
#include "trx0types.h"
 
33
 
 
34
/********************************************************************//**
 
35
Low-level function which reads a page asynchronously from a file to the
 
36
buffer buf_pool if it is not already there, in which case does nothing.
 
37
Sets the io_fix flag and sets an exclusive lock on the buffer frame. The
 
38
flag is cleared and the x-lock released by an i/o-handler thread.
 
39
@return 1 if a read request was queued, 0 if the page already resided
 
40
in buf_pool, or if the page is in the doublewrite buffer blocks in
 
41
which case it is never read into the pool, or if the tablespace does
 
42
not exist or is being dropped TODO update
 
43
@return 1 if read request is issued. 0 if it is not */
 
44
UNIV_INTERN
 
45
ulint
 
46
buf_read_page_low(
 
47
/*==============*/
 
48
        ulint*  err,    /*!< out: DB_SUCCESS or DB_TABLESPACE_DELETED if we are
 
49
                        trying to read from a non-existent tablespace, or a
 
50
                        tablespace which is just now being dropped */
 
51
        ibool   sync,   /*!< in: true if synchronous aio is desired */
 
52
        ulint   mode,   /*!< in: BUF_READ_IBUF_PAGES_ONLY, ...,
 
53
                        ORed to OS_AIO_SIMULATED_WAKE_LATER (see below
 
54
                        at read-ahead functions) */
 
55
        ulint   space,  /*!< in: space id */
 
56
        ulint   zip_size,/*!< in: compressed page size, or 0 */
 
57
        ibool   unzip,  /*!< in: true=request uncompressed page */
 
58
        ib_int64_t tablespace_version, /*!< in: if the space memory object has
 
59
                                       this timestamp different from what we are giving here,
 
60
                                       treat the tablespace as dropped; this is a timestamp we
 
61
                                       use to stop dangling page reads from a tablespace
 
62
                                       which we have DISCARDed + IMPORTed back */
 
63
        ulint   offset);/*!< in: page number */
 
64
 
 
65
/********************************************************************//**
 
66
High-level function which reads a page asynchronously from a file to the
 
67
buffer buf_pool if it is not already there. Sets the io_fix flag and sets
 
68
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
 
69
released by the i/o-handler thread.
 
70
@return TRUE if page has been read in, FALSE in case of failure */
 
71
UNIV_INTERN
 
72
ibool
 
73
buf_read_page(
 
74
/*==========*/
 
75
        ulint   space,  /*!< in: space id */
 
76
        ulint   zip_size,/*!< in: compressed page size in bytes, or 0 */
 
77
        ulint   offset);/*!< in: page number */
 
78
/********************************************************************//**
 
79
Applies linear read-ahead if in the buf_pool the page is a border page of
 
80
a linear read-ahead area and all the pages in the area have been accessed.
 
81
Does not read any page if the read-ahead mechanism is not activated. Note
 
82
that the the algorithm looks at the 'natural' adjacent successor and
 
83
predecessor of the page, which on the leaf level of a B-tree are the next
 
84
and previous page in the chain of leaves. To know these, the page specified
 
85
in (space, offset) must already be present in the buf_pool. Thus, the
 
86
natural way to use this function is to call it when a page in the buf_pool
 
87
is accessed the first time, calling this function just after it has been
 
88
bufferfixed.
 
89
NOTE 1: as this function looks at the natural predecessor and successor
 
90
fields on the page, what happens, if these are not initialized to any
 
91
sensible value? No problem, before applying read-ahead we check that the
 
92
area to read is within the span of the space, if not, read-ahead is not
 
93
applied. An uninitialized value may result in a useless read operation, but
 
94
only very improbably.
 
95
NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this
 
96
function must be written such that it cannot end up waiting for these
 
97
latches!
 
98
NOTE 3: the calling thread must want access to the page given: this rule is
 
99
set to prevent unintended read-aheads performed by ibuf routines, a situation
 
100
which could result in a deadlock if the OS does not support asynchronous io.
 
101
@return number of page read requests issued */
 
102
UNIV_INTERN
 
103
ulint
 
104
buf_read_ahead_linear(
 
105
/*==================*/
 
106
        ulint   space,  /*!< in: space id */
 
107
        ulint   zip_size,/*!< in: compressed page size in bytes, or 0 */
 
108
        ulint   offset);/*!< in: page number of a page; NOTE: the current thread
 
109
                        must want access to this page (see NOTE 3 above) */
 
110
/********************************************************************//**
 
111
Issues read requests for pages which the ibuf module wants to read in, in
 
112
order to contract the insert buffer tree. Technically, this function is like
 
113
a read-ahead function. */
 
114
UNIV_INTERN
 
115
void
 
116
buf_read_ibuf_merge_pages(
 
117
/*======================*/
 
118
        ibool           sync,           /*!< in: TRUE if the caller
 
119
                                        wants this function to wait
 
120
                                        for the highest address page
 
121
                                        to get read in, before this
 
122
                                        function returns */
 
123
        const ulint*    space_ids,      /*!< in: array of space ids */
 
124
        const ib_int64_t* space_versions,/*!< in: the spaces must have
 
125
                                        this version number
 
126
                                        (timestamp), otherwise we
 
127
                                        discard the read; we use this
 
128
                                        to cancel reads if DISCARD +
 
129
                                        IMPORT may have changed the
 
130
                                        tablespace size */
 
131
        const ulint*    page_nos,       /*!< in: array of page numbers
 
132
                                        to read, with the highest page
 
133
                                        number the last in the
 
134
                                        array */
 
135
        ulint           n_stored);      /*!< in: number of elements
 
136
                                        in the arrays */
 
137
/********************************************************************//**
 
138
Issues read requests for pages which recovery wants to read in. */
 
139
UNIV_INTERN
 
140
void
 
141
buf_read_recv_pages(
 
142
/*================*/
 
143
        ibool           sync,           /*!< in: TRUE if the caller
 
144
                                        wants this function to wait
 
145
                                        for the highest address page
 
146
                                        to get read in, before this
 
147
                                        function returns */
 
148
        ulint           space,          /*!< in: space id */
 
149
        ulint           zip_size,       /*!< in: compressed page size in
 
150
                                        bytes, or 0 */
 
151
        const ulint*    page_nos,       /*!< in: array of page numbers
 
152
                                        to read, with the highest page
 
153
                                        number the last in the
 
154
                                        array */
 
155
        ulint           n_stored);      /*!< in: number of page numbers
 
156
                                        in the array */
 
157
 
 
158
/** The size in pages of the area which the read-ahead algorithms read if
 
159
invoked */
 
160
#define BUF_READ_AHEAD_AREA(b)          64
 
161
 
 
162
/** @name Modes used in read-ahead @{ */
 
163
/** read only pages belonging to the insert buffer tree */
 
164
#define BUF_READ_IBUF_PAGES_ONLY        131
 
165
/** read any page */
 
166
#define BUF_READ_ANY_PAGE               132
 
167
/* @} */
 
168
 
 
169
#endif