Drizzled Public API Documentation

fil0fil.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003 Copyright (C) 1995, 2010, Innobase Oy. All Rights Reserved.
00004 
00005 This program is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; version 2 of the License.
00008 
00009 This program is distributed in the hope that it will be useful, but WITHOUT
00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with
00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
00015 St, Fifth Floor, Boston, MA 02110-1301 USA
00016 
00017 *****************************************************************************/
00018 
00019 /**************************************************/
00026 #pragma once
00027 #ifndef fil0fil_h
00028 #define fil0fil_h
00029 
00030 #include "univ.i"
00031 #include "dict0types.h"
00032 #include "ut0byte.h"
00033 #include "os0file.h"
00034 #ifndef UNIV_HOTBACKUP
00035 #include "sync0rw.h"
00036 #include "ibuf0types.h"
00037 #endif /* !UNIV_HOTBACKUP */
00038 
00042 extern const char*  fil_path_to_mysql_datadir;
00043 
00045 #define FIL_IBD_FILE_INITIAL_SIZE 4
00046 
00048 #define FIL_NULL  ULINT32_UNDEFINED
00049 
00050 /* Space address data type; this is intended to be used when
00051 addresses accurate to a byte are stored in file pages. If the page part
00052 of the address is FIL_NULL, the address is considered undefined. */
00053 
00054 typedef byte  fil_faddr_t;  
00056 #define FIL_ADDR_PAGE 0 /* first in address is the page offset */
00057 #define FIL_ADDR_BYTE 4 /* then comes 2-byte byte offset within page*/
00058 
00059 #define FIL_ADDR_SIZE 6 /* address size is 6 bytes */
00060 
00064 typedef struct fil_addr_struct  fil_addr_t;
00066 struct fil_addr_struct{
00067   ulint page;   
00068   ulint boffset;  
00069 };
00070 
00072 extern fil_addr_t fil_addr_null;
00073 
00075 #define FIL_PAGE_SPACE_OR_CHKSUM 0  
00079 #define FIL_PAGE_OFFSET   4 
00080 #define FIL_PAGE_PREV   8 
00087 #define FIL_PAGE_NEXT   12  
00097 #define FIL_PAGE_LSN    16  
00099 #define FIL_PAGE_TYPE   24  
00114 #define FIL_PAGE_FILE_FLUSH_LSN 26  
00119 #define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID  34 
00121 #define FIL_PAGE_DATA   38  
00122 /* @} */
00123 
00124 #define FIL_PAGE_END_LSN_OLD_CHKSUM 8 
00128 #define FIL_PAGE_DATA_END 8 
00129 /* @} */
00130 
00132 #define FIL_PAGE_INDEX    17855 
00133 #define FIL_PAGE_UNDO_LOG 2 
00134 #define FIL_PAGE_INODE    3 
00135 #define FIL_PAGE_IBUF_FREE_LIST 4 
00136 /* File page types introduced in MySQL/InnoDB 5.1.7 */
00137 #define FIL_PAGE_TYPE_ALLOCATED 0 
00138 #define FIL_PAGE_IBUF_BITMAP  5 
00139 #define FIL_PAGE_TYPE_SYS 6 
00140 #define FIL_PAGE_TYPE_TRX_SYS 7 
00141 #define FIL_PAGE_TYPE_FSP_HDR 8 
00142 #define FIL_PAGE_TYPE_XDES  9 
00143 #define FIL_PAGE_TYPE_BLOB  10  
00144 #define FIL_PAGE_TYPE_ZBLOB 11  
00145 #define FIL_PAGE_TYPE_ZBLOB2  12  
00146 /* @} */
00147 
00149 #define FIL_TABLESPACE    501 
00150 #define FIL_LOG     502 
00151 /* @} */
00152 
00154 extern ulint  fil_n_log_flushes;
00155 
00157 extern ulint  fil_n_pending_log_flushes;
00159 extern ulint  fil_n_pending_tablespace_flushes;
00160 
00161 
00162 #ifndef UNIV_HOTBACKUP
00163 /*******************************************************************/
00167 UNIV_INTERN
00168 ib_int64_t
00169 fil_space_get_version(
00170 /*==================*/
00171   ulint id);  
00172 /*******************************************************************/
00175 UNIV_INTERN
00176 rw_lock_t*
00177 fil_space_get_latch(
00178 /*================*/
00179   ulint id, 
00180   ulint*  zip_size);
00182 /*******************************************************************/
00185 UNIV_INTERN
00186 ulint
00187 fil_space_get_type(
00188 /*===============*/
00189   ulint id);  
00190 #endif /* !UNIV_HOTBACKUP */
00191 /*******************************************************************/
00193 UNIV_INTERN
00194 void
00195 fil_node_create(
00196 /*============*/
00197   const char* name, 
00198   ulint   size, 
00200   ulint   id, 
00201   ibool   is_raw);
00203 #ifdef UNIV_LOG_ARCHIVE
00204 /****************************************************************/
00207 UNIV_INTERN
00208 void
00209 fil_space_truncate_start(
00210 /*=====================*/
00211   ulint id,   
00212   ulint trunc_len); 
00215 #endif /* UNIV_LOG_ARCHIVE */
00216 /*******************************************************************/
00220 UNIV_INTERN
00221 ibool
00222 fil_space_create(
00223 /*=============*/
00224   const char* name, 
00225   ulint   id, 
00226   ulint   zip_size,
00228   ulint   purpose);
00229 /*******************************************************************/
00234 UNIV_INTERN
00235 ibool
00236 fil_assign_new_space_id(
00237 /*====================*/
00238   ulint*  space_id);  
00239 /*******************************************************************/
00243 UNIV_INTERN
00244 ulint
00245 fil_space_get_size(
00246 /*===============*/
00247   ulint id);  
00248 /*******************************************************************/
00252 UNIV_INTERN
00253 ulint
00254 fil_space_get_flags(
00255 /*================*/
00256   ulint id);  
00257 /*******************************************************************/
00261 UNIV_INTERN
00262 ulint
00263 fil_space_get_zip_size(
00264 /*===================*/
00265   ulint id);  
00266 /*******************************************************************/
00270 UNIV_INTERN
00271 ibool
00272 fil_check_adress_in_tablespace(
00273 /*===========================*/
00274   ulint id, 
00275   ulint page_no);
00276 /****************************************************************/
00278 UNIV_INTERN
00279 void
00280 fil_init(
00281 /*=====*/
00282   ulint hash_size,  
00283   ulint max_n_open);  
00284 /*******************************************************************/
00286 UNIV_INTERN
00287 void
00288 fil_close(void);
00289 /*===========*/
00290 /*******************************************************************/
00296 UNIV_INTERN
00297 void
00298 fil_open_log_and_system_tablespace_files(void);
00299 /*==========================================*/
00300 /*******************************************************************/
00303 UNIV_INTERN
00304 void
00305 fil_close_all_files(void);
00306 /*=====================*/
00307 /*******************************************************************/
00310 UNIV_INTERN
00311 void
00312 fil_set_max_space_id_if_bigger(
00313 /*===========================*/
00314   ulint max_id);
00315 #ifndef UNIV_HOTBACKUP
00316 /****************************************************************/
00320 UNIV_INTERN
00321 ulint
00322 fil_write_flushed_lsn_to_data_files(
00323 /*================================*/
00324   ib_uint64_t lsn,    
00325   ulint   arch_log_no); 
00327 /*******************************************************************/
00330 UNIV_INTERN
00331 void
00332 fil_read_flushed_lsn_and_arch_log_no(
00333 /*=================================*/
00334   os_file_t data_file,    
00335   ibool   one_read_already, 
00338 #ifdef UNIV_LOG_ARCHIVE
00339   ulint*    min_arch_log_no,  
00340   ulint*    max_arch_log_no,  
00341 #endif /* UNIV_LOG_ARCHIVE */
00342   ib_uint64_t*  min_flushed_lsn,  
00343   ib_uint64_t*  max_flushed_lsn); 
00344 /*******************************************************************/
00348 UNIV_INTERN
00349 ibool
00350 fil_inc_pending_ibuf_merges(
00351 /*========================*/
00352   ulint id);  
00353 /*******************************************************************/
00355 UNIV_INTERN
00356 void
00357 fil_decr_pending_ibuf_merges(
00358 /*=========================*/
00359   ulint id);  
00360 #endif /* !UNIV_HOTBACKUP */
00361 /*******************************************************************/
00375 UNIV_INTERN
00376 byte*
00377 fil_op_log_parse_or_replay(
00378 /*=======================*/
00379   byte* ptr,    
00382   byte* end_ptr,  
00383   ulint type,   
00384   ulint space_id, 
00387   ulint log_flags); 
00389 /*******************************************************************/
00393 UNIV_INTERN
00394 ibool
00395 fil_delete_tablespace(
00396 /*==================*/
00397   ulint id);  
00398 #ifndef UNIV_HOTBACKUP
00399 /*******************************************************************/
00408 UNIV_INTERN
00409 ibool
00410 fil_discard_tablespace(
00411 /*===================*/
00412   ulint id);  
00413 #endif /* !UNIV_HOTBACKUP */
00414 /*******************************************************************/
00418 UNIV_INTERN
00419 ibool
00420 fil_rename_tablespace(
00421 /*==================*/
00422   const char* old_name, 
00426   ulint   id,   
00427   const char* new_name);  
00431 /*******************************************************************/
00438 UNIV_INTERN
00439 ulint
00440 fil_create_new_single_table_tablespace(
00441 /*===================================*/
00442   ulint   space_id, 
00443   const char* tablename,  
00447   ibool   is_temp,  
00449   ulint   flags,    
00450   ulint   size);    
00453 #ifndef UNIV_HOTBACKUP
00454 /********************************************************************/
00464 UNIV_INTERN
00465 ibool
00466 fil_open_single_table_tablespace(
00467 /*=============================*/
00468   ibool   check_space_id, 
00475   ulint   id,   
00476   ulint   flags,    
00477   const char* name);    
00479 /********************************************************************/
00489 UNIV_INTERN
00490 ibool
00491 fil_reset_too_high_lsns(
00492 /*====================*/
00493   const char* name,   
00495   ib_uint64_t current_lsn); 
00498 #endif /* !UNIV_HOTBACKUP */
00499 /********************************************************************/
00507 UNIV_INTERN
00508 ulint
00509 fil_load_single_table_tablespaces(void);
00510 /*===================================*/
00511 /*******************************************************************/
00515 UNIV_INTERN
00516 ibool
00517 fil_tablespace_deleted_or_being_deleted_in_mem(
00518 /*===========================================*/
00519   ulint   id, 
00520   ib_int64_t  version);
00523 /*******************************************************************/
00526 UNIV_INTERN
00527 ibool
00528 fil_tablespace_exists_in_mem(
00529 /*=========================*/
00530   ulint id);  
00531 #ifndef UNIV_HOTBACKUP
00532 /*******************************************************************/
00537 UNIV_INTERN
00538 ibool
00539 fil_space_for_table_exists_in_mem(
00540 /*==============================*/
00541   ulint   id,   
00542   const char* name,   
00545   ibool   is_temp,  
00547   ibool   mark_space, 
00553   ibool   print_error_if_does_not_exist);
00558 #else /* !UNIV_HOTBACKUP */
00559 /********************************************************************/
00564 UNIV_INTERN
00565 void
00566 fil_extend_tablespaces_to_stored_len(void);
00567 /*======================================*/
00568 #endif /* !UNIV_HOTBACKUP */
00569 /**********************************************************************/
00574 UNIV_INTERN
00575 ibool
00576 fil_extend_space_to_desired_size(
00577 /*=============================*/
00578   ulint*  actual_size,  
00581   ulint space_id, 
00582   ulint size_after_extend);
00585 /*******************************************************************/
00588 UNIV_INTERN
00589 ibool
00590 fil_space_reserve_free_extents(
00591 /*===========================*/
00592   ulint id,   
00593   ulint n_free_now, 
00594   ulint n_to_reserve);  
00595 /*******************************************************************/
00597 UNIV_INTERN
00598 void
00599 fil_space_release_free_extents(
00600 /*===========================*/
00601   ulint id,   
00602   ulint n_reserved);  
00603 /*******************************************************************/
00606 UNIV_INTERN
00607 ulint
00608 fil_space_get_n_reserved_extents(
00609 /*=============================*/
00610   ulint id);    
00611 /********************************************************************/
00615 UNIV_INTERN
00616 ulint
00617 fil_io(
00618 /*===*/
00619   ulint type,   
00628   ibool sync,   
00629   ulint space_id, 
00630   ulint zip_size, 
00632   ulint block_offset, 
00633   ulint byte_offset,  
00636   ulint len,    
00639   void* buf,    
00642   void* message); 
00644 /**********************************************************************/
00649 UNIV_INTERN
00650 void
00651 fil_aio_wait(
00652 /*=========*/
00653   ulint segment); 
00655 /**********************************************************************/
00658 UNIV_INTERN
00659 void
00660 fil_flush(
00661 /*======*/
00662   ulint space_id);  
00664 /**********************************************************************/
00667 UNIV_INTERN
00668 void
00669 fil_flush_file_spaces(
00670 /*==================*/
00671   ulint purpose); 
00672 /******************************************************************/
00675 UNIV_INTERN
00676 ibool
00677 fil_validate(void);
00678 /*==============*/
00679 /********************************************************************/
00682 UNIV_INTERN
00683 ibool
00684 fil_addr_is_null(
00685 /*=============*/
00686   fil_addr_t  addr);  
00687 /********************************************************************/
00690 UNIV_INTERN
00691 ulint
00692 fil_page_get_prev(
00693 /*==============*/
00694   const byte* page);  
00695 /********************************************************************/
00698 UNIV_INTERN
00699 ulint
00700 fil_page_get_next(
00701 /*==============*/
00702   const byte* page);  
00703 /*********************************************************************/
00705 UNIV_INTERN
00706 void
00707 fil_page_set_type(
00708 /*==============*/
00709   byte* page, 
00710   ulint type);  
00711 /*********************************************************************/
00715 UNIV_INTERN
00716 ulint
00717 fil_page_get_type(
00718 /*==============*/
00719   const byte* page);  
00721 /*******************************************************************/
00724 UNIV_INTERN
00725 ibool
00726 fil_tablespace_is_being_deleted(
00727 /*============================*/
00728   ulint   id);  
00730 typedef struct fil_space_struct fil_space_t;
00731 
00732 #endif