diff options
Diffstat (limited to 'innobase/include')
-rw-r--r-- | innobase/include/btr0btr.h | 13 | ||||
-rw-r--r-- | innobase/include/btr0pcur.h | 8 | ||||
-rw-r--r-- | innobase/include/btr0pcur.ic | 18 | ||||
-rw-r--r-- | innobase/include/buf0buf.h | 17 | ||||
-rw-r--r-- | innobase/include/db0err.h | 3 | ||||
-rw-r--r-- | innobase/include/dict0dict.h | 14 | ||||
-rw-r--r-- | innobase/include/fil0fil.h | 2 | ||||
-rw-r--r-- | innobase/include/lock0lock.h | 48 | ||||
-rw-r--r-- | innobase/include/log0recv.h | 1 | ||||
-rw-r--r-- | innobase/include/os0file.h | 3 | ||||
-rw-r--r-- | innobase/include/os0proc.h | 9 | ||||
-rw-r--r-- | innobase/include/os0thread.h | 7 | ||||
-rw-r--r-- | innobase/include/page0cur.h | 7 | ||||
-rw-r--r-- | innobase/include/page0page.h | 10 | ||||
-rw-r--r-- | innobase/include/que0que.h | 8 | ||||
-rw-r--r-- | innobase/include/read0read.h | 8 | ||||
-rw-r--r-- | innobase/include/rem0rec.h | 12 | ||||
-rw-r--r-- | innobase/include/rem0rec.ic | 18 | ||||
-rw-r--r-- | innobase/include/row0mysql.h | 43 | ||||
-rw-r--r-- | innobase/include/srv0srv.h | 33 | ||||
-rw-r--r-- | innobase/include/srv0start.h | 2 | ||||
-rw-r--r-- | innobase/include/sync0rw.h | 3 | ||||
-rw-r--r-- | innobase/include/sync0sync.h | 6 | ||||
-rw-r--r-- | innobase/include/trx0purge.h | 3 | ||||
-rw-r--r-- | innobase/include/trx0trx.h | 116 |
25 files changed, 324 insertions, 88 deletions
diff --git a/innobase/include/btr0btr.h b/innobase/include/btr0btr.h index f66ad3639d4..3cd44ab5175 100644 --- a/innobase/include/btr0btr.h +++ b/innobase/include/btr0btr.h @@ -399,6 +399,19 @@ btr_print_tree( dict_tree_t* tree, /* in: tree */ ulint width); /* in: print this many entries from start and end */ +/**************************************************************** +Checks the size and number of fields in a record based on the definition of +the index. */ + +ibool +btr_index_rec_validate( +/*====================*/ + /* out: TRUE if ok */ + rec_t* rec, /* in: index record */ + dict_index_t* index, /* in: index */ + ibool dump_on_error); /* in: TRUE if the function + should print hex dump of record + and page on error */ /****************************************************************** Checks the consistency of an index tree. */ diff --git a/innobase/include/btr0pcur.h b/innobase/include/btr0pcur.h index 05b55e4491d..9d07dd0de18 100644 --- a/innobase/include/btr0pcur.h +++ b/innobase/include/btr0pcur.h @@ -298,6 +298,14 @@ btr_pcur_move_to_prev( function may release the page latch */ mtr_t* mtr); /* in: mtr */ /************************************************************* +Moves the persistent cursor to the last record on the same page. */ +UNIV_INLINE +void +btr_pcur_move_to_last_on_page( +/*==========================*/ + btr_pcur_t* cursor, /* in: persistent cursor */ + mtr_t* mtr); /* in: mtr */ +/************************************************************* Moves the persistent cursor to the next user record in the tree. If no user records are left, the cursor ends up 'after last in tree'. */ UNIV_INLINE diff --git a/innobase/include/btr0pcur.ic b/innobase/include/btr0pcur.ic index a60140e4aa9..a1db2cc52dd 100644 --- a/innobase/include/btr0pcur.ic +++ b/innobase/include/btr0pcur.ic @@ -285,6 +285,24 @@ btr_pcur_move_to_prev_on_page( } /************************************************************* +Moves the persistent cursor to the last record on the same page. */ +UNIV_INLINE +void +btr_pcur_move_to_last_on_page( +/*==========================*/ + btr_pcur_t* cursor, /* in: persistent cursor */ + mtr_t* mtr) /* in: mtr */ +{ + UT_NOT_USED(mtr); + ut_ad(cursor->latch_mode != BTR_NO_LATCHES); + + page_cur_set_after_last(buf_frame_align(btr_pcur_get_rec(cursor)), + btr_pcur_get_page_cur(cursor)); + + cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; +} + +/************************************************************* Moves the persistent cursor to the next user record in the tree. If no user records are left, the cursor ends up 'after last in tree'. */ UNIV_INLINE diff --git a/innobase/include/buf0buf.h b/innobase/include/buf0buf.h index 591c0ec54ab..f76c437bd1d 100644 --- a/innobase/include/buf0buf.h +++ b/innobase/include/buf0buf.h @@ -274,6 +274,15 @@ buf_page_peek_block( ulint space, /* in: space id */ ulint offset);/* in: page number */ /************************************************************************ +Resets the check_index_page_at_flush field of a page if found in the buffer +pool. */ + +void +buf_reset_check_index_page_at_flush( +/*================================*/ + ulint space, /* in: space id */ + ulint offset);/* in: page number */ +/************************************************************************ Sets file_page_was_freed TRUE if the page is found in the buffer pool. This function should be called when we free a file page and want the debug version to check that it is not accessed any more unless @@ -648,6 +657,14 @@ struct buf_block_struct{ then it can wait for this rw-lock */ buf_block_t* hash; /* node used in chaining to the page hash table */ + ibool check_index_page_at_flush; + /* TRUE if we know that this is + an index page, and want the database + to check its consistency before flush; + note that there may be pages in the + buffer pool which are index pages, + but this flag is not set because + we do not keep track of all pages */ /* 2. Page flushing fields */ UT_LIST_NODE_T(buf_block_t) flush_list; diff --git a/innobase/include/db0err.h b/innobase/include/db0err.h index ddfbd5b7862..86b79b65bf2 100644 --- a/innobase/include/db0err.h +++ b/innobase/include/db0err.h @@ -41,7 +41,8 @@ Created 5/24/1996 Heikki Tuuri which is referenced */ #define DB_CANNOT_ADD_CONSTRAINT 38 /* adding a foreign key constraint to a table failed */ - +#define DB_CORRUPTION 39 /* data structure corruption noticed */ + /* The following are partial failure codes */ #define DB_FAIL 1000 #define DB_OVERFLOW 1001 diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index dd92c5aa467..b5e6e04a1de 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -26,6 +26,18 @@ Created 1/8/1996 Heikki Tuuri #include "ut0byte.h" #include "trx0types.h" +/************************************************************************* +Accepts a specified string. Comparisons are case-insensitive. */ + +char* +dict_accept( +/*========*/ + /* out: if string was accepted, the pointer + is moved after that, else ptr is returned */ + char* ptr, /* in: scan from this */ + const char* string,/* in: accept only this string as the next + non-whitespace string */ + ibool* success);/* out: TRUE if accepted */ /************************************************************************ Decrements the count of open MySQL handles to a table. */ @@ -798,7 +810,7 @@ dict_mutex_exit_for_mysql(void); extern dict_sys_t* dict_sys; /* the dictionary system */ -extern rw_lock_t dict_foreign_key_check_lock; +extern rw_lock_t dict_operation_lock; /* Dictionary system struct */ struct dict_sys_struct{ diff --git a/innobase/include/fil0fil.h b/innobase/include/fil0fil.h index 63e20221c16..23ef0304b2d 100644 --- a/innobase/include/fil0fil.h +++ b/innobase/include/fil0fil.h @@ -73,6 +73,8 @@ extern fil_addr_t fil_addr_null; /* File page types */ #define FIL_PAGE_INDEX 17855 #define FIL_PAGE_UNDO_LOG 2 +#define FIL_PAGE_INODE 3 +#define FIL_PAGE_IBUF_FREE_LIST 4 /* Space types */ #define FIL_TABLESPACE 501 diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h index 288356d3270..d3b3d55d015 100644 --- a/innobase/include/lock0lock.h +++ b/innobase/include/lock0lock.h @@ -292,16 +292,12 @@ lock_sec_rec_modify_check_and_lock( dict_index_t* index, /* in: secondary index */ que_thr_t* thr); /* in: query thread */ /************************************************************************* -Checks if locks of other transactions prevent an immediate read, or passing -over by a read cursor, of a clustered index record. If they do, first tests -if the query thread should anyway be suspended for some reason; if not, then -puts the transaction and the query thread to the lock wait state and inserts a -waiting request for a record lock to the lock queue. Sets the requested mode -lock on the record. */ +Like the counterpart for a clustered index below, but now we read a +secondary index record. */ ulint -lock_clust_rec_read_check_and_lock( -/*===============================*/ +lock_sec_rec_read_check_and_lock( +/*=============================*/ /* out: DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, @@ -309,18 +305,24 @@ lock_clust_rec_read_check_and_lock( rec_t* rec, /* in: user record or page supremum record which should be read or passed over by a read cursor */ - dict_index_t* index, /* in: clustered index */ + dict_index_t* index, /* in: secondary index */ ulint mode, /* in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE */ + ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or + LOCK_REC_NOT_GAP */ que_thr_t* thr); /* in: query thread */ /************************************************************************* -Like the counterpart for a clustered index above, but now we read a -secondary index record. */ +Checks if locks of other transactions prevent an immediate read, or passing +over by a read cursor, of a clustered index record. If they do, first tests +if the query thread should anyway be suspended for some reason; if not, then +puts the transaction and the query thread to the lock wait state and inserts a +waiting request for a record lock to the lock queue. Sets the requested mode +lock on the record. */ ulint -lock_sec_rec_read_check_and_lock( -/*=============================*/ +lock_clust_rec_read_check_and_lock( +/*===============================*/ /* out: DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, @@ -328,10 +330,12 @@ lock_sec_rec_read_check_and_lock( rec_t* rec, /* in: user record or page supremum record which should be read or passed over by a read cursor */ - dict_index_t* index, /* in: secondary index */ + dict_index_t* index, /* in: clustered index */ ulint mode, /* in: mode of the lock which the read cursor should set on records: LOCK_S or LOCK_X; the latter is possible in SELECT FOR UPDATE */ + ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or + LOCK_REC_NOT_GAP */ que_thr_t* thr); /* in: query thread */ /************************************************************************* Checks that a record is seen in a consistent read. */ @@ -509,6 +513,7 @@ lock_validate(void); extern lock_sys_t* lock_sys; /* Lock modes and types */ +/* Basic modes */ #define LOCK_NONE 0 /* this flag is used elsewhere to note consistent read */ #define LOCK_IS 2 /* intention shared */ @@ -519,15 +524,20 @@ extern lock_sys_t* lock_sys; in an exclusive mode */ #define LOCK_MODE_MASK 0xF /* 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 type_mode field in a lock */ +/* Waiting lock flag */ #define LOCK_WAIT 256 /* this wait bit should be so high that it can be ORed to the lock mode and type; when this bit is set, it means that the lock has not yet been granted, it is just waiting for its turn in the wait queue */ +/* Precise modes */ +#define LOCK_ORDINARY 0 /* this flag denotes an ordinary next-key lock + in contrast to LOCK_GAP or LOCK_REC_NOT_GAP */ #define LOCK_GAP 512 /* this gap bit should be so high that it can be ORed to the other flags; when this bit is set, it means that the @@ -537,7 +547,15 @@ extern lock_sys_t* lock_sys; the bit is set; locks of this type are created when records are removed from the index chain of records */ -#define LOCK_INSERT_INTENTION 1024 /* this bit is set when we place a waiting +#define LOCK_REC_NOT_GAP 1024 /* this bit means that the lock is only on + the index record and does NOT block inserts + to the gap before the index record; this is + used in the case when we retrieve a record + with a unique key, and is also used in + locking plain SELECTs (not part of UPDATE + or DELETE) when the user has set the READ + COMMITTED isolation level */ +#define LOCK_INSERT_INTENTION 2048 /* this bit is set when we place a waiting gap type record lock request in order to let an insert of an index record to wait until there are no conflicting locks by other diff --git a/innobase/include/log0recv.h b/innobase/include/log0recv.h index baa2ba50c7d..7418e4abf1b 100644 --- a/innobase/include/log0recv.h +++ b/innobase/include/log0recv.h @@ -334,6 +334,7 @@ extern ibool recv_no_ibuf_operations; extern ibool recv_needed_recovery; extern ibool recv_is_making_a_backup; +extern ulint recv_max_parsed_page_no; /* Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many times! */ diff --git a/innobase/include/os0file.h b/innobase/include/os0file.h index d65c7fd47e3..a7624a90d5e 100644 --- a/innobase/include/os0file.h +++ b/innobase/include/os0file.h @@ -111,6 +111,7 @@ log. */ #define OS_WIN31 1 #define OS_WIN95 2 #define OS_WINNT 3 +#define OS_WIN2000 4 extern ulint os_n_file_reads; extern ulint os_n_file_writes; @@ -122,7 +123,7 @@ Gets the operating system version. Currently works only on Windows. */ ulint os_get_os_version(void); /*===================*/ - /* out: OS_WIN95, OS_WIN31, OS_WINNT (2000 == NT) */ + /* out: OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */ /******************************************************************** Creates the seek mutexes used in positioned reads and writes. */ diff --git a/innobase/include/os0proc.h b/innobase/include/os0proc.h index 9da1f33e070..79750e5c1f7 100644 --- a/innobase/include/os0proc.h +++ b/innobase/include/os0proc.h @@ -16,6 +16,15 @@ typedef void* os_process_t; typedef unsigned long int os_process_id_t; /******************************************************************** +Converts the current process id to a number. It is not guaranteed that the +number is unique. In Linux returns the 'process number' of the current +thread. That number is the same as one sees in 'top', for example. In Linux +the thread id is not the same as one sees in 'top'. */ + +ulint +os_proc_get_number(void); +/*====================*/ +/******************************************************************** Allocates non-cacheable memory. */ void* diff --git a/innobase/include/os0thread.h b/innobase/include/os0thread.h index 8355afa46e9..efc8651e06d 100644 --- a/innobase/include/os0thread.h +++ b/innobase/include/os0thread.h @@ -16,11 +16,8 @@ Created 9/8/1995 Heikki Tuuri this is also the size of the wait slot array for MySQL threads which can wait inside InnoDB */ #ifdef __WIN__ -/* Windows 95/98/ME seemed to have difficulties creating the all -the event semaphores for the wait array slots. If the computer had -<= 64 MB memory, InnoDB startup could take minutes or even crash. -That is why we set this to only 1000 in Windows. */ - +/* Create less event semaphores because Win 98/ME had difficult creating +40000 event semaphores */ #define OS_THREAD_MAX_N 1000 #else #define OS_THREAD_MAX_N 10000 diff --git a/innobase/include/page0cur.h b/innobase/include/page0cur.h index 144e0e02b21..c3f0decdb4b 100644 --- a/innobase/include/page0cur.h +++ b/innobase/include/page0cur.h @@ -26,7 +26,12 @@ Created 10/4/1994 Heikki Tuuri #define PAGE_CUR_GE 2 #define PAGE_CUR_L 3 #define PAGE_CUR_LE 4 -#define PAGE_CUR_DBG 5 +#define PAGE_CUR_LE_OR_EXTENDS 5 /* This is a search mode used in + "column LIKE 'abc%' ORDER BY column DESC"; + we have to find strings which are <= 'abc' or + which extend it */ +#define PAGE_CUR_DBG 6 + extern ulint page_cur_short_succ; diff --git a/innobase/include/page0page.h b/innobase/include/page0page.h index 2f77127466f..b5e33af5bc0 100644 --- a/innobase/include/page0page.h +++ b/innobase/include/page0page.h @@ -666,6 +666,16 @@ page_rec_validate( /* out: TRUE if ok */ rec_t* rec); /* in: record on the page */ /******************************************************************* +This function checks the consistency of an index page when we do not +know the index. This is also resilient so that this should never crash +even if the page is total garbage. */ + +ibool +page_simple_validate( +/*=================*/ + /* out: TRUE if ok */ + page_t* page); /* in: index page */ +/******************************************************************* This function checks the consistency of an index page. */ ibool diff --git a/innobase/include/que0que.h b/innobase/include/que0que.h index cdaeeae1fde..a3ed18e2b14 100644 --- a/innobase/include/que0que.h +++ b/innobase/include/que0que.h @@ -117,6 +117,7 @@ que_thr_stop( /************************************************************************** Moves a thread from another state to the QUE_THR_RUNNING state. Increments the n_active_thrs counters of the query graph and transaction. */ + void que_thr_move_to_run_state_for_mysql( /*================================*/ @@ -125,14 +126,17 @@ que_thr_move_to_run_state_for_mysql( /************************************************************************** A patch for MySQL used to 'stop' a dummy query thread used in MySQL select, when there is no error or lock wait. */ + void que_thr_stop_for_mysql_no_error( /*============================*/ que_thr_t* thr, /* in: query thread */ trx_t* trx); /* in: transaction */ /************************************************************************** -A patch for MySQL used to 'stop' a dummy query thread used in MySQL -select. */ +A patch for MySQL used to 'stop' a dummy query thread used in MySQL. The +query thread is stopped and made inactive, except in the case where +it was put to the lock wait state in lock0lock.c, but the lock has already +been granted or the transaction chosen as a victim in deadlock resolution. */ void que_thr_stop_for_mysql( diff --git a/innobase/include/read0read.h b/innobase/include/read0read.h index cebb2d6701c..db6bf888095 100644 --- a/innobase/include/read0read.h +++ b/innobase/include/read0read.h @@ -45,6 +45,14 @@ read_view_close( /*============*/ read_view_t* view); /* in: read view */ /************************************************************************* +Closes a consistent read view for MySQL. This function is called at an SQL +statement end if the trx isolation level is <= TRX_ISO_READ_COMMITTED. */ + +void +read_view_close_for_mysql( +/*======================*/ + trx_t* trx); /* in: trx which has a read view */ +/************************************************************************* Checks if a read view sees the specified transaction. */ UNIV_INLINE ibool diff --git a/innobase/include/rem0rec.h b/innobase/include/rem0rec.h index 12e3a8b39d6..b28f39925c1 100644 --- a/innobase/include/rem0rec.h +++ b/innobase/include/rem0rec.h @@ -148,12 +148,22 @@ data field in the record. */ byte* rec_get_nth_field( /*==============*/ - /* out: pointer to the field, NULL if SQL null */ + /* out: pointer to the field */ rec_t* rec, /* in: record */ ulint n, /* in: index of the field */ ulint* len); /* out: length of the field; UNIV_SQL_NULL if SQL null */ /**************************************************************** +Return field length or UNIV_SQL_NULL. */ +UNIV_INLINE +ulint +rec_get_nth_field_len( +/*==================*/ + /* out: length of the field; UNIV_SQL_NULL if SQL + null */ + rec_t* rec, /* in: record */ + ulint n); /* in: index of the field */ +/**************************************************************** Gets the physical size of a field. Also an SQL null may have a field of size > 0, if the data type is of a fixed size. */ UNIV_INLINE diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic index aaa3c58a003..9dfd4faeec8 100644 --- a/innobase/include/rem0rec.ic +++ b/innobase/include/rem0rec.ic @@ -65,6 +65,24 @@ a field stored to another page: */ #define REC_2BYTE_EXTERN_MASK 0x4000 +/**************************************************************** +Return field length or UNIV_SQL_NULL. */ +UNIV_INLINE +ulint +rec_get_nth_field_len( +/*==================*/ + /* out: length of the field; UNIV_SQL_NULL if SQL + null */ + rec_t* rec, /* in: record */ + ulint n) /* in: index of the field */ +{ + ulint len; + + rec_get_nth_field(rec, n, &len); + + return(len); +} + /*************************************************************** Sets the value of the ith field SQL null bit. */ diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h index 8152c534f48..44b470fe7ea 100644 --- a/innobase/include/row0mysql.h +++ b/innobase/include/row0mysql.h @@ -230,18 +230,35 @@ row_update_cascade_for_mysql( or set null operation */ dict_table_t* table); /* in: table where we do the operation */ /************************************************************************* -Locks the data dictionary exclusively for performing a table create -operation. */ +Locks the data dictionary exclusively for performing a table create or other +data dictionary modification operation. */ void -row_mysql_lock_data_dictionary(void); -/*================================*/ +row_mysql_lock_data_dictionary( +/*===========================*/ + trx_t* trx); /* in: transaction */ /************************************************************************* -Unlocks the data dictionary exclusively lock. */ +Unlocks the data dictionary exclusive lock. */ void -row_mysql_unlock_data_dictionary(void); -/*==================================*/ +row_mysql_unlock_data_dictionary( +/*=============================*/ + trx_t* trx); /* in: transaction */ +/************************************************************************* +Locks the data dictionary in shared mode from modifications, for performing +foreign key check, rollback, or other operation invisible to MySQL. */ + +void +row_mysql_freeze_data_dictionary( +/*=============================*/ + trx_t* trx); /* in: transaction */ +/************************************************************************* +Unlocks the data dictionary shared lock. */ + +void +row_mysql_unfreeze_data_dictionary( +/*===============================*/ + trx_t* trx); /* in: transaction */ /************************************************************************* Does a table creation operation for MySQL. If the name of the created table ends to characters INNODB_MONITOR, then this also starts @@ -310,11 +327,9 @@ output by the master thread. */ int row_drop_table_for_mysql( /*=====================*/ - /* out: error code or DB_SUCCESS */ - char* name, /* in: table name */ - trx_t* trx, /* in: transaction handle */ - ibool has_dict_mutex);/* in: TRUE if the caller already owns the - dictionary system mutex */ + /* out: error code or DB_SUCCESS */ + char* name, /* in: table name */ + trx_t* trx); /* in: transaction handle */ /************************************************************************* Drops a database for MySQL. */ @@ -393,6 +408,10 @@ struct row_prebuilt_struct { an SQL statement: we may have to set an intention lock on the table, create a consistent read view etc. */ + ibool mysql_has_locked; /* this is set TRUE when MySQL + calls external_lock on this handle + with a lock flag, and set FALSE when + with the F_UNLOCK flag */ ibool clust_index_was_generated; /* if the user did not define a primary key in MySQL, then Innobase diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index 9de5e9ccfc9..ad6f71f7a3a 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -28,6 +28,9 @@ extern os_event_t srv_lock_timeout_thread_event; at a time */ #define SRV_AUTO_EXTEND_INCREMENT (8 * ((1024 * 1024) / UNIV_PAGE_SIZE)) +/* This is set to TRUE if the MySQL user has set it in MySQL */ +extern ibool srv_lower_case_table_names; + /* Server parameters which are read from the initfile */ extern char* srv_data_home; @@ -57,8 +60,6 @@ extern ulint srv_flush_log_at_trx_commit; extern byte srv_latin1_ordering[256];/* The sort order table of the latin1 character set */ -extern ibool srv_use_native_aio; - extern ulint srv_pool_size; extern ulint srv_mem_pool_size; extern ulint srv_lock_table_size; @@ -70,8 +71,9 @@ extern dulint srv_archive_recovery_limit_lsn; extern ulint srv_lock_wait_timeout; -extern char* srv_unix_file_flush_method_str; +extern char* srv_file_flush_method_str; extern ulint srv_unix_file_flush_method; +extern ulint srv_win_file_flush_method; extern ulint srv_force_recovery; extern ulint srv_thread_concurrency; @@ -154,13 +156,19 @@ typedef struct srv_sys_struct srv_sys_t; /* The server system */ extern srv_sys_t* srv_sys; -/* Alternatives for the field flush option in Unix; see the InnoDB manual about +/* Alternatives for the file flush option in Unix; see the InnoDB manual about what these mean */ -#define SRV_UNIX_FDATASYNC 1 +#define SRV_UNIX_FDATASYNC 1 /* This is the default; it is currently mapped + to a call of fsync() because fdatasync() + seemed to corrupt files in Linux and Solaris */ #define SRV_UNIX_O_DSYNC 2 #define SRV_UNIX_LITTLESYNC 3 #define SRV_UNIX_NOSYNC 4 +/* Alternatives for file i/o in Windows */ +#define SRV_WIN_IO_NORMAL 1 +#define SRV_WIN_IO_UNBUFFERED 2 /* This is the default */ + /* Alternatives for srv_force_recovery. Non-zero values are intended to help the user get a damaged database up so that he can dump intact tables and rows with SELECT INTO OUTFILE. The database must not otherwise @@ -311,15 +319,17 @@ srv_conc_exit_innodb( trx_t* trx); /* in: transaction object associated with the thread */ /******************************************************************* -Puts a MySQL OS thread to wait for a lock to be released. */ +Puts a MySQL OS thread to wait for a lock to be released. If an error +occurs during the wait trx->error_state associated with thr is +!= DB_SUCCESS when we return. DB_LOCK_WAIT_TIMEOUT and DB_DEADLOCK +are possible errors. DB_DEADLOCK is returned if selective deadlock +resolution chose this transaction as a victim. */ -ibool +void srv_suspend_mysql_thread( /*=====================*/ - /* out: TRUE if the lock wait timeout was - exceeded */ - que_thr_t* thr); /* in: query thread associated with - the MySQL OS thread */ + que_thr_t* thr); /* in: query thread associated with the MySQL + OS thread */ /************************************************************************ Releases a MySQL OS thread waiting for a lock to be released, if the thread is already suspended. */ @@ -407,3 +417,4 @@ struct srv_sys_struct{ extern ulint srv_n_threads_active[]; #endif + diff --git a/innobase/include/srv0start.h b/innobase/include/srv0start.h index 646d2c1bb06..24cdecb7341 100644 --- a/innobase/include/srv0start.h +++ b/innobase/include/srv0start.h @@ -79,6 +79,8 @@ innobase_shutdown_for_mysql(void); /*=============================*/ /* out: DB_SUCCESS or error code */ +extern ulint srv_sizeof_trx_t_in_ha_innodb_cc; + extern ibool srv_startup_is_before_trx_rollback_phase; extern ibool srv_is_being_shut_down; diff --git a/innobase/include/sync0rw.h b/innobase/include/sync0rw.h index 7ad38f5bc7f..5aa3dcdffc3 100644 --- a/innobase/include/sync0rw.h +++ b/innobase/include/sync0rw.h @@ -335,7 +335,8 @@ ibool rw_lock_own( /*========*/ rw_lock_t* lock, /* in: rw-lock */ - ulint lock_type); /* in: lock type */ + ulint lock_type); /* in: lock type: RW_LOCK_SHARED, + RW_LOCK_EX */ /********************************************************************** Checks if somebody has locked the rw-lock in the specified mode. */ diff --git a/innobase/include/sync0sync.h b/innobase/include/sync0sync.h index 5bfa0bc2d48..320f8faf12d 100644 --- a/innobase/include/sync0sync.h +++ b/innobase/include/sync0sync.h @@ -371,10 +371,12 @@ or row lock! */ #define SYNC_NO_ORDER_CHECK 3000 /* this can be used to suppress latching order checking */ #define SYNC_LEVEL_NONE 2000 /* default: level not defined */ -#define SYNC_FOREIGN_KEY_CHECK 1001 +#define SYNC_DICT_OPERATION 1001 /* table create, drop, etc. reserve + this in X-mode, implicit or backround + operations purge, rollback, foreign + key checks reserve this in S-mode */ #define SYNC_DICT 1000 #define SYNC_DICT_AUTOINC_MUTEX 999 -#define SYNC_PURGE_IS_RUNNING 997 #define SYNC_DICT_HEADER 995 #define SYNC_IBUF_HEADER 914 #define SYNC_IBUF_PESS_INSERT_MUTEX 912 diff --git a/innobase/include/trx0purge.h b/innobase/include/trx0purge.h index 087be2f060e..049c79aec9b 100644 --- a/innobase/include/trx0purge.h +++ b/innobase/include/trx0purge.h @@ -111,9 +111,6 @@ struct trx_purge_struct{ of the trx system and it never ends */ que_t* query; /* The query graph which will do the parallelized purge operation */ - rw_lock_t purge_is_running;/* Purge operation set an x-latch here - while it is accessing a table: this - prevents dropping of the table */ rw_lock_t latch; /* The latch protecting the purge view. A purge operation must acquire an x-latch here for the instant at which diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h index 9b29c481b6d..34f820f03e7 100644 --- a/innobase/include/trx0trx.h +++ b/innobase/include/trx0trx.h @@ -327,6 +327,7 @@ struct trx_struct{ time_t start_time; /* time the trx object was created or the state last time became TRX_ACTIVE */ + ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */ ibool check_foreigns; /* normally TRUE, but if the user wants to suppress foreign key checks, (in table imports, for example) we @@ -350,6 +351,9 @@ struct trx_struct{ /*------------------------------*/ void* mysql_thd; /* MySQL thread handle corresponding to this trx, or NULL */ + char** mysql_query_str;/* pointer to the field in mysqld_thd + which contains the pointer to the + current SQL query string */ char* mysql_log_file_name; /* if MySQL binlog is used, this field contains a pointer to the latest file @@ -371,6 +375,9 @@ struct trx_struct{ replication has processed */ os_thread_id_t mysql_thread_id;/* id of the MySQL thread associated with this transaction object */ + ulint mysql_process_no;/* since in Linux, 'top' reports + process id's and not thread id's, we + store the process number too */ /*------------------------------*/ ulint n_mysql_tables_in_use; /* number of Innobase tables used in the processing of the current @@ -379,9 +386,10 @@ struct trx_struct{ /* how many tables the current SQL statement uses, except those in consistent read */ - ibool has_dict_foreign_key_check_lock; - /* TRUE if the trx currently holds - an s-lock on dict_foreign_... */ + ibool dict_operation_lock_mode; + /* 0, RW_S_LATCH, or RW_X_LATCH: + the latch mode trx currently holds + on dict_operation_lock */ ibool has_search_latch; /* TRUE if this trx has latched the search system latch in S-mode */ @@ -420,36 +428,11 @@ struct trx_struct{ mysql_trx_list; /* list of transactions created for MySQL */ /*------------------------------*/ - mutex_t undo_mutex; /* mutex protecting the fields in this - section (down to undo_no_arr), EXCEPT - last_sql_stat_start, which can be - accessed only when we know that there - cannot be any activity in the undo - logs! */ - dulint undo_no; /* next undo log record number to - assign */ - trx_savept_t last_sql_stat_start; - /* undo_no when the last sql statement - was started: in case of an error, trx - is rolled back down to this undo - number; see note at undo_mutex! */ - trx_rseg_t* rseg; /* rollback segment assigned to the - transaction, or NULL if not assigned - yet */ - trx_undo_t* insert_undo; /* pointer to the insert undo log, or - NULL if no inserts performed yet */ - trx_undo_t* update_undo; /* pointer to the update undo log, or - NULL if no update performed yet */ - dulint roll_limit; /* least undo number to undo during - a rollback */ - ulint pages_undone; /* number of undo log pages undone - since the last undo log truncation */ - trx_undo_arr_t* undo_no_arr; /* array of undo numbers of undo log - records which are currently processed - by a rollback operation */ - /*------------------------------*/ ulint error_state; /* 0 if no error, otherwise error - number */ + number; NOTE That ONLY the thread + doing the transaction is allowed to + set this field: this is NOT protected + by the kernel mutex */ void* error_info; /* if the error number indicates a duplicate key error, a pointer to the problematic index is stored here */ @@ -486,6 +469,12 @@ struct trx_struct{ TRX_QUE_LOCK_WAIT, this points to the lock request, otherwise this is NULL */ + ibool was_chosen_as_deadlock_victim; + /* when the transaction decides to wait + for a lock, this it sets this to FALSE; + if another transaction chooses this + transaction as a victim in deadlock + resolution, it sets this to TRUE */ time_t wait_started; /* lock wait started at this time */ UT_LIST_BASE_NODE_T(que_thr_t) wait_thrs; /* query threads belonging to this @@ -501,6 +490,34 @@ struct trx_struct{ /*------------------------------*/ mem_heap_t* read_view_heap; /* memory heap for the read view */ read_view_t* read_view; /* consistent read view or NULL */ + /*------------------------------*/ + mutex_t undo_mutex; /* mutex protecting the fields in this + section (down to undo_no_arr), EXCEPT + last_sql_stat_start, which can be + accessed only when we know that there + cannot be any activity in the undo + logs! */ + dulint undo_no; /* next undo log record number to + assign */ + trx_savept_t last_sql_stat_start; + /* undo_no when the last sql statement + was started: in case of an error, trx + is rolled back down to this undo + number; see note at undo_mutex! */ + trx_rseg_t* rseg; /* rollback segment assigned to the + transaction, or NULL if not assigned + yet */ + trx_undo_t* insert_undo; /* pointer to the insert undo log, or + NULL if no inserts performed yet */ + trx_undo_t* update_undo; /* pointer to the update undo log, or + NULL if no update performed yet */ + dulint roll_limit; /* least undo number to undo during + a rollback */ + ulint pages_undone; /* number of undo log pages undone + since the last undo log truncation */ + trx_undo_arr_t* undo_no_arr; /* array of undo numbers of undo log + records which are currently processed + by a rollback operation */ }; #define TRX_MAX_N_THREADS 32 /* maximum number of concurrent @@ -523,6 +540,41 @@ struct trx_struct{ #define TRX_QUE_ROLLING_BACK 3 /* transaction is rolling back */ #define TRX_QUE_COMMITTING 4 /* transaction is committing */ +/* Transaction isolation levels */ +#define TRX_ISO_READ_UNCOMMITTED 1 /* dirty read: non-locking + SELECTs are performed so that + we do not look at a possible + earlier version of a record; + thus they are not 'consistent' + reads under this isolation + level; otherwise like level + 2 */ + +#define TRX_ISO_READ_COMMITTED 2 /* somewhat Oracle-like + isolation, except that in + range UPDATE and DELETE we + must block phantom rows + with next-key locks; + SELECT ... FOR UPDATE and ... + LOCK IN SHARE MODE only lock + the index records, NOT the + gaps before them, and thus + allow free inserting; + each consistent read reads its + own snapshot */ + +#define TRX_ISO_REPEATABLE_READ 3 /* this is the default; + all consistent reads in the + same trx read the same + snapshot; + full next-key locking used + in locking reads to block + insertions into gaps */ + +#define TRX_ISO_SERIALIZABLE 4 /* all plain SELECTs are + converted to LOCK IN SHARE + MODE reads */ + /* Types of a trx signal */ #define TRX_SIG_NO_SIGNAL 100 #define TRX_SIG_TOTAL_ROLLBACK 1 |