~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-07-30 20:31:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1679.
  • Revision ID: brian@gaz-20100730203119-89g2ye4zwnvcacxg
First pass in encapsulating row

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1995, 2010, 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/fil0fil.h
21
 
The low-level file system
22
 
 
23
 
Created 10/25/1995 Heikki Tuuri
24
 
*******************************************************/
25
 
 
26
 
#ifndef fil0fil_h
27
 
#define fil0fil_h
28
 
 
29
 
#include "univ.i"
30
 
#include "dict0types.h"
31
 
#include "ut0byte.h"
32
 
#include "os0file.h"
33
 
#ifndef UNIV_HOTBACKUP
34
 
#include "sync0rw.h"
35
 
#include "ibuf0types.h"
36
 
#endif /* !UNIV_HOTBACKUP */
37
 
 
38
 
/** When mysqld is run, the default directory "." is the mysqld datadir,
39
 
but in the MySQL Embedded Server Library and ibbackup it is not the default
40
 
directory, and we must set the base file path explicitly */
41
 
extern const char*      fil_path_to_mysql_datadir;
42
 
 
43
 
/** Initial size of a single-table tablespace in pages */
44
 
#define FIL_IBD_FILE_INITIAL_SIZE       4
45
 
 
46
 
/** 'null' (undefined) page offset in the context of file spaces */
47
 
#define FIL_NULL        ULINT32_UNDEFINED
48
 
 
49
 
/* Space address data type; this is intended to be used when
50
 
addresses accurate to a byte are stored in file pages. If the page part
51
 
of the address is FIL_NULL, the address is considered undefined. */
52
 
 
53
 
typedef byte    fil_faddr_t;    /*!< 'type' definition in C: an address
54
 
                                stored in a file page is a string of bytes */
55
 
#define FIL_ADDR_PAGE   0       /* first in address is the page offset */
56
 
#define FIL_ADDR_BYTE   4       /* then comes 2-byte byte offset within page*/
57
 
 
58
 
#define FIL_ADDR_SIZE   6       /* address size is 6 bytes */
59
 
 
60
 
/** A struct for storing a space address FIL_ADDR, when it is used
61
 
in C program data structures. */
62
 
 
63
 
typedef struct fil_addr_struct  fil_addr_t;
64
 
/** File space address */
65
 
struct fil_addr_struct{
66
 
        ulint   page;           /*!< page number within a space */
67
 
        ulint   boffset;        /*!< byte offset within the page */
68
 
};
69
 
 
70
 
/** The null file address */
71
 
extern fil_addr_t       fil_addr_null;
72
 
 
73
 
/** The byte offsets on a file page for various variables @{ */
74
 
#define FIL_PAGE_SPACE_OR_CHKSUM 0      /*!< in < MySQL-4.0.14 space id the
75
 
                                        page belongs to (== 0) but in later
76
 
                                        versions the 'new' checksum of the
77
 
                                        page */
78
 
#define FIL_PAGE_OFFSET         4       /*!< page offset inside space */
79
 
#define FIL_PAGE_PREV           8       /*!< if there is a 'natural'
80
 
                                        predecessor of the page, its
81
 
                                        offset.  Otherwise FIL_NULL.
82
 
                                        This field is not set on BLOB
83
 
                                        pages, which are stored as a
84
 
                                        singly-linked list.  See also
85
 
                                        FIL_PAGE_NEXT. */
86
 
#define FIL_PAGE_NEXT           12      /*!< if there is a 'natural' successor
87
 
                                        of the page, its offset.
88
 
                                        Otherwise FIL_NULL.
89
 
                                        B-tree index pages
90
 
                                        (FIL_PAGE_TYPE contains FIL_PAGE_INDEX)
91
 
                                        on the same PAGE_LEVEL are maintained
92
 
                                        as a doubly linked list via
93
 
                                        FIL_PAGE_PREV and FIL_PAGE_NEXT
94
 
                                        in the collation order of the
95
 
                                        smallest user record on each page. */
96
 
#define FIL_PAGE_LSN            16      /*!< lsn of the end of the newest
97
 
                                        modification log record to the page */
98
 
#define FIL_PAGE_TYPE           24      /*!< file page type: FIL_PAGE_INDEX,...,
99
 
                                        2 bytes.
100
 
 
101
 
                                        The contents of this field can only
102
 
                                        be trusted in the following case:
103
 
                                        if the page is an uncompressed
104
 
                                        B-tree index page, then it is
105
 
                                        guaranteed that the value is
106
 
                                        FIL_PAGE_INDEX.
107
 
                                        The opposite does not hold.
108
 
 
109
 
                                        In tablespaces created by
110
 
                                        MySQL/InnoDB 5.1.7 or later, the
111
 
                                        contents of this field is valid
112
 
                                        for all uncompressed pages. */
113
 
#define FIL_PAGE_FILE_FLUSH_LSN 26      /*!< this is only defined for the
114
 
                                        first page in a system tablespace
115
 
                                        data file (ibdata*, not *.ibd):
116
 
                                        the file has been flushed to disk
117
 
                                        at least up to this lsn */
118
 
#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID  34 /*!< starting from 4.1.x this
119
 
                                        contains the space id of the page */
120
 
#define FIL_PAGE_DATA           38      /*!< start of the data on the page */
121
 
/* @} */
122
 
/** File page trailer @{ */
123
 
#define FIL_PAGE_END_LSN_OLD_CHKSUM 8   /*!< the low 4 bytes of this are used
124
 
                                        to store the page checksum, the
125
 
                                        last 4 bytes should be identical
126
 
                                        to the last 4 bytes of FIL_PAGE_LSN */
127
 
#define FIL_PAGE_DATA_END       8       /*!< size of the page trailer */
128
 
/* @} */
129
 
 
130
 
/** File page types (values of FIL_PAGE_TYPE) @{ */
131
 
#define FIL_PAGE_INDEX          17855   /*!< B-tree node */
132
 
#define FIL_PAGE_UNDO_LOG       2       /*!< Undo log page */
133
 
#define FIL_PAGE_INODE          3       /*!< Index node */
134
 
#define FIL_PAGE_IBUF_FREE_LIST 4       /*!< Insert buffer free list */
135
 
/* File page types introduced in MySQL/InnoDB 5.1.7 */
136
 
#define FIL_PAGE_TYPE_ALLOCATED 0       /*!< Freshly allocated page */
137
 
#define FIL_PAGE_IBUF_BITMAP    5       /*!< Insert buffer bitmap */
138
 
#define FIL_PAGE_TYPE_SYS       6       /*!< System page */
139
 
#define FIL_PAGE_TYPE_TRX_SYS   7       /*!< Transaction system data */
140
 
#define FIL_PAGE_TYPE_FSP_HDR   8       /*!< File space header */
141
 
#define FIL_PAGE_TYPE_XDES      9       /*!< Extent descriptor page */
142
 
#define FIL_PAGE_TYPE_BLOB      10      /*!< Uncompressed BLOB page */
143
 
#define FIL_PAGE_TYPE_ZBLOB     11      /*!< First compressed BLOB page */
144
 
#define FIL_PAGE_TYPE_ZBLOB2    12      /*!< Subsequent compressed BLOB page */
145
 
/* @} */
146
 
 
147
 
/** Space types @{ */
148
 
#define FIL_TABLESPACE          501     /*!< tablespace */
149
 
#define FIL_LOG                 502     /*!< redo log */
150
 
/* @} */
151
 
 
152
 
/** The number of fsyncs done to the log */
153
 
extern ulint    fil_n_log_flushes;
154
 
 
155
 
/** Number of pending redo log flushes */
156
 
extern ulint    fil_n_pending_log_flushes;
157
 
/** Number of pending tablespace flushes */
158
 
extern ulint    fil_n_pending_tablespace_flushes;
159
 
 
160
 
 
161
 
#ifndef UNIV_HOTBACKUP
162
 
/*******************************************************************//**
163
 
Returns the version number of a tablespace, -1 if not found.
164
 
@return version number, -1 if the tablespace does not exist in the
165
 
memory cache */
166
 
UNIV_INTERN
167
 
ib_int64_t
168
 
fil_space_get_version(
169
 
/*==================*/
170
 
        ulint   id);    /*!< in: space id */
171
 
/*******************************************************************//**
172
 
Returns the latch of a file space.
173
 
@return latch protecting storage allocation */
174
 
UNIV_INTERN
175
 
rw_lock_t*
176
 
fil_space_get_latch(
177
 
/*================*/
178
 
        ulint   id,     /*!< in: space id */
179
 
        ulint*  zip_size);/*!< out: compressed page size, or
180
 
                        0 for uncompressed tablespaces */
