~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/fsp0fsp.h

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#define FSP_DOWN        ((byte)112)     /* alphabetically downwards */
25
25
#define FSP_NO_DIR      ((byte)113)     /* no order */
26
26
 
27
 
/* File space extent size (one megabyte) in pages */
28
 
#define FSP_EXTENT_SIZE         (1 << (20 - UNIV_PAGE_SIZE_SHIFT))
 
27
/* File space extent size in pages */
 
28
#define FSP_EXTENT_SIZE         64
29
29
 
30
30
/* On a page of any file segment, data may be put starting from this offset: */
31
31
#define FSEG_PAGE_DATA          FIL_PAGE_DATA
41
41
 
42
42
/**************************************************************************
43
43
Initializes the file space system. */
44
 
UNIV_INTERN
 
44
 
45
45
void
46
46
fsp_init(void);
47
47
/*==========*/
48
48
/**************************************************************************
49
 
Gets the current free limit of the system tablespace.  The free limit
50
 
means the place of the first page which has never been put to the the
51
 
free list for allocation.  The space above that address is initialized
52
 
to zero.  Sets also the global variable log_fsp_current_free_limit. */
53
 
UNIV_INTERN
54
 
ulint
55
 
fsp_header_get_free_limit(void);
 
49
Gets the current free limit of a tablespace. The free limit means the
 
50
place of the first page which has never been put to the the free list
 
51
for allocation. The space above that address is initialized to zero.
 
52
Sets also the global variable log_fsp_current_free_limit. */
 
53
 
 
54
ulint
 
55
fsp_header_get_free_limit(
 
56
/*======================*/
 
57
                        /* out: free limit in megabytes */
 
58
        ulint   space); /* in: space id, must be 0 */
 
59
/**************************************************************************
 
60
Gets the size of the tablespace from the tablespace header. If we do not
 
61
have an auto-extending data file, this should be equal to the size of the
 
62
data files. If there is an auto-extending data file, this can be smaller. */
 
63
 
 
64
ulint
 
65
fsp_header_get_tablespace_size(
56
66
/*===========================*/
57
 
                        /* out: free limit in megabytes */
58
 
/**************************************************************************
59
 
Gets the size of the system tablespace from the tablespace header.  If
60
 
we do not have an auto-extending data file, this should be equal to
61
 
the size of the data files.  If there is an auto-extending data file,
62
 
this can be smaller. */
63
 
UNIV_INTERN
64
 
ulint
65
 
fsp_header_get_tablespace_size(void);
66
 
/*================================*/
67
67
                        /* out: size in pages */
 
68
        ulint   space); /* in: space id, must be 0 */
68
69
/**************************************************************************
69
70
Reads the file space size stored in the header page. */
70
 
UNIV_INTERN
 
71
 
71
72
ulint
72
73
fsp_get_size_low(
73
74
/*=============*/
75
76
        page_t* page);  /* in: header page (page 0 in the tablespace) */
76
77
/**************************************************************************
77
78
Reads the space id from the first page of a tablespace. */
78
 
UNIV_INTERN
 
79
 
79
80
ulint
80
81
fsp_header_get_space_id(
81
82
/*====================*/
82
 
                                /* out: space id, ULINT UNDEFINED if error */
83
 
        const page_t*   page);  /* in: first page of a tablespace */
84
 
/**************************************************************************
85
 
Reads the space flags from the first page of a tablespace. */
86
 
UNIV_INTERN
87
 
ulint
88
 
fsp_header_get_flags(
89
 
/*=================*/
90
 
                                /* out: flags */
91
 
        const page_t*   page);  /* in: first page of a tablespace */
92
 
/**************************************************************************
93
 
Reads the compressed page size from the first page of a tablespace. */
94
 
UNIV_INTERN
95
 
ulint
96
 
fsp_header_get_zip_size(
97
 
/*====================*/
98
 
                                /* out: compressed page size in bytes,
99
 
                                or 0 if uncompressed */
100
 
        const page_t*   page);  /* in: first page of a tablespace */
101
 
/**************************************************************************
102
 
Writes the space id and compressed page size to a tablespace header.
103
 
This function is used past the buffer pool when we in fil0fil.c create
104
 
a new single-table tablespace. */
105
 
UNIV_INTERN
 
83
                        /* out: space id, ULINT UNDEFINED if error */
 
