MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fil0fil.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1995, 2013, Oracle and/or its affiliates. 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.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #ifndef fil0fil_h
27 #define fil0fil_h
28 
29 #include "univ.i"
30 
31 #ifndef UNIV_INNOCHECKSUM
32 
33 #include "dict0types.h"
34 #include "ut0byte.h"
35 #include "os0file.h"
36 #ifndef UNIV_HOTBACKUP
37 #include "sync0rw.h"
38 #include "ibuf0types.h"
39 #include "log0log.h"
40 #endif /* !UNIV_HOTBACKUP */
41 
42 #include <list>
43 
44 // Forward declaration
45 struct trx_t;
46 struct fil_space_t;
47 
48 typedef std::list<const char*> space_name_list_t;
49 
53 extern const char* fil_path_to_mysql_datadir;
54 
56 #define FIL_IBD_FILE_INITIAL_SIZE 4
57 
59 #define FIL_NULL ULINT32_UNDEFINED
60 
61 /* Space address data type; this is intended to be used when
62 addresses accurate to a byte are stored in file pages. If the page part
63 of the address is FIL_NULL, the address is considered undefined. */
64 
65 typedef byte fil_faddr_t;
67 #define FIL_ADDR_PAGE 0 /* first in address is the page offset */
68 #define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/
69 
70 #define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
71 
73 struct fil_addr_t{
74  ulint page;
75  ulint boffset;
76 };
77 
80 
81 #endif /* !UNIV_INNOCHECKSUM */
82 
84 #define FIL_PAGE_SPACE_OR_CHKSUM 0
88 #define FIL_PAGE_OFFSET 4
89 #define FIL_PAGE_PREV 8
96 #define FIL_PAGE_NEXT 12
106 #define FIL_PAGE_LSN 16
108 #define FIL_PAGE_TYPE 24
123 #define FIL_PAGE_FILE_FLUSH_LSN 26
128 #define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34
130 #define FIL_PAGE_DATA 38
131 /* @} */
132 
133 #define FIL_PAGE_END_LSN_OLD_CHKSUM 8
137 #define FIL_PAGE_DATA_END 8
138 /* @} */
139 
140 #ifndef UNIV_INNOCHECKSUM
141 
143 #define FIL_PAGE_INDEX 17855
144 #define FIL_PAGE_UNDO_LOG 2
145 #define FIL_PAGE_INODE 3
146 #define FIL_PAGE_IBUF_FREE_LIST 4
147 /* File page types introduced in MySQL/InnoDB 5.1.7 */
148 #define FIL_PAGE_TYPE_ALLOCATED 0
149 #define FIL_PAGE_IBUF_BITMAP 5
150 #define FIL_PAGE_TYPE_SYS 6
151 #define FIL_PAGE_TYPE_TRX_SYS 7
152 #define FIL_PAGE_TYPE_FSP_HDR 8
153 #define FIL_PAGE_TYPE_XDES 9
154 #define FIL_PAGE_TYPE_BLOB 10
155 #define FIL_PAGE_TYPE_ZBLOB 11
156 #define FIL_PAGE_TYPE_ZBLOB2 12
157 #define FIL_PAGE_TYPE_LAST FIL_PAGE_TYPE_ZBLOB2
158 
159 /* @} */
160 
162 #define FIL_TABLESPACE 501
163 #define FIL_LOG 502
164 /* @} */
165 
167 extern ulint fil_n_log_flushes;
168 
170 extern ulint fil_n_pending_log_flushes;
173 
175 extern ulint fil_n_file_opened;
176 
177 #ifndef UNIV_HOTBACKUP
178 /*******************************************************************/
182 UNIV_INTERN
183 ib_int64_t
185 /*==================*/
186  ulint id);
187 /*******************************************************************/
190 UNIV_INTERN
191 rw_lock_t*
193 /*================*/
194  ulint id,
195  ulint* zip_size);
197 /*******************************************************************/
200 UNIV_INTERN
201 ulint
203 /*===============*/
204  ulint id);
205 #endif /* !UNIV_HOTBACKUP */
206 /*******************************************************************/
209 UNIV_INTERN
210 char*
212 /*============*/
213  const char* name,
214  ulint size,
216  ulint id,
217  ibool is_raw)
219  __attribute__((nonnull, warn_unused_result));
220 #ifdef UNIV_LOG_ARCHIVE
221 /****************************************************************/
224 UNIV_INTERN
225 void
226 fil_space_truncate_start(
227 /*=====================*/
228  ulint id,
229  ulint trunc_len);
232 #endif /* UNIV_LOG_ARCHIVE */
233 /*******************************************************************/
237 UNIV_INTERN
238 ibool
240 /*=============*/
241  const char* name,
242  ulint id,
243  ulint zip_size,
245  ulint purpose);
246 /*******************************************************************/
251 UNIV_INTERN
252 ibool
254 /*====================*/
255  ulint* space_id);
256 /*******************************************************************/
261 UNIV_INTERN
262 char*
264 /*=====================*/
265  ulint id);
266 /*******************************************************************/
270 UNIV_INTERN
271 ulint
273 /*===============*/
274  ulint id);
275 /*******************************************************************/
279 UNIV_INTERN
280 ulint
282 /*================*/
283  ulint id);
284 /*******************************************************************/
288 UNIV_INTERN
289 ulint
291 /*===================*/
292  ulint id);
293 /*******************************************************************/
297 UNIV_INTERN
298 ibool
300 /*===========================*/
301  ulint id,
302  ulint page_no);
303 /****************************************************************/
305 UNIV_INTERN
306 void
307 fil_init(
308 /*=====*/
309  ulint hash_size,
310  ulint max_n_open);
311 /*******************************************************************/
313 UNIV_INTERN
314 void
315 fil_close(void);
316 /*===========*/
317 /*******************************************************************/
323 UNIV_INTERN
324 void
326 /*==========================================*/
327 /*******************************************************************/
330 UNIV_INTERN
331 void
332 fil_close_all_files(void);
333 /*=====================*/
334 /*******************************************************************/
337 UNIV_INTERN
338 void
340 /*================*/
341  bool free);
342 /*******************************************************************/
345 UNIV_INTERN
346 void
348 /*===========================*/
349  ulint max_id);
350 #ifndef UNIV_HOTBACKUP
351 /****************************************************************/
355 UNIV_INTERN
356 dberr_t
358 /*================================*/
359  lsn_t lsn,
360  ulint arch_log_no);
361 /*******************************************************************/
366 UNIV_INTERN
367 const char*
369 /*================*/
370  os_file_t data_file,
371  ibool one_read_already,
374  ulint* flags,
375  ulint* space_id,
376 #ifdef UNIV_LOG_ARCHIVE
377  ulint* min_arch_log_no,
379  ulint* max_arch_log_no,
381 #endif /* UNIV_LOG_ARCHIVE */
382  lsn_t* min_flushed_lsn,
384  lsn_t* max_flushed_lsn)
386  __attribute__((warn_unused_result));
387 /*******************************************************************/
390 UNIV_INTERN
391 ibool
393 /*================*/
394  ulint id);
395 /*******************************************************************/
397 UNIV_INTERN
398 void
400 /*=================*/
401  ulint id);
402 #endif /* !UNIV_HOTBACKUP */
403 /*******************************************************************/
417 UNIV_INTERN
418 byte*
420 /*=======================*/
421  byte* ptr,
424  byte* end_ptr,
425  ulint type,
426  ulint space_id,
429  ulint log_flags);
431 /*******************************************************************/
435 UNIV_INTERN
436 dberr_t
438 /*==================*/
439  ulint id,
440  buf_remove_t buf_remove);
443 /*******************************************************************/
447 UNIV_INTERN
448 dberr_t
450 /*=================*/
451  trx_t* trx,
452  ulint id);
453 #ifndef UNIV_HOTBACKUP
454 /*******************************************************************/
468 UNIV_INTERN
469 dberr_t
471 /*===================*/
472  ulint id)
473  __attribute__((warn_unused_result));
474 #endif /* !UNIV_HOTBACKUP */
475 /*******************************************************************/
479 UNIV_INTERN
480 ibool
482 /*==================*/
483  const char* old_name_in,
488  ulint id,
489  const char* new_name,
492  const char* new_path);
497 /*******************************************************************/
501 UNIV_INTERN
502 char*
504 /*==============*/
505  const char* name,
506  bool is_full_path);
507 /*******************************************************************/
511 UNIV_INTERN
512 char*
514 /*==============*/
515  const char* name);
516 /*******************************************************************/
521 UNIV_INTERN
522 dberr_t
524 /*=================*/
525  const char* tablename,
526  const char* filepath);
527 /*******************************************************************/
529 UNIV_INTERN
530 void
532 /*==================*/
533  const char* tablename);
534 /*******************************************************************/
541 UNIV_INTERN
542 char*
544 /*===============*/
545  const char* name);
546 /*******************************************************************/
553 UNIV_INTERN
554 dberr_t
556 /*===================================*/
557  ulint space_id,
558  const char* tablename,
561  const char* dir_path,
562  ulint flags,
563  ulint flags2,
564  ulint size)
567  __attribute__((nonnull, warn_unused_result));
568 #ifndef UNIV_HOTBACKUP
569 /********************************************************************/
590 UNIV_INTERN
591 dberr_t
593 /*=============================*/
594  bool validate,
595  bool fix_dict,
596  ulint id,
597  ulint flags,
598  const char* tablename,
600  const char* filepath)
601  __attribute__((nonnull(5), warn_unused_result));
602 
603 #endif /* !UNIV_HOTBACKUP */
604 /********************************************************************/
612 UNIV_INTERN
613 dberr_t
615 /*===================================*/
616 /*******************************************************************/
620 UNIV_INTERN
621 ibool
623 /*===========================================*/
624  ulint id,
625  ib_int64_t version);
628 /*******************************************************************/
631 UNIV_INTERN
632 ibool
634 /*=========================*/
635  ulint id);
636 #ifndef UNIV_HOTBACKUP
637 /*******************************************************************/
642 UNIV_INTERN
643 ibool
645 /*==============================*/
646  ulint id,
647  const char* name,
649  ibool mark_space,
655  ibool print_error_if_does_not_exist,
660  bool adjust_space,
662  mem_heap_t* heap,
663  table_id_t table_id);
664 #else /* !UNIV_HOTBACKUP */
665 /********************************************************************/
670 UNIV_INTERN
671 void
672 fil_extend_tablespaces_to_stored_len(void);
673 /*======================================*/
674 #endif /* !UNIV_HOTBACKUP */
675 /**********************************************************************/
680 UNIV_INTERN
681 ibool
683 /*=============================*/
684  ulint* actual_size,
687  ulint space_id,
688  ulint size_after_extend);
691 /*******************************************************************/
694 UNIV_INTERN
695 ibool
697 /*===========================*/
698  ulint id,
699  ulint n_free_now,
700  ulint n_to_reserve);
701 /*******************************************************************/
703 UNIV_INTERN
704 void
706 /*===========================*/
707  ulint id,
708  ulint n_reserved);
709 /*******************************************************************/
712 UNIV_INTERN
713 ulint
715 /*=============================*/
716  ulint id);
717 /********************************************************************/
721 UNIV_INTERN
722 dberr_t
723 fil_io(
724 /*===*/
725  ulint type,
734  bool sync,
735  ulint space_id,
736  ulint zip_size,
738  ulint block_offset,
739  ulint byte_offset,
742  ulint len,
745  void* buf,
748  void* message)
750  __attribute__((nonnull(8)));
751 /**********************************************************************/
756 UNIV_INTERN
757 void
759 /*=========*/
760  ulint segment);
762 /**********************************************************************/
765 UNIV_INTERN
766 void
767 fil_flush(
768 /*======*/
769  ulint space_id);
771 /**********************************************************************/
774 UNIV_INTERN
775 void
777 /*==================*/
778  ulint purpose);
779 /******************************************************************/
782 UNIV_INTERN
783 ibool
784 fil_validate(void);
785 /*==============*/
786 /********************************************************************/
789 UNIV_INTERN
790 ibool
792 /*=============*/
793  fil_addr_t addr);
794 /********************************************************************/
797 UNIV_INTERN
798 ulint
800 /*==============*/
801  const byte* page);
802 /********************************************************************/
805 UNIV_INTERN
806 ulint
808 /*==============*/
809  const byte* page);
810 /*********************************************************************/
812 UNIV_INTERN
813 void
815 /*==============*/
816  byte* page,
817  ulint type);
818 /*********************************************************************/
822 UNIV_INTERN
823 ulint
825 /*==============*/
826  const byte* page);
828 /*******************************************************************/
831 UNIV_INTERN
832 ibool
834 /*============================*/
835  ulint id);
837 /********************************************************************/
840 UNIV_INTERN
841 void
843 /*============*/
844  const char* path);
847 struct PageCallback {
848 
852  :
853  m_zip_size(),
854  m_page_size(),
855  m_filepath() UNIV_NOTHROW {}
856 
857  virtual ~PageCallback() UNIV_NOTHROW {}
858 
864  virtual dberr_t init(
865  os_offset_t file_size,
866  const buf_block_t* block) UNIV_NOTHROW = 0;
867 
876  virtual dberr_t operator()(
878  buf_block_t* block) UNIV_NOTHROW = 0;
879 
885  void set_file(const char* filename, os_file_t file) UNIV_NOTHROW
886  {
887  m_file = file;
888  m_filepath = filename;
889  }
890 
893  virtual ulint get_space_id() const UNIV_NOTHROW = 0;
894 
897  ulint get_zip_size() const
898  {
899  return(m_zip_size);
900  }
901 
905  dberr_t set_zip_size(const buf_frame_t* page) UNIV_NOTHROW;
906 
909  ulint get_page_size() const
910  {
911  return(m_page_size);
912  }
913 
915  ulint m_zip_size;
916 
918  ulint m_page_size;
919 
922 
924  const char* m_filepath;
925 
926 protected:
927  // Disable copying
928  PageCallback(const PageCallback&);
929  PageCallback& operator=(const PageCallback&);
930 };
931 
932 /********************************************************************/
938 UNIV_INTERN
939 dberr_t
941 /*===================*/
943  ulint n_io_buffers,
944  PageCallback& callback)
945  __attribute__((nonnull, warn_unused_result));
946 
947 /*******************************************************************/
951 UNIV_INTERN
952 ulint
954 /*=======================*/
955  const char* name);
963 UNIV_INTERN
964 dberr_t
966 /*================*/
967  space_name_list_t& space_name_list)
969  __attribute__((warn_unused_result));
970 
971 /****************************************************************/
973 UNIV_INTERN
974 void
976 /*===============*/
977  ulint old_space_id,
979  const char* old_name,
980  ulint new_space_id,
982  const char* new_name,
983  const char* tmp_name,
985  mtr_t* mtr)
986  __attribute__((nonnull));
987 
988 #endif /* !UNIV_INNOCHECKSUM */
989 #endif /* fil0fil_h */