2001-02-17 13:19:19 +01:00
|
|
|
/******************************************************
|
|
|
|
The transaction lock system
|
|
|
|
|
|
|
|
(c) 1996 Innobase Oy
|
|
|
|
|
|
|
|
Created 5/7/1996 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#ifndef lock0lock_h
|
|
|
|
#define lock0lock_h
|
|
|
|
|
|
|
|
#include "univ.i"
|
|
|
|
#include "trx0types.h"
|
|
|
|
#include "rem0types.h"
|
|
|
|
#include "dict0types.h"
|
|
|
|
#include "que0types.h"
|
|
|
|
#include "page0types.h"
|
|
|
|
#include "lock0types.h"
|
|
|
|
#include "read0types.h"
|
|
|
|
#include "hash0hash.h"
|
|
|
|
|
2005-06-17 14:29:03 +02:00
|
|
|
#ifdef UNIV_DEBUG
|
2001-02-17 13:19:19 +01:00
|
|
|
extern ibool lock_print_waits;
|
2005-06-17 14:29:03 +02:00
|
|
|
#endif /* UNIV_DEBUG */
|
2004-04-06 15:14:43 +02:00
|
|
|
/* Buffer for storing information about the most recent deadlock error */
|
|
|
|
extern FILE* lock_latest_err_file;
|
2001-02-17 13:19:19 +01:00
|
|
|
|
2001-10-10 21:47:08 +02:00
|
|
|
/*************************************************************************
|
|
|
|
Gets the size of a lock struct. */
|
2001-02-17 13:19:19 +01:00
|
|
|
|
2001-10-10 21:47:08 +02:00
|
|
|
ulint
|
|
|
|
lock_get_size(void);
|
|
|
|
/*===============*/
|
|
|
|
/* out: size in bytes */
|
2001-02-17 13:19:19 +01:00
|
|
|
/*************************************************************************
|
|
|
|
Creates the lock system at database start. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_sys_create(
|
|
|
|
/*============*/
|
|
|
|
ulint n_cells); /* in: number of slots in lock hash table */
|
|
|
|
/*************************************************************************
|
|
|
|
Checks if some transaction has an implicit x-lock on a record in a secondary
|
|
|
|
index. */
|
|
|
|
|
|
|
|
trx_t*
|
|
|
|
lock_sec_rec_some_has_impl_off_kernel(
|
|
|
|
/*==================================*/
|
|
|
|
/* out: transaction which has the x-lock, or
|
|
|
|
NULL */
|
|
|
|
rec_t* rec, /* in: user record */
|
2004-12-02 18:45:07 +01:00
|
|
|
dict_index_t* index, /* in: secondary index */
|
|
|
|
const ulint* offsets);/* in: rec_get_offsets(rec, index) */
|
2001-02-17 13:19:19 +01:00
|
|
|
/*************************************************************************
|
|
|
|
Checks if some transaction has an implicit x-lock on a record in a clustered
|
|
|
|
index. */
|
|
|
|
UNIV_INLINE
|
|
|
|
trx_t*
|
|
|
|
lock_clust_rec_some_has_impl(
|
|
|
|
/*=========================*/
|
|
|
|
/* out: transaction which has the x-lock, or
|
|
|
|
NULL */
|
|
|
|
rec_t* rec, /* in: user record */
|
2004-12-02 18:45:07 +01:00
|
|
|
dict_index_t* index, /* in: clustered index */
|
|
|
|
const ulint* offsets);/* in: rec_get_offsets(rec, index) */
|
2001-02-17 13:19:19 +01:00
|
|
|
/*****************************************************************
|
|
|
|
Makes a record to inherit the locks of another record as gap type
|
|
|
|
locks, but does not reset the lock bits of the other record. Also
|
|
|
|
waiting lock requests on rec are inherited as GRANTED gap locks. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_rec_inherit_to_gap(
|
|
|
|
/*====================*/
|
|
|
|
rec_t* heir, /* in: record which inherits */
|
|
|
|
rec_t* rec); /* in: record from which inherited; does NOT reset
|
|
|
|
the locks on this record */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when we have reorganized a page. NOTE: we copy
|
|
|
|
also the locks set on the infimum of the page; the infimum may carry
|
|
|
|
locks if an update of a record is occurring on the page, and its locks
|
|
|
|
were temporarily stored on the infimum. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_move_reorganize_page(
|
|
|
|
/*======================*/
|
|
|
|
page_t* page, /* in: old index page */
|
|
|
|
page_t* new_page); /* in: reorganized page */
|
|
|
|
/*****************************************************************
|
|
|
|
Moves the explicit locks on user records to another page if a record
|
|
|
|
list end is moved to another page. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_move_rec_list_end(
|
|
|
|
/*===================*/
|
|
|
|
page_t* new_page, /* in: index page to move to */
|
|
|
|
page_t* page, /* in: index page */
|
|
|
|
rec_t* rec); /* in: record on page: this is the
|
|
|
|
first record moved */
|
|
|
|
/*****************************************************************
|
|
|
|
Moves the explicit locks on user records to another page if a record
|
|
|
|
list start is moved to another page. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_move_rec_list_start(
|
|
|
|
/*=====================*/
|
|
|
|
page_t* new_page, /* in: index page to move to */
|
|
|
|
page_t* page, /* in: index page */
|
|
|
|
rec_t* rec, /* in: record on page: this is the
|
|
|
|
first record NOT copied */
|
|
|
|
rec_t* old_end); /* in: old previous-to-last record on
|
|
|
|
new_page before the records were copied */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a page is split to the right. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_split_right(
|
|
|
|
/*====================*/
|
|
|
|
page_t* right_page, /* in: right page */
|
|
|
|
page_t* left_page); /* in: left page */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a page is merged to the right. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_merge_right(
|
|
|
|
/*====================*/
|
|
|
|
rec_t* orig_succ, /* in: original successor of infimum
|
|
|
|
on the right page before merge */
|
|
|
|
page_t* left_page); /* in: merged index page which will be
|
|
|
|
discarded */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when the root page is copied to another in
|
|
|
|
btr_root_raise_and_insert. Note that we leave lock structs on the
|
|
|
|
root page, even though they do not make sense on other than leaf
|
|
|
|
pages: the reason is that in a pessimistic update the infimum record
|
|
|
|
of the root page will act as a dummy carrier of the locks of the record
|
|
|
|
to be updated. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_root_raise(
|
|
|
|
/*===================*/
|
|
|
|
page_t* new_page, /* in: index page to which copied */
|
|
|
|
page_t* root); /* in: root page */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a page is copied to another and the original page
|
|
|
|
is removed from the chain of leaf pages, except if page is the root! */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_copy_and_discard(
|
|
|
|
/*=========================*/
|
|
|
|
page_t* new_page, /* in: index page to which copied */
|
|
|
|
page_t* page); /* in: index page; NOT the root! */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a page is split to the left. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_split_left(
|
|
|
|
/*===================*/
|
|
|
|
page_t* right_page, /* in: right page */
|
|
|
|
page_t* left_page); /* in: left page */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a page is merged to the left. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_merge_left(
|
|
|
|
/*===================*/
|
|
|
|
page_t* left_page, /* in: left page to which merged */
|
|
|
|
rec_t* orig_pred, /* in: original predecessor of supremum
|
|
|
|
on the left page before merge */
|
|
|
|
page_t* right_page); /* in: merged index page which will be
|
|
|
|
discarded */
|
|
|
|
/*****************************************************************
|
|
|
|
Resets the original locks on heir and replaces them with gap type locks
|
|
|
|
inherited from rec. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_rec_reset_and_inherit_gap_locks(
|
|
|
|
/*=================================*/
|
|
|
|
rec_t* heir, /* in: heir record */
|
|
|
|
rec_t* rec); /* in: record */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a page is discarded. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_discard(
|
|
|
|
/*================*/
|
|
|
|
rec_t* heir, /* in: record which will inherit the locks */
|
|
|
|
page_t* page); /* in: index page which will be discarded */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a new user record is inserted. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_insert(
|
|
|
|
/*===============*/
|
|
|
|
rec_t* rec); /* in: the inserted record */
|
|
|
|
/*****************************************************************
|
|
|
|
Updates the lock table when a record is removed. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_update_delete(
|
|
|
|
/*===============*/
|
|
|
|
rec_t* rec); /* in: the record to be removed */
|
|
|
|
/*************************************************************************
|
|
|
|
Stores on the page infimum record the explicit locks of another record.
|
|
|
|
This function is used to store the lock state of a record when it is
|
|
|
|
updated and the size of the record changes in the update. The record
|
|
|
|
is in such an update moved, perhaps to another page. The infimum record
|
|
|
|
acts as a dummy carrier record, taking care of lock releases while the
|
|
|
|
actual record is being moved. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_rec_store_on_page_infimum(
|
|
|
|
/*===========================*/
|
2005-04-25 09:14:35 +02:00
|
|
|
page_t* page, /* in: page containing the record */
|
2001-02-17 13:19:19 +01:00
|
|
|
rec_t* rec); /* in: record whose lock state is stored
|
|
|
|
on the infimum record of the same page; lock
|
|
|
|
bits are reset on the record */
|
|
|
|
/*************************************************************************
|
|
|
|
Restores the state of explicit lock requests on a single record, where the
|
|
|
|
state was stored on the infimum of the page. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_rec_restore_from_page_infimum(
|
|
|
|
/*===============================*/
|
|
|
|
rec_t* rec, /* in: record whose lock state is restored */
|
|
|
|
page_t* page); /* in: page (rec is not necessarily on this page)
|
|
|
|
whose infimum stored the lock state; lock bits are
|
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
2006-03-10 17:22:21 +01:00
|
|
|
reset on the infimum */
|
2001-02-17 13:19:19 +01:00
|
|
|
/*************************************************************************
|
|
|
|
Returns TRUE if there are explicit record locks on a page. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_rec_expl_exist_on_page(
|
|
|
|
/*========================*/
|
|
|
|
/* out: TRUE if there are explicit record locks on
|
|
|
|
the page */
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no);/* in: page number */
|
|
|
|
/*************************************************************************
|
|
|
|
Checks if locks of other transactions prevent an immediate insert of
|
|
|
|
a 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 gap x-lock to the lock queue. */
|
|
|
|
|
|
|
|
ulint
|
|
|
|
lock_rec_insert_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,
|
|
|
|
does nothing */
|
|
|
|
rec_t* rec, /* in: record after which to insert */
|
|
|
|
dict_index_t* index, /* in: index */
|
|
|
|
que_thr_t* thr, /* in: query thread */
|
|
|
|
ibool* inherit);/* out: set to TRUE if the new inserted
|
|
|
|
record maybe should inherit LOCK_GAP type
|
|
|
|
locks from the successor record */
|
|
|
|
/*************************************************************************
|
|
|
|
Checks if locks of other transactions prevent an immediate modify (update,
|
|
|
|
delete mark, or delete unmark) 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 x-lock to the
|
|
|
|
lock queue. */
|
|
|
|
|
|
|
|
ulint
|
|
|
|
lock_clust_rec_modify_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,
|
|
|
|
does nothing */
|
|
|
|
rec_t* rec, /* in: record which should be modified */
|
|
|
|
dict_index_t* index, /* in: clustered index */
|
2004-12-02 18:45:07 +01:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
2001-02-17 13:19:19 +01:00
|
|
|
que_thr_t* thr); /* in: query thread */
|
|
|
|
/*************************************************************************
|
|
|
|
Checks if locks of other transactions prevent an immediate modify
|
|
|
|
(delete mark or delete unmark) of a secondary index record. */
|
|
|
|
|
|
|
|
ulint
|
|
|
|
lock_sec_rec_modify_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,
|
|
|
|
does nothing */
|
|
|
|
rec_t* rec, /* in: record which should be modified;
|
|
|
|
NOTE: as this is a secondary index, we
|
|
|
|
always have to modify the clustered index
|
|
|
|
record first: see the comment below */
|
|
|
|
dict_index_t* index, /* in: secondary index */
|
|
|
|
que_thr_t* thr); /* in: query thread */
|
|
|
|
/*************************************************************************
|
Bug#53674: InnoDB: Error: unlock row could not find a 4 mode lock on the record
In semi-consistent read, only unlock freshly locked non-matching records.
Define DB_SUCCESS_LOCKED_REC for indicating a successful operation
where a record lock was created.
lock_rec_lock_fast(): Return LOCK_REC_SUCCESS,
LOCK_REC_SUCCESS_CREATED, or LOCK_REC_FAIL instead of TRUE/FALSE.
lock_sec_rec_read_check_and_lock(),
lock_clust_rec_read_check_and_lock(), lock_rec_enqueue_waiting(),
lock_rec_lock_slow(), lock_rec_lock(), row_ins_set_shared_rec_lock(),
row_ins_set_exclusive_rec_lock(), sel_set_rec_lock(),
row_sel_get_clust_rec_for_mysql(): Return DB_SUCCESS_LOCKED_REC if a
new record lock was created. Adjust callers.
row_unlock_for_mysql(): Correct the function documentation.
row_prebuilt_t::new_rec_locks: Correct the documentation.
2010-06-02 12:26:37 +02:00
|
|
|
Like lock_clust_rec_read_check_and_lock(), but reads a
|
2002-10-29 22:16:46 +01:00
|
|
|
secondary index record. */
|
2001-02-17 13:19:19 +01:00
|
|
|
|
|
|
|
ulint
|
2002-10-29 22:16:46 +01:00
|
|
|
lock_sec_rec_read_check_and_lock(
|
|
|
|
/*=============================*/
|
Bug#53674: InnoDB: Error: unlock row could not find a 4 mode lock on the record
In semi-consistent read, only unlock freshly locked non-matching records.
Define DB_SUCCESS_LOCKED_REC for indicating a successful operation
where a record lock was created.
lock_rec_lock_fast(): Return LOCK_REC_SUCCESS,
LOCK_REC_SUCCESS_CREATED, or LOCK_REC_FAIL instead of TRUE/FALSE.
lock_sec_rec_read_check_and_lock(),
lock_clust_rec_read_check_and_lock(), lock_rec_enqueue_waiting(),
lock_rec_lock_slow(), lock_rec_lock(), row_ins_set_shared_rec_lock(),
row_ins_set_exclusive_rec_lock(), sel_set_rec_lock(),
row_sel_get_clust_rec_for_mysql(): Return DB_SUCCESS_LOCKED_REC if a
new record lock was created. Adjust callers.
row_unlock_for_mysql(): Correct the function documentation.
row_prebuilt_t::new_rec_locks: Correct the documentation.
2010-06-02 12:26:37 +02:00
|
|
|
/* out: DB_SUCCESS, DB_SUCCESS_LOCKED_REC,
|
|
|
|
DB_LOCK_WAIT, DB_DEADLOCK,
|
|
|
|
or DB_QUE_THR_SUSPENDED */
|
2001-02-17 13:19:19 +01:00
|
|
|
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
|
|
|
|
does nothing */
|
|
|
|
rec_t* rec, /* in: user record or page supremum record
|
|
|
|
which should be read or passed over by a read
|
|
|
|
cursor */
|
2002-10-29 22:16:46 +01:00
|
|
|
dict_index_t* index, /* in: secondary index */
|
2004-12-02 18:45:07 +01:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
2001-02-17 13:19:19 +01:00
|
|
|
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 */
|
2002-10-29 22:16:46 +01:00
|
|
|
ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
|
|
|
|
LOCK_REC_NOT_GAP */
|
2001-02-17 13:19:19 +01:00
|
|
|
que_thr_t* thr); /* in: query thread */
|
|
|
|
/*************************************************************************
|
2002-10-29 22:16:46 +01:00
|
|
|
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. */
|
2001-02-17 13:19:19 +01:00
|
|
|
|
|
|
|
ulint
|
2002-10-29 22:16:46 +01:00
|
|
|
lock_clust_rec_read_check_and_lock(
|
|
|
|
/*===============================*/
|
Bug#53674: InnoDB: Error: unlock row could not find a 4 mode lock on the record
In semi-consistent read, only unlock freshly locked non-matching records.
Define DB_SUCCESS_LOCKED_REC for indicating a successful operation
where a record lock was created.
lock_rec_lock_fast(): Return LOCK_REC_SUCCESS,
LOCK_REC_SUCCESS_CREATED, or LOCK_REC_FAIL instead of TRUE/FALSE.
lock_sec_rec_read_check_and_lock(),
lock_clust_rec_read_check_and_lock(), lock_rec_enqueue_waiting(),
lock_rec_lock_slow(), lock_rec_lock(), row_ins_set_shared_rec_lock(),
row_ins_set_exclusive_rec_lock(), sel_set_rec_lock(),
row_sel_get_clust_rec_for_mysql(): Return DB_SUCCESS_LOCKED_REC if a
new record lock was created. Adjust callers.
row_unlock_for_mysql(): Correct the function documentation.
row_prebuilt_t::new_rec_locks: Correct the documentation.
2010-06-02 12:26:37 +02:00
|
|
|
/* out: DB_SUCCESS, DB_SUCCESS_LOCKED_REC,
|
|
|
|
DB_LOCK_WAIT, DB_DEADLOCK,
|
|
|
|
or DB_QUE_THR_SUSPENDED */
|
2001-02-17 13:19:19 +01:00
|
|
|
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
|
|
|
|
does nothing */
|
|
|
|
rec_t* rec, /* in: user record or page supremum record
|
|
|
|
which should be read or passed over by a read
|
|
|
|
cursor */
|
2002-10-29 22:16:46 +01:00
|
|
|
dict_index_t* index, /* in: clustered index */
|
2004-12-02 18:45:07 +01:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
2001-02-17 13:19:19 +01:00
|
|
|
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 */
|
2002-10-29 22:16:46 +01:00
|
|
|
ulint gap_mode,/* in: LOCK_ORDINARY, LOCK_GAP, or
|
|
|
|
LOCK_REC_NOT_GAP */
|
2001-02-17 13:19:19 +01:00
|
|
|
que_thr_t* thr); /* in: query thread */
|
|
|
|
/*************************************************************************
|
2004-12-10 11:55:56 +01:00
|
|
|
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. This is an alternative version of
|
|
|
|
lock_clust_rec_read_check_and_lock() that does not require the parameter
|
|
|
|
"offsets". */
|
|
|
|
|
|
|
|
ulint
|
|
|
|
lock_clust_rec_read_check_and_lock_alt(
|
|
|
|
/*===================================*/
|
|
|
|
/* out: DB_SUCCESS, DB_LOCK_WAIT,
|
|
|
|
DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
|
|
|
|
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
|
|
|
|
does nothing */
|
|
|
|
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 */
|
|
|
|
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 */
|
|
|
|
/*************************************************************************
|
2001-02-17 13:19:19 +01:00
|
|
|
Checks that a record is seen in a consistent read. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_clust_rec_cons_read_sees(
|
|
|
|
/*==========================*/
|
|
|
|
/* out: TRUE if sees, or FALSE if an earlier
|
|
|
|
version of the record should be retrieved */
|
|
|
|
rec_t* rec, /* in: user record which should be read or
|
|
|
|
passed over by a read cursor */
|
|
|
|
dict_index_t* index, /* in: clustered index */
|
2004-12-02 18:45:07 +01:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
2001-02-17 13:19:19 +01:00
|
|
|
read_view_t* view); /* in: consistent read view */
|
|
|
|
/*************************************************************************
|
|
|
|
Checks that a non-clustered index record is seen in a consistent read. */
|
|
|
|
|
|
|
|
ulint
|
|
|
|
lock_sec_rec_cons_read_sees(
|
|
|
|
/*========================*/
|
|
|
|
/* out: TRUE if certainly sees, or FALSE if an
|
|
|
|
earlier version of the clustered index record
|
|
|
|
might be needed: NOTE that a non-clustered
|
|
|
|
index page contains so little information on
|
|
|
|
its modifications that also in the case FALSE,
|
|
|
|
the present version of rec may be the right,
|
|
|
|
but we must check this from the clustered
|
|
|
|
index record */
|
|
|
|
rec_t* rec, /* in: user record which should be read or
|
|
|
|
passed over by a read cursor */
|
|
|
|
dict_index_t* index, /* in: non-clustered index */
|
|
|
|
read_view_t* view); /* in: consistent read view */
|
|
|
|
/*************************************************************************
|
|
|
|
Locks the specified database table in the mode given. If the lock cannot
|
|
|
|
be granted immediately, the query thread is put to wait. */
|
|
|
|
|
|
|
|
ulint
|
|
|
|
lock_table(
|
|
|
|
/*=======*/
|
|
|
|
/* out: DB_SUCCESS, DB_LOCK_WAIT,
|
|
|
|
DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */
|
|
|
|
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
|
2005-06-08 14:45:56 +02:00
|
|
|
does nothing */
|
2001-02-17 13:19:19 +01:00
|
|
|
dict_table_t* table, /* in: database table in dictionary cache */
|
|
|
|
ulint mode, /* in: lock mode */
|
|
|
|
que_thr_t* thr); /* in: query thread */
|
|
|
|
/*************************************************************************
|
|
|
|
Checks if there are any locks set on the table. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_is_on_table(
|
|
|
|
/*=============*/
|
|
|
|
/* out: TRUE if there are lock(s) */
|
|
|
|
dict_table_t* table); /* in: database table in dictionary cache */
|
2005-12-22 06:39:02 +01:00
|
|
|
/*****************************************************************
|
|
|
|
Removes a granted record lock of a transaction from the queue and grants
|
|
|
|
locks to other transactions waiting in the queue if they now are entitled
|
|
|
|
to a lock. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_rec_unlock(
|
|
|
|
/*============*/
|
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
2006-03-10 17:22:21 +01:00
|
|
|
trx_t* trx, /* in: transaction that has set a record
|
2005-12-22 06:39:02 +01:00
|
|
|
lock */
|
|
|
|
rec_t* rec, /* in: record */
|
|
|
|
ulint lock_mode); /* in: LOCK_S or LOCK_X */
|
2001-02-17 13:19:19 +01:00
|
|
|
/*************************************************************************
|
2004-04-29 15:42:33 +02:00
|
|
|
Releases a table lock.
|
|
|
|
Releases possible other transactions waiting for this lock. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_table_unlock(
|
|
|
|
/*==============*/
|
|
|
|
lock_t* lock); /* in: lock */
|
|
|
|
/*************************************************************************
|
2001-10-10 21:47:08 +02:00
|
|
|
Releases an auto-inc lock a transaction possibly has on a table.
|
|
|
|
Releases possible other transactions waiting for this lock. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_table_unlock_auto_inc(
|
|
|
|
/*=======================*/
|
|
|
|
trx_t* trx); /* in: transaction */
|
|
|
|
/*************************************************************************
|
2001-02-17 13:19:19 +01:00
|
|
|
Releases transaction locks, and releases possible other transactions waiting
|
|
|
|
because of these locks. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_release_off_kernel(
|
|
|
|
/*====================*/
|
|
|
|
trx_t* trx); /* in: transaction */
|
|
|
|
/*************************************************************************
|
2001-10-10 21:47:08 +02:00
|
|
|
Cancels a waiting lock request and releases possible other transactions
|
|
|
|
waiting behind it. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_cancel_waiting_and_release(
|
|
|
|
/*============================*/
|
|
|
|
lock_t* lock); /* in: waiting lock request */
|
2008-12-14 21:00:37 +01:00
|
|
|
|
2001-10-10 21:47:08 +02:00
|
|
|
/*************************************************************************
|
2008-12-14 21:00:37 +01:00
|
|
|
Removes locks on a table to be dropped or truncated.
|
|
|
|
If remove_also_table_sx_locks is TRUE then table-level S and X locks are
|
|
|
|
also removed in addition to other table-level and record-level locks.
|
|
|
|
No lock, that is going to be removed, is allowed to be a wait lock. */
|
2001-04-10 20:58:07 +02:00
|
|
|
|
|
|
|
void
|
2008-12-14 21:00:37 +01:00
|
|
|
lock_remove_all_on_table(
|
|
|
|
/*=====================*/
|
|
|
|
dict_table_t* table, /* in: table to be dropped
|
|
|
|
or truncated */
|
|
|
|
ibool remove_also_table_sx_locks);/* in: also removes
|
|
|
|
table S and X locks */
|
|
|
|
|
2001-04-10 20:58:07 +02:00
|
|
|
/*************************************************************************
|
2001-02-17 13:19:19 +01:00
|
|
|
Calculates the fold value of a page file address: used in inserting or
|
|
|
|
searching for a lock in the hash table. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
lock_rec_fold(
|
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
2006-03-10 17:22:21 +01:00
|
|
|
/*==========*/
|
2001-02-17 13:19:19 +01:00
|
|
|
/* out: folded value */
|
|
|
|
ulint space, /* in: space */
|
|
|
|
ulint page_no);/* in: page number */
|
|
|
|
/*************************************************************************
|
|
|
|
Calculates the hash value of a page file address: used in inserting or
|
|
|
|
searching for a lock in the hash table. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
lock_rec_hash(
|
|
|
|
/*==========*/
|
|
|
|
/* out: hashed value */
|
|
|
|
ulint space, /* in: space */
|
|
|
|
ulint page_no);/* in: page number */
|
|
|
|
/*************************************************************************
|
2004-11-30 16:34:37 +01:00
|
|
|
Gets the source table of an ALTER TABLE transaction. The table must be
|
|
|
|
covered by an IX or IS table lock. */
|
2004-11-03 20:32:48 +01:00
|
|
|
|
|
|
|
dict_table_t*
|
2004-11-30 16:34:37 +01:00
|
|
|
lock_get_src_table(
|
|
|
|
/*===============*/
|
|
|
|
/* out: the source table of transaction,
|
|
|
|
if it is covered by an IX or IS table lock;
|
|
|
|
dest if there is no source table, and
|
|
|
|
NULL if the transaction is locking more than
|
|
|
|
two tables or an inconsistency is found */
|
|
|
|
trx_t* trx, /* in: transaction */
|
|
|
|
dict_table_t* dest, /* in: destination of ALTER TABLE */
|
|
|
|
ulint* mode); /* out: lock mode of the source table */
|
|
|
|
/*************************************************************************
|
|
|
|
Determine if the given table is exclusively "owned" by the given
|
|
|
|
transaction, i.e., transaction holds LOCK_IX and possibly LOCK_AUTO_INC
|
|
|
|
on the table. */
|
|
|
|
|
|
|
|
ibool
|
2004-11-30 21:17:03 +01:00
|
|
|
lock_is_table_exclusive(
|
2004-11-30 22:10:17 +01:00
|
|
|
/*====================*/
|
2004-11-30 16:34:37 +01:00
|
|
|
/* out: TRUE if table is only locked by trx,
|
|
|
|
with LOCK_IX, and possibly LOCK_AUTO_INC */
|
|
|
|
dict_table_t* table, /* in: table */
|
|
|
|
trx_t* trx); /* in: transaction */
|
2004-11-03 20:32:48 +01:00
|
|
|
/*************************************************************************
|
2007-07-25 03:34:31 +02:00
|
|
|
Checks if a lock request lock1 has to wait for request lock2. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_has_to_wait(
|
|
|
|
/*=============*/
|
|
|
|
/* out: TRUE if lock1 has to wait for lock2 to be
|
|
|
|
removed */
|
|
|
|
lock_t* lock1, /* in: waiting lock */
|
|
|
|
lock_t* lock2); /* in: another lock; NOTE that it is assumed that this
|
|
|
|
has a lock bit set on the same record as in lock1 if
|
|
|
|
the locks are record locks */
|
|
|
|
/*************************************************************************
|
2003-06-15 00:04:28 +02:00
|
|
|
Checks that a transaction id is sensible, i.e., not in the future. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_check_trx_id_sanity(
|
|
|
|
/*=====================*/
|
|
|
|
/* out: TRUE if ok */
|
|
|
|
dulint trx_id, /* in: trx id */
|
|
|
|
rec_t* rec, /* in: user record */
|
|
|
|
dict_index_t* index, /* in: clustered index */
|
2004-12-02 18:45:07 +01:00
|
|
|
const ulint* offsets, /* in: rec_get_offsets(rec, index) */
|
2003-06-15 00:04:28 +02:00
|
|
|
ibool has_kernel_mutex);/* in: TRUE if the caller owns the
|
|
|
|
kernel mutex */
|
|
|
|
/*************************************************************************
|
2001-02-17 13:19:19 +01:00
|
|
|
Validates the lock queue on a single record. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_rec_queue_validate(
|
|
|
|
/*====================*/
|
|
|
|
/* out: TRUE if ok */
|
|
|
|
rec_t* rec, /* in: record to look at */
|
2004-12-02 18:45:07 +01:00
|
|
|
dict_index_t* index, /* in: index, or NULL if not known */
|
|
|
|
const ulint* offsets);/* in: rec_get_offsets(rec, index) */
|
2001-02-17 13:19:19 +01:00
|
|
|
/*************************************************************************
|
|
|
|
Prints info of a table lock. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_table_print(
|
|
|
|
/*=============*/
|
2004-04-06 15:14:43 +02:00
|
|
|
FILE* file, /* in: file where to print */
|
2001-02-17 13:19:19 +01:00
|
|
|
lock_t* lock); /* in: table type lock */
|
|
|
|
/*************************************************************************
|
|
|
|
Prints info of a record lock. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_rec_print(
|
|
|
|
/*===========*/
|
2004-04-06 15:14:43 +02:00
|
|
|
FILE* file, /* in: file where to print */
|
2001-02-17 13:19:19 +01:00
|
|
|
lock_t* lock); /* in: record type lock */
|
|
|
|
/*************************************************************************
|
|
|
|
Prints info of locks for all transactions. */
|
|
|
|
|
2009-12-23 07:59:34 +01:00
|
|
|
ibool
|
2005-04-19 13:35:47 +02:00
|
|
|
lock_print_info_summary(
|
|
|
|
/*====================*/
|
2009-12-23 07:59:34 +01:00
|
|
|
/* out: FALSE if not able to obtain
|
|
|
|
kernel mutex and exits without
|
|
|
|
printing info */
|
|
|
|
FILE* file, /* in: file where to print */
|
|
|
|
ibool nowait);/* in: whether to wait for the kernel
|
|
|
|
mutex */
|
2005-04-19 13:35:47 +02:00
|
|
|
/*************************************************************************
|
|
|
|
Prints info of locks for each transaction. */
|
|
|
|
|
|
|
|
void
|
|
|
|
lock_print_info_all_transactions(
|
|
|
|
/*=============================*/
|
2004-04-06 15:14:43 +02:00
|
|
|
FILE* file); /* in: file where to print */
|
2001-02-17 13:19:19 +01:00
|
|
|
/*************************************************************************
|
|
|
|
Validates the lock queue on a table. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_table_queue_validate(
|
|
|
|
/*======================*/
|
|
|
|
/* out: TRUE if ok */
|
|
|
|
dict_table_t* table); /* in: table */
|
|
|
|
/*************************************************************************
|
|
|
|
Validates the record lock queues on a page. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_rec_validate_page(
|
|
|
|
/*===================*/
|
|
|
|
/* out: TRUE if ok */
|
|
|
|
ulint space, /* in: space id */
|
|
|
|
ulint page_no);/* in: page number */
|
|
|
|
/*************************************************************************
|
|
|
|
Validates the lock system. */
|
|
|
|
|
|
|
|
ibool
|
|
|
|
lock_validate(void);
|
|
|
|
/*===============*/
|
|
|
|
/* out: TRUE if ok */
|
Applied innodb-5.1-ss475 snapshot.
* Fix BUG#15650: "DELETE with LEFT JOIN crashes server with innodb_locks_unsafe_for binlog"
* Fix BUG#17134: "Partitions: uncommitted changes are visible"
* Fix BUG#17992: "Partitions: InnoDB, somehow rotten table after UPDATE"
row0ins.c: MySQL's partitioned table code does not set preduilt->sql_stat_start right
if it does an insert in the same statement after doing a search first in the same
partition table. We now write trx id always to the buffer, not just when flag
sql_stat_start is on. This will waste CPU time very sightly.
* Fix BUG#18077: "InnoDB uses full explicit table locks in stored FUNCTION"
* Fix BUG#18238: "When locks exhaust the buffer pool, InnoDB does not roll back the trx"
* Fix BUG#18252" "Disk space leak in updates of InnoDB BLOB rows in 5.0 and 5.1"
* Fix BUG#18283: "When InnoDB returns error 'lock table full', MySQL can write to binlog too much"
* Fix BUG#18350: "Use consistent read in CREATE ... SELECT ... if innodb_locks_unsafe_for_binlog"
* Fix BUG#18384: "InnoDB memory leak on duplicate key errors in 5.0 if row has many columns"
* Fix BUG#18934: "InnoDB crashes when table uses column names like DB_ROW_ID"
Refuse tables that use reserved column names.
* InnoDB's SQL parser:
- Add support for UNSIGNED types, EXIT keyword, quoted identifiers, user-function callbacks
for processing results of FETCH statements, bound literals, DATA_VARCHAR for bound literals.
- Allow bound literals of type non-INTEGER to be of length 0.
- Add make_flex.sh and update lexer/parser generation documentation.
- Add comment clarifying the difference between 'alias' and 'indirection' fields in sym_node_t.
- Remove never reached duplicate code in pars_set_dfield_type().
- Rewrite pars_info datatypes and APIs, add a few helper functions.
- Since the functions definitions in pars_info_t are accessed after pars_sql() returns
in the query graph execution stage, we can't free pars_info_t in pars_sql(). Instead,
make pars_sql() transfer ownership of pars_info_t to the created query graph, and
make que_graph_free() free it if needed.
- Allow access to system columns like DB_ROW_ID.
* Use bound literals in row_truncate_table_for_mysql, row_drop_table_for_mysql,
row_discard_tablespace_for_mysql, and row_rename_table_for_mysql.
* Setting an isolation level of the transaction to read committed weakens the locks for
this session similarly like the option innodb_locks_unsafe_for binlog. This patch removes
alnost all gap locking (used in next-key locking) and makes MySQL to release the row locks
on the rows which does not belong to result set. Additionally, nonlocking selects on
INSERT INTO SELECT, UPDATE ... (SELECT ...), and CREATE ... SELECT ... use a nonlocking
consistent read. If a binlog is used, then binlog format should be set to row based
binloging to make the execution of the complex SQL statements.
* Disable the statistic variables btr_search_n_hash_fail and n_hash_succ, n_hash_fail,
n_patt_succ, and n_searches of btr_search_t in builds without #ifdef UNIV_SEARCH_PERF_STAT.
* Make innodb.test faster. Group all consistent read test cases to a one test case and
wait their lock timeout after all have been send to the server. Decrease amount of rows
inserted in a certain test - this has no effect on the effectiveness of the test and
reduces the running time by ~10 sec. Remove temporary work-arounds from innodb.result
now that ALTER TABLE DROP FOREIGN KEY works once again.
* Make innodb_unsafe_binlog.test faster. Grout all consistent read test cases to a one
test case amd wait their lock timeout after all have been sent to the server. Remove
unnecessary option --loose_innodb_lock_wait_timeout.
* Print dictionary memory size in SHOW INNODB STATUS.
* Fix memory leaks in row_create_table_for_mysql() in rare corner cases.
* Remove code related to clustered tables. They were never implemented, and the
implementation would be challenging with ROW_FORMAT=COMPACT. Remove the table types
DICT_TABLE_CLUSTER_MEMBER and DICT_TABLE_CLUSTER and all related tests and functions.
dict_table_t: Remove mix_id, mix_len, mix_id_len, mix_id_buf, and cluster_name.
plan_t: Remove mixed_index.
dict_create_sys_tables_tuple(): Set MIX_ID=0, MIX_LEN=0, CLUSTER_NAME=NULL when
inserting into SYS_TABLES.
dict_tree_check_search_tuple(): Enclose in #ifdef UNIV_DEBUG.
* Move calling of thr_local_free() from trx_free_for_mysql() to
innobase_close_connection().
2006-04-23 10:48:31 +02:00
|
|
|
/*************************************************************************
|
|
|
|
Return approximate number or record locks (bits set in the bitmap) for
|
2007-08-25 03:14:52 +02:00
|
|
|
this transaction. Since delete-marked records may be removed, the
|
Applied innodb-5.1-ss475 snapshot.
* Fix BUG#15650: "DELETE with LEFT JOIN crashes server with innodb_locks_unsafe_for binlog"
* Fix BUG#17134: "Partitions: uncommitted changes are visible"
* Fix BUG#17992: "Partitions: InnoDB, somehow rotten table after UPDATE"
row0ins.c: MySQL's partitioned table code does not set preduilt->sql_stat_start right
if it does an insert in the same statement after doing a search first in the same
partition table. We now write trx id always to the buffer, not just when flag
sql_stat_start is on. This will waste CPU time very sightly.
* Fix BUG#18077: "InnoDB uses full explicit table locks in stored FUNCTION"
* Fix BUG#18238: "When locks exhaust the buffer pool, InnoDB does not roll back the trx"
* Fix BUG#18252" "Disk space leak in updates of InnoDB BLOB rows in 5.0 and 5.1"
* Fix BUG#18283: "When InnoDB returns error 'lock table full', MySQL can write to binlog too much"
* Fix BUG#18350: "Use consistent read in CREATE ... SELECT ... if innodb_locks_unsafe_for_binlog"
* Fix BUG#18384: "InnoDB memory leak on duplicate key errors in 5.0 if row has many columns"
* Fix BUG#18934: "InnoDB crashes when table uses column names like DB_ROW_ID"
Refuse tables that use reserved column names.
* InnoDB's SQL parser:
- Add support for UNSIGNED types, EXIT keyword, quoted identifiers, user-function callbacks
for processing results of FETCH statements, bound literals, DATA_VARCHAR for bound literals.
- Allow bound literals of type non-INTEGER to be of length 0.
- Add make_flex.sh and update lexer/parser generation documentation.
- Add comment clarifying the difference between 'alias' and 'indirection' fields in sym_node_t.
- Remove never reached duplicate code in pars_set_dfield_type().
- Rewrite pars_info datatypes and APIs, add a few helper functions.
- Since the functions definitions in pars_info_t are accessed after pars_sql() returns
in the query graph execution stage, we can't free pars_info_t in pars_sql(). Instead,
make pars_sql() transfer ownership of pars_info_t to the created query graph, and
make que_graph_free() free it if needed.
- Allow access to system columns like DB_ROW_ID.
* Use bound literals in row_truncate_table_for_mysql, row_drop_table_for_mysql,
row_discard_tablespace_for_mysql, and row_rename_table_for_mysql.
* Setting an isolation level of the transaction to read committed weakens the locks for
this session similarly like the option innodb_locks_unsafe_for binlog. This patch removes
alnost all gap locking (used in next-key locking) and makes MySQL to release the row locks
on the rows which does not belong to result set. Additionally, nonlocking selects on
INSERT INTO SELECT, UPDATE ... (SELECT ...), and CREATE ... SELECT ... use a nonlocking
consistent read. If a binlog is used, then binlog format should be set to row based
binloging to make the execution of the complex SQL statements.
* Disable the statistic variables btr_search_n_hash_fail and n_hash_succ, n_hash_fail,
n_patt_succ, and n_searches of btr_search_t in builds without #ifdef UNIV_SEARCH_PERF_STAT.
* Make innodb.test faster. Group all consistent read test cases to a one test case and
wait their lock timeout after all have been send to the server. Decrease amount of rows
inserted in a certain test - this has no effect on the effectiveness of the test and
reduces the running time by ~10 sec. Remove temporary work-arounds from innodb.result
now that ALTER TABLE DROP FOREIGN KEY works once again.
* Make innodb_unsafe_binlog.test faster. Grout all consistent read test cases to a one
test case amd wait their lock timeout after all have been sent to the server. Remove
unnecessary option --loose_innodb_lock_wait_timeout.
* Print dictionary memory size in SHOW INNODB STATUS.
* Fix memory leaks in row_create_table_for_mysql() in rare corner cases.
* Remove code related to clustered tables. They were never implemented, and the
implementation would be challenging with ROW_FORMAT=COMPACT. Remove the table types
DICT_TABLE_CLUSTER_MEMBER and DICT_TABLE_CLUSTER and all related tests and functions.
dict_table_t: Remove mix_id, mix_len, mix_id_len, mix_id_buf, and cluster_name.
plan_t: Remove mixed_index.
dict_create_sys_tables_tuple(): Set MIX_ID=0, MIX_LEN=0, CLUSTER_NAME=NULL when
inserting into SYS_TABLES.
dict_tree_check_search_tuple(): Enclose in #ifdef UNIV_DEBUG.
* Move calling of thr_local_free() from trx_free_for_mysql() to
innobase_close_connection().
2006-04-23 10:48:31 +02:00
|
|
|
record count will not be precise. */
|
|
|
|
|
|
|
|
ulint
|
|
|
|
lock_number_of_rows_locked(
|
|
|
|
/*=======================*/
|
|
|
|
trx_t* trx); /* in: transaction */
|
2001-02-17 13:19:19 +01:00
|
|
|
|
|
|
|
/* The lock system */
|
|
|
|
extern lock_sys_t* lock_sys;
|
|
|
|
|
|
|
|
/* Lock modes and types */
|
2002-10-29 22:16:46 +01:00
|
|
|
/* Basic modes */
|
2001-02-17 13:19:19 +01:00
|
|
|
#define LOCK_NONE 0 /* this flag is used elsewhere to note
|
|
|
|
consistent read */
|
|
|
|
#define LOCK_IS 2 /* intention shared */
|
|
|
|
#define LOCK_IX 3 /* intention exclusive */
|
|
|
|
#define LOCK_S 4 /* shared */
|
|
|
|
#define LOCK_X 5 /* exclusive */
|
2001-10-10 21:47:08 +02:00
|
|
|
#define LOCK_AUTO_INC 6 /* locks the auto-inc counter of a table
|
|
|
|
in an exclusive mode */
|
2004-04-01 15:51:34 +02:00
|
|
|
#define LOCK_MODE_MASK 0xFUL /* mask used to extract mode from the
|
2001-02-17 13:19:19 +01:00
|
|
|
type_mode field in a lock */
|
2002-10-29 22:16:46 +01:00
|
|
|
/* Lock types */
|
2001-02-17 13:19:19 +01:00
|
|
|
#define LOCK_TABLE 16 /* these type values should be so high that */
|
|
|
|
#define LOCK_REC 32 /* they can be ORed to the lock mode */
|
2004-04-01 15:51:34 +02:00
|
|
|
#define LOCK_TYPE_MASK 0xF0UL /* mask used to extract lock type from the
|
2001-02-17 13:19:19 +01:00
|
|
|
type_mode field in a lock */
|
2002-10-29 22:16:46 +01:00
|
|
|
/* Waiting lock flag */
|
2001-02-17 13:19:19 +01:00
|
|
|
#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 */
|
2002-10-29 22:16:46 +01:00
|
|
|
/* Precise modes */
|
|
|
|
#define LOCK_ORDINARY 0 /* this flag denotes an ordinary next-key lock
|
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
2006-03-10 17:22:21 +01:00
|
|
|
in contrast to LOCK_GAP or LOCK_REC_NOT_GAP */
|
2001-02-17 13:19:19 +01:00
|
|
|
#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
|
|
|
|
lock holds only on the gap before the record;
|
|
|
|
for instance, an x-lock on the gap does not
|
|
|
|
give permission to modify the record on which
|
|
|
|
the bit is set; locks of this type are created
|
|
|
|
when records are removed from the index chain
|
|
|
|
of records */
|
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
2006-03-10 17:22:21 +01:00
|
|
|
#define LOCK_REC_NOT_GAP 1024 /* this bit means that the lock is only on
|
2002-10-29 22:16:46 +01:00
|
|
|
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
|
2002-08-22 12:22:04 +02:00
|
|
|
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
|
|
|
|
transactions on the gap; note that this flag
|
|
|
|
remains set when the waiting lock is granted,
|
|
|
|
or if the lock is inherited to a neighboring
|
|
|
|
record */
|
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
2006-03-10 17:22:21 +01:00
|
|
|
|
2001-02-17 13:19:19 +01:00
|
|
|
/* When lock bits are reset, the following flags are available: */
|
|
|
|
#define LOCK_RELEASE_WAIT 1
|
|
|
|
#define LOCK_NOT_RELEASE_WAIT 2
|
|
|
|
|
|
|
|
/* Lock operation struct */
|
|
|
|
typedef struct lock_op_struct lock_op_t;
|
|
|
|
struct lock_op_struct{
|
|
|
|
dict_table_t* table; /* table to be locked */
|
|
|
|
ulint mode; /* lock mode */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define LOCK_OP_START 1
|
|
|
|
#define LOCK_OP_COMPLETE 2
|
|
|
|
|
|
|
|
/* The lock system struct */
|
|
|
|
struct lock_sys_struct{
|
|
|
|
hash_table_t* rec_hash; /* hash table of the record locks */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The lock system */
|
|
|
|
extern lock_sys_t* lock_sys;
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef UNIV_NONINL
|
|
|
|
#include "lock0lock.ic"
|
|
|
|
#endif
|
|
|
|
|
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
2006-03-10 17:22:21 +01:00
|
|
|
#endif
|