diff options
author | jan@hundin.mysql.fi <> | 2005-04-18 12:17:32 +0300 |
---|---|---|
committer | jan@hundin.mysql.fi <> | 2005-04-18 12:17:32 +0300 |
commit | 384efc449398925cca78d5fe98d3ac53e3b6aa6d (patch) | |
tree | 4fbea185fc44cfd8a323bda87c1af75a8ee9d5b6 /innobase/row | |
parent | 39f412d32950062a8a7cba2d32e1d8556e3b56ee (diff) | |
download | mariadb-git-384efc449398925cca78d5fe98d3ac53e3b6aa6d.tar.gz |
Fixed a bug: deadlock without any locking, simple select and update (Bug #7975).
Backported from 5.0.3.
Diffstat (limited to 'innobase/row')
-rw-r--r-- | innobase/row/row0ins.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index 15ffabf70cc..5ca1ee51cbd 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -51,14 +51,19 @@ innobase_invalidate_query_cache( chars count */ /********************************************************************** -This function returns true if SQL-query in the current thread +This function returns true if + +1) SQL-query in the current thread is either REPLACE or LOAD DATA INFILE REPLACE. + +2) SQL-query in the current thread +is INSERT ON DUPLICATE KEY UPDATE. + NOTE that /mysql/innobase/row/row0ins.c must contain the prototype for this function ! */ ibool -innobase_query_is_replace(void); -/*===========================*/ +innobase_query_is_update(void); /************************************************************************* Creates an insert node struct. */ @@ -1562,12 +1567,12 @@ row_ins_scan_sec_index_for_duplicate( trx = thr_get_trx(thr); ut_ad(trx); - if (innobase_query_is_replace()) { + if (innobase_query_is_update()) { - /* The manual defines the REPLACE semantics that it - is either an INSERT or DELETE(s) for duplicate key - + INSERT. Therefore, we should take X-lock for - duplicates */ + /* If the SQL-query will update or replace + duplicate key we will take X-lock for + duplicates ( REPLACE, LOAD DATAFILE REPLACE, + INSERT ON DUPLICATE KEY UPDATE). */ err = row_ins_set_exclusive_rec_lock( LOCK_ORDINARY,rec,index,thr); @@ -1675,12 +1680,12 @@ row_ins_duplicate_error_in_clust( sure that in roll-forward we get the same duplicate errors as in original execution */ - if (innobase_query_is_replace()) { + if (innobase_query_is_update()) { - /* The manual defines the REPLACE semantics - that it is either an INSERT or DELETE(s) - for duplicate key + INSERT. Therefore, we - should take X-lock for duplicates */ + /* If the SQL-query will update or replace + duplicate key we will take X-lock for + duplicates ( REPLACE, LOAD DATAFILE REPLACE, + INSERT ON DUPLICATE KEY UPDATE). */ err = row_ins_set_exclusive_rec_lock( LOCK_REC_NOT_GAP,rec,cursor->index, @@ -1713,12 +1718,12 @@ row_ins_duplicate_error_in_clust( if (rec != page_get_supremum_rec(page)) { - /* The manual defines the REPLACE semantics that it - is either an INSERT or DELETE(s) for duplicate key - + INSERT. Therefore, we should take X-lock for - duplicates. */ + if (innobase_query_is_update()) { - if (innobase_query_is_replace()) { + /* If the SQL-query will update or replace + duplicate key we will take X-lock for + duplicates ( REPLACE, LOAD DATAFILE REPLACE, + INSERT ON DUPLICATE KEY UPDATE). */ err = row_ins_set_exclusive_rec_lock( LOCK_REC_NOT_GAP, |