181
 
/*******************************************************************//**
182
 
Returns the type of a file space.
183
 
@return FIL_TABLESPACE or FIL_LOG */
184
 
UNIV_INTERN
185
 
ulint
186
 
fil_space_get_type(
187
 
/*===============*/
188
 
        ulint   id);    /*!< in: space id */
189
 
#endif /* !UNIV_HOTBACKUP */
190
 
/*******************************************************************//**
191
 
Appends a new file to the chain of files of a space. File must be closed. */
192
 
UNIV_INTERN
193
 
void
194
 
fil_node_create(
195
 
/*============*/
196
 
        const char*     name,   /*!< in: file name (file must be closed) */
197
 
        ulint           size,   /*!< in: file size in database blocks, rounded
198
 
                                downwards to an integer */
199
 
        ulint           id,     /*!< in: space id where to append */
200
 
        ibool           is_raw);/*!< in: TRUE if a raw device or
201
 
                                a raw disk partition */
202
 
#ifdef UNIV_LOG_ARCHIVE
203
 
/****************************************************************//**
204
 
Drops files from the start of a file space, so that its size is cut by
205
 
the amount given. */
206
 
UNIV_INTERN
207
 
void
208
 
fil_space_truncate_start(
209
 
/*=====================*/
210
 
        ulint   id,             /*!< in: space id */
211
 
        ulint   trunc_len);     /*!< in: truncate by this much; it is an error
212
 
                                if this does not equal to the combined size of
213
 
                                some initial files in the space */
214
 
#endif /* UNIV_LOG_ARCHIVE */
215
 
/*******************************************************************//**
216
 
Creates a space memory object and puts it to the 'fil system' hash table. If
217
 
there is an error, prints an error message to the .err log.
218
 
@return TRUE if success */
219
 
UNIV_INTERN
220
 
ibool
221
 
fil_space_create(
222
 
/*=============*/
223
 
        const char*     name,   /*!< in: space name */
224
 
        ulint           id,     /*!< in: space id */
225
 
        ulint           zip_size,/*!< in: compressed page size, or
226
 
                                0 for uncompressed tablespaces */
227
 
        ulint           purpose);/*!< in: FIL_TABLESPACE, or FIL_LOG if log */
228
 
/*******************************************************************//**
229
 
Assigns a new space id for a new single-table tablespace. This works simply by
230
 
incrementing the global counter. If 4 billion id's is not enough, we may need
231
 
to recycle id's.
232
 
@return TRUE if assigned, FALSE if not */
233
 
UNIV_INTERN
234
 
ibool
235
 
fil_assign_new_space_id(
236
 
/*====================*/
237
 
        ulint*  space_id);      /*!< in/out: space id */
238
 
/*******************************************************************//**
239
 
Returns the size of the space in pages. The tablespace must be cached in the
240
 
memory cache.
241
 
@return space size, 0 if space not found */
242
 
UNIV_INTERN
243
 
ulint
244
 
fil_space_get_size(
245
 
/*===============*/
246
 
        ulint   id);    /*!< in: space id */
247
 
/*******************************************************************//**
248
 
Returns the flags of the space. The tablespace must be cached
249
 
in the memory cache.
250
 
@return flags, ULINT_UNDEFINED if space not found */
251
 
UNIV_INTERN
252
 
ulint
253
 
fil_space_get_flags(
254
 
/*================*/
255
 
        ulint   id);    /*!< in: space id */
256
 
/*******************************************************************//**
257
 
Returns the compressed page size of the space, or 0 if the space
258
 
is not compressed. The tablespace must be cached in the memory cache.
259
 
@return compressed page size, ULINT_UNDEFINED if space not found */
260
 
UNIV_INTERN
261
 
ulint
262
 
fil_space_get_zip_size(
263
 
/*===================*/
264
 
        ulint   id);    /*!< in: space id */
265
 
/*******************************************************************//**
266
 
Checks if the pair space, page_no refers to an existing page in a tablespace
267
 
file space. The tablespace must be cached in the memory cache.
268
 
@return TRUE if the address is meaningful */
269
 
UNIV_INTERN
270
 
ibool
271
 
fil_check_adress_in_tablespace(
272
 
/*===========================*/
273
 
        ulint   id,     /*!< in: space id */
274
 
        ulint   page_no);/*!< in: page number */