84
        page_t* page);   /* in: first page of a tablespace */
 
85
/**************************************************************************
 
86
Writes the space id to a tablespace header. This function is used past the
 
87
buffer pool when we in fil0fil.c create a new single-table tablespace. */
 
88
 
106
89
void
107
 
fsp_header_init_fields(
108
 
/*===================*/
109
 
        page_t* page,           /* in/out: first page in the space */
110
 
        ulint   space_id,       /* in: space id */
111
 
        ulint   flags);         /* in: tablespace flags (FSP_SPACE_FLAGS):
112
 
                                0, or table->flags if newer than COMPACT */
 
90
fsp_header_write_space_id(
 
91
/*======================*/
 
92
        page_t* page,           /* in: first page in the space */
 
93
        ulint   space_id);      /* in: space id */
113
94
/**************************************************************************
114
95
Initializes the space header of a new created space and creates also the
115
96
insert buffer tree root if space == 0. */
116
 
UNIV_INTERN
 
97
 
117
98
void
118
99
fsp_header_init(
119
100
/*============*/
120
 
        ulint   space,          /* in: space id */
121
 
        ulint   size,           /* in: current size in blocks */
122
 
        mtr_t*  mtr);           /* in: mini-transaction handle */
 
101
        ulint   space,  /* in: space id */
 
102
        ulint   size,   /* in: current size in blocks */
 
103
        mtr_t*  mtr);   /* in: mini-transaction handle */
123
104
/**************************************************************************
124
105
Increases the space size field of a space. */
125
 
UNIV_INTERN
 
106
 
126
107
void
127
108
fsp_header_inc_size(
128
109
/*================*/
131
112
        mtr_t*  mtr);   /* in: mini-transaction handle */
132
113
/**************************************************************************
133
114
Creates a new segment. */
134
 
UNIV_INTERN
135
 
buf_block_t*
 
115
 
 
116
page_t*
136
117
fseg_create(
137
118
/*========*/
138
 
                        /* out: the block where the segment header is placed,
 
119
                        /* out: the page where the segment header is placed,
139
120
                        x-latched, NULL if could not create segment
140
121
                        because of lack of space */
141
122
        ulint   space,  /* in: space id */
148
129
        mtr_t*  mtr);   /* in: mtr */
149
130
/**************************************************************************
150
131
Creates a new segment. */
151
 
UNIV_INTERN
152
 
buf_block_t*
 
