Drizzled Public API Documentation

fil0fil.h
Go to the documentation of this file.
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 /**************************************************/
26 #pragma once
27 #ifndef fil0fil_h
28 #define fil0fil_h
29 
30 #include "univ.i"
31 #include "dict0types.h"
32 #include "ut0byte.h"
33 #include "os0file.h"
34 #ifndef UNIV_HOTBACKUP
35 #include "sync0rw.h"
36 #include "ibuf0types.h"
37 #endif /* !UNIV_HOTBACKUP */
38 
42 extern const char* fil_path_to_mysql_datadir;
43 
45 #define FIL_IBD_FILE_INITIAL_SIZE 4
46 
48 #define FIL_NULL ULINT32_UNDEFINED
49 
50 /* Space address data type; this is intended to be used when
51 addresses accurate to a byte are stored in file pages. If the page part
52 of the address is FIL_NULL, the address is considered undefined. */
53 
54 typedef byte fil_faddr_t;
56 #define FIL_ADDR_PAGE 0 /* first in address is the page offset */
57 #define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/
58 
59 #define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
60 
64 typedef struct fil_addr_struct fil_addr_t;
67  ulint page;
68  ulint boffset;
69 };
70 
72 extern fil_addr_t fil_addr_null;
73 
75 #define FIL_PAGE_SPACE_OR_CHKSUM 0
79 #define FIL_PAGE_OFFSET 4
80 #define FIL_PAGE_PREV 8
87 #define FIL_PAGE_NEXT 12
97 #define FIL_PAGE_LSN 16
99 #define FIL_PAGE_TYPE 24
114 #define FIL_PAGE_FILE_FLUSH_LSN 26
119 #define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34
121 #define FIL_PAGE_DATA 38
122 /* @} */
123 
124 #define FIL_PAGE_END_LSN_OLD_CHKSUM 8
128 #define FIL_PAGE_DATA_END 8
129 /* @} */
130 
132 #define FIL_PAGE_INDEX 17855
133 #define FIL_PAGE_UNDO_LOG 2
134 #define FIL_PAGE_INODE 3
135 #define FIL_PAGE_IBUF_FREE_LIST 4
136 /* File page types introduced in MySQL/InnoDB 5.1.7 */
137 #define FIL_PAGE_TYPE_ALLOCATED 0
138 #define FIL_PAGE_IBUF_BITMAP 5
139 #define FIL_PAGE_TYPE_SYS 6
140 #define FIL_PAGE_TYPE_TRX_SYS 7
141 #define FIL_PAGE_TYPE_FSP_HDR 8
142 #define FIL_PAGE_TYPE_XDES 9
143 #define FIL_PAGE_TYPE_BLOB 10
144 #define FIL_PAGE_TYPE_ZBLOB 11
145 #define FIL_PAGE_TYPE_ZBLOB2 12
146 /* @} */
147 
149 #define FIL_TABLESPACE 501
150 #define FIL_LOG 502
151 /* @} */
152 
154 extern ulint fil_n_log_flushes;
155 
157 extern ulint fil_n_pending_log_flushes;
159 extern ulint fil_n_pending_tablespace_flushes;
160 
161 
162 #ifndef UNIV_HOTBACKUP
163 /*******************************************************************/
167 UNIV_INTERN
168 ib_int64_t
169 fil_space_get_version(
170 /*==================*/
171  ulint id);
172 /*******************************************************************/
175 UNIV_INTERN
176 rw_lock_t*
177 fil_space_get_latch(
178 /*================*/
179  ulint id,
180  ulint* zip_size);
182 /*******************************************************************/
185 UNIV_INTERN
186 ulint
187 fil_space_get_type(
188 /*===============*/
189  ulint id);
190 #endif /* !UNIV_HOTBACKUP */
191 /*******************************************************************/
193 UNIV_INTERN
194 void
195 fil_node_create(
196 /*============*/
197  const char* name,
198  ulint size,
200  ulint id,
201  ibool is_raw);
203 #ifdef UNIV_LOG_ARCHIVE
204 /****************************************************************/
207 UNIV_INTERN
208 void
209 fil_space_truncate_start(
210 /*=====================*/
211  ulint id,
212  ulint trunc_len);
215 #endif /* UNIV_LOG_ARCHIVE */
216 /*******************************************************************/
220 UNIV_INTERN
221 ibool
222 fil_space_create(
223 /*=============*/
224  const char* name,
225  ulint id,
226  ulint zip_size,
228  ulint purpose);
229 /*******************************************************************/
234 UNIV_INTERN
235 ibool
236 fil_assign_new_space_id(
237 /*====================*/
238  ulint* space_id);
239 /*******************************************************************/
243 UNIV_INTERN
244 ulint
245 fil_space_get_size(
246 /*===============*/
247  ulint id);
248 /*******************************************************************/
252 UNIV_INTERN
253 ulint
254 fil_space_get_flags(
255 /*================*/
256  ulint id);
257 /*******************************************************************/
261 UNIV_INTERN
262 ulint
263 fil_space_get_zip_size(
264 /*===================*/
265  ulint id);
266 /*******************************************************************/
270 UNIV_INTERN
271 ibool
272 fil_check_adress_in_tablespace(
273 /*===========================*/
274  ulint id,
275  ulint page_no);
276 /****************************************************************/
278 UNIV_INTERN
279 void
280 fil_init(
281 /*=====*/
282  ulint hash_size,
283  ulint max_n_open);
284 /*******************************************************************/
286 UNIV_INTERN
287 void
288 fil_close(void);
289 /*===========*/
290 /*******************************************************************/
296 UNIV_INTERN
297 void
298 fil_open_log_and_system_tablespace_files(void);
299 /*==========================================*/
300 /*******************************************************************/
303 UNIV_INTERN
304 void
305 fil_close_all_files(void);
306 /*=====================*/
307 /*******************************************************************/
310 UNIV_INTERN
311 void
312 fil_set_max_space_id_if_bigger(
313 /*===========================*/
314  ulint max_id);
315 #ifndef UNIV_HOTBACKUP
316 /****************************************************************/
320 UNIV_INTERN
321 ulint
322 fil_write_flushed_lsn_to_data_files(
323 /*================================*/
324  ib_uint64_t lsn,
325  ulint arch_log_no);
327 /*******************************************************************/
330 UNIV_INTERN
331 void
332 fil_read_flushed_lsn_and_arch_log_no(
333 /*=================================*/
334  os_file_t data_file,
335  ibool one_read_already,
338 #ifdef UNIV_LOG_ARCHIVE
339  ulint* min_arch_log_no,
340  ulint* max_arch_log_no,
341 #endif /* UNIV_LOG_ARCHIVE */
342  ib_uint64_t* min_flushed_lsn,
343  ib_uint64_t* max_flushed_lsn);
344 /*******************************************************************/
348 UNIV_INTERN
349 ibool
350 fil_inc_pending_ibuf_merges(
351 /*========================*/
352  ulint id);
353 /*******************************************************************/
355 UNIV_INTERN
356 void
357 fil_decr_pending_ibuf_merges(
358 /*=========================*/
359  ulint id);
360 #endif /* !UNIV_HOTBACKUP */
361 /*******************************************************************/
375 UNIV_INTERN
376 byte*
377 fil_op_log_parse_or_replay(
378 /*=======================*/
379  byte* ptr,
382  byte* end_ptr,
383  ulint type,
384  ulint space_id,
387  ulint log_flags);
389 /*******************************************************************/
393 UNIV_INTERN
394 ibool
395 fil_delete_tablespace(
396 /*==================*/
397  ulint id);
398 #ifndef UNIV_HOTBACKUP
399 /*******************************************************************/
408 UNIV_INTERN
409 ibool
410 fil_discard_tablespace(
411 /*===================*/
412  ulint id);
413 #endif /* !UNIV_HOTBACKUP */
414 /*******************************************************************/
418 UNIV_INTERN
419 ibool
420 fil_rename_tablespace(
421 /*==================*/
422  const char* old_name,
426  ulint id,
427  const char* new_name);
431 /*******************************************************************/
438 UNIV_INTERN
439 ulint
440 fil_create_new_single_table_tablespace(
441 /*===================================*/
442  ulint space_id,
443  const char* tablename,
447  ibool is_temp,
449  ulint flags,
450  ulint size);
453 #ifndef UNIV_HOTBACKUP
454 /********************************************************************/
464 UNIV_INTERN
465 ibool
466 fil_open_single_table_tablespace(
467 /*=============================*/
468  ibool check_space_id,
475  ulint id,
476  ulint flags,
477  const char* name);
479 /********************************************************************/
489 UNIV_INTERN
490 ibool
491 fil_reset_too_high_lsns(
492 /*====================*/
493  const char* name,
495  ib_uint64_t current_lsn);
498 #endif /* !UNIV_HOTBACKUP */
499 /********************************************************************/
507 UNIV_INTERN
508 ulint
509 fil_load_single_table_tablespaces(void);
510 /*===================================*/
511 /*******************************************************************/
515 UNIV_INTERN
516 ibool
517 fil_tablespace_deleted_or_being_deleted_in_mem(
518 /*===========================================*/
519  ulint id,
520  ib_int64_t version);
523 /*******************************************************************/
526 UNIV_INTERN
527 ibool
528 fil_tablespace_exists_in_mem(
529 /*=========================*/
530  ulint id);
531 #ifndef UNIV_HOTBACKUP
532 /*******************************************************************/
537 UNIV_INTERN
538 ibool
539 fil_space_for_table_exists_in_mem(
540 /*==============================*/
541  ulint id,
542  const char* name,
545  ibool is_temp,
547  ibool mark_space,
553  ibool print_error_if_does_not_exist);
558 #else /* !UNIV_HOTBACKUP */
559 /********************************************************************/
564 UNIV_INTERN
565 void
566 fil_extend_tablespaces_to_stored_len(void);
567 /*======================================*/
568 #endif /* !UNIV_HOTBACKUP */
569 /**********************************************************************/
574 UNIV_INTERN
575 ibool
576 fil_extend_space_to_desired_size(
577 /*=============================*/
578  ulint* actual_size,
581  ulint space_id,
582  ulint size_after_extend);
585 /*******************************************************************/
588 UNIV_INTERN
589 ibool
590 fil_space_reserve_free_extents(
591 /*===========================*/
592  ulint id,
593  ulint n_free_now,
594  ulint n_to_reserve);
595 /*******************************************************************/
597 UNIV_INTERN
598 void
599 fil_space_release_free_extents(
600 /*===========================*/
601  ulint id,
602  ulint n_reserved);
603 /*******************************************************************/
606 UNIV_INTERN
607 ulint
608 fil_space_get_n_reserved_extents(
609 /*=============================*/
610  ulint id);
611 /********************************************************************/
615 UNIV_INTERN
616 ulint
617 fil_io(
618 /*===*/
619  ulint type,
628  ibool sync,
629  ulint space_id,
630  ulint zip_size,
632  ulint block_offset,
633  ulint byte_offset,
636  ulint len,
639  void* buf,
642  void* message);
644 /********************************************************************/
646 UNIV_INTERN
647 bool
648 fil_is_exist(
649 /*=========*/
650  ulint space_id,
651  ulint block_offset);
652  /**********************************************************************/
657 UNIV_INTERN
658 void
659 fil_aio_wait(
660 /*=========*/
661  ulint segment);
663 /**********************************************************************/
666 UNIV_INTERN
667 void
668 fil_flush(
669 /*======*/
670  ulint space_id);
672 /**********************************************************************/
675 UNIV_INTERN
676 void
677 fil_flush_file_spaces(
678 /*==================*/
679  ulint purpose);
680 /******************************************************************/
683 UNIV_INTERN
684 ibool
685 fil_validate(void);
686 /*==============*/
687 /********************************************************************/
690 UNIV_INTERN
691 ibool
692 fil_addr_is_null(
693 /*=============*/
694  fil_addr_t addr);
695 /********************************************************************/
698 UNIV_INTERN
699 ulint
700 fil_page_get_prev(
701 /*==============*/
702  const byte* page);
703 /********************************************************************/
706 UNIV_INTERN
707 ulint
708 fil_page_get_next(
709 /*==============*/
710  const byte* page);
711 /*********************************************************************/
713 UNIV_INTERN
714 void
715 fil_page_set_type(
716 /*==============*/
717  byte* page,
718  ulint type);
719 /*********************************************************************/
723 UNIV_INTERN
724 ulint
725 fil_page_get_type(
726 /*==============*/
727  const byte* page);
729 /*******************************************************************/
732 UNIV_INTERN
733 ibool
734 fil_tablespace_is_being_deleted(
735 /*============================*/
736  ulint id);
738 typedef struct fil_space_struct fil_space_t;
739 
740 #endif