275
 
/****************************************************************//**
276
 
Initializes the tablespace memory cache. */
277
 
UNIV_INTERN
278
 
void
279
 
fil_init(
280
 
/*=====*/
281
 
        ulint   hash_size,      /*!< in: hash table size */
282
 
        ulint   max_n_open);    /*!< in: max number of open files */
283
 
/*******************************************************************//**
284
 
Initializes the tablespace memory cache. */
285
 
UNIV_INTERN
286
 
void
287
 
fil_close(void);
288
 
/*===========*/
289
 
/*******************************************************************//**
290
 
Opens all log files and system tablespace data files. They stay open until the
291
 
database server shutdown. This should be called at a server startup after the
292
 
space objects for the log and the system tablespace have been created. The
293
 
purpose of this operation is to make sure we never run out of file descriptors
294
 
if we need to read from the insert buffer or to write to the log. */
295
 
UNIV_INTERN
296
 
void
297
 
fil_open_log_and_system_tablespace_files(void);
298
 
/*==========================================*/
299
 
/*******************************************************************//**
300
 
Closes all open files. There must not be any pending i/o's or not flushed
301
 
modifications in the files. */
302
 
UNIV_INTERN
303
 
void
304
 
fil_close_all_files(void);
305
 
/*=====================*/
306
 
/*******************************************************************//**
307
 
Sets the max tablespace id counter if the given number is bigger than the
308
 
previous value. */
309
 
UNIV_INTERN
310
 
void
311
 
fil_set_max_space_id_if_bigger(
312
 
/*===========================*/
313
 
        ulint   max_id);/*!< in: maximum known id */
314
 
#ifndef UNIV_HOTBACKUP
315
 
/****************************************************************//**
316
 
Writes the flushed lsn and the latest archived log number to the page
317
 
header of the first page of each data file in the system tablespace.
318
 
@return DB_SUCCESS or error number */
319
 
UNIV_INTERN
320
 
ulint
321
 
fil_write_flushed_lsn_to_data_files(
322
 
/*================================*/
323
 
        ib_uint64_t     lsn,            /*!< in: lsn to write */
324
 
        ulint           arch_log_no);   /*!< in: latest archived log
325
 
                                        file number */
326
 
/*******************************************************************//**
327
 
Reads the flushed lsn and arch no fields from a data file at database
328
 
startup. */
329
 
UNIV_INTERN
330
 
void
331
 
fil_read_flushed_lsn_and_arch_log_no(
332
 
/*=================================*/
333
 
        os_file_t       data_file,              /*!< in: open data file */
334
 
        ibool           one_read_already,       /*!< in: TRUE if min and max
335
 
                                                parameters below already
336
 
                                                contain sensible data */
337
 
#ifdef UNIV_LOG_ARCHIVE
338
 
        ulint*          min_arch_log_no,        /*!< in/out: */
339
 
        ulint*          max_arch_log_no,        /*!< in/out: */
340
 
#endif /* UNIV_LOG_ARCHIVE */
341
 
        ib_uint64_t*    min_flushed_lsn,        /*!< in/out: */
342
 
        ib_uint64_t*    max_flushed_lsn);       /*!< in/out: */
343
 
/*******************************************************************//**
344
 
Increments the count of pending insert buffer page merges, if space is not
345
 
being deleted.
346
 
@return TRUE if being deleted, and ibuf merges should be skipped */
347
 
UNIV_INTERN
348
 
ibool
349
 
fil_inc_pending_ibuf_merges(
350
 
/*========================*/
351
 
        ulint   id);    /*!< in: space id */
352
 
/*******************************************************************//**
353
 
Decrements the count of pending insert buffer page merges. */
354
 
UNIV_INTERN
355
 
void
356
 
fil_decr_pending_ibuf_merges(
357
 
/*=========================*/
358
 
        ulint   id);    /*!< in: space id */
359
 
#endif /* !UNIV_HOTBACKUP */
360
 
/*******************************************************************//**
361
 
Parses the body of a log record written about an .ibd file operation. That is,
362
 
the log record part after the standard (type, space id, page no) header of the
363
 
log record.
364
 
 
365
 
If desired, also replays the delete or rename operation if the .ibd file
366
 
exists and the space id in it matches. Replays the create operation if a file
367
 
at that path does not exist yet. If the database directory for the file to be
368
 
created does not exist, then we create the directory, too.
369
 
 
370
 
Note that ibbackup --apply-log sets fil_path_to_mysql_datadir to point to the
371
 
datadir that we should use in replaying the file operations.
372
 
@return end of log record, or NULL if the record was not completely
373
 
contained between ptr and end_ptr */
374
 