132
 
 
133
page_t*
153
134
fseg_create_general(
154
135
/*================*/
155
 
                        /* out: the block where the segment header is placed,
 
136
                        /* out: the page where the segment header is placed,
156
137
                        x-latched, NULL if could not create segment
157
138
                        because of lack of space */
158
139
        ulint   space,  /* in: space id */
172
153
/**************************************************************************
173
154
Calculates the number of pages reserved by a segment, and how many pages are
174
155
currently used. */
175
 
UNIV_INTERN
 
156
 
176
157
ulint
177
158
fseg_n_reserved_pages(
178
159
/*==================*/
184
165
Allocates a single free page from a segment. This function implements
185
166
the intelligent allocation strategy which tries to minimize
186
167
file space fragmentation. */
187
 
UNIV_INTERN
 
168
 
188
169
ulint
189
170
fseg_alloc_free_page(
190
171
/*=================*/
202
183
Allocates a single free page from a segment. This function implements
203
184
the intelligent allocation strategy which tries to minimize file space
204
185
fragmentation. */
205
 
UNIV_INTERN
 
186
 
206
187
ulint
207
188
fseg_alloc_free_page_general(
208
189
/*=========================*/
246
227
split or merge in a B-tree. But we do not want to waste disk space if the table
247
228
only occupies < 32 pages. That is why we apply different rules in that special
248
229
case, just ensuring that there are 3 free pages available. */
249
 
UNIV_INTERN
 
230
 
250
231
ibool
251
232
fsp_reserve_free_extents(
252
233
/*=====================*/
263
244
will be able to insert new data to the database without running out the
264
245
tablespace. Only free extents are taken into account and we also subtract
265
246
the safety margin required by the above function fsp_reserve_free_extents. */
266
 
UNIV_INTERN
 
247
 
267
248
ullint
268
249
fsp_get_available_space_in_free_extents(
269
250
/*====================================*/
271
252
        ulint   space); /* in: space id */
272
253
/**************************************************************************
273
254
Frees a single page of a segment. */
274
 
UNIV_INTERN
 
255
 
275
256
void
276
257
fseg_free_page(
277
258
/*===========*/
282
263
/***********************************************************************
283
264
Frees a segment. The freeing is performed in several mini-transactions,
284
265
so that there is no danger of bufferfixing too many buffer pages. */
285
 
UNIV_INTERN
 
266
 
286
267
void
287
268
fseg_free(
288
269
/*======*/
289
270
        ulint   space,  /* in: space id */
290
 
        ulint   zip_size,/* in: compressed page size in bytes
291
 
                        or 0 for uncompressed pages */
292
271
        ulint   page_no,/* in: page number where the segment header is
293
272
                        placed */
294
273
        ulint   offset);/* in: byte offset of the segment header on that
298
277
by repeatedly calling this function in different mini-transactions.
299
278
Doing the freeing in a single mini-transaction might result in
300
279
too big a mini-transaction. */
301
 
UNIV_INTERN
 
280
 
302
281
ibool
303
282
fseg_free_step(
304
283
/*===========*/
311
290
/**************************************************************************
312
291
Frees part of a segment. Differs from fseg_free_step because this function
313
292
leaves the header page unfreed. */
314
 
UNIV_INTERN
 
293
 
315
294
ibool
316
295
fseg_free_step_not_header(
317
296
/*======================*/
327
306
fsp_descr_page(
328
307
/*===========*/
329
308
                        /* out: TRUE if a descriptor page */
330
 
        ulint   zip_size,/* in: compressed page size in bytes;
331
 
                        0 for uncompressed pages */
332
309
        ulint   page_no);/* in: page number */
333
310
/***************************************************************
334
311
Parses a redo log record of a file page init. */
335
 
UNIV_INTERN
 
312
 
336
313
byte*
337
314
fsp_parse_init_file_page(
338
315
/*=====================*/
339
 
                                /* out: end of log record or NULL */
340
 
        byte*           ptr,    /* in: buffer */
341
 
        byte*           end_ptr, /* in: buffer end */
342
 
        buf_block_t*    block); /* in: block or NULL */
 
316
                        /* out: end of log record or NULL */
 
317
        byte*   ptr,    /* in: buffer */
 
318
        byte*   end_ptr,/* in: buffer end */
 
319
        page_t* page);  /* in: page or NULL */
343
320
/***********************************************************************
344
321
Validates the file space system and its segments. */
345
 
UNIV_INTERN
 
322
 
346
323
ibool
347
324
fsp_validate(
348
325
/*=========*/
350
327
        ulint   space); /* in: space id */
351
328
/***********************************************************************
352
329
Prints info of a file space. */
353
 
UNIV_INTERN
 
330
 
354
331
void
355
332
fsp_print(
356
333
/*======*/
357
334
        ulint   space); /* in: space id */
358
335
/***********************************************************************
359
336
Validates a segment. */
360
 
UNIV_INTERN
 
337
 
361
338
ibool
362
339
fseg_validate(
363
340
/*==========*/
364
341
                                /* out: TRUE if ok */
365
342
        fseg_header_t*  header, /* in: segment header */
366
343
        mtr_t*          mtr2);  /* in: mtr */
367
 
#ifdef UNIV_BTR_PRINT
368
344
/***********************************************************************
369
345
Writes info of a segment. */
370
 
UNIV_INTERN
 
346
 
371
347
void
372
348
fseg_print(
373
349
/*=======*/
374
350
        fseg_header_t*  header, /* in: segment header */
375
351
        mtr_t*          mtr);   /* in: mtr */
376
 
#endif /* UNIV_BTR_PRINT */
377
352
 
378
353
/* Flags for fsp_reserve_free_extents */
379
354
#define FSP_NORMAL      1000000
383
358
/* Number of pages described in a single descriptor page: currently each page
384
359
description takes less than 1 byte; a descriptor page is repeated every
385
360
this many file pages */
386
 
/* #define XDES_DESCRIBED_PER_PAGE              UNIV_PAGE_SIZE */
387
 
/* This has been replaced with either UNIV_PAGE_SIZE or page_zip->size. */
 
361
#define XDES_DESCRIBED_PER_PAGE         UNIV_PAGE_SIZE
388
362
 
389
363
/* The space low address page map */
390
364
/*--------------------------------------*/