30
14
#include "dict0types.h"
15
#include "ibuf0types.h"
31
16
#include "ut0byte.h"
32
17
#include "os0file.h"
33
#ifndef UNIV_HOTBACKUP
35
#include "ibuf0types.h"
36
#endif /* !UNIV_HOTBACKUP */
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 */
19
/* When mysqld is run, the default directory "." is the mysqld datadir, but in
20
ibbackup we must set it explicitly; the patgh must NOT contain the trailing
41
22
extern const char* fil_path_to_mysql_datadir;
43
/** Initial size of a single-table tablespace in pages */
24
/* Initial size of a single-table tablespace in pages */
44
25
#define FIL_IBD_FILE_INITIAL_SIZE 4
46
/** 'null' (undefined) page offset in the context of file spaces */
27
/* 'null' (undefined) page offset in the context of file spaces */
47
28
#define FIL_NULL ULINT32_UNDEFINED
49
30
/* Space address data type; this is intended to be used when
50
31
addresses accurate to a byte are stored in file pages. If the page part
51
32
of the address is FIL_NULL, the address is considered undefined. */
53
typedef byte fil_faddr_t; /*!< 'type' definition in C: an address
34
typedef byte fil_faddr_t; /* 'type' definition in C: an address
54
35
stored in a file page is a string of bytes */
55
36
#define FIL_ADDR_PAGE 0 /* first in address is the page offset */
56
37
#define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/
58
39
#define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
60
/** A struct for storing a space address FIL_ADDR, when it is used
41
/* A struct for storing a space address FIL_ADDR, when it is used
61
42
in C program data structures. */
63
44
typedef struct fil_addr_struct fil_addr_t;
64
/** File space address */
65
45
struct fil_addr_struct{
66
ulint page; /*!< page number within a space */
67
ulint boffset; /*!< byte offset within the page */
46
ulint page; /* page number within a space */
47
ulint boffset; /* byte offset within the page */
70
/** The null file address */
50
/* Null file address */
71
51
extern fil_addr_t fil_addr_null;
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
53
/* The byte offsets on a file page for various variables */
54
#define FIL_PAGE_SPACE_OR_CHKSUM 0 /* in < MySQL-4.0.14 space id the
75
55
page belongs to (== 0) but in later
76
56
versions the 'new' checksum of the
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
86
#define FIL_PAGE_NEXT 12 /*!< if there is a 'natural' successor
58
#define FIL_PAGE_OFFSET 4 /* page offset inside space */
59
#define FIL_PAGE_PREV 8 /* if there is a 'natural' predecessor
60
of the page, its offset.
62
This field is not set on BLOB pages,
63
which are stored as a singly-linked
64
list. See also FIL_PAGE_NEXT. */
65
#define FIL_PAGE_NEXT 12 /* if there is a 'natural' successor
87
66
of the page, its offset.
88
67
Otherwise FIL_NULL.
110
89
MySQL/InnoDB 5.1.7 or later, the
111
90
contents of this field is valid
112
91
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
92
#define FIL_PAGE_FILE_FLUSH_LSN 26 /* this is only defined for the
93
first page in a data file: the file
94
has been flushed to disk at least up
96
#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34 /* starting from 4.1.x this
119
97
contains the space id of the page */
120
#define FIL_PAGE_DATA 38 /*!< start of the data on the page */
122
/** File page trailer @{ */
123
#define FIL_PAGE_END_LSN_OLD_CHKSUM 8 /*!< the low 4 bytes of this are used
98
#define FIL_PAGE_DATA 38 /* start of the data on the page */
100
/* File page trailer */
101
#define FIL_PAGE_END_LSN_OLD_CHKSUM 8 /* the low 4 bytes of this are used
124
102
to store the page checksum, the
125
103
last 4 bytes should be identical
126
104
to the last 4 bytes of FIL_PAGE_LSN */
127
#define FIL_PAGE_DATA_END 8 /*!< size of the page trailer */
105
#define FIL_PAGE_DATA_END 8
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 */
107
/* File page types (values of FIL_PAGE_TYPE) */
108
#define FIL_PAGE_INDEX 17855 /* B-tree node */
109
#define FIL_PAGE_UNDO_LOG 2 /* Undo log page */
110
#define FIL_PAGE_INODE 3 /* Index node */
111
#define FIL_PAGE_IBUF_FREE_LIST 4 /* Insert buffer free list */
135
112
/* 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 */
147
/** Space types @{ */
148
#define FIL_TABLESPACE 501 /*!< tablespace */
149
#define FIL_LOG 502 /*!< redo log */
152
/** The number of fsyncs done to the log */
113
#define FIL_PAGE_TYPE_ALLOCATED 0 /* Freshly allocated page */
114
#define FIL_PAGE_IBUF_BITMAP 5 /* Insert buffer bitmap */
115
#define FIL_PAGE_TYPE_SYS 6 /* System page */
116
#define FIL_PAGE_TYPE_TRX_SYS 7 /* Transaction system data */
117
#define FIL_PAGE_TYPE_FSP_HDR 8 /* File space header */
118
#define FIL_PAGE_TYPE_XDES 9 /* Extent descriptor page */
119
#define FIL_PAGE_TYPE_BLOB 10 /* Uncompressed BLOB page */
120
#define FIL_PAGE_TYPE_ZBLOB 11 /* First compressed BLOB page */
121
#define FIL_PAGE_TYPE_ZBLOB2 12 /* Subsequent compressed BLOB page */
124
#define FIL_TABLESPACE 501
153
127
extern ulint fil_n_log_flushes;
155
/** Number of pending redo log flushes */
156
129
extern ulint fil_n_pending_log_flushes;
157
/** Number of pending tablespace flushes */
158
130
extern ulint fil_n_pending_tablespace_flushes;
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
133
/***********************************************************************
134
Returns the version number of a tablespace, -1 if not found. */
168
137
fil_space_get_version(
169
138
/*==================*/
170
ulint id); /*!< in: space id */
171
/*******************************************************************//**
172
Returns the latch of a file space.
173
@return latch protecting storage allocation */
139
/* out: version number, -1 if the tablespace does not
140
exist in the memory cache */
141
ulint id); /* in: space id */
142
/***********************************************************************
143
Returns the latch of a file space. */
176
146
fil_space_get_latch(
177
147
/*================*/
178
ulint id, /*!< in: space id */
179
ulint* zip_size);/*!< out: compressed page size, or
148
/* out: latch protecting storage allocation */
149
ulint id, /* in: space id */
150
ulint* zip_size);/* out: compressed page size, or
180
151
0 for uncompressed tablespaces */
181
/*******************************************************************//**
182
Returns the type of a file space.
183
@return FIL_TABLESPACE or FIL_LOG */
152
/***********************************************************************
153
Returns the type of a file space. */
186
156
fil_space_get_type(
187
157
/*===============*/
188
ulint id); /*!< in: space id */
189
#endif /* !UNIV_HOTBACKUP */
190
/*******************************************************************//**
158
/* out: FIL_TABLESPACE or FIL_LOG */
159
ulint id); /* in: space id */
160
/***********************************************************************
161
Returns the ibuf data of a file space. */
164
fil_space_get_ibuf_data(
165
/*====================*/
166
/* out: ibuf data for this space */
167
ulint id); /* in: space id */
168
/***********************************************************************
191
169
Appends a new file to the chain of files of a space. File must be closed. */
196
const char* name, /*!< in: file name (file must be closed) */
197
ulint size, /*!< in: file size in database blocks, rounded
174
const char* name, /* in: file name (file must be closed) */
175
ulint size, /* in: file size in database blocks, rounded
198
176
downwards to an integer */
199
ulint id, /*!< in: space id where to append */
200
ibool is_raw);/*!< in: TRUE if a raw device or
177
ulint id, /* in: space id where to append */
178
ibool is_raw);/* in: TRUE if a raw device or
201
179
a raw disk partition */
202
180
#ifdef UNIV_LOG_ARCHIVE
203
/****************************************************************//**
181
/********************************************************************
204
182
Drops files from the start of a file space, so that its size is cut by
205
183
the amount given. */
208
186
fil_space_truncate_start(
209
187
/*=====================*/
210
ulint id, /*!< in: space id */
211
ulint trunc_len); /*!< in: truncate by this much; it is an error
188
ulint id, /* in: space id */
189
ulint trunc_len); /* in: truncate by this much; it is an error
212
190
if this does not equal to the combined size of
213
191
some initial files in the space */
214
192
#endif /* UNIV_LOG_ARCHIVE */
215
/*******************************************************************//**
193
/***********************************************************************
216
194
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 */
195
there is an error, prints an error message to the .err log. */
221
198
fil_space_create(
222
199
/*=============*/
223
const char* name, /*!< in: space name */
224
ulint id, /*!< in: space id */
225
ulint zip_size,/*!< in: compressed page size, or
200
/* out: TRUE if success */
201
const char* name, /* in: space name */
202
ulint id, /* in: space id */
203
ulint zip_size,/* in: compressed page size, or
226
204
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
232
@return TRUE if assigned, FALSE if not */
205
ulint purpose);/* in: FIL_TABLESPACE, or FIL_LOG if log */
206
/***********************************************************************
207
Frees a space object from a the tablespace memory cache. Closes the files in
208
the chain but does not delete them. */
235
fil_assign_new_space_id(
236
/*====================*/
237
ulint* space_id); /*!< in/out: space id */
238
/*******************************************************************//**
213
/* out: TRUE if success */
214
ulint id); /* in: space id */
215
/***********************************************************************
239
216
Returns the size of the space in pages. The tablespace must be cached in the
241
@return space size, 0 if space not found */
244
220
fil_space_get_size(
245
221
/*===============*/
246
ulint id); /*!< in: space id */
247
/*******************************************************************//**
222
/* out: space size, 0 if space not found */
223
ulint id); /* in: space id */
224
/***********************************************************************
248
225
Returns the flags of the space. The tablespace must be cached
250
@return flags, ULINT_UNDEFINED if space not found */
226
in the memory cache. */
253
229
fil_space_get_flags(
254
230
/*================*/
255
ulint id); /*!< in: space id */
256
/*******************************************************************//**
231
/* out: flags, ULINT_UNDEFINED if space not found */
232
ulint id); /* in: space id */
233
/***********************************************************************
257
234
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 */
235
is not compressed. The tablespace must be cached in the memory cache. */
262
238
fil_space_get_zip_size(
263
239
/*===================*/
264
ulint id); /*!< in: space id */
265
/*******************************************************************//**
240
/* out: compressed page size, ULINT_UNDEFINED
241
if space not found */
242
ulint id); /* in: space id */
243
/***********************************************************************
266
244
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 */
245
file space. The tablespace must be cached in the memory cache. */
271
248
fil_check_adress_in_tablespace(
272
249
/*===========================*/
273
ulint id, /*!< in: space id */
274
ulint page_no);/*!< in: page number */
275
/****************************************************************//**
250
/* out: TRUE if the address is meaningful */
251
ulint id, /* in: space id */
252
ulint page_no);/* in: page number */
253
/********************************************************************
276
254
Initializes the tablespace memory cache. */
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. */
289
/*******************************************************************//**
259
ulint max_n_open); /* in: max number of open files */
260
/***********************************************************************
290
261
Opens all log files and system tablespace data files. They stay open until the
291
262
database server shutdown. This should be called at a server startup after the
292
263
space objects for the log and the system tablespace have been created. The
297
268
fil_open_log_and_system_tablespace_files(void);
298
269
/*==========================================*/
299
/*******************************************************************//**
270
/***********************************************************************
300
271
Closes all open files. There must not be any pending i/o's or not flushed
301
272
modifications in the files. */
304
275
fil_close_all_files(void);
305
276
/*=====================*/
306
/*******************************************************************//**
277
/***********************************************************************
307
278
Sets the max tablespace id counter if the given number is bigger than the
308
279
previous value. */
311
282
fil_set_max_space_id_if_bigger(
312
283
/*===========================*/
313
ulint max_id);/*!< in: maximum known id */
314
#ifndef UNIV_HOTBACKUP
315
/****************************************************************//**
284
ulint max_id);/* in: maximum known id */
285
/********************************************************************
286
Initializes the ibuf data structure for space 0 == the system tablespace.
287
This can be called after the file space headers have been created and the
288
dictionary system has been initialized. */
291
fil_ibuf_init_at_db_start(void);
292
/*===========================*/
293
/********************************************************************
316
294
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 */
295
header of the first page of each data file in the system tablespace. */
321
298
fil_write_flushed_lsn_to_data_files(
322
299
/*================================*/
323
ib_uint64_t lsn, /*!< in: lsn to write */
324
ulint arch_log_no); /*!< in: latest archived log
300
/* out: DB_SUCCESS or error number */
301
ib_uint64_t lsn, /* in: lsn to write */
302
ulint arch_log_no); /* in: latest archived log
326
/*******************************************************************//**
304
/***********************************************************************
327
305
Reads the flushed lsn and arch no fields from a data file at database
331
309
fil_read_flushed_lsn_and_arch_log_no(
332
310
/*=================================*/
333
os_file_t data_file, /*!< in: open data file */
334
ibool one_read_already, /*!< in: TRUE if min and max
311
os_file_t data_file, /* in: open data file */
312
ibool one_read_already, /* in: TRUE if min and max
335
313
parameters below already
336
314
contain sensible data */
337
315
#ifdef UNIV_LOG_ARCHIVE
338
ulint* min_arch_log_no, /*!< in/out: */
339
ulint* max_arch_log_no, /*!< in/out: */
316
ulint* min_arch_log_no, /* in/out: */
317
ulint* max_arch_log_no, /* in/out: */
340
318
#endif /* UNIV_LOG_ARCHIVE */
341
ib_uint64_t* min_flushed_lsn, /*!< in/out: */
342
ib_uint64_t* max_flushed_lsn); /*!< in/out: */
343
/*******************************************************************//**
319
ib_uint64_t* min_flushed_lsn, /* in/out: */
320
ib_uint64_t* max_flushed_lsn); /* in/out: */
321
/***********************************************************************
344
322
Increments the count of pending insert buffer page merges, if space is not
346
@return TRUE if being deleted, and ibuf merges should be skipped */
349
326
fil_inc_pending_ibuf_merges(
350
327
/*========================*/
351
ulint id); /*!< in: space id */
352
/*******************************************************************//**
328
/* out: TRUE if being deleted, and ibuf merges should
330
ulint id); /* in: space id */
331
/***********************************************************************
353
332
Decrements the count of pending insert buffer page merges. */
356
335
fil_decr_pending_ibuf_merges(
357
336
/*=========================*/
358
ulint id); /*!< in: space id */
359
#endif /* !UNIV_HOTBACKUP */
360
/*******************************************************************//**
337
ulint id); /* in: space id */
338
/***********************************************************************
361
339
Parses the body of a log record written about an .ibd file operation. That is,
362
340
the log record part after the standard (type, space id, page no) header of the
368
346
created does not exist, then we create the directory, too.
370
348
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 */
349
datadir that we should use in replaying the file operations. */
376
352
fil_op_log_parse_or_replay(
377
353
/*=======================*/
378
byte* ptr, /*!< in: buffer containing the log record body,
354
/* out: end of log record, or NULL if the
355
record was not completely contained between
357
byte* ptr, /* in: buffer containing the log record body,
379
358
or an initial segment of it, if the record does
380
359
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
360
byte* end_ptr, /* in: buffer end */
361
ulint type, /* in: the type of this log record */
362
ulint space_id); /* in: the space id of the tablespace in
384
363
question, or 0 if the log record should
385
364
only be parsed but not replayed */
386
ulint log_flags); /*!< in: redo log flags
387
(stored in the page number parameter) */
388
/*******************************************************************//**
365
/***********************************************************************
389
366
Deletes a single-table tablespace. The tablespace must be cached in the
391
@return TRUE if success */
394
370
fil_delete_tablespace(
395
371
/*==================*/
396
ulint id); /*!< in: space id */
397
#ifndef UNIV_HOTBACKUP
398
/*******************************************************************//**
372
/* out: TRUE if success */
373
ulint id); /* in: space id */
374
/***********************************************************************
399
375
Discards a single-table tablespace. The tablespace must be cached in the
400
376
memory cache. Discarding is like deleting a tablespace, but
401
377
1) we do not drop the table from the data dictionary;
402
378
2) we remove all insert buffer entries for the tablespace immediately; in DROP
403
379
TABLE they are only removed gradually in the background;
404
380
3) when the user does IMPORT TABLESPACE, the tablespace will have the same id
405
as it originally had.
406
@return TRUE if success */
381
as it originally had. */
409
384
fil_discard_tablespace(
410
385
/*===================*/
411
ulint id); /*!< in: space id */
412
#endif /* !UNIV_HOTBACKUP */
413
/*******************************************************************//**
386
/* out: TRUE if success */
387
ulint id); /* in: space id */
388
/***********************************************************************
414
389
Renames a single-table tablespace. The tablespace must be cached in the
415
tablespace memory cache.
416
@return TRUE if success */
390
tablespace memory cache. */
419
393
fil_rename_tablespace(
420
394
/*==================*/
421
const char* old_name, /*!< in: old table name in the standard
395
/* out: TRUE if success */
396
const char* old_name, /* in: old table name in the standard
422
397
databasename/tablename format of
423
398
InnoDB, or NULL if we do the rename
424
399
based on the space id only */
425
ulint id, /*!< in: space id */
426
const char* new_name); /*!< in: new table name in the standard
400
ulint id, /* in: space id */
401
const char* new_name); /* in: new table name in the standard
427
402
databasename/tablename format
430
/*******************************************************************//**
405
/***********************************************************************
431
406
Creates a new single-table tablespace to a database directory of MySQL.
432
407
Database directories are under the 'datadir' of MySQL. The datadir is the
433
408
directory of a running mysqld program. We can refer to it by simply the
434
409
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 */
410
dir of the mysqld server. */
439
413
fil_create_new_single_table_tablespace(
440
414
/*===================================*/
441
ulint space_id, /*!< in: space id */
442
const char* tablename, /*!< in: the table name in the usual
415
/* out: DB_SUCCESS or error code */
416
ulint* space_id, /* in/out: space id; if this is != 0,
417
then this is an input parameter,
419
const char* tablename, /* in: the table name in the usual
443
420
databasename/tablename format
444
421
of InnoDB, or a dir path to a temp
446
ibool is_temp, /*!< in: TRUE if a table created with
423
ibool is_temp, /* in: TRUE if a table created with
447
424
CREATE TEMPORARY TABLE */
448
ulint flags, /*!< in: tablespace flags */
449
ulint size); /*!< in: the initial size of the
425
ulint flags, /* in: tablespace flags */
426
ulint size); /* in: the initial size of the
450
427
tablespace file in pages,
451
428
must be >= FIL_IBD_FILE_INITIAL_SIZE */
452
#ifndef UNIV_HOTBACKUP
453
/********************************************************************//**
429
/************************************************************************
454
430
Tries to open a single-table tablespace and optionally checks the space id is
455
431
right in it. If does not succeed, prints an error message to the .err log. This
456
432
function is used to open a tablespace when we start up mysqld, and also in
483
459
after it performed these cleanup operations on the .ibd file, so that it at
484
460
the shutdown stamped the latest lsn to the FIL_PAGE_FILE_FLUSH_LSN in the
485
461
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 */
462
lsn's just by looking at that flush lsn. */
490
465
fil_reset_too_high_lsns(
491
466
/*====================*/
492
const char* name, /*!< in: table name in the
467
/* out: TRUE if success */
468
const char* name, /* in: table name in the
493
469
databasename/tablename format */
494
ib_uint64_t current_lsn); /*!< in: reset lsn's if the lsn stamped
470
ib_uint64_t current_lsn); /* in: reset lsn's if the lsn stamped
495
471
to FIL_PAGE_FILE_FLUSH_LSN in the
496
472
first page is too high */
497
#endif /* !UNIV_HOTBACKUP */
498
/********************************************************************//**
473
/************************************************************************
499
474
At the server startup, if we need crash recovery, scans the database
500
475
directories under the MySQL datadir, looking for .ibd files. Those files are
501
476
single-table tablespaces. We need to know the space id in each of them so that
502
477
we know into which file we should look to check the contents of a page stored
503
478
in the doublewrite buffer, also to know where to apply log records where the
505
@return DB_SUCCESS or error number */
508
482
fil_load_single_table_tablespaces(void);
509
483
/*===================================*/
510
/*******************************************************************//**
484
/* out: DB_SUCCESS or error number */
485
/************************************************************************
486
If we need crash recovery, and we have called
487
fil_load_single_table_tablespaces() and dict_load_single_table_tablespaces(),
488
we can call this function to print an error message of orphaned .ibd files
489
for which there is not a data dictionary entry with a matching table name
493
fil_print_orphaned_tablespaces(void);
494
/*================================*/
495
/***********************************************************************
511
496
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 */
497
or is being deleted there. */
516
500
fil_tablespace_deleted_or_being_deleted_in_mem(
517
501
/*===========================================*/
518
ulint id, /*!< in: space id */
519
ib_int64_t version);/*!< in: tablespace_version should be this; if
502
/* out: TRUE if does not exist or is being\
504
ulint id, /* in: space id */
505
ib_int64_t version);/* in: tablespace_version should be this; if
520
506
you pass -1 as the value of this, then this
521
507
parameter is ignored */
522
/*******************************************************************//**
523
Returns TRUE if a single-table tablespace exists in the memory cache.
524
@return TRUE if exists */
508
/***********************************************************************
509
Returns TRUE if a single-table tablespace exists in the memory cache. */
527
512
fil_tablespace_exists_in_mem(
528
513
/*=========================*/
529
ulint id); /*!< in: space id */
530
#ifndef UNIV_HOTBACKUP
531
/*******************************************************************//**
514
/* out: TRUE if exists */
515
ulint id); /* in: space id */
516
/***********************************************************************
532
517
Returns TRUE if a matching tablespace exists in the InnoDB tablespace memory
533
518
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 */
519
there may be many tablespaces which are not yet in the memory cache. */
538
522
fil_space_for_table_exists_in_mem(
539
523
/*==============================*/
540
ulint id, /*!< in: space id */
541
const char* name, /*!< in: table name in the standard
524
/* out: TRUE if a matching tablespace
525
exists in the memory cache */
526
ulint id, /* in: space id */
527
const char* name, /* in: table name in the standard
542
528
'databasename/tablename' format or
543
529
the dir path to a temp table */
544
ibool is_temp, /*!< in: TRUE if created with CREATE
530
ibool is_temp, /* in: TRUE if created with CREATE
545
531
TEMPORARY TABLE */
546
ibool mark_space, /*!< in: in crash recovery, at database
532
ibool mark_space, /* in: in crash recovery, at database
547
533
startup we mark all spaces which have
548
534
an associated table in the InnoDB
549
535
data dictionary, so that
550
536
we can print a warning about orphaned
552
538
ibool print_error_if_does_not_exist);
553
/*!< in: print detailed error
539
/* in: print detailed error
554
540
information to the .err log if a
555
541
matching tablespace is not found from
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. */
565
fil_extend_tablespaces_to_stored_len(void);
566
/*======================================*/
567
#endif /* !UNIV_HOTBACKUP */
568
/**********************************************************************//**
543
/**************************************************************************
569
544
Tries to extend a data file so that it would accommodate the number of pages
570
545
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 */
546
enough already, does nothing. */
575
549
fil_extend_space_to_desired_size(
576
550
/*=============================*/
577
ulint* actual_size, /*!< out: size of the space after extension;
551
/* out: TRUE if success */
552
ulint* actual_size, /* out: size of the space after extension;
578
553
if we ran out of disk space this may be lower
579
554
than the desired size */
580
ulint space_id, /*!< in: space id */
581
ulint size_after_extend);/*!< in: desired size in pages after the
555
ulint space_id, /* in: space id */
556
ulint size_after_extend);/* in: desired size in pages after the
582
557
extension; if the current space size is bigger
583
558
than this already, the function does nothing */
584
/*******************************************************************//**
585
Tries to reserve free extents in a file space.
586
@return TRUE if succeed */
559
#ifdef UNIV_HOTBACKUP
560
/************************************************************************
561
Extends all tablespaces to the size stored in the space header. During the
562
ibbackup --apply-log phase we extended the spaces on-demand so that log records
563
could be appllied, but that may have left spaces still too small compared to
564
the size stored in the space header. */
567
fil_extend_tablespaces_to_stored_len(void);
568
/*======================================*/
570
/***********************************************************************
571
Tries to reserve free extents in a file space. */
589
574
fil_space_reserve_free_extents(
590
575
/*===========================*/
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
/*******************************************************************//**
576
/* out: TRUE if succeed */
577
ulint id, /* in: space id */
578
ulint n_free_now, /* in: number of free extents now */
579
ulint n_to_reserve); /* in: how many one wants to reserve */
580
/***********************************************************************
595
581
Releases free extents in a file space. */
598
584
fil_space_release_free_extents(
599
585
/*===========================*/
600
ulint id, /*!< in: space id */
601
ulint n_reserved); /*!< in: how many one reserved */
602
/*******************************************************************//**
586
ulint id, /* in: space id */
587
ulint n_reserved); /* in: how many one reserved */
588
/***********************************************************************
603
589
Gets the number of reserved extents. If the database is silent, this number
604
590
should be zero. */
607
593
fil_space_get_n_reserved_extents(
608
594
/*=============================*/
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 */
595
ulint id); /* in: space id */
596
/************************************************************************
597
Reads or writes data. This operation is asynchronous (aio). */
618
ulint type, /*!< in: OS_FILE_READ or OS_FILE_WRITE,
602
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
603
if we are trying to do i/o on a tablespace
604
which does not exist */
605
ulint type, /* in: OS_FILE_READ or OS_FILE_WRITE,
619
606
ORed to OS_FILE_LOG, if a log i/o
620
607
and ORed to OS_AIO_SIMULATED_WAKE_LATER
621
608
if simulated aio and we want to post a
652
ulint segment); /*!< in: the number of the segment in the aio
639
ulint segment); /* in: the number of the segment in the aio
653
640
array to wait for */
654
/**********************************************************************//**
641
/**************************************************************************
655
642
Flushes to disk possible writes cached by the OS. If the space does not exist
656
643
or is being dropped, does not do anything. */
661
ulint space_id); /*!< in: file space id (this can be a group of
648
ulint space_id); /* in: file space id (this can be a group of
662
649
log files or a tablespace of the database) */
663
/**********************************************************************//**
650
/**************************************************************************
664
651
Flushes to disk writes in file spaces of the given type possibly cached by
668
655
fil_flush_file_spaces(
669
656
/*==================*/
670
ulint purpose); /*!< in: FIL_TABLESPACE, FIL_LOG */
671
/******************************************************************//**
672
Checks the consistency of the tablespace cache.
673
@return TRUE if ok */
657
ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */
658
/**********************************************************************
659
Checks the consistency of the tablespace cache. */
676
662
fil_validate(void);
677
663
/*==============*/
678
/********************************************************************//**
679
Returns TRUE if file address is undefined.
680
@return TRUE if undefined */
664
/* out: TRUE if ok */
665
/************************************************************************
666
Returns TRUE if file address is undefined. */
683
669
fil_addr_is_null(
684
670
/*=============*/
685
fil_addr_t addr); /*!< in: address */
686
/********************************************************************//**
687
Get the predecessor of a file page.
688
@return FIL_PAGE_PREV */
693
const byte* page); /*!< in: file page */
694
/********************************************************************//**
695
Get the successor of a file page.
696
@return FIL_PAGE_NEXT */
701
const byte* page); /*!< in: file page */
702
/*********************************************************************//**
671
/* out: TRUE if undefined */
672
fil_addr_t addr); /* in: address */
673
/************************************************************************
674
Accessor functions for a file page */
677
fil_page_get_prev(const byte* page);
679
fil_page_get_next(const byte* page);
680
/*************************************************************************
703
681
Sets the file page type. */
706
684
fil_page_set_type(
707
685
/*==============*/
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 */
686
byte* page, /* in: file page */
687
ulint type); /* in: type */
688
/*************************************************************************
689
Gets the file page type. */
716
692
fil_page_get_type(
717
693
/*==============*/
718
const byte* page); /*!< in: file page */
694
/* out: type; NOTE that if the type
695
has not been written to page, the
696
return value not defined */
697
const byte* page); /* in: file page */
720
/*******************************************************************//**
721
Returns TRUE if a single-table tablespace is being deleted.
722
@return TRUE if being deleted */
725
fil_tablespace_is_being_deleted(
726
/*============================*/
727
ulint id); /*!< in: space id */
729
700
typedef struct fil_space_struct fil_space_t;