UNIV_INTERN
375
 
byte*
376
 
fil_op_log_parse_or_replay(
377
 
/*=======================*/
378
 
        byte*   ptr,            /*!< in: buffer containing the log record body,
379
 
                                or an initial segment of it, if the record does
380
 
                                not fir completely between ptr and end_ptr */
381
 
        byte*   end_ptr,        /*!< in: buffer end */
382
 
        ulint   type,           /*!< in: the type of this log record */
383
 
        ulint   space_id,       /*!< in: the space id of the tablespace in
384
 
                                question, or 0 if the log record should
385
 
                                only be parsed but not replayed */
386
 
        ulint   log_flags);     /*!< in: redo log flags
387
 
                                (stored in the page number parameter) */
388
 
/*******************************************************************//**
389
 
Deletes a single-table tablespace. The tablespace must be cached in the
390
 
memory cache.
391
 
@return TRUE if success */
392
 
UNIV_INTERN
393
 
ibool
394
 
fil_delete_tablespace(
395
 
/*==================*/
396
 
        ulint   id);    /*!< in: space id */
397
 
#ifndef UNIV_HOTBACKUP
398
 
/*******************************************************************//**
399
 
Discards a single-table tablespace. The tablespace must be cached in the
400
 
memory cache. Discarding is like deleting a tablespace, but
401
 
1) we do not drop the table from the data dictionary;
402
 
2) we remove all insert buffer entries for the tablespace immediately; in DROP
403
 
TABLE they are only removed gradually in the background;
404
 
3) when the user does IMPORT TABLESPACE, the tablespace will have the same id
405
 
as it originally had.
406
 
@return TRUE if success */
407
 
UNIV_INTERN
408
 
ibool
409
 
fil_discard_tablespace(
410
 
/*===================*/
411
 
        ulint   id);    /*!< in: space id */
412
 
#endif /* !UNIV_HOTBACKUP */
413
 
/*******************************************************************//**
414
 
Renames a single-table tablespace. The tablespace must be cached in the
415
 
tablespace memory cache.
416
 
@return TRUE if success */
417
 
UNIV_INTERN
418
 
ibool
419
 
fil_rename_tablespace(
420
 
/*==================*/
421
 
        const char*     old_name,       /*!< in: old table name in the standard
422
 
                                        databasename/tablename format of
423
 
                                        InnoDB, or NULL if we do the rename
424
 
                                        based on the space id only */
425
 
        ulint           id,             /*!< in: space id */
426
 
        const char*     new_name);      /*!< in: new table name in the standard
427
 
                                        databasename/tablename format
428
 
                                        of InnoDB */
429
 
 
430
 
/*******************************************************************//**
431
 
Creates a new single-table tablespace to a database directory of MySQL.
432
 
Database directories are under the 'datadir' of MySQL. The datadir is the
433
 
directory of a running mysqld program. We can refer to it by simply the
434
 
path '.'. Tables created with CREATE TEMPORARY TABLE we place in the temp
435
 
dir of the mysqld server.
436
 
@return DB_SUCCESS or error code */
437
 
UNIV_INTERN
438
 
ulint
439
 
fil_create_new_single_table_tablespace(
440
 
/*===================================*/
441
 
        ulint           space_id,       /*!< in: space id */
442
 
        const char*     tablename,      /*!< in: the table name in the usual
443
 
                                        databasename/tablename format
444
 
                                        of InnoDB, or a dir path to a temp
445
 
                                        table */
446
 
        ibool           is_temp,        /*!< in: TRUE if a table created with
447
 
                                        CREATE TEMPORARY TABLE */
448
 
        ulint           flags,          /*!< in: tablespace flags */
449
 
        ulint           size);          /*!< in: the initial size of the
450
 
                                        tablespace file in pages,
451
 
                                        must be >= FIL_IBD_FILE_INITIAL_SIZE */
452
 
#ifndef UNIV_HOTBACKUP
453
 
