diff options
author | unknown <heikki@hundin.mysql.fi> | 2003-10-07 17:28:59 +0300 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2003-10-07 17:28:59 +0300 |
commit | d1485aad0eb79559902b1af26502b7cc53f8e95a (patch) | |
tree | d53a5cc4e9736e149276ba08d53a7dd09a14b4fd /innobase/include | |
parent | d1ab51eb947623f45a8314cb9c0b6ddc15f0d148 (diff) | |
download | mariadb-git-d1485aad0eb79559902b1af26502b7cc53f8e95a.tar.gz |
Many files:
Multiple tablespaces for InnoDB
sql_table.cc:
Tell explicitly that InnoDB should retrieve all columns in CHECKSUM TABLE
sql_update.cc, sql_select.cc, my_base.h:
More descriptive flag name HA_EXTRA_RETRIEVE_ALL_COLS
include/my_base.h:
More descriptive flag name HA_EXTRA_RETRIEVE_ALL_COLS
sql/sql_select.cc:
More descriptive flag name HA_EXTRA_RETRIEVE_ALL_COLS
sql/sql_update.cc:
More descriptive flag name HA_EXTRA_RETRIEVE_ALL_COLS
sql/sql_table.cc:
Tell explicitly that InnoDB should retrieve all columns in CHECKSUM TABLE
sql/sql_db.cc:
Multiple tablespaces for InnoDB
sql/ha_innodb.cc:
Multiple tablespaces for InnoDB
sql/mysqld.cc:
Multiple tablespaces for InnoDB
sql/set_var.cc:
Multiple tablespaces for InnoDB
sql/sql_cache.cc:
Multiple tablespaces for InnoDB
sql/ha_innodb.h:
Multiple tablespaces for InnoDB
innobase/include/btr0btr.ic:
Multiple tablespaces for InnoDB
innobase/include/btr0pcur.ic:
Multiple tablespaces for InnoDB
innobase/include/data0type.ic:
Multiple tablespaces for InnoDB
innobase/include/dyn0dyn.ic:
Multiple tablespaces for InnoDB
innobase/include/fut0lst.ic:
Multiple tablespaces for InnoDB
innobase/include/log0log.ic:
Multiple tablespaces for InnoDB
innobase/include/mach0data.ic:
Multiple tablespaces for InnoDB
innobase/include/mtr0log.ic:
Multiple tablespaces for InnoDB
innobase/include/rem0rec.ic:
Multiple tablespaces for InnoDB
innobase/include/ut0byte.ic:
Multiple tablespaces for InnoDB
innobase/include/ut0ut.ic:
Multiple tablespaces for InnoDB
innobase/include/buf0buf.h:
Multiple tablespaces for InnoDB
innobase/include/buf0lru.h:
Multiple tablespaces for InnoDB
innobase/include/buf0rea.h:
Multiple tablespaces for InnoDB
innobase/include/data0type.h:
Multiple tablespaces for InnoDB
innobase/include/db0err.h:
Multiple tablespaces for InnoDB
innobase/include/dict0boot.h:
Multiple tablespaces for InnoDB
innobase/include/dict0dict.h:
Multiple tablespaces for InnoDB
innobase/include/dict0load.h:
Multiple tablespaces for InnoDB
innobase/include/dict0mem.h:
Multiple tablespaces for InnoDB
innobase/include/fil0fil.h:
Multiple tablespaces for InnoDB
innobase/include/fsp0fsp.h:
Multiple tablespaces for InnoDB
innobase/include/ibuf0ibuf.h:
Multiple tablespaces for InnoDB
innobase/include/lock0lock.h:
Multiple tablespaces for InnoDB
innobase/include/log0log.h:
Multiple tablespaces for InnoDB
innobase/include/log0recv.h:
Multiple tablespaces for InnoDB
innobase/include/os0file.h:
Multiple tablespaces for InnoDB
innobase/include/page0page.h:
Multiple tablespaces for InnoDB
innobase/include/que0types.h:
Multiple tablespaces for InnoDB
innobase/include/rem0rec.h:
Multiple tablespaces for InnoDB
innobase/include/srv0srv.h:
Multiple tablespaces for InnoDB
innobase/include/srv0start.h:
Multiple tablespaces for InnoDB
innobase/include/sync0sync.h:
Multiple tablespaces for InnoDB
innobase/include/trx0sys.h:
Multiple tablespaces for InnoDB
innobase/include/ut0byte.h:
Multiple tablespaces for InnoDB
innobase/include/univ.i:
Multiple tablespaces for InnoDB
innobase/btr/btr0cur.c:
Multiple tablespaces for InnoDB
innobase/btr/btr0sea.c:
Multiple tablespaces for InnoDB
innobase/buf/buf0buf.c:
Multiple tablespaces for InnoDB
innobase/buf/buf0flu.c:
Multiple tablespaces for InnoDB
innobase/buf/buf0lru.c:
Multiple tablespaces for InnoDB
innobase/buf/buf0rea.c:
Multiple tablespaces for InnoDB
innobase/data/data0type.c:
Multiple tablespaces for InnoDB
innobase/dict/dict0boot.c:
Multiple tablespaces for InnoDB
innobase/dict/dict0crea.c:
Multiple tablespaces for InnoDB
innobase/dict/dict0dict.c:
Multiple tablespaces for InnoDB
innobase/dict/dict0load.c:
Multiple tablespaces for InnoDB
innobase/dict/dict0mem.c:
Multiple tablespaces for InnoDB
innobase/fil/fil0fil.c:
Multiple tablespaces for InnoDB
innobase/fsp/fsp0fsp.c:
Multiple tablespaces for InnoDB
innobase/ha/ha0ha.c:
Multiple tablespaces for InnoDB
innobase/ibuf/ibuf0ibuf.c:
Multiple tablespaces for InnoDB
innobase/log/log0log.c:
Multiple tablespaces for InnoDB
innobase/log/log0recv.c:
Multiple tablespaces for InnoDB
innobase/mach/mach0data.c:
Multiple tablespaces for InnoDB
innobase/mem/mem0dbg.c:
Multiple tablespaces for InnoDB
innobase/mem/mem0pool.c:
Multiple tablespaces for InnoDB
innobase/mtr/mtr0log.c:
Multiple tablespaces for InnoDB
innobase/os/os0file.c:
Multiple tablespaces for InnoDB
innobase/os/os0proc.c:
Multiple tablespaces for InnoDB
innobase/page/page0cur.c:
Multiple tablespaces for InnoDB
innobase/que/que0que.c:
Multiple tablespaces for InnoDB
innobase/row/row0ins.c:
Multiple tablespaces for InnoDB
innobase/row/row0mysql.c:
Multiple tablespaces for InnoDB
innobase/row/row0sel.c:
Multiple tablespaces for InnoDB
innobase/row/row0upd.c:
Multiple tablespaces for InnoDB
innobase/srv/srv0srv.c:
Multiple tablespaces for InnoDB
innobase/srv/srv0start.c:
Multiple tablespaces for InnoDB
innobase/sync/sync0rw.c:
Multiple tablespaces for InnoDB
innobase/sync/sync0sync.c:
Multiple tablespaces for InnoDB
innobase/trx/trx0sys.c:
Multiple tablespaces for InnoDB
innobase/trx/trx0trx.c:
Multiple tablespaces for InnoDB
innobase/trx/trx0undo.c:
Multiple tablespaces for InnoDB
innobase/ut/ut0byte.c:
Multiple tablespaces for InnoDB
innobase/ut/ut0ut.c:
Multiple tablespaces for InnoDB
Diffstat (limited to 'innobase/include')
36 files changed, 791 insertions, 276 deletions
diff --git a/innobase/include/btr0btr.ic b/innobase/include/btr0btr.ic index 09006828cc9..16057d2c8a6 100644 --- a/innobase/include/btr0btr.ic +++ b/innobase/include/btr0btr.ic @@ -189,6 +189,7 @@ btr_node_ptr_get_child_page_no( ulint n_fields; byte* field; ulint len; + ulint page_no; n_fields = rec_get_n_fields(rec); @@ -197,7 +198,16 @@ btr_node_ptr_get_child_page_no( ut_ad(len == 4); - return(mach_read_from_4(field)); + page_no = mach_read_from_4(field); + + if (page_no == 0) { + fprintf(stderr, +"InnoDB: a nonsensical page number 0 in a node ptr record at offset %lu\n", + (ulint)(rec - buf_frame_align(rec))); + buf_page_print(buf_frame_align(rec)); + } + + return(page_no); } /****************************************************************** diff --git a/innobase/include/btr0pcur.ic b/innobase/include/btr0pcur.ic index a1db2cc52dd..b553a569bda 100644 --- a/innobase/include/btr0pcur.ic +++ b/innobase/include/btr0pcur.ic @@ -564,7 +564,7 @@ btr_pcur_open_at_index_side( } btr_cur_open_at_index_side(from_left, index, latch_mode, - btr_pcur_get_btr_cur(pcur), mtr); + btr_pcur_get_btr_cur(pcur), mtr); pcur->pos_state = BTR_PCUR_IS_POSITIONED; pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h index d2ee1a440c7..0457da60534 100644 --- a/innobase/include/buf0buf.h +++ b/innobase/include/buf0buf.h @@ -626,19 +626,27 @@ buf_pool_get_nth_block( ulint i); /* in: index of the block */ /************************************************************************ Function which inits a page for read to the buffer buf_pool. If the page is -already in buf_pool, does nothing. Sets the io_fix flag to BUF_IO_READ and -sets a non-recursive exclusive lock on the buffer frame. The io-handler must -take care that the flag is cleared and the lock released later. This is one -of the functions which perform the state transition NOT_USED => FILE_PAGE to -a block (the other is buf_page_create). */ +(1) already in buf_pool, or +(2) if we specify to read only ibuf pages and the page is not an ibuf page, or +(3) if the space is deleted or being deleted, +then this function does nothing. +Sets the io_fix flag to BUF_IO_READ and sets a non-recursive exclusive lock +on the buffer frame. The io-handler must take care that the flag is cleared +and the lock released later. This is one of the functions which perform the +state transition NOT_USED => FILE_PAGE to a block (the other is +buf_page_create). */ buf_block_t* buf_page_init_for_read( /*===================*/ - /* out: pointer to the block */ - ulint mode, /* in: BUF_READ_IBUF_PAGES_ONLY, ... */ - ulint space, /* in: space id */ - ulint offset);/* in: page number */ + /* out: pointer to the block or NULL */ + ulint* err, /* out: DB_SUCCESS or DB_TABLESPACE_DELETED */ + ulint mode, /* in: BUF_READ_IBUF_PAGES_ONLY, ... */ + ulint space, /* in: space id */ + ib_longlong tablespace_version,/* in: prevents reading from a wrong + version of the tablespace in case we have done + DISCARD + IMPORT */ + ulint offset);/* in: page number */ /************************************************************************ Completes an asynchronous read or write request of a file page to or from the buffer pool. */ diff --git a/innobase/include/buf0lru.h b/innobase/include/buf0lru.h index 5c995b259bf..69a376f8cab 100644 --- a/innobase/include/buf0lru.h +++ b/innobase/include/buf0lru.h @@ -37,6 +37,16 @@ These are low-level functions #define BUF_LRU_FREE_SEARCH_LEN (5 + 2 * BUF_READ_AHEAD_AREA) /********************************************************************** +Invalidates all pages belonging to a given tablespace when we are deleting +the data file(s) of that tablespace. A PROBLEM: if readahead is being started, +what guarantees that it will not try to read in pages after this operation has +completed? */ + +void +buf_LRU_invalidate_tablespace( +/*==========================*/ + ulint id); /* in: space id */ +/********************************************************************** Gets the minimum LRU_position field for the blocks in an initial segment (determined by BUF_LRU_INITIAL_RATIO) of the LRU list. The limit is not guaranteed to be precise, because the ulint_clock may wrap around. */ diff --git a/innobase/include/buf0rea.h b/innobase/include/buf0rea.h index aed965a6b21..380a42f4b80 100644 --- a/innobase/include/buf0rea.h +++ b/innobase/include/buf0rea.h @@ -59,7 +59,7 @@ buf_read_ahead_linear( must want access to this page (see NOTE 3 above) */ /************************************************************************ Issues read requests for pages which the ibuf module wants to read in, in -order to contract insert buffer trees. Technically, this function is like +order to contract the insert buffer tree. Technically, this function is like a read-ahead function. */ void @@ -68,9 +68,14 @@ buf_read_ibuf_merge_pages( ibool sync, /* in: TRUE if the caller wants this function to wait for the highest address page to get read in, before this function returns */ - ulint space, /* in: space id */ - ulint* page_nos, /* in: array of page numbers to read, with - the highest page number last in the array */ + ulint* space_ids, /* in: array of space ids */ + ib_longlong* space_versions,/* in: the spaces must have this version + number (timestamp), otherwise we discard the + read; we use this to cancel reads if + DISCARD + IMPORT may have changed the + tablespace size */ + ulint* page_nos, /* in: array of page numbers to read, with the + highest page number the last in the array */ ulint n_stored); /* in: number of page numbers in the array */ /************************************************************************ Issues read requests for pages which recovery wants to read in. */ diff --git a/innobase/include/data0type.h b/innobase/include/data0type.h index 4da686bf2e1..f202230bb94 100644 --- a/innobase/include/data0type.h +++ b/innobase/include/data0type.h @@ -89,6 +89,8 @@ be less than 256 */ alphabetical order for a single field and decide the storage size of an SQL null*/ #define DATA_ORDER_NULL_TYPE_BUF_SIZE 4 +/* In the >= 4.1.x storage format we need 2 bytes more for the charset */ +#define DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE 6 /************************************************************************* Sets a data type structure. */ @@ -172,24 +174,36 @@ dtype_is_fixed_size( /* out: TRUE if fixed size */ dtype_t* type); /* in: type */ /************************************************************************** +Reads to a type the stored information which determines its alphabetical +ordering and the storage size of an SQL NULL value. */ +UNIV_INLINE +void +dtype_read_for_order_and_null_size( +/*===============================*/ + dtype_t* type, /* in: type struct */ + byte* buf); /* in: buffer for the stored order info */ +/************************************************************************** Stores for a type the information which determines its alphabetical ordering -and the storage size of an SQL NULL value. */ +and the storage size of an SQL NULL value. This is the >= 4.1.x storage +format. */ UNIV_INLINE void -dtype_store_for_order_and_null_size( -/*================================*/ - byte* buf, /* in: buffer for DATA_ORDER_NULL_TYPE_BUF_SIZE +dtype_new_store_for_order_and_null_size( +/*====================================*/ + byte* buf, /* in: buffer for + DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE bytes where we store the info */ dtype_t* type); /* in: type struct */ /************************************************************************** Reads to a type the stored information which determines its alphabetical -ordering and the storage size of an SQL NULL value. */ +ordering and the storage size of an SQL NULL value. This is the 4.1.x storage +format. */ UNIV_INLINE void -dtype_read_for_order_and_null_size( -/*===============================*/ +dtype_new_read_for_order_and_null_size( +/*===================================*/ dtype_t* type, /* in: type struct */ - byte* buf); /* in: buffer for the stored order info */ + byte* buf); /* in: buffer for stored type order info */ /************************************************************************* Validates a data type structure. */ @@ -211,6 +225,7 @@ dtype_print( struct dtype_struct{ ulint mtype; /* main data type */ ulint prtype; /* precise type; MySQL data type */ + ulint chrset; /* MySQL character set code */ /* remaining two fields do not affect alphabetical ordering: */ diff --git a/innobase/include/data0type.ic b/innobase/include/data0type.ic index ddd0b0ae8cc..5d39b3e430b 100644 --- a/innobase/include/data0type.ic +++ b/innobase/include/data0type.ic @@ -27,6 +27,7 @@ dtype_set( type->prtype = prtype; type->len = len; type->prec = prec; + type->chrset = 0; ut_ad(dtype_validate(type)); } @@ -127,18 +128,20 @@ dtype_get_pad_char( /************************************************************************** Stores for a type the information which determines its alphabetical ordering -and the storage size of an SQL NULL value. */ +and the storage size of an SQL NULL value. This is the >= 4.1.x storage +format. */ UNIV_INLINE void -dtype_store_for_order_and_null_size( -/*================================*/ - byte* buf, /* in: buffer for DATA_ORDER_NULL_TYPE_BUF_SIZE +dtype_new_store_for_order_and_null_size( +/*====================================*/ + byte* buf, /* in: buffer for + DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE bytes where we store the info */ dtype_t* type) /* in: type struct */ { - ut_ad(4 == DATA_ORDER_NULL_TYPE_BUF_SIZE); + ut_ad(6 == DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); - buf[0] = (byte)(type->mtype & 0xFF); + buf[0] = (byte)(type->mtype & 0xFFUL); if (type->prtype & DATA_BINARY_TYPE) { buf[0] = buf[0] | 128; @@ -148,9 +151,11 @@ dtype_store_for_order_and_null_size( buf[0] = buf[0] | 64; } - buf[1] = (byte)(type->prtype & 0xFF); + buf[1] = (byte)(type->prtype & 0xFFUL); + + mach_write_to_2(buf + 2, type->len & 0xFFFFUL); - mach_write_to_2(buf + 2, type->len & 0xFFFF); + mach_write_to_2(buf + 4, type->chrset & 0xFFFFUL); } /************************************************************************** @@ -179,6 +184,35 @@ dtype_read_for_order_and_null_size( type->len = mach_read_from_2(buf + 2); } +/************************************************************************** +Reads to a type the stored information which determines its alphabetical +ordering and the storage size of an SQL NULL value. This is the 4.1.x storage +format. */ +UNIV_INLINE +void +dtype_new_read_for_order_and_null_size( +/*===================================*/ + dtype_t* type, /* in: type struct */ + byte* buf) /* in: buffer for stored type order info */ +{ + ut_ad(6 == DATA_NEW_ORDER_NULL_TYPE_BUF_SIZE); + + type->mtype = buf[0] & 63; + type->prtype = buf[1]; + + if (buf[0] & 128) { + type->prtype = type->prtype | DATA_BINARY_TYPE; + } + + if (buf[0] & 64) { + type->prtype = type->prtype | DATA_NONLATIN1; + } + + type->len = mach_read_from_2(buf + 2); + + type->chrset = mach_read_from_2(buf + 4); +} + /*************************************************************************** Returns the size of a fixed size data type, 0 if not a fixed size type. */ UNIV_INLINE diff --git a/innobase/include/db0err.h b/innobase/include/db0err.h index 854b9794c00..be7667bfd0c 100644 --- a/innobase/include/db0err.h +++ b/innobase/include/db0err.h @@ -48,6 +48,11 @@ Created 5/24/1996 Heikki Tuuri from a table failed */ #define DB_NO_SAVEPOINT 42 /* no savepoint exists with the given name */ +#define DB_TABLESPACE_ALREADY_EXISTS 43 /* we cannot create a new single-table + tablespace because a file of the same + name already exists */ +#define DB_TABLESPACE_DELETED 44 /* tablespace does not exist or is + being dropped right now */ /* The following are partial failure codes */ #define DB_FAIL 1000 diff --git a/innobase/include/dict0boot.h b/innobase/include/dict0boot.h index cb631be7e35..35eff5af29a 100644 --- a/innobase/include/dict0boot.h +++ b/innobase/include/dict0boot.h @@ -93,7 +93,7 @@ dict_create(void); indexes; ibuf tables and indexes are assigned as the id the number DICT_IBUF_ID_MIN plus the space id */ -#define DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFF, 0) +#define DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFFUL, 0) /* The offset of the dictionary header on the page */ #define DICT_HDR FSEG_PAGE_DATA diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index b5ec5381db2..234dece2cda 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -51,6 +51,16 @@ Inits the data dictionary module. */ void dict_init(void); /*===========*/ +/************************************************************************ +Gets the space id of every table of the data dictionary and makes a linear +list and a hash table of them to the data dictionary cache. This function +can be called at database startup if we did not need to do a crash recovery. +In crash recovery we must scan the space id's from the .ibd files in MySQL +database directories. */ + +void +dict_load_space_id_list(void); +/*=========================*/ /************************************************************************** Returns a stored procedure object and memoryfixes it. */ UNIV_INLINE @@ -187,6 +197,15 @@ dict_table_rename_in_cache( to preserve the original table name in constraints which reference it */ /************************************************************************** +Change the id of a table object in the dictionary cache. This is used in +DISCARD TABLESPACE. */ + +void +dict_table_change_id_in_cache( +/*==========================*/ + dict_table_t* table, /* in: table object already in cache */ + dulint new_id);/* in: new id to set */ +/************************************************************************** Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. At least one of foreign table or referenced table must already be in @@ -734,7 +753,8 @@ dict_tree_build_node_ptr( /*=====================*/ /* out, own: node pointer */ dict_tree_t* tree, /* in: index tree */ - rec_t* rec, /* in: record for which to build node pointer */ + rec_t* rec, /* in: record for which to build node + pointer */ ulint page_no,/* in: page number to put in node pointer */ mem_heap_t* heap, /* in: memory heap where pointer created */ ulint level); /* in: level of rec in tree: 0 means leaf @@ -902,7 +922,7 @@ struct dict_sys_struct{ dict_table_t* sys_columns; /* SYS_COLUMNS table */ dict_table_t* sys_indexes; /* SYS_INDEXES table */ dict_table_t* sys_fields; /* SYS_FIELDS table */ -}; +}; #ifndef UNIV_NONINL #include "dict0dict.ic" diff --git a/innobase/include/dict0load.h b/innobase/include/dict0load.h index b60996a8dab..f7168a0f45f 100644 --- a/innobase/include/dict0load.h +++ b/innobase/include/dict0load.h @@ -15,6 +15,17 @@ Created 4/24/1996 Heikki Tuuri #include "ut0byte.h" /************************************************************************ +In a crash recovery we already have all the tablespace objects created. +This function compares the space id information in the InnoDB data dictionary +to what we already read with fil_load_single_table_tablespaces(). +In a normal startup we just scan the biggest space id, and store it to +fil_system. */ + +void +dict_check_tablespaces_or_store_max_id( +/*===================================*/ + ibool in_crash_recovery); /* in: are we doing a crash recovery */ +/************************************************************************ Finds the first table name in the given database. */ char* @@ -32,7 +43,10 @@ a foreign key references columns in this table. */ dict_table_t* dict_load_table( /*============*/ - /* out: table, NULL if does not exist */ + /* out: table, NULL if does not exist; if the table is + stored in an .ibd file, but the file does not exist, + then we set the ibd_file_missing flag TRUE in the table + object we return */ char* name); /* in: table name */ /*************************************************************************** Loads a table object based on the table id. */ diff --git a/innobase/include/dict0mem.h b/innobase/include/dict0mem.h index 03dc913a7c9..b18e20a644a 100644 --- a/innobase/include/dict0mem.h +++ b/innobase/include/dict0mem.h @@ -309,6 +309,13 @@ struct dict_table_struct{ char* name; /* table name */ ulint space; /* space where the clustered index of the table is placed */ + ibool ibd_file_missing;/* TRUE if this is in a single-table + tablespace and the .ibd file is missing; then + we must return in ha_innodb.cc an error if the + user tries to query such an orphaned table */ + ibool tablespace_discarded;/* this flag is set TRUE when the + user calls DISCARD TABLESPACE on this table, + and reset to FALSE in IMPORT TABLESPACE */ hash_node_t name_hash; /* hash chain node */ hash_node_t id_hash; /* hash chain node */ ulint n_def; /* number of columns defined so far */ diff --git a/innobase/include/dyn0dyn.ic b/innobase/include/dyn0dyn.ic index 787615cae09..b6c4808398b 100644 --- a/innobase/include/dyn0dyn.ic +++ b/innobase/include/dyn0dyn.ic @@ -7,7 +7,7 @@ Created 2/5/1996 Heikki Tuuri *******************************************************/ #define DYN_BLOCK_MAGIC_N 375767 -#define DYN_BLOCK_FULL_FLAG 0x1000000 +#define DYN_BLOCK_FULL_FLAG 0x1000000UL /**************************************************************** Adds a new block to a dyn array. */ diff --git a/innobase/include/fil0fil.h b/innobase/include/fil0fil.h index ad3149f0b36..c76c87395b4 100644 --- a/innobase/include/fil0fil.h +++ b/innobase/include/fil0fil.h @@ -60,10 +60,8 @@ extern fil_addr_t fil_addr_null; first page in a data file: the file has been flushed to disk at least up to this lsn */ -#define FIL_PAGE_ARCH_LOG_NO 34 /* this is only defined for the - first page in a data file: the latest - archived log file number when the - flush lsn above was written */ +#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34 /* starting from 4.1.x this + contains the space id of the page */ #define FIL_PAGE_DATA 38 /* start of the data on the page */ /* File page trailer */ @@ -86,50 +84,51 @@ extern fil_addr_t fil_addr_null; extern ulint fil_n_pending_log_flushes; extern ulint fil_n_pending_tablespace_flushes; + /*********************************************************************** -Reserves a right to open a single file. The right must be released with -fil_release_right_to_open. */ +Returns the version number of a tablespace, -1 if not found. */ -void -fil_reserve_right_to_open(void); -/*===========================*/ +ib_longlong +fil_space_get_version( +/*==================*/ + /* out: version number, -1 if the tablespace does not + exist in the memory cache */ + ulint id); /* in: space id */ /*********************************************************************** -Releases a right to open a single file. */ +Returns the latch of a file space. */ -void -fil_release_right_to_open(void); -/*===========================*/ -/************************************************************************ -Returns TRUE if file address is undefined. */ -ibool -fil_addr_is_null( -/*=============*/ - /* out: TRUE if undefined */ - fil_addr_t addr); /* in: address */ -/******************************************************************** -Initializes the file system of this module. */ +rw_lock_t* +fil_space_get_latch( +/*================*/ + /* out: latch protecting storage allocation */ + ulint id); /* in: space id */ +/*********************************************************************** +Returns the type of a file space. */ -void -fil_init( -/*=====*/ - ulint max_n_open); /* in: max number of open files */ -/******************************************************************** -Initializes the ibuf indexes at a database start. This can be called -after the file space headers have been created and the dictionary system -has been initialized. */ +ulint +fil_space_get_type( +/*===============*/ + /* out: FIL_TABLESPACE or FIL_LOG */ + ulint id); /* in: space id */ +/*********************************************************************** +Returns the ibuf data of a file space. */ -void -fil_ibuf_init_at_db_start(void); -/*===========================*/ +ibuf_data_t* +fil_space_get_ibuf_data( +/*====================*/ + /* out: ibuf data for this space */ + ulint id); /* in: space id */ /*********************************************************************** -Creates a space object and puts it to the file system. */ +Appends a new file to the chain of files of a space. File must be closed. */ void -fil_space_create( -/*=============*/ - char* name, /* in: space name */ - ulint id, /* in: space id */ - ulint purpose);/* in: FIL_TABLESPACE, or FIL_LOG if log */ +fil_node_create( +/*============*/ + char* name, /* in: file name (file must be closed) */ + ulint size, /* in: file size in database blocks, rounded downwards + to an integer */ + ulint id, /* in: space id where to append */ + ibool is_raw);/* in: TRUE if a raw device or a raw disk partition */ /******************************************************************** Drops files from the start of a file space, so that its size is cut by the amount given. */ @@ -141,48 +140,88 @@ fil_space_truncate_start( ulint trunc_len); /* in: truncate by this much; it is an error if this does not equal to the combined size of some initial files in the space */ -/************************************************************************** -Tries to extend a data file by the number of pages given. Any fractions of a -megabyte are ignored. */ +/*********************************************************************** +Creates a space memory object and puts it to the 'fil system' hash table. If +there is an error, prints an error message to the .err log. */ ibool -fil_extend_last_data_file( -/*======================*/ - /* out: TRUE if success, also if we run - out of disk space we may return TRUE */ - ulint* actual_increase,/* out: number of pages we were able to - extend, here the orginal size of the file and - the resulting size of the file are rounded - downwards to a full megabyte, and the - difference expressed in pages is returned */ - ulint size_increase); /* in: try to extend this many pages */ +fil_space_create( +/*=============*/ + /* out: TRUE if success */ + char* name, /* in: space name */ + ulint id, /* in: space id */ + ulint purpose);/* in: FIL_TABLESPACE, or FIL_LOG if log */ /*********************************************************************** -Frees a space object from a file system. Closes the files in the chain -but does not delete them. */ +Frees a space object from a the tablespace memory cache. Closes the files in +the chain but does not delete them. */ -void +ibool fil_space_free( /*===========*/ + /* out: TRUE if success */ ulint id); /* in: space id */ /*********************************************************************** -Returns the latch of a file space. */ - -rw_lock_t* -fil_space_get_latch( -/*================*/ - /* out: latch protecting storage allocation */ - ulint id); /* in: space id */ -/*********************************************************************** -Returns the type of a file space. */ +Returns the size of the space in pages. The tablespace must be cached in the +memory cache. */ ulint -fil_space_get_type( +fil_space_get_size( /*===============*/ - /* out: FIL_TABLESPACE or FIL_LOG */ + /* out: space size, 0 if space not found */ ulint id); /* in: space id */ +/*********************************************************************** +Checks if the pair space, page_no refers to an existing page in a tablespace +file space. The tablespace must be cached in the memory cache. */ + +ibool +fil_check_adress_in_tablespace( +/*===========================*/ + /* out: TRUE if the address is meaningful */ + ulint id, /* in: space id */ + ulint page_no);/* in: page number */ +/******************************************************************** +Initializes the tablespace memory cache. */ + +void +fil_init( +/*=====*/ + ulint max_n_open); /* in: max number of open files */ +/*********************************************************************** +Opens all log files and system tablespace data files. They stay open until the +database server shutdown. This should be called at a server startup after the +space objects for the log and the system tablespace have been created. The +purpose of this operation is to make sure we never run out of file descriptors +if we need to read from the insert buffer or to write to the log. */ + +void +fil_open_log_and_system_tablespace_files(void); +/*==========================================*/ +/*********************************************************************** +Closes all open files. There must not be any pending i/o's or not flushed +modifications in the files. */ + +void +fil_close_all_files(void); +/*=====================*/ +/*********************************************************************** +Sets the max tablespace id counter if the given number is bigger than the +previous value. */ + +void +fil_set_max_space_id_if_bigger( +/*===========================*/ + ulint max_id);/* in: maximum known id */ +/******************************************************************** +Initializes the ibuf data structure for space 0 == the system tablespace. +This can be called after the file space headers have been created and the +dictionary system has been initialized. */ + +void +fil_ibuf_init_at_db_start(void); +/*===========================*/ /******************************************************************** Writes the flushed lsn and the latest archived log number to the page -header of the first page of each data file. */ +header of the first page of each data file in the system tablespace. */ ulint fil_write_flushed_lsn_to_data_files( @@ -205,48 +244,221 @@ fil_read_flushed_lsn_and_arch_log_no( dulint* max_flushed_lsn, /* in/out: */ ulint* max_arch_log_no); /* in/out: */ /*********************************************************************** -Returns the ibuf data of a file space. */ +Increments the count of pending insert buffer page merges, if space is not +being deleted. */ -ibuf_data_t* -fil_space_get_ibuf_data( -/*====================*/ - /* out: ibuf data for this space */ +ibool +fil_inc_pending_ibuf_merges( +/*========================*/ + /* out: TRUE if being deleted, and ibuf merges should + be skipped */ + ulint id); /* in: space id */ +/*********************************************************************** +Decrements the count of pending insert buffer page merges. */ + +void +fil_decr_pending_ibuf_merges( +/*========================*/ ulint id); /* in: space id */ /*********************************************************************** -Returns the size of the space in pages. */ +Deletes a single-table tablespace. The tablespace must be cached in the +memory cache. */ + +ibool +fil_delete_tablespace( +/*==================*/ + /* out: TRUE if success */ + ulint id); /* in: space id */ +/*********************************************************************** +Discards a single-table tablespace. The tablespace must be cached in the +memory cache. Discarding is like deleting a tablespace, but +1) we do not drop the table from the data dictionary; +2) we remove all insert buffer entries for the tablespace immediately; in DROP +TABLE they are only removed gradually in the background; +3) when the user does IMPORT TABLESPACE, the tablespace will have the same id +as it originally had. */ + +ibool +fil_discard_tablespace( +/*===================*/ + /* out: TRUE if success */ + ulint id); /* in: space id */ +/*********************************************************************** +Renames a single-table tablespace. The tablespace must be cached in the +tablespace memory cache. */ + +ibool +fil_rename_tablespace( +/*==================*/ + /* out: TRUE if success */ + char* old_name, /* in: old table name in the standard + databasename/tablename format of InnoDB */ + ulint id, /* in: space id */ + char* new_name); /* in: new table name in the standard + databasename/tablename format of InnoDB */ +/*********************************************************************** +Creates a new single-table tablespace to a database directory of MySQL. +Database directories are under the 'datadir' of MySQL. The datadir is the +directory of a running mysqld program. We can refer to it by simply the +path '.'. */ ulint -fil_space_get_size( -/*===============*/ - /* out: space size */ +fil_create_new_single_table_tablespace( +/*===================================*/ + /* out: DB_SUCCESS or error code */ + ulint* space_id, /* out: space id */ + char* tablename, /* in: the table name in the usual + databasename/tablename format of InnoDB */ + ulint size); /* in: the initial size of the tablespace file + in pages */ +/************************************************************************ +Tries to open a single-table tablespace and checks the space id is right in +it. If does not succeed, prints an error message to the .err log. This +function is used to open the tablespace when we load a table definition +to the dictionarky cache. NOTE that we assume this operation is used under the +protection of the dictionary mutex, so that two users cannot race here. */ + +ibool +fil_open_single_table_tablespace( +/*=============================*/ + /* out: TRUE if success */ + ulint id, /* in: space id */ + char* name); /* in: table name in the databasename/tablename + format */ +/************************************************************************ +At the server startup, if we need crash recovery, scans the database +directories under the MySQL datadir, looking for .ibd files. Those files are +single-table tablespaces. We need to know the space id in each of them so that +we know into which file we should look to check the contents of a page stored +in the doublewrite buffer, also to know where to apply log records where the +space id is != 0. */ + +ulint +fil_load_single_table_tablespaces(void); +/*===================================*/ + /* out: DB_SUCCESS or error number */ +/************************************************************************ +If we need crash recovery, and we have called +fil_load_single_table_tablespaces() and dict_load_single_table_tablespaces(), +we can call this function to print an error message of orphaned .ibd files +for which there is not a data dictionary entry with a matching table name +and space id. */ + +void +fil_print_orphaned_tablespaces(void); +/*================================*/ +/*********************************************************************** +Returns TRUE if a single-table tablespace does not exist in the memory cache, +or is being deleted there. */ + +ibool +fil_tablespace_deleted_or_being_deleted_in_mem( +/*===========================================*/ + /* out: TRUE if does not exist or is being\ + deleted */ + ulint id, /* in: space id */ + ib_longlong version);/* in: tablespace_version should be this; if + you pass -1 as the value of this, then this + parameter is ignored */ +/*********************************************************************** +Returns TRUE if a single-table tablespace exists in the memory cache. */ + +ibool +fil_tablespace_exists_in_mem( +/*=========================*/ + /* out: TRUE if exists */ ulint id); /* in: space id */ /*********************************************************************** -Checks if the pair space, page_no refers to an existing page in a -tablespace file space. */ +Returns TRUE if a matching tablespace exists in the InnoDB tablespace memory +cache. Note that if we have not done a crash recovery at the database startup, +there may be many tablespaces which are not yet in the memory cache. */ ibool -fil_check_adress_in_tablespace( +fil_space_for_table_exists_in_mem( +/*==============================*/ + /* out: TRUE if a matching tablespace + exists in the memory cache */ + ulint id, /* in: space id */ + char* name, /* in: table name in the standard + 'databasename/tablename' format */ + ibool mark_space, /* in: in crash recovery, at database startup + we mark all spaces which have an associated + table in the InnoDB data dictionary, so that + we can print a warning about orphaned + tablespaces */ + ibool print_error_if_does_not_exist); + /* in: print detailed error information to + the .err log if a matching tablespace is + not found from memory */ +/************************************************************************** +Tries to extend a data file by the number of pages given. Fractions of 1 MB +are ignored. The tablespace must be cached in the memory cache. */ + +ibool +fil_extend_last_data_file( +/*======================*/ + /* out: TRUE if success, also if we run + out of disk space we may return TRUE */ + ulint* actual_increase,/* out: number of pages we were able to + extend, here the original size of the file and + the resulting size of the file are rounded + downwards to a full megabyte, and the + difference expressed in pages is returned */ + ulint space_id, /* in: space id */ + ulint size, /* in: current size of the space in pages, as + stored in the fsp header */ + ulint size_increase); /* in: try to extend this many pages */ +/************************************************************************** +Tries to extend a data file so that it would accommodate the number of pages +given. The tablespace must be cached in the memory cache. */ + +ibool +fil_extend_data_file_with_pages( +/*============================*/ + /* out: TRUE if success */ + ulint space_id, /* in: space id, must be != 0 */ + ulint size, /* in: current size of the space in pages, as + stored in the fsp header */ + ulint size_after_extend);/* in: desired size in pages after the + extension, should be less than 4 GB (this + function is primarily intended for increasing + the data file size from < 64 pages to up to + 64 pages) */ +/*********************************************************************** +Tries to reserve free extents in a file space. */ + +ibool +fil_space_reserve_free_extents( /*===========================*/ - /* out: TRUE if the address is meaningful */ - ulint id, /* in: space id */ - ulint page_no);/* in: page number */ + /* out: TRUE if succeed */ + ulint id, /* in: space id */ + ulint n_free_now, /* in: number of free extents now */ + ulint n_to_reserve); /* in: how many one wants to reserve */ /*********************************************************************** -Appends a new file to the chain of files of a space. -File must be closed. */ +Releases free extents in a file space. */ void -fil_node_create( -/*============*/ - char* name, /* in: file name (file must be closed) */ - ulint size, /* in: file size in database blocks, rounded downwards - to an integer */ - ulint id); /* in: space id where to append */ +fil_space_release_free_extents( +/*===========================*/ + ulint id, /* in: space id */ + ulint n_reserved); /* in: how many one reserved */ +/*********************************************************************** +Gets the number of reserved extents. If the database is silent, this number +should be zero. */ + +ulint +fil_space_get_n_reserved_extents( +/*=============================*/ + ulint id); /* in: space id */ /************************************************************************ Reads or writes data. This operation is asynchronous (aio). */ -void +ulint fil_io( /*===*/ + /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED + if we are trying to do i/o on a tablespace + which does not exist */ ulint type, /* in: OS_FILE_READ or OS_FILE_WRITE, ORed to OS_FILE_LOG, if a log i/o and ORed to OS_AIO_SIMULATED_WAKE_LATER @@ -262,9 +474,9 @@ fil_io( ulint byte_offset, /* in: remainder of offset in bytes; in aio this must be divisible by the OS block size */ - ulint len, /* in: how many bytes to read; this must - not cross a file boundary; in aio this must - be a block size multiple */ + ulint len, /* in: how many bytes to read or write; this + must not cross a file boundary; in aio this + must be a block size multiple */ void* buf, /* in/out: buffer where to store read data or from where to write; in aio this must be appropriately aligned */ @@ -272,12 +484,15 @@ fil_io( aio used, else ignored */ /************************************************************************ Reads data from a space to a buffer. Remember that the possible incomplete -blocks at the end of a file are ignored: they are not taken into account when +blocks at the end of file are ignored: they are not taken into account when calculating the byte offset within a space. */ -void +ulint fil_read( /*=====*/ + /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED + if we are trying to do i/o on a tablespace + which does not exist */ ibool sync, /* in: TRUE if synchronous aio is desired */ ulint space_id, /* in: space id */ ulint block_offset, /* in: offset in number of blocks */ @@ -292,12 +507,15 @@ fil_read( aio used, else ignored */ /************************************************************************ Writes data to a space from a buffer. Remember that the possible incomplete -blocks at the end of a file are ignored: they are not taken into account when +blocks at the end of file are ignored: they are not taken into account when calculating the byte offset within a space. */ -void +ulint fil_write( /*======*/ + /* out: DB_SUCCESS, or DB_TABLESPACE_DELETED + if we are trying to do i/o on a tablespace + which does not exist */ ibool sync, /* in: TRUE if synchronous aio is desired */ ulint space_id, /* in: space id */ ulint block_offset, /* in: offset in number of blocks */ @@ -322,7 +540,8 @@ fil_aio_wait( ulint segment); /* in: the number of the segment in the aio array to wait for */ /************************************************************************** -Flushes to disk possible writes cached by the OS. */ +Flushes to disk possible writes cached by the OS. If the space does not exist +or is being dropped, does not do anything. */ void fil_flush( @@ -338,13 +557,21 @@ fil_flush_file_spaces( /*==================*/ ulint purpose); /* in: FIL_TABLESPACE, FIL_LOG */ /********************************************************************** -Checks the consistency of the file system. */ +Checks the consistency of the tablespace cache. */ ibool fil_validate(void); /*==============*/ /* out: TRUE if ok */ /************************************************************************ +Returns TRUE if file address is undefined. */ + +ibool +fil_addr_is_null( +/*=============*/ + /* out: TRUE if undefined */ + fil_addr_t addr); /* in: address */ +/************************************************************************ Accessor functions for a file page */ ulint @@ -368,32 +595,7 @@ fil_page_get_type( /* out: type; NOTE that if the type has not been written to page, the return value not defined */ byte* page); /* in: file page */ -/*********************************************************************** -Tries to reserve free extents in a file space. */ - -ibool -fil_space_reserve_free_extents( -/*===========================*/ - /* out: TRUE if succeed */ - ulint id, /* in: space id */ - ulint n_free_now, /* in: number of free extents now */ - ulint n_to_reserve); /* in: how many one wants to reserve */ -/*********************************************************************** -Releases free extents in a file space. */ -void -fil_space_release_free_extents( -/*===========================*/ - ulint id, /* in: space id */ - ulint n_reserved); /* in: how many one reserved */ -/*********************************************************************** -Gets the number of reserved extents. If the database is silent, this number -should be zero. */ - -ulint -fil_space_get_n_reserved_extents( -/*=============================*/ - ulint id); /* in: space id */ typedef struct fil_space_struct fil_space_t; diff --git a/innobase/include/fsp0fsp.h b/innobase/include/fsp0fsp.h index 3494f336b1e..127e01ef59f 100644 --- a/innobase/include/fsp0fsp.h +++ b/innobase/include/fsp0fsp.h @@ -55,7 +55,7 @@ ulint fsp_header_get_free_limit( /*======================*/ /* out: free limit in megabytes */ - ulint space); /* in: space id */ + ulint space); /* in: space id, must be 0 */ /************************************************************************** Gets the size of the tablespace from the tablespace header. If we do not have an auto-extending data file, this should be equal to the size of the @@ -65,9 +65,27 @@ ulint fsp_header_get_tablespace_size( /*===========================*/ /* out: size in pages */ - ulint space); /* in: space id */ + ulint space); /* in: space id, must be 0 */ +/************************************************************************** +Reads the space id from the first page of a tablespace. */ + +ulint +fsp_header_get_space_id( +/*====================*/ + /* out: space id, ULINT UNDEFINED if error */ + page_t* page); /* in: first page of a tablespace */ /************************************************************************** -Initializes the space header of a new created space. */ +Writes the space id to a tablespace header. This function is used past the +buffer pool when we in fil0fil.c create a new single-table tablespace. */ + +void +fsp_header_write_space_id( +/*======================*/ + page_t* page, /* in: first page in the space */ + ulint space_id); /* in: space id */ +/************************************************************************** +Initializes the space header of a new created space and creates also the +insert buffer tree root if space == 0. */ void fsp_header_init( @@ -117,12 +135,12 @@ fseg_create_general( will belong to the created segment */ ulint byte_offset, /* in: byte offset of the created segment header on the page */ - ibool has_done_reservation, /* in: TRUE if the caller has - already done the reservation for the pages - with fsp_reserve_free_extents (at least 2 extents: - one for the inode and, then there other for the - segment) is no need to do the check for this - individual operation */ + ibool has_done_reservation, /* in: TRUE if the caller has already + done the reservation for the pages with + fsp_reserve_free_extents (at least 2 extents: one for + the inode and the other for the segment) then there is + no need to do the check for this individual + operation */ mtr_t* mtr); /* in: mtr */ /************************************************************************** Calculates the number of pages reserved by a segment, and how many pages are @@ -194,12 +212,21 @@ two types of allocation: when space is scarce, FSP_NORMAL allocations will not succeed, but the latter two allocations will succeed, if possible. The purpose is to avoid dead end where the database is full but the user cannot free any space because these freeing operations temporarily -reserve some space. */ +reserve some space. + +Single-table tablespaces whose size is < 32 pages are a special case. In this +function we would liberally reserve several 64 page extents for every page +split or merge in a B-tree. But we do not want to waste disk space if the table +only occupies < 32 pages. That is why we apply different rules in that special +case, just ensuring that there are 3 free pages available. */ ibool fsp_reserve_free_extents( /*=====================*/ /* out: TRUE if we were able to make the reservation */ + ulint* n_reserved,/* out: number of extents actually reserved; if we + return TRUE and the tablespace size is < 64 pages, + then this can be 0, otherwise it is n_ext */ ulint space, /* in: space id */ ulint n_ext, /* in: number of extents to reserve */ ulint alloc_type,/* in: FSP_NORMAL, FSP_UNDO, or FSP_CLEANING */ @@ -337,8 +364,8 @@ pages: */ #define FSP_FIRST_INODE_PAGE_NO 2 #define FSP_IBUF_HEADER_PAGE_NO 3 #define FSP_IBUF_TREE_ROOT_PAGE_NO 4 - /* The ibuf tree root page number in each - tablespace; its fseg inode is on the page + /* The ibuf tree root page number in + tablespace 0; its fseg inode is on the page number FSP_FIRST_INODE_PAGE_NO */ #define FSP_TRX_SYS_PAGE_NO 5 #define FSP_FIRST_RSEG_PAGE_NO 6 diff --git a/innobase/include/fut0lst.ic b/innobase/include/fut0lst.ic index d2e79cf7640..c0d61833b48 100644 --- a/innobase/include/fut0lst.ic +++ b/innobase/include/fut0lst.ic @@ -23,7 +23,7 @@ Created 11/28/1995 Heikki Tuuri #define FLST_FIRST 4 /* 6-byte address of the first element of the list; undefined if empty list */ #define FLST_LAST (4 + FIL_ADDR_SIZE) /* 6-byte address of the - first element of the list; undefined + last element of the list; undefined if empty list */ /************************************************************************ diff --git a/innobase/include/ibuf0ibuf.h b/innobase/include/ibuf0ibuf.h index a290e90e4db..bf03b06bd28 100644 --- a/innobase/include/ibuf0ibuf.h +++ b/innobase/include/ibuf0ibuf.h @@ -40,6 +40,13 @@ void ibuf_init_at_db_start(void); /*=======================*/ /************************************************************************* +Reads the biggest tablespace id from the high end of the insert buffer +tree and updates the counter in fil_system. */ + +void +ibuf_update_max_tablespace_id(void); +/*===============================*/ +/************************************************************************* Initializes an ibuf bitmap page. */ void @@ -207,8 +214,8 @@ When an index page is read from a disk to the buffer pool, this function inserts to the page the possible index entries buffered in the insert buffer. The entries are deleted from the insert buffer. If the page is not read, but created in the buffer pool, this function deletes its buffered entries from -the insert buffer; note that there can exist entries if the page belonged to -an index which was dropped. */ +the insert buffer; there can exist entries for such a page if the page +belonged to an index which subsequently was dropped. */ void ibuf_merge_or_delete_for_page( @@ -216,7 +223,21 @@ ibuf_merge_or_delete_for_page( page_t* page, /* in: if page has been read from disk, pointer to the page x-latched, else NULL */ ulint space, /* in: space id of the index page */ - ulint page_no);/* in: page number of the index page */ + ulint page_no,/* in: page number of the index page */ + ibool update_ibuf_bitmap);/* in: normally this is set to TRUE, but if + we have deleted or are deleting the tablespace, then we + naturally do not want to update a non-existent bitmap + page */ +/************************************************************************* +Deletes all entries in the insert buffer for a given space id. This is used +in DISCARD TABLESPACE and IMPORT TABLESPACE. +NOTE: this does not update the page free bitmaps in the space. The space will +become CORRUPT when you call this function! */ + +void +ibuf_delete_for_discarded_space( +/*============================*/ + ulint space); /* in: space id */ /************************************************************************* Contracts insert buffer trees by reading pages to the buffer pool. */ @@ -266,6 +287,13 @@ ibuf_count_get( ulint space, /* in: space id */ ulint page_no);/* in: page number */ /********************************************************************** +Looks if the insert buffer is empty. */ + +ibool +ibuf_is_empty(void); +/*===============*/ + /* out: TRUE if empty */ +/********************************************************************** Prints info of ibuf. */ void diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h index 5608ba020b7..49f4597b30c 100644 --- a/innobase/include/lock0lock.h +++ b/innobase/include/lock0lock.h @@ -534,12 +534,12 @@ extern lock_sys_t* lock_sys; #define LOCK_X 5 /* exclusive */ #define LOCK_AUTO_INC 6 /* locks the auto-inc counter of a table in an exclusive mode */ -#define LOCK_MODE_MASK 0xF /* mask used to extract mode from the +#define LOCK_MODE_MASK 0xFUL /* mask used to extract mode from the type_mode field in a lock */ /* Lock types */ #define LOCK_TABLE 16 /* these type values should be so high that */ #define LOCK_REC 32 /* they can be ORed to the lock mode */ -#define LOCK_TYPE_MASK 0xF0 /* mask used to extract lock type from the +#define LOCK_TYPE_MASK 0xF0UL /* mask used to extract lock type from the type_mode field in a lock */ /* Waiting lock flag */ #define LOCK_WAIT 256 /* this wait bit should be so high that diff --git a/innobase/include/log0log.h b/innobase/include/log0log.h index 24ec28a56e6..dc44429d636 100644 --- a/innobase/include/log0log.h +++ b/innobase/include/log0log.h @@ -519,9 +519,9 @@ Peeks the current lsn. */ ibool log_peek_lsn( /*=========*/ - /* out: TRUE if success, FALSE if could not get the - log system mutex */ - dulint* lsn); /* out: if returns TRUE, current lsn is here */ + /* out: TRUE if success, FALSE if could not get the + log system mutex */ + dulint* lsn); /* out: if returns TRUE, current lsn is here */ /************************************************************************** Refreshes the statistics used to print per-second averages. */ @@ -549,7 +549,7 @@ extern log_t* log_sys; highest bit is set to 1 if this is the first log block in a log flush write segment */ -#define LOG_BLOCK_FLUSH_BIT_MASK 0x80000000 +#define LOG_BLOCK_FLUSH_BIT_MASK 0x80000000UL /* mask used to get the highest bit in the preceding field */ #define LOG_BLOCK_HDR_DATA_LEN 4 /* number of bytes of log written to @@ -600,12 +600,18 @@ extern log_t* log_sys; #define LOG_CHECKPOINT_CHECKSUM_1 LOG_CHECKPOINT_ARRAY_END #define LOG_CHECKPOINT_CHECKSUM_2 (4 + LOG_CHECKPOINT_ARRAY_END) #define LOG_CHECKPOINT_FSP_FREE_LIMIT (8 + LOG_CHECKPOINT_ARRAY_END) - /* current fsp free limit in the - tablespace, in units of one megabyte */ + /* current fsp free limit in + tablespace 0, in units of one + megabyte; this information is only used + by ibbackup to decide if it can + truncate unused ends of + non-auto-extending data files in space + 0 */ #define LOG_CHECKPOINT_FSP_MAGIC_N (12 + LOG_CHECKPOINT_ARRAY_END) /* this magic number tells if the checkpoint contains the above field: - the field was added to InnoDB-3.23.50 */ + the field was added to + InnoDB-3.23.50 */ #define LOG_CHECKPOINT_SIZE (16 + LOG_CHECKPOINT_ARRAY_END) #define LOG_CHECKPOINT_FSP_MAGIC_N_VAL 1441231243 @@ -794,11 +800,11 @@ struct log_struct{ called */ /* Fields involved in checkpoints */ - ulint log_group_capacity; /* capacity of the log group; if - the checkpoint age exceeds this, it is - a serious error because it is possible - we will then overwrite log and spoil - crash recovery */ + ulint log_group_capacity; /* capacity of the log group; if + the checkpoint age exceeds this, it is + a serious error because it is possible + we will then overwrite log and spoil + crash recovery */ ulint max_modified_age_async; /* when this recommended value for lsn - buf_pool_get_oldest_modification() @@ -840,7 +846,8 @@ struct log_struct{ /* Fields involved in archiving */ ulint archiving_state;/* LOG_ARCH_ON, LOG_ARCH_STOPPING LOG_ARCH_STOPPED, LOG_ARCH_OFF */ - dulint archived_lsn; /* archiving has advanced to this lsn */ + dulint archived_lsn; /* archiving has advanced to this + lsn */ ulint max_archived_lsn_age_async; /* recommended maximum age of archived_lsn, before we start diff --git a/innobase/include/log0log.ic b/innobase/include/log0log.ic index 8de239df0bd..7ae7e859032 100644 --- a/innobase/include/log0log.ic +++ b/innobase/include/log0log.ic @@ -182,9 +182,9 @@ log_block_convert_lsn_to_no( no = ut_dulint_get_low(lsn) / OS_FILE_LOG_BLOCK_SIZE; no += (ut_dulint_get_high(lsn) % OS_FILE_LOG_BLOCK_SIZE) - * 2 * (0x80000000 / OS_FILE_LOG_BLOCK_SIZE); + * 2 * (0x80000000UL / OS_FILE_LOG_BLOCK_SIZE); - no = no & 0x3FFFFFFF; + no = no & 0x3FFFFFFFUL; return(no + 1); } @@ -206,7 +206,7 @@ log_block_calc_checksum( sh = 0; for (i = 0; i < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE; i++) { - sum = sum & 0x7FFFFFFF; + sum = sum & 0x7FFFFFFFUL; sum += (((ulint)(*(block + i))) << sh) + (ulint)(*(block + i)); sh++; if (sh > 24) { @@ -346,7 +346,7 @@ log_reserve_and_write_fast( #ifdef UNIV_LOG_DEBUG log_check_log_recs(log->buf + log->old_buf_free, - log->buf_free - log->old_buf_free, log->old_lsn); + log->buf_free - log->old_buf_free, log->old_lsn); #endif return(lsn); } diff --git a/innobase/include/log0recv.h b/innobase/include/log0recv.h index 7b27ee34541..0a4f56816a1 100644 --- a/innobase/include/log0recv.h +++ b/innobase/include/log0recv.h @@ -25,8 +25,8 @@ recv_read_cp_info_for_backup( byte* hdr, /* in: buffer containing the log group header */ dulint* lsn, /* out: checkpoint lsn */ ulint* offset, /* out: checkpoint offset in the log group */ - ulint* fsp_limit,/* out: fsp limit, 1000000000 if the database - is running with < version 3.23.50 of InnoDB */ + ulint* fsp_limit,/* out: fsp limit of space 0, 1000000000 if the + database is running with < version 3.23.50 of InnoDB */ dulint* cp_no, /* out: checkpoint number */ dulint* first_header_lsn); /* out: lsn of of the start of the first log file */ @@ -334,7 +334,6 @@ extern ibool recv_no_ibuf_operations; extern ibool recv_needed_recovery; extern ibool recv_lsn_checks_on; - extern ibool recv_is_making_a_backup; extern ulint recv_max_parsed_page_no; diff --git a/innobase/include/mach0data.ic b/innobase/include/mach0data.ic index 1d6badd035b..0934c27d9f4 100644 --- a/innobase/include/mach0data.ic +++ b/innobase/include/mach0data.ic @@ -17,7 +17,7 @@ mach_write_to_1( ulint n) /* in: ulint integer to be stored, >= 0, < 256 */ { ut_ad(b); - ut_ad(n <= 0xFF); + ut_ad(n <= 0xFFUL); b[0] = (byte)n; } @@ -46,7 +46,7 @@ mach_write_to_2( ulint n) /* in: ulint integer to be stored */ { ut_ad(b); - ut_ad(n <= 0xFFFF); + ut_ad(n <= 0xFFFFUL); b[0] = (byte)(n >> 8); b[1] = (byte)(n); @@ -79,7 +79,7 @@ mach_write_to_3( ulint n) /* in: ulint integer to be stored */ { ut_ad(b); - ut_ad(n <= 0xFFFFFF); + ut_ad(n <= 0xFFFFFFUL); b[0] = (byte)(n >> 16); b[1] = (byte)(n >> 8); @@ -222,20 +222,20 @@ mach_write_compressed( { ut_ad(b); - if (n < 0x80) { + if (n < 0x80UL) { mach_write_to_1(b, n); return(1); - } else if (n < 0x4000) { - mach_write_to_2(b, n | 0x8000); + } else if (n < 0x4000UL) { + mach_write_to_2(b, n | 0x8000UL); return(2); - } else if (n < 0x200000) { - mach_write_to_3(b, n | 0xC00000); + } else if (n < 0x200000UL) { + mach_write_to_3(b, n | 0xC00000UL); return(3); - } else if (n < 0x10000000) { - mach_write_to_4(b, n | 0xE0000000); + } else if (n < 0x10000000UL) { + mach_write_to_4(b, n | 0xE0000000UL); return(4); } else { - mach_write_to_1(b, 0xF0); + mach_write_to_1(b, 0xF0UL); mach_write_to_4(b + 1, n); return(5); } @@ -250,13 +250,13 @@ mach_get_compressed_size( /* out: compressed size in bytes */ ulint n) /* in: ulint integer (< 2^32) to be stored */ { - if (n < 0x80) { + if (n < 0x80UL) { return(1); - } else if (n < 0x4000) { + } else if (n < 0x4000UL) { return(2); - } else if (n < 0x200000) { + } else if (n < 0x200000UL) { return(3); - } else if (n < 0x10000000) { + } else if (n < 0x10000000UL) { return(4); } else { return(5); @@ -278,16 +278,16 @@ mach_read_compressed( flag = mach_read_from_1(b); - if (flag < 0x80) { + if (flag < 0x80UL) { return(flag); - } else if (flag < 0xC0) { - return(mach_read_from_2(b) & 0x7FFF); - } else if (flag < 0xE0) { - return(mach_read_from_3(b) & 0x3FFFFF); - } else if (flag < 0xF0) { - return(mach_read_from_4(b) & 0x1FFFFFFF); + } else if (flag < 0xC0UL) { + return(mach_read_from_2(b) & 0x7FFFUL); + } else if (flag < 0xE0UL) { + return(mach_read_from_3(b) & 0x3FFFFFUL); + } else if (flag < 0xF0UL) { + return(mach_read_from_4(b) & 0x1FFFFFFFUL); } else { - ut_ad(flag == 0xF0); + ut_ad(flag == 0xF0UL); return(mach_read_from_4(b + 1)); } } @@ -477,7 +477,7 @@ mach_dulint_write_much_compressed( return(mach_write_compressed(b, ut_dulint_get_low(n))); } - *b = 0xFF; + *b = (byte)0xFF; size = 1 + mach_write_compressed(b + 1, ut_dulint_get_high(n)); size += mach_write_compressed(b + size, ut_dulint_get_low(n)); @@ -517,7 +517,7 @@ mach_dulint_read_much_compressed( ut_ad(b); - if (*b != 0xFF) { + if (*b != (byte)0xFF) { high = 0; size = 0; } else { @@ -717,11 +717,10 @@ mach_write_to_2_little_endian( { ut_ad(n < 256 * 256); - *dest = (byte)(n & 0xFF); + *dest = (byte)(n & 0xFFUL); n = n >> 8; dest++; - *dest = (byte)(n & 0xFF); + *dest = (byte)(n & 0xFFUL); } - diff --git a/innobase/include/mtr0log.ic b/innobase/include/mtr0log.ic index 0598f1a9536..c2150660794 100644 --- a/innobase/include/mtr0log.ic +++ b/innobase/include/mtr0log.ic @@ -163,13 +163,6 @@ mlog_write_initial_log_record_fast( space = buf_block_get_space(block); offset = buf_block_get_page_no(block); - if (space != 0 || offset > 0x8FFFFFFF) { - fprintf(stderr, - "InnoDB: error: buffer page pointer %lx has nonsensical space id %lu\n" - "InnoDB: or page no %lu\n", (ulint)ptr, space, offset); - ut_a(0); - } - mach_write_to_1(log_ptr, type); log_ptr++; log_ptr += mach_write_compressed(log_ptr, space); diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index 5c52f0e92bf..9f1c18829c4 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -11,9 +11,11 @@ Created 10/21/1995 Heikki Tuuri #include "univ.i" +#ifndef __WIN__ +#include <dirent.h> +#include <sys/stat.h> +#endif -/* If the following is set to TRUE, we do not call os_file_flush in every -os_file_write */ extern ibool os_do_not_call_flush_at_each_write; extern ibool os_has_said_disk_full; extern ibool os_aio_print_debug; @@ -57,6 +59,7 @@ log. */ #define OS_FILE_OPEN 51 #define OS_FILE_CREATE 52 #define OS_FILE_OVERWRITE 53 +#define OS_FILE_OPEN_RAW 54 #define OS_FILE_READ_ONLY 333 #define OS_FILE_READ_WRITE 444 @@ -117,6 +120,36 @@ extern ulint os_n_file_reads; extern ulint os_n_file_writes; extern ulint os_n_fsyncs; +/* File types for directory entry data type */ + +enum os_file_type_enum{ + OS_FILE_TYPE_UNKNOWN = 0, + OS_FILE_TYPE_FILE, /* regular file */ + OS_FILE_TYPE_DIR, /* directory */ + OS_FILE_TYPE_LINK /* symbolic link */ +}; +typedef enum os_file_type_enum os_file_type_t; + +/* Maximum path string length in bytes when referring to tables with in the +'./databasename/tablename.ibd' path format; we can allocate at least 2 buffers +of this size from the thread stack; that is why this should not be made much +bigger than 4000 bytes */ +#define OS_FILE_MAX_PATH 4000 + +/* Struct used in fetching information of a file in a directory */ +typedef struct os_file_stat_struct os_file_stat_t; +struct os_file_stat_struct{ + char name[OS_FILE_MAX_PATH]; /* path to a file */ + os_file_type_t type; /* file type */ + ib_longlong size; /* file size */ +}; + +#ifdef __WIN___ +typedef HANDLE os_file_dir_t; /* directory stream */ +#else +typedef DIR* os_file_dir_t; /* directory stream */ +#endif + /*************************************************************************** Gets the operating system version. Currently works only on Windows. */ @@ -130,6 +163,42 @@ Creates the seek mutexes used in positioned reads and writes. */ void os_io_init_simple(void); /*===================*/ +/*************************************************************************** +The os_file_opendir() function opens a directory stream corresponding to the +directory named by the dirname argument. The directory stream is positioned +at the first entry. In both Unix and Windows we automatically skip the '.' +and '..' items at the start of the directory listing. */ + +os_file_dir_t +os_file_opendir( +/*============*/ + /* out: directory stream, NULL if error */ + char* dirname, /* in: directory name; it must not contain + a trailing '\' or '/' */ + ibool error_is_fatal);/* in: TRUE if we should treat an error as a + fatal error; if we try to open symlinks then + we do not wish a fatal error if it happens + not to be a directory */ +/*************************************************************************** +Closes a directory stream. */ + +int +os_file_closedir( +/*=============*/ + /* out: 0 if success, -1 if failure */ + os_file_dir_t dir); /* in: directory stream */ +/*************************************************************************** +This function returns information of the next file in the directory. We jump +over the '.' and '..' entries in the directory. */ + +int +os_file_readdir_next_file( +/*======================*/ + /* out: 0 if ok, -1 if error, 1 if at the end + of the directory */ + char* dirname,/* in: directory name or path */ + os_file_dir_t dir, /* in: directory stream */ + os_file_stat_t* info); /* in/out: buffer where the info is returned */ /******************************************************************** A simple function to open or create a file. */ @@ -173,7 +242,9 @@ os_file_create( ulint create_mode,/* in: OS_FILE_OPEN if an existing file is opened (if does not exist, error), or OS_FILE_CREATE if a new file is created (if exists, error), OS_FILE_OVERWRITE - if a new file is created or an old overwritten */ + if a new file is created or an old overwritten; + OS_FILE_OPEN_RAW, if a raw device or disk partition + should be opened */ ulint purpose,/* in: OS_FILE_AIO, if asynchronous, non-buffered i/o is desired, OS_FILE_NORMAL, if any normal file; NOTE that it also depends on type, os_aio_.. and srv_.. @@ -183,6 +254,25 @@ os_file_create( ulint type, /* in: OS_DATA_FILE or OS_LOG_FILE */ ibool* success);/* out: TRUE if succeed, FALSE if error */ /*************************************************************************** +Deletes a file. The file has to be closed before calling this. */ + +ibool +os_file_delete( +/*===========*/ + /* out: TRUE if success */ + char* name); /* in: file path as a null-terminated string */ +/*************************************************************************** +Renames a file (can also move it to another directory). It is safest that the +file is closed before calling this function. */ + +ibool +os_file_rename( +/*===========*/ + /* out: TRUE if success */ + char* oldpath, /* in: old file path as a null-terminated + string */ + char* newpath); /* in: new file path */ +/*************************************************************************** Closes a file handle. In case of error, error number can be retrieved with os_file_get_last_error. */ @@ -238,9 +328,12 @@ overwrite the error number). If the number is not known to this program, the OS error number + 100 is returned. */ ulint -os_file_get_last_error(void); -/*========================*/ - /* out: error number, or OS error number + 100 */ +os_file_get_last_error( +/*===================*/ + /* out: error number, or OS error + number + 100 */ + ibool report_all_errors); /* in: TRUE if we want an error message + printed of all errors */ /*********************************************************************** Requests a synchronous read operation. */ diff --git a/innobase/include/page0page.h b/innobase/include/page0page.h index 04f771c3abd..969313614e3 100644 --- a/innobase/include/page0page.h +++ b/innobase/include/page0page.h @@ -596,7 +596,8 @@ byte* page_parse_delete_rec_list( /*=======================*/ /* out: end of log record or NULL */ - byte type, /* in: MLOG_LIST_END_DELETE or MLOG_LIST_START_DELETE */ + byte type, /* in: MLOG_LIST_END_DELETE or + MLOG_LIST_START_DELETE */ byte* ptr, /* in: buffer */ byte* end_ptr,/* in: buffer end */ page_t* page, /* in: page or NULL */ diff --git a/innobase/include/que0types.h b/innobase/include/que0types.h index c7ce09db40b..e59c2313a5a 100644 --- a/innobase/include/que0types.h +++ b/innobase/include/que0types.h @@ -36,7 +36,8 @@ struct que_common_struct{ if the buffer has been allocated dynamically: if this field is != 0, and the node is a symbol node or a function node, then we - have to free the data field in val explicitly */ + have to free the data field in val + explicitly */ }; #endif diff --git a/innobase/include/rem0rec.h b/innobase/include/rem0rec.h index b28f39925c1..ebdd3c1ac81 100644 --- a/innobase/include/rem0rec.h +++ b/innobase/include/rem0rec.h @@ -21,7 +21,7 @@ Created 5/30/1994 Heikki Tuuri /* Flag denoting the predefined minimum record: this bit is ORed in the 4 info bits of a record */ -#define REC_INFO_MIN_REC_FLAG 0x10 +#define REC_INFO_MIN_REC_FLAG 0x10UL /* Number of extra bytes in a record, in addition to the data and the offsets */ @@ -406,8 +406,8 @@ rec_sprintf( /* Maximum lengths for the data in a physical record if the offsets are given in one byte (resp. two byte) format. */ -#define REC_1BYTE_OFFS_LIMIT 0x7F -#define REC_2BYTE_OFFS_LIMIT 0x7FFF +#define REC_1BYTE_OFFS_LIMIT 0x7FUL +#define REC_2BYTE_OFFS_LIMIT 0x7FFFUL /* The data size of record must be smaller than this because we reserve two upmost bits in a two byte offset for special purposes */ diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic index 9dfd4faeec8..f4acd8547db 100644 --- a/innobase/include/rem0rec.ic +++ b/innobase/include/rem0rec.ic @@ -29,41 +29,41 @@ significant bytes and bits are written below less significant. and the shift needed to obtain each bit-field of the record. */ #define REC_NEXT 2 -#define REC_NEXT_MASK 0xFFFF +#define REC_NEXT_MASK 0xFFFFUL #define REC_NEXT_SHIFT 0 #define REC_SHORT 3 /* This is single byte bit-field */ -#define REC_SHORT_MASK 0x1 +#define REC_SHORT_MASK 0x1UL #define REC_SHORT_SHIFT 0 #define REC_N_FIELDS 4 -#define REC_N_FIELDS_MASK 0x7FE +#define REC_N_FIELDS_MASK 0x7FEUL #define REC_N_FIELDS_SHIFT 1 #define REC_HEAP_NO 5 -#define REC_HEAP_NO_MASK 0xFFF8 +#define REC_HEAP_NO_MASK 0xFFF8UL #define REC_HEAP_NO_SHIFT 3 #define REC_N_OWNED 6 /* This is single byte bit-field */ -#define REC_N_OWNED_MASK 0xF +#define REC_N_OWNED_MASK 0xFUL #define REC_N_OWNED_SHIFT 0 -#define REC_INFO_BITS_MASK 0xF0 +#define REC_INFO_BITS_MASK 0xF0UL #define REC_INFO_BITS_SHIFT 0 /* The deleted flag in info bits */ -#define REC_INFO_DELETED_FLAG 0x20 /* when bit is set to 1, it means the +#define REC_INFO_DELETED_FLAG 0x20UL /* when bit is set to 1, it means the record has been delete marked */ /* The following masks are used to filter the SQL null bit from one-byte and two-byte offsets */ -#define REC_1BYTE_SQL_NULL_MASK 0x80 -#define REC_2BYTE_SQL_NULL_MASK 0x8000 +#define REC_1BYTE_SQL_NULL_MASK 0x80UL +#define REC_2BYTE_SQL_NULL_MASK 0x8000UL /* In a 2-byte offset the second most significant bit denotes a field stored to another page: */ -#define REC_2BYTE_EXTERN_MASK 0x4000 +#define REC_2BYTE_EXTERN_MASK 0x4000UL /**************************************************************** Return field length or UNIV_SQL_NULL. */ @@ -133,7 +133,7 @@ rec_set_bit_field_1( ut_ad(rec); ut_ad(offs <= REC_N_EXTRA_BYTES); ut_ad(mask); - ut_ad(mask <= 0xFF); + ut_ad(mask <= 0xFFUL); ut_ad(((mask >> shift) << shift) == mask); ut_ad(((val << shift) & mask) == (val << shift)); @@ -172,8 +172,8 @@ rec_set_bit_field_2( { ut_ad(rec); ut_ad(offs <= REC_N_EXTRA_BYTES); - ut_ad(mask > 0xFF); - ut_ad(mask <= 0xFFFF); + ut_ad(mask > 0xFFUL); + ut_ad(mask <= 0xFFFFUL); ut_ad((mask >> shift) & 1); ut_ad(0 == ((mask >> shift) & ((mask >> shift) + 1))); ut_ad(((mask >> shift) << shift) == mask); @@ -188,8 +188,8 @@ rec_set_bit_field_2( + (REC_N_FIELDS_MASK << (8 * (REC_N_FIELDS - 4))) + (REC_HEAP_NO_MASK << (8 * (REC_HEAP_NO - 4))) + (REC_N_OWNED_MASK << (8 * (REC_N_OWNED - 3))) - + (REC_INFO_BITS_MASK << (8 * (REC_INFO_BITS - 3)))); - if (m != ut_dbg_zero + 0xFFFFFFFF) { + + (REC_INFO_BITS_MASK << (8 * (REC_INFO_BITS - 3)))); + if (m != ut_dbg_zero + 0xFFFFFFFFUL) { printf("Sum of masks %lx\n", m); ut_error; } diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index 87643e87a68..094b95e68d3 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -17,6 +17,8 @@ Created 10/10/1995 Heikki Tuuri #include "que0types.h" #include "trx0types.h" +extern char* srv_main_thread_op_info; + /* Buffer which can be used in printing fatal error messages */ extern char srv_fatal_errbuf[]; @@ -36,6 +38,8 @@ extern ibool srv_lower_case_table_names; extern char* srv_data_home; extern char* srv_arch_dir; +extern ibool srv_file_per_table; + extern ulint srv_n_data_files; extern char** srv_data_file_names; extern ulint* srv_data_file_sizes; @@ -76,6 +80,8 @@ extern char* srv_file_flush_method_str; extern ulint srv_unix_file_flush_method; extern ulint srv_win_file_flush_method; +extern ulint srv_max_n_open_files; + extern ulint srv_max_dirty_pages_pct; extern ulint srv_force_recovery; diff --git a/innobase/include/srv0start.h b/innobase/include/srv0start.h index 8d2c3fa12c5..97a59fd14c7 100644 --- a/innobase/include/srv0start.h +++ b/innobase/include/srv0start.h @@ -11,6 +11,7 @@ Created 10/10/1995 Heikki Tuuri #define srv0start_h #include "univ.i" +#include "ut0byte.h" /************************************************************************* Normalizes a directory path for Windows: converts slashes to backslashes. */ @@ -79,12 +80,17 @@ innobase_shutdown_for_mysql(void); /*=============================*/ /* out: DB_SUCCESS or error code */ +extern dulint srv_shutdown_lsn; +extern dulint srv_start_lsn; + extern ulint srv_sizeof_trx_t_in_ha_innodb_cc; extern ibool srv_is_being_started; extern ibool srv_startup_is_before_trx_rollback_phase; extern ibool srv_is_being_shut_down; +extern ibool srv_start_raw_disk_in_use; + /* At a shutdown the value first climbs from 0 to SRV_SHUTDOWN_CLEANUP and then to SRV_SHUTDOWN_LAST_PHASE, and so on */ @@ -94,4 +100,7 @@ extern ulint srv_shutdown_state; #define SRV_SHUTDOWN_LAST_PHASE 2 #define SRV_SHUTDOWN_EXIT_THREADS 3 +/* Log 'spaces' have id's >= this */ +#define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0UL + #endif diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h index 320f8faf12d..330b6b77b08 100644 --- a/innobase/include/sync0sync.h +++ b/innobase/include/sync0sync.h @@ -381,8 +381,8 @@ or row lock! */ #define SYNC_IBUF_HEADER 914 #define SYNC_IBUF_PESS_INSERT_MUTEX 912 #define SYNC_IBUF_MUTEX 910 /* ibuf mutex is really below - SYNC_FSP_PAGE: we assign value this - high only to get the program to pass + SYNC_FSP_PAGE: we assign a value this + high only to make the program to pass the debug checks */ /*-------------------------------*/ #define SYNC_INDEX_TREE 900 @@ -401,7 +401,7 @@ or row lock! */ #define SYNC_FSP_PAGE 395 /*------------------------------------- Insert buffer headers */ /*------------------------------------- ibuf_mutex */ -/*------------------------------------- Insert buffer trees */ +/*------------------------------------- Insert buffer tree */ #define SYNC_IBUF_BITMAP_MUTEX 351 #define SYNC_IBUF_BITMAP 350 /*-------------------------------*/ diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h index a54a6424a4f..0005c4a1711 100644 --- a/innobase/include/trx0sys.h +++ b/innobase/include/trx0sys.h @@ -37,21 +37,35 @@ extern trx_sys_t* trx_sys; /* Doublewrite system */ extern trx_doublewrite_t* trx_doublewrite; +extern ibool trx_doublewrite_must_reset_space_ids; +extern ibool trx_sys_multiple_tablespace_format; /******************************************************************** -Creates the doublewrite buffer at a database start. The header of the +Creates the doublewrite buffer to a new InnoDB installation. The header of the doublewrite buffer is placed on the trx system header page. */ void trx_sys_create_doublewrite_buf(void); /*================================*/ /******************************************************************** -At a database startup uses a possible doublewrite buffer to restore +At a database startup initializes the doublewrite buffer memory structure if +we already have a doublewrite buffer created in the data files. If we are +upgrading to an InnoDB version which supports multiple tablespaces, then this +function performs the necessary update operations. If we are in a crash +recovery, this function uses a possible doublewrite buffer to restore half-written pages in the data files. */ void -trx_sys_doublewrite_restore_corrupt_pages(void); -/*===========================================*/ +trx_sys_doublewrite_init_or_restore_pages( +/*======================================*/ + ibool restore_corrupt_pages); +/******************************************************************** +Marks the trx sys header when we have successfully upgraded to the >= 4.1.x +multiple tablespace format. */ + +void +trx_sys_mark_upgraded_to_multiple_tablespaces(void); +/*===============================================*/ /******************************************************************** Determines if a page number is located inside the doublewrite buffer. */ @@ -354,8 +368,17 @@ this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */ sys header is half-written to disk, we still may be able to recover the information */ +#define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE) + /* If this is not yet set to + .._N, we must reset the + doublewrite buffer, because + starting from 4.1.x the space + id of a data page is stored to + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_NO */ /*-------------------------------------------------------------*/ #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855 +#define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386 + #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE diff --git a/innobase/include/univ.i b/innobase/include/univ.i index 4854e5a7b78..463f7e5d04d 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -88,10 +88,9 @@ memory is read outside the allocated blocks. */ /* #define UNIV_DEBUG -#define UNIV_SYNC_DEBUG #define UNIV_MEM_DEBUG - #define UNIV_IBUF_DEBUG +#define UNIV_SYNC_DEBUG #define UNIV_SEARCH_DEBUG #define UNIV_SYNC_PERF_STAT #define UNIV_SEARCH_PERF_STAT diff --git a/innobase/include/ut0byte.h b/innobase/include/ut0byte.h index 4fb45221899..4274956421e 100644 --- a/innobase/include/ut0byte.h +++ b/innobase/include/ut0byte.h @@ -152,7 +152,7 @@ ut_dulint_align_up( Increments a dulint variable by 1. */ #define UT_DULINT_INC(D)\ {\ - if ((D).low == 0xFFFFFFFF) {\ + if ((D).low == 0xFFFFFFFFUL) {\ (D).high = (D).high + 1;\ (D).low = 0;\ } else {\ diff --git a/innobase/include/ut0byte.ic b/innobase/include/ut0byte.ic index f0df9cc35a3..5a70dcf12a8 100644 --- a/innobase/include/ut0byte.ic +++ b/innobase/include/ut0byte.ic @@ -152,13 +152,13 @@ ut_dulint_add( dulint a, /* in: dulint */ ulint b) /* in: ulint */ { - if (0xFFFFFFFF - b >= a.low) { + if (0xFFFFFFFFUL - b >= a.low) { a.low += b; return(a); } - a.low = a.low - (0xFFFFFFFF - b) - 1; + a.low = a.low - (0xFFFFFFFFUL - b) - 1; a.high++; @@ -183,7 +183,7 @@ ut_dulint_subtract( b -= a.low + 1; - a.low = 0xFFFFFFFF - b; + a.low = 0xFFFFFFFFUL - b; ut_ad(a.high > 0); @@ -214,7 +214,7 @@ ut_dulint_minus( ut_ad(a.high == b.high + 1); - diff = (ulint)(0xFFFFFFFF - b.low); + diff = (ulint)(0xFFFFFFFFUL - b.low); diff += 1 + a.low; ut_ad(diff > a.low); diff --git a/innobase/include/ut0ut.ic b/innobase/include/ut0ut.ic index 9d7dd283f29..9a0ef1c0d5b 100644 --- a/innobase/include/ut0ut.ic +++ b/innobase/include/ut0ut.ic @@ -110,7 +110,7 @@ ut_2pow_remainder( ulint n, /* in: number to be divided */ ulint m) /* in: divisor; power of 2 */ { - ut_ad(0x80000000 % m == 0); + ut_ad(0x80000000UL % m == 0); return(n & (m - 1)); } @@ -125,7 +125,7 @@ ut_2pow_round( ulint n, /* in: number to be rounded */ ulint m) /* in: divisor; power of 2 */ { - ut_ad(0x80000000 % m == 0); + ut_ad(0x80000000UL % m == 0); return(n & ~(m - 1)); } |