100
104
completes, we decrement the count and return the file node to the LRU-list if
101
105
the count drops to zero. */
103
/* When mysqld is run, the default directory "." is the mysqld datadir,
107
/** When mysqld is run, the default directory "." is the mysqld datadir,
104
108
but in the MySQL Embedded Server Library and ibbackup it is not the default
105
109
directory, and we must set the base file path explicitly */
106
110
UNIV_INTERN const char* fil_path_to_mysql_datadir = ".";
108
/* The number of fsyncs done to the log */
112
/** The number of fsyncs done to the log */
109
113
UNIV_INTERN ulint fil_n_log_flushes = 0;
115
/** Number of pending redo log flushes */
111
116
UNIV_INTERN ulint fil_n_pending_log_flushes = 0;
117
/** Number of pending tablespace flushes */
112
118
UNIV_INTERN ulint fil_n_pending_tablespace_flushes = 0;
114
/* Null file address */
120
/** The null file address */
115
121
UNIV_INTERN fil_addr_t fil_addr_null = {FIL_NULL, 0};
117
/* File node of a tablespace or the log data space */
123
/** File node of a tablespace or the log data space */
118
124
struct fil_node_struct {
119
fil_space_t* space; /* backpointer to the space where this node
125
fil_space_t* space; /*!< backpointer to the space where this node
121
char* name; /* path to the file */
122
ibool open; /* TRUE if file open */
123
os_file_t handle; /* OS handle to the file, if file open */
124
ibool is_raw_disk;/* TRUE if the 'file' is actually a raw
127
char* name; /*!< path to the file */
128
ibool open; /*!< TRUE if file open */
129
os_file_t handle; /*!< OS handle to the file, if file open */
130
ibool is_raw_disk;/*!< TRUE if the 'file' is actually a raw
125
131
device or a raw disk partition */
126
ulint size; /* size of the file in database pages, 0 if
132
ulint size; /*!< size of the file in database pages, 0 if
127
133
not known yet; the possible last incomplete
128
134
megabyte may be ignored if space == 0 */
130
/* count of pending i/o's on this file;
136
/*!< count of pending i/o's on this file;
131
137
closing of the file is not allowed if
133
139
ulint n_pending_flushes;
134
/* count of pending flushes on this file;
140
/*!< count of pending flushes on this file;
135
141
closing of the file is not allowed if
137
ib_int64_t modification_counter;/* when we write to the file we
143
ib_int64_t modification_counter;/*!< when we write to the file we
138
144
increment this by one */
139
ib_int64_t flush_counter;/* up to what modification_counter value
140
we have flushed the modifications to disk */
145
ib_int64_t flush_counter;/*!< up to what
146
modification_counter value we have
147
flushed the modifications to disk */
141
148
UT_LIST_NODE_T(fil_node_t) chain;
142
/* link field for the file chain */
149
/*!< link field for the file chain */
143
150
UT_LIST_NODE_T(fil_node_t) LRU;
144
/* link field for the LRU list */
151
/*!< link field for the LRU list */
152
ulint magic_n;/*!< FIL_NODE_MAGIC_N */
155
/** Value of fil_node_struct::magic_n */
148
156
#define FIL_NODE_MAGIC_N 89389
150
/* Tablespace or log data space: let us call them by a common name space */
158
/** Tablespace or log data space: let us call them by a common name space */
151
159
struct fil_space_struct {
152
char* name; /* space name = the path to the first file in
160
char* name; /*!< space name = the path to the first file in
154
ulint id; /* space id */
162
ulint id; /*!< space id */
155
163
ib_int64_t tablespace_version;
156
/* in DISCARD/IMPORT this timestamp is used to
157
check if we should ignore an insert buffer
158
merge request for a page because it actually
159
was for the previous incarnation of the
161
ibool mark; /* this is set to TRUE at database startup if
164
/*!< in DISCARD/IMPORT this timestamp
165
is used to check if we should ignore
166
an insert buffer merge request for a
167
page because it actually was for the
168
previous incarnation of the space */
169
ibool mark; /*!< this is set to TRUE at database startup if
162
170
the space corresponds to a table in the InnoDB
163
171
data dictionary; so we can print a warning of
164
172
orphaned tablespaces */
165
ibool stop_ios;/* TRUE if we want to rename the .ibd file of
166
tablespace and want to stop temporarily
167
posting of new i/o requests on the file */
173
ibool stop_ios;/*!< TRUE if we want to rename the
174
.ibd file of tablespace and want to
175
stop temporarily posting of new i/o
176
requests on the file */
168
177
ibool stop_ibuf_merges;
169
/* we set this TRUE when we start deleting a
170
single-table tablespace */
178
/*!< we set this TRUE when we start
179
deleting a single-table tablespace */
171
180
ibool is_being_deleted;
172
/* this is set to TRUE when we start
181
/*!< this is set to TRUE when we start
173
182
deleting a single-table tablespace and its
174
183
file; when this flag is set no further i/o
175
184
or flush requests can be placed on this space,
176
185
though there may be such requests still being
177
186
processed on this space */
178
ulint purpose;/* FIL_TABLESPACE, FIL_LOG, or FIL_ARCH_LOG */
187
ulint purpose;/*!< FIL_TABLESPACE, FIL_LOG, or
179
189
UT_LIST_BASE_NODE_T(fil_node_t) chain;
180
/* base node for the file chain */
181
ulint size; /* space size in pages; 0 if a single-table
190
/*!< base node for the file chain */
191
ulint size; /*!< space size in pages; 0 if a single-table
182
192
tablespace whose size we do not know yet;
183
193
last incomplete megabytes in data files may be
184
194
ignored if space == 0 */
185
ulint flags; /* in: compressed page size
186
and file format, or 0 */
195
ulint flags; /*!< compressed page size and file format, or 0 */
187
196
ulint n_reserved_extents;
188
/* number of reserved free extents for
197
/*!< number of reserved free extents for
189
198
ongoing operations like B-tree page split */
190
ulint n_pending_flushes; /* this is > 0 when flushing
199
ulint n_pending_flushes; /*!< this is positive when flushing
191
200
the tablespace to disk; dropping of the
192
tablespace is forbidden if this is > 0 */
193
ulint n_pending_ibuf_merges;/* this is > 0 when merging
194
insert buffer entries to a page so that we
195
may need to access the ibuf bitmap page in the
196
tablespade: dropping of the tablespace is
197
forbidden if this is > 0 */
198
hash_node_t hash; /* hash chain node */
199
hash_node_t name_hash;/* hash chain the name_hash table */
200
rw_lock_t latch; /* latch protecting the file space storage
201
tablespace is forbidden if this is positive */
202
ulint n_pending_ibuf_merges;/*!< this is positive
203
when merging insert buffer entries to
204
a page so that we may need to access
205
the ibuf bitmap page in the
206
tablespade: dropping of the tablespace
207
is forbidden if this is positive */
208
hash_node_t hash; /*!< hash chain node */
209
hash_node_t name_hash;/*!< hash chain the name_hash table */
210
#ifndef UNIV_HOTBACKUP
211
rw_lock_t latch; /*!< latch protecting the file space storage
213
#endif /* !UNIV_HOTBACKUP */
202
214
UT_LIST_NODE_T(fil_space_t) unflushed_spaces;
203
/* list of spaces with at least one unflushed
215
/*!< list of spaces with at least one unflushed
204
216
file we have written to */
205
ibool is_in_unflushed_spaces; /* TRUE if this space is
206
currently in the list above */
217
ibool is_in_unflushed_spaces; /*!< TRUE if this space is
218
currently in unflushed_spaces */
207
219
UT_LIST_NODE_T(fil_space_t) space_list;
208
/* list of all spaces */
220
/*!< list of all spaces */
221
ulint magic_n;/*!< FIL_SPACE_MAGIC_N */
224
/** Value of fil_space_struct::magic_n */
212
225
#define FIL_SPACE_MAGIC_N 89472
214
/* The tablespace memory cache; also the totality of logs = the log data space,
215
is stored here; below we talk about tablespaces, but also the ib_logfiles
216
form a 'space' and it is handled here */
227
/** The tablespace memory cache */
218
228
typedef struct fil_system_struct fil_system_t;
230
/** The tablespace memory cache; also the totality of logs (the log
231
data space) is stored here; below we talk about tablespaces, but also
232
the ib_logfiles form a 'space' and it is handled here */
219
234
struct fil_system_struct {
220
mutex_t mutex; /* The mutex protecting the cache */
221
hash_table_t* spaces; /* The hash table of spaces in the
235
#ifndef UNIV_HOTBACKUP
236
mutex_t mutex; /*!< The mutex protecting the cache */
237
#endif /* !UNIV_HOTBACKUP */
238
hash_table_t* spaces; /*!< The hash table of spaces in the
222
239
system; they are hashed on the space
224
hash_table_t* name_hash; /* hash table based on the space
241
hash_table_t* name_hash; /*!< hash table based on the space
226
243
UT_LIST_BASE_NODE_T(fil_node_t) LRU;
227
/* base node for the LRU list of the
244
/*!< base node for the LRU list of the
228
245
most recently used open files with no
229
246
pending i/o's; if we start an i/o on
230
247
the file, we first remove it from this
280
297
fil_node_prepare_for_io(
281
298
/*====================*/
282
fil_node_t* node, /* in: file node */
283
fil_system_t* system, /* in: tablespace memory cache */
284
fil_space_t* space); /* in: space */
285
/************************************************************************
299
fil_node_t* node, /*!< in: file node */
300
fil_system_t* system, /*!< in: tablespace memory cache */
301
fil_space_t* space); /*!< in: space */
302
/********************************************************************//**
286
303
Updates the data structures when an i/o operation finishes. Updates the
287
304
pending i/o's field in the node appropriately. */
290
307
fil_node_complete_io(
291
308
/*=================*/
292
fil_node_t* node, /* in: file node */
293
fil_system_t* system, /* in: tablespace memory cache */
294
ulint type); /* in: OS_FILE_WRITE or OS_FILE_READ; marks
309
fil_node_t* node, /*!< in: file node */
310
fil_system_t* system, /*!< in: tablespace memory cache */
311
ulint type); /*!< in: OS_FILE_WRITE or OS_FILE_READ; marks
295
312
the node as modified if
296
313
type == OS_FILE_WRITE */
297
/***********************************************************************
314
/*******************************************************************//**
298
315
Checks if a single-table tablespace for a given table name exists in the
299
tablespace memory cache. */
316
tablespace memory cache.
317
@return space id, ULINT_UNDEFINED if not found */
302
320
fil_get_space_id_for_table(
303
321
/*=======================*/
304
/* out: space id, ULINT_UNDEFINED if not
306
const char* name); /* in: table name in the standard
322
const char* name); /*!< in: table name in the standard
307
323
'databasename/tablename' format */
308
/************************************************************************
324
/********************************************************************//**
309
325
Reads data from a space to a buffer. Remember that the possible incomplete
310
326
blocks at the end of file are ignored: they are not taken into account when
311
calculating the byte offset within a space. */
327
calculating the byte offset within a space.
328
@return DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do
329
i/o on a tablespace which does not exist */
316
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
317
if we are trying to do i/o on a tablespace
318
which does not exist */
319
ibool sync, /* in: TRUE if synchronous aio is desired */
320
ulint space_id, /* in: space id */
321
ulint zip_size, /* in: compressed page size in bytes;
334
ibool sync, /*!< in: TRUE if synchronous aio is desired */
335
ulint space_id, /*!< in: space id */
336
ulint zip_size, /*!< in: compressed page size in bytes;
322
337
0 for uncompressed pages */
323
ulint block_offset, /* in: offset in number of blocks */
324
ulint byte_offset, /* in: remainder of offset in bytes; in aio
338
ulint block_offset, /*!< in: offset in number of blocks */
339
ulint byte_offset, /*!< in: remainder of offset in bytes; in aio
325
340
this must be divisible by the OS block size */
326
ulint len, /* in: how many bytes to read; this must not
341
ulint len, /*!< in: how many bytes to read; this must not
327
342
cross a file boundary; in aio this must be a
328
343
block size multiple */
329
void* buf, /* in/out: buffer where to store data read;
344
void* buf, /*!< in/out: buffer where to store data read;
330
345
in aio this must be appropriately aligned */
331
void* message) /* in: message for aio handler if non-sync
346
void* message) /*!< in: message for aio handler if non-sync
332
347
aio used, else ignored */
334
349
return(fil_io(OS_FILE_READ, sync, space_id, zip_size, block_offset,
335
350
byte_offset, len, buf, message));
338
/************************************************************************
353
/********************************************************************//**
339
354
Writes data to a space from a buffer. Remember that the possible incomplete
340
355
blocks at the end of file are ignored: they are not taken into account when
341
calculating the byte offset within a space. */
356
calculating the byte offset within a space.
357
@return DB_SUCCESS, or DB_TABLESPACE_DELETED if we are trying to do
358
i/o on a tablespace which does not exist */
346
/* out: DB_SUCCESS, or DB_TABLESPACE_DELETED
347
if we are trying to do i/o on a tablespace
348
which does not exist */
349
ibool sync, /* in: TRUE if synchronous aio is desired */
350
ulint space_id, /* in: space id */
351
ulint zip_size, /* in: compressed page size in bytes;
363
ibool sync, /*!< in: TRUE if synchronous aio is desired */
364
ulint space_id, /*!< in: space id */
365
ulint zip_size, /*!< in: compressed page size in bytes;
352
366
0 for uncompressed pages */
353
ulint block_offset, /* in: offset in number of blocks */
354
ulint byte_offset, /* in: remainder of offset in bytes; in aio
367
ulint block_offset, /*!< in: offset in number of blocks */
368
ulint byte_offset, /*!< in: remainder of offset in bytes; in aio
355
369
this must be divisible by the OS block size */
356
ulint len, /* in: how many bytes to write; this must
370
ulint len, /*!< in: how many bytes to write; this must
357
371
not cross a file boundary; in aio this must
358
372
be a block size multiple */
359
void* buf, /* in: buffer from which to write; in aio
373
void* buf, /*!< in: buffer from which to write; in aio
360
374
this must be appropriately aligned */
361
void* message) /* in: message for aio handler if non-sync
375
void* message) /*!< in: message for aio handler if non-sync
362
376
aio used, else ignored */
364
378
return(fil_io(OS_FILE_WRITE, sync, space_id, zip_size, block_offset,
365
379
byte_offset, len, buf, message));
368
/***********************************************************************
382
/*******************************************************************//**
369
383
Returns the table space by a given id, NULL if not found. */
372
386
fil_space_get_by_id(
373
387
/*================*/
374
ulint id) /* in: space id */
388
ulint id) /*!< in: space id */
376
390
fil_space_t* space;
795
/************************************************************************
807
/********************************************************************//**
796
808
Tries to close a file in the LRU list. The caller must hold the fil_sys
810
@return TRUE if success, FALSE if should retry later; since i/o's
811
generally complete in < 100 ms, and as InnoDB writes at most 128 pages
812
from the buffer pool in a batch, and then immediately flushes the
813
files, there is a good chance that the next time we find a suitable
814
node from the LRU list */
800
817
fil_try_to_close_file_in_LRU(
801
818
/*=========================*/
802
/* out: TRUE if success, FALSE if should retry
803
later; since i/o's generally complete in <
804
100 ms, and as InnoDB writes at most 128 pages
805
from the buffer pool in a batch, and then
806
immediately flushes the files, there is a good
807
chance that the next time we find a suitable
808
node from the LRU list */
809
ibool print_info) /* in: if TRUE, prints information why it
819
ibool print_info) /*!< in: if TRUE, prints information why it
810
820
cannot close a file */
812
fil_system_t* system = fil_system;
813
822
fil_node_t* node;
815
ut_ad(mutex_own(&(system->mutex)));
824
ut_ad(mutex_own(&fil_system->mutex));
817
node = UT_LIST_GET_LAST(system->LRU);
826
node = UT_LIST_GET_LAST(fil_system->LRU);
819
828
if (print_info) {
821
830
"InnoDB: fil_sys open file LRU len %lu\n",
822
(ulong) UT_LIST_GET_LEN(system->LRU));
831
(ulong) UT_LIST_GET_LEN(fil_system->LRU));
825
834
while (node != NULL) {
826
835
if (node->modification_counter == node->flush_counter
827
836
&& node->n_pending_flushes == 0) {
829
fil_node_close_file(node, system);
838
fil_node_close_file(node, fil_system);
1185
1191
rw_lock_create(&space->latch, SYNC_FSP);
1187
HASH_INSERT(fil_space_t, hash, system->spaces, id, space);
1193
HASH_INSERT(fil_space_t, hash, fil_system->spaces, id, space);
1189
HASH_INSERT(fil_space_t, name_hash, system->name_hash,
1195
HASH_INSERT(fil_space_t, name_hash, fil_system->name_hash,
1190
1196
ut_fold_string(name), space);
1191
1197
space->is_in_unflushed_spaces = FALSE;
1193
UT_LIST_ADD_LAST(space_list, system->space_list, space);
1199
UT_LIST_ADD_LAST(space_list, fil_system->space_list, space);
1195
mutex_exit(&(system->mutex));
1201
mutex_exit(&fil_system->mutex);
1200
/***********************************************************************
1206
/*******************************************************************//**
1201
1207
Assigns a new space id for a new single-table tablespace. This works simply by
1202
1208
incrementing the global counter. If 4 billion id's is not enough, we may need
1210
@return new tablespace id; ULINT_UNDEFINED if could not assign an id */
1206
1213
fil_assign_new_space_id(void)
1207
1214
/*=========================*/
1208
/* out: new tablespace id; ULINT_UNDEFINED if could
1211
fil_system_t* system = fil_system;
1214
mutex_enter(&(system->mutex));
1216
system->max_assigned_id++;
1218
id = system->max_assigned_id;
1218
mutex_enter(&fil_system->mutex);
1220
fil_system->max_assigned_id++;
1222
id = fil_system->max_assigned_id;
1220
1224
if (id > (SRV_LOG_SPACE_FIRST_ID / 2) && (id % 1000000UL == 0)) {
1221
1225
ut_print_timestamp(stderr);
1494
/********************************************************************
1495
Creates a the tablespace memory cache. */
1500
/* out, own: tablespace memory cache */
1501
ulint hash_size, /* in: hash table size */
1502
ulint max_n_open) /* in: maximum number of open files; must be
1505
fil_system_t* system;
1507
ut_a(hash_size > 0);
1508
ut_a(max_n_open > 0);
1510
system = mem_alloc(sizeof(fil_system_t));
1512
mutex_create(&system->mutex, SYNC_ANY_LATCH);
1514
system->spaces = hash_create(hash_size);
1515
system->name_hash = hash_create(hash_size);
1517
UT_LIST_INIT(system->LRU);
1520
system->max_n_open = max_n_open;
1522
system->modification_counter = 0;
1523
system->max_assigned_id = 0;
1525
system->tablespace_version = 0;
1527
UT_LIST_INIT(system->unflushed_spaces);
1528
UT_LIST_INIT(system->space_list);
1533
/********************************************************************
1471
/****************************************************************//**
1534
1472
Initializes the tablespace memory cache. */
1539
ulint max_n_open) /* in: max number of open files */
1477
ulint hash_size, /*!< in: hash table size */
1478
ulint max_n_open) /*!< in: max number of open files */
1543
1480
ut_a(fil_system == NULL);
1545
if (srv_file_per_table) {
1551
fil_system = fil_system_create(hash_size, max_n_open);
1482
ut_a(hash_size > 0);
1483
ut_a(max_n_open > 0);
1485
fil_system = mem_alloc(sizeof(fil_system_t));
1487
mutex_create(&fil_system->mutex, SYNC_ANY_LATCH);
1489
fil_system->spaces = hash_create(hash_size);
1490
fil_system->name_hash = hash_create(hash_size);
1492
UT_LIST_INIT(fil_system->LRU);
1494
fil_system->n_open = 0;
1495
fil_system->max_n_open = max_n_open;
1497
fil_system->modification_counter = 0;
1498
fil_system->max_assigned_id = 0;
1500
fil_system->tablespace_version = 0;
1502
UT_LIST_INIT(fil_system->unflushed_spaces);
1503
UT_LIST_INIT(fil_system->space_list);
1554
/***********************************************************************
1506
/*******************************************************************//**
1555
1507
Opens all log files and system tablespace data files. They stay open until the
1556
1508
database server shutdown. This should be called at a server startup after the
1557
1509
space objects for the log and the system tablespace have been created. The
1617
1569
fil_close_all_files(void)
1618
1570
/*=====================*/
1620
fil_system_t* system = fil_system;
1621
1572
fil_space_t* space;
1622
1573
fil_node_t* node;
1624
mutex_enter(&(system->mutex));
1575
mutex_enter(&fil_system->mutex);
1626
space = UT_LIST_GET_FIRST(system->space_list);
1577
space = UT_LIST_GET_FIRST(fil_system->space_list);
1628
1579
while (space != NULL) {
1629
1580
node = UT_LIST_GET_FIRST(space->chain);
1631
1582
while (node != NULL) {
1632
1583
if (node->open) {
1633
fil_node_close_file(node, system);
1584
fil_node_close_file(node, fil_system);
1635
1586
node = UT_LIST_GET_NEXT(chain, node);
1637
1588
space = UT_LIST_GET_NEXT(space_list, space);
1640
mutex_exit(&(system->mutex));
1591
mutex_exit(&fil_system->mutex);
1643
/***********************************************************************
1594
/*******************************************************************//**
1644
1595
Sets the max tablespace id counter if the given number is bigger than the
1645
1596
previous value. */
1648
1599
fil_set_max_space_id_if_bigger(
1649
1600
/*===========================*/
1650
ulint max_id) /* in: maximum known id */
1601
ulint max_id) /*!< in: maximum known id */
1652
fil_system_t* system = fil_system;
1654
1603
if (max_id >= SRV_LOG_SPACE_FIRST_ID) {
1655
1604
fprintf(stderr,
1656
1605
"InnoDB: Fatal error: max tablespace id"
1657
1606
" is too high, %lu\n", (ulong) max_id);
1661
mutex_enter(&(system->mutex));
1663
if (system->max_assigned_id < max_id) {
1665
system->max_assigned_id = max_id;
1668
mutex_exit(&(system->mutex));
1610
mutex_enter(&fil_system->mutex);
1612
if (fil_system->max_assigned_id < max_id) {
1614
fil_system->max_assigned_id = max_id;
1617
mutex_exit(&fil_system->mutex);
1671
/********************************************************************
1620
/****************************************************************//**
1672
1621
Writes the flushed lsn and the latest archived log number to the page header
1673
1622
of the first page of a data file of the system tablespace (space 0),
1674
1623
which is uncompressed. */
2564
2518
return(success);
2567
/***********************************************************************
2521
/*******************************************************************//**
2568
2522
Creates a new single-table tablespace to a database directory of MySQL.
2569
2523
Database directories are under the 'datadir' of MySQL. The datadir is the
2570
2524
directory of a running mysqld program. We can refer to it by simply the
2571
2525
path '.'. Tables created with CREATE TEMPORARY TABLE we place in the temp
2572
dir of the mysqld server. */
2526
dir of the mysqld server.
2527
@return DB_SUCCESS or error code */
2575
2530
fil_create_new_single_table_tablespace(
2576
2531
/*===================================*/
2577
/* out: DB_SUCCESS or error code */
2578
ulint* space_id, /* in/out: space id; if this is != 0,
2532
ulint* space_id, /*!< in/out: space id; if this is != 0,
2579
2533
then this is an input parameter,
2580
2534
otherwise output */
2581
const char* tablename, /* in: the table name in the usual
2535
const char* tablename, /*!< in: the table name in the usual
2582
2536
databasename/tablename format
2583
2537
of InnoDB, or a dir path to a temp
2585
ibool is_temp, /* in: TRUE if a table created with
2539
ibool is_temp, /*!< in: TRUE if a table created with
2586
2540
CREATE TEMPORARY TABLE */
2587
ulint flags, /* in: tablespace flags */
2588
ulint size) /* in: the initial size of the
2541
ulint flags, /*!< in: tablespace flags */
2542
ulint size) /*!< in: the initial size of the
2589
2543
tablespace file in pages,
2590
2544
must be >= FIL_IBD_FILE_INITIAL_SIZE */
3557
3512
space = UT_LIST_GET_NEXT(space_list, space);
3560
mutex_exit(&(system->mutex));
3515
mutex_exit(&fil_system->mutex);
3563
/***********************************************************************
3518
/*******************************************************************//**
3564
3519
Returns TRUE if a single-table tablespace does not exist in the memory cache,
3565
or is being deleted there. */
3520
or is being deleted there.
3521
@return TRUE if does not exist or is being\ deleted */
3568
3524
fil_tablespace_deleted_or_being_deleted_in_mem(
3569
3525
/*===========================================*/
3570
/* out: TRUE if does not exist or is being\
3572
ulint id, /* in: space id */
3573
ib_int64_t version)/* in: tablespace_version should be this; if
3526
ulint id, /*!< in: space id */
3527
ib_int64_t version)/*!< in: tablespace_version should be this; if
3574
3528
you pass -1 as the value of this, then this
3575
3529
parameter is ignored */
3577
fil_system_t* system = fil_system;
3578
3531
fil_space_t* space;
3582
mutex_enter(&(system->mutex));
3535
mutex_enter(&fil_system->mutex);
3584
3537
space = fil_space_get_by_id(id);
3586
3539
if (space == NULL || space->is_being_deleted) {
3587
mutex_exit(&(system->mutex));
3540
mutex_exit(&fil_system->mutex);
3592
3545
if (version != ((ib_int64_t)-1)
3593
3546
&& space->tablespace_version != version) {
3594
mutex_exit(&(system->mutex));
3547
mutex_exit(&fil_system->mutex);
3599
mutex_exit(&(system->mutex));
3552
mutex_exit(&fil_system->mutex);
3604
/***********************************************************************
3605
Returns TRUE if a single-table tablespace exists in the memory cache. */
3557
/*******************************************************************//**
3558
Returns TRUE if a single-table tablespace exists in the memory cache.
3559
@return TRUE if exists */
3608
3562
fil_tablespace_exists_in_mem(
3609
3563
/*=========================*/
3610
/* out: TRUE if exists */
3611
ulint id) /* in: space id */
3564
ulint id) /*!< in: space id */
3613
fil_system_t* system = fil_system;
3614
3566
fil_space_t* space;
3618
mutex_enter(&(system->mutex));
3570
mutex_enter(&fil_system->mutex);
3620
3572
space = fil_space_get_by_id(id);
3622
if (space == NULL) {
3623
mutex_exit(&(system->mutex));
3628
mutex_exit(&(system->mutex));
3574
mutex_exit(&fil_system->mutex);
3576
return(space != NULL);
3633
/***********************************************************************
3579
/*******************************************************************//**
3634
3580
Returns TRUE if a matching tablespace exists in the InnoDB tablespace memory
3635
3581
cache. Note that if we have not done a crash recovery at the database startup,
3636
there may be many tablespaces which are not yet in the memory cache. */
3582
there may be many tablespaces which are not yet in the memory cache.
3583
@return TRUE if a matching tablespace exists in the memory cache */
3639
3586
fil_space_for_table_exists_in_mem(
3640
3587
/*==============================*/
3641
/* out: TRUE if a matching tablespace
3642
exists in the memory cache */
3643
ulint id, /* in: space id */
3644
const char* name, /* in: table name in the standard
3588
ulint id, /*!< in: space id */
3589
const char* name, /*!< in: table name in the standard
3645
3590
'databasename/tablename' format or
3646
3591
the dir path to a temp table */
3647
ibool is_temp, /* in: TRUE if created with CREATE
3592
ibool is_temp, /*!< in: TRUE if created with CREATE
3648
3593
TEMPORARY TABLE */
3649
ibool mark_space, /* in: in crash recovery, at database
3594
ibool mark_space, /*!< in: in crash recovery, at database
3650
3595
startup we mark all spaces which have
3651
3596
an associated table in the InnoDB
3652
3597
data dictionary, so that
3653
3598
we can print a warning about orphaned
3655
3600
ibool print_error_if_does_not_exist)
3656
/* in: print detailed error
3601
/*!< in: print detailed error
3657
3602
information to the .err log if a
3658
3603
matching tablespace is not found from
3661
fil_system_t* system = fil_system;
3662
3606
fil_space_t* namespace;
3663
3607
fil_space_t* space;
3668
mutex_enter(&(system->mutex));
3612
mutex_enter(&fil_system->mutex);
3670
3614
path = fil_make_ibd_name(name, is_temp);
4726
4666
fil_node = UT_LIST_GET_NEXT(LRU, fil_node);
4729
mutex_exit(&(system->mutex));
4669
mutex_exit(&fil_system->mutex);
4734
/************************************************************************
4735
Returns TRUE if file address is undefined. */
4674
/********************************************************************//**
4675
Returns TRUE if file address is undefined.
4676
@return TRUE if undefined */
4738
4679
fil_addr_is_null(
4739
4680
/*=============*/
4740
/* out: TRUE if undefined */
4741
fil_addr_t addr) /* in: address */
4681
fil_addr_t addr) /*!< in: address */
4743
4683
return(addr.page == FIL_NULL);
4746
/************************************************************************
4747
Accessor functions for a file page */
4686
/********************************************************************//**
4687
Get the predecessor of a file page.
4688
@return FIL_PAGE_PREV */
4750
fil_page_get_prev(const byte* page)
4693
const byte* page) /*!< in: file page */
4752
4695
return(mach_read_from_4(page + FIL_PAGE_PREV));
4698
/********************************************************************//**
4699
Get the successor of a file page.
4700
@return FIL_PAGE_NEXT */
4757
fil_page_get_next(const byte* page)
4705
const byte* page) /*!< in: file page */
4759
4707
return(mach_read_from_4(page + FIL_PAGE_NEXT));
4762
/*************************************************************************
4710
/*********************************************************************//**
4763
4711
Sets the file page type. */
4766
4714
fil_page_set_type(
4767
4715
/*==============*/
4768
byte* page, /* in: file page */
4769
ulint type) /* in: type */
4716
byte* page, /*!< in/out: file page */
4717
ulint type) /*!< in: type */
4773
4721
mach_write_to_2(page + FIL_PAGE_TYPE, type);
4776
/*************************************************************************
4777
Gets the file page type. */
4724
/*********************************************************************//**
4725
Gets the file page type.
4726
@return type; NOTE that if the type has not been written to page, the
4727
return value not defined */
4780
4730
fil_page_get_type(
4781
4731
/*==============*/
4782
/* out: type; NOTE that if the type
4783
has not been written to page, the return value
4785
const byte* page) /* in: file page */
4732
const byte* page) /*!< in: file page */