/********************************************************************//**
454
 
Tries to open a single-table tablespace and optionally checks the space id is
455
 
right in it. If does not succeed, prints an error message to the .err log. This
456
 
function is used to open a tablespace when we start up mysqld, and also in
457
 
IMPORT TABLESPACE.
458
 
NOTE that we assume this operation is used either at the database startup
459
 
or under the protection of the dictionary mutex, so that two users cannot
460
 
race here. This operation does not leave the file associated with the
461
 
tablespace open, but closes it after we have looked at the space id in it.
462
 
@return TRUE if success */
463
 
UNIV_INTERN
464
 
ibool
465
 
fil_open_single_table_tablespace(
466
 
/*=============================*/
467
 
        ibool           check_space_id, /*!< in: should we check that the space
468
 
                                        id in the file is right; we assume
469
 
                                        that this function runs much faster
470
 
                                        if no check is made, since accessing
471
 
                                        the file inode probably is much
472
 
                                        faster (the OS caches them) than
473
 
                                        accessing the first page of the file */
474
 
        ulint           id,             /*!< in: space id */
475
 
        ulint           flags,          /*!< in: tablespace flags */
476
 
        const char*     name);          /*!< in: table name in the
477
 
                                        databasename/tablename format */
478
 
/********************************************************************//**
479
 
It is possible, though very improbable, that the lsn's in the tablespace to be
480
 
imported have risen above the current system lsn, if a lengthy purge, ibuf
481
 
merge, or rollback was performed on a backup taken with ibbackup. If that is
482
 
the case, reset page lsn's in the file. We assume that mysqld was shut down
483
 
after it performed these cleanup operations on the .ibd file, so that it at
484
 
the shutdown stamped the latest lsn to the FIL_PAGE_FILE_FLUSH_LSN in the
485
 
first page of the .ibd file, and we can determine whether we need to reset the
486
 
lsn's just by looking at that flush lsn.
487
 
@return TRUE if success */
488
 
UNIV_INTERN
489
 
ibool
490
 
fil_reset_too_high_lsns(
491
 
/*====================*/
492
 
        const char*     name,           /*!< in: table name in the
493
 
                                        databasename/tablename format */
494
 
        ib_uint64_t     current_lsn);   /*!< in: reset lsn's if the lsn stamped
495
 
                                        to FIL_PAGE_FILE_FLUSH_LSN in the
496
 
                                        first page is too high */
497
 
#endif /* !UNIV_HOTBACKUP */
498
 
/********************************************************************//**
499
 
At the server startup, if we need crash recovery, scans the database
500
 
directories under the MySQL datadir, looking for .ibd files. Those files are
501
 
single-table tablespaces. We need to know the space id in each of them so that
502
 
we know into which file we should look to check the contents of a page stored
503
 
in the doublewrite buffer, also to know where to apply log records where the
504
 
space id is != 0.
505
 
@return DB_SUCCESS or error number */
506
 
UNIV_INTERN
507
 
ulint
508
 
fil_load_single_table_tablespaces(void);
509
 
/*===================================*/
510
 
/*******************************************************************//**
511
 
Returns TRUE if a single-table tablespace does not exist in the memory cache,
512
 
or is being deleted there.
513
 
@return TRUE if does not exist or is being\ deleted */
514
 
UNIV_INTERN
515
 
ibool
516
 
fil_tablespace_deleted_or_being_deleted_in_mem(
517
 
/*===========================================*/
518
 
        ulint           id,     /*!< in: space id */
519
 
        ib_int64_t      version);/*!< in: tablespace_version should be this; if
520
 
                                you pass -1 as the value of this, then this
521
 
                                parameter is ignored */
522
 
/*******************************************************************//**
523
 
Returns TRUE if a single-table tablespace exists in the memory cache.
524
 
@return TRUE if exists */
525
 
UNIV_INTERN
526
 
ibool
527
 
fil_tablespace_exists_in_mem(
528
 
/*=========================*/
529
 
        ulint   id);    /*!< in: space id */
530
 
#ifndef UNIV_HOTBACKUP
531
 
/*******************************************************************//**
532
 
Returns TRUE if a matching tablespace exists in the InnoDB tablespace memory
533
 
cache. Note that if we have not done a crash recovery at the database startup,
534
 
there may be many tablespaces which are not yet in the memory cache.
535
 
@return TRUE if a matching tablespace exists in the memory cache */
536
 
UNIV_INTERN
537
 
ibool
538
 
fil_space_for_table_exists_in_mem(
539
 
/*==============================*/
540
 
        ulint           id,             /*!< in: space id */
541
 
        const char*     name,           /*!< in: table name in the standard
542
 
                                        'databasename/tablename' format or
543
 
                                        the dir path to a temp table */
544
 
        ibool           is_temp,        /*!< in: TRUE if created with CREATE
545
 
                                        TEMPORARY TABLE */
546
 
        ibool           mark_space,     /*!< in: in crash recovery, at database
547
 
                                        startup we mark all spaces which have
548
 
                                        an associated table in the InnoDB
549
 
                                        data dictionary, so that
550
 
                                        we can print a warning about orphaned
551
 
                                        tablespaces */
552
 
        ibool           print_error_if_does_not_exist);
553
 
                                        /*!< in: print detailed error
554
 
                                        information to the .err log if a
555
 
                                        matching tablespace is not found from
556
 
                                        memory */
557
 
#else /* !UNIV_HOTBACKUP */
558
 
/********************************************************************//**
559
 
Extends all tablespaces to the size stored in the space header. During the
560
 
ibbackup --apply-log phase we extended the spaces on-demand so that log records
561
 
could be appllied, but that may have left spaces still too small compared to
562
 
the size stored in the space header. */
563
 
UNIV_INTERN
564
 
void
565
 
fil_extend_tablespaces_to_stored_len(void);
566
 
/*======================================*/
567
 
#endif /* !UNIV_HOTBACKUP */
568
 
/**********************************************************************//**
569
 
Tries to extend a data file so that it would accommodate the number of pages
570
 
given. The tablespace must be cached in the memory cache. If the space is big
571
 
enough already, does nothing.
572
 
@return TRUE if success */
573
 
UNIV_INTERN
574
 
ibool
575
 
fil_extend_space_to_desired_size(
576
 
/*=============================*/
577
 
        ulint*  actual_size,    /*!< out: size of the space after extension;
578
 
                                if we ran out of disk space this may be lower
579
 
                                than the desired size */
580
 
        ulint   space_id,       /*!< in: space id */
581
 
        ulint   size_after_extend);/*!< in: desired size in pages after the
582
 
                                extension; if the current space size is bigger
583
 
                                than this already, the function does nothing */
584
 
/*******************************************************************//**
585
 
Tries to reserve free extents in a file space.
586
 
@return TRUE if succeed */
587
 
UNIV_INTERN
588
 
ibool
589
 
fil_space_reserve_free_extents(
590
 
/*===========================*/
591
 
        ulint   id,             /*!< in: space id */
592
 
        ulint   n_free_now,     /*!< in: number of free extents now */
593
 
        ulint   n_to_reserve);  /*!< in: how many one wants to reserve */
594
 
/*******************************************************************//**
595
 
Releases free extents in a file space. */
596
 
UNIV_INTERN
597
 
void
598
 
fil_space_release_free_extents(
599
 
/*===========================*/
600
 
        ulint   id,             /*!< in: space id */
601
 
        ulint   n_reserved);    /*!< in: how many one reserved */
602
 
/*******************************************************************//**
603
 
Gets the number of reserved extents. If the database is silent, this number
604
 
should be zero. */
605
 
UNIV_INTERN
606
 
ulint
607
 
fil_space_get_n_reserved_extents(
608
 
/*=============================*/
609
 
        ulint   id);            /*!< in: space id */
610
 
/********************************************************************//**
611
 
Reads or writes data. This operation is asynchronous (aio).
612
 
@return DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do
613
 
i/o on a tablespace which does not exist */
614
 
UNIV_INTERN
615
 
ulint
616
 
fil_io(
617
 
/*===*/
618
 
        ulint   type,           /*!< in: OS_FILE_READ or OS_FILE_WRITE,
619
 
                                ORed to OS_FILE_LOG, if a log i/o
620
 
                                and ORed to OS_AIO_SIMULATED_WAKE_LATER
621
 
                                if simulated aio and we want to post a
622
 
                                batch of i/os; NOTE that a simulated batch
623
 
                                may introduce hidden chances of deadlocks,
624
 
                                because i/os are not actually handled until
625
 
                                all have been posted: use with great
626
 
                                caution! */
627
 
        ibool   sync,           /*!< in: TRUE if synchronous aio is desired */
628
 
        ulint   space_id,       /*!< in: space id */
629
 
        ulint   zip_size,       /*!< in: compressed page size in bytes;
630
 
                                0 for uncompressed pages */
631
 
        ulint   block_offset,   /*!< in: offset in number of blocks */
632
 
        ulint   byte_offset,    /*!< in: remainder of offset in bytes; in
633
 
                                aio this must be divisible by the OS block
634
 
                                size */
635
 
        ulint   len,            /*!< in: how many bytes to read or write; this
636
 
                                must not cross a file boundary; in aio this
637
 
                                must be a block size multiple */
638
 
        void*   buf,            /*!< in/out: buffer where to store read data
639
 
                                or from where to write; in aio this must be
640
 
                                appropriately aligned */
641
 
        void*   message);       /*!< in: message for aio handler if non-sync
642
 
                                aio used, else ignored */
643
 
/**********************************************************************//**
644
 
Waits for an aio operation to complete. This function is used to write the
645
 
handler for completed requests. The aio array of pending requests is divided
646
 
into segments (see os0file.c for more info). The thread specifies which
647
 
segment it wants to wait for. */
648
 
UNIV_INTERN
649
 
void
650
 
fil_aio_wait(
651
 
/*=========*/
652
 
        ulint   segment);       /*!< in: the number of the segment in the aio
653
 
                                array to wait for */
654
 
/**********************************************************************//**
655
 
Flushes to disk possible writes cached by the OS. If the space does not exist
656
 
or is being dropped, does not do anything. */
657
 
UNIV_INTERN
658
 
void
659
 
fil_flush(
660
 
/*======*/
661
 
        ulint   space_id);      /*!< in: file space id (this can be a group of
662
 
                                log files or a tablespace of the database) */
663
 
/**********************************************************************//**
664
 
Flushes to disk writes in file spaces of the given type possibly cached by
665
 
the OS. */
666
 
UNIV_INTERN
667
 
void
668
 
fil_flush_file_spaces(
669
 
/*==================*/
670
 
        ulint   purpose);       /*!< in: FIL_TABLESPACE, FIL_LOG */
671
 
/******************************************************************//**
672
 
Checks the consistency of the tablespace cache.
673
 
@return TRUE if ok */
674
 
UNIV_INTERN
675
 
ibool
676
 
fil_validate(void);
677
 
/*==============*/
678
 
/********************************************************************//**
679
 
Returns TRUE if file address is undefined.
680
 
@return TRUE if undefined */
681
 
UNIV_INTERN
682
 
ibool
683
 
fil_addr_is_null(
684
 
/*=============*/
685
 
        fil_addr_t      addr);  /*!< in: address */
686
 
/********************************************************************//**
687
 
Get the predecessor of a file page.
688
 
@return FIL_PAGE_PREV */
689
 
UNIV_INTERN
690
 
ulint
691
 
fil_page_get_prev(
692
 
/*==============*/
693
 
        const byte*     page);  /*!< in: file page */
694
 
/********************************************************************//**
695
 
Get the successor of a file page.
696
 
@return FIL_PAGE_NEXT */
697
 
UNIV_INTERN
698
 
ulint
699
 
fil_page_get_next(
700
 
/*==============*/
701
 
        const byte*     page);  /*!< in: file page */
702
 
/*********************************************************************//**
703
 
Sets the file page type. */
704
 
UNIV_INTERN
705
 
void
706
 
fil_page_set_type(
707
 
/*==============*/
708
 
        byte*   page,   /*!< in/out: file page */
709
 
        ulint   type);  /*!< in: type */
710
 
/*********************************************************************//**
711
 
Gets the file page type.
712
 
@return type; NOTE that if the type has not been written to page, the
713
 
return value not defined */
714
 
UNIV_INTERN
715
 
ulint
716
 
fil_page_get_type(
717
 
/*==============*/
718
 
        const byte*     page);  /*!< in: file page */
719
 
 
720
 
/*******************************************************************//**
721
 
Returns TRUE if a single-table tablespace is being deleted.
722
 
@return TRUE if being deleted */
723
 
UNIV_INTERN
724
 
ibool
725
 
fil_tablespace_is_being_deleted(
726
 
/*============================*/
727
 
        ulint           id);    /*!< in: space id */
728
 
 
729
 
typedef struct fil_space_struct fil_space_t;
730
 
 
731
 
#endif