diff options
author | unknown <jan@hundin.mysql.fi> | 2005-04-18 12:17:32 +0300 |
---|---|---|
committer | unknown <jan@hundin.mysql.fi> | 2005-04-18 12:17:32 +0300 |
commit | 56ea770272bf6c81873922aa8a0c146f4e9921b0 (patch) | |
tree | 4fbea185fc44cfd8a323bda87c1af75a8ee9d5b6 /sql/ha_innodb.cc | |
parent | b51f70b81e6af314093dd28728a3dc68d1a28fff (diff) | |
download | mariadb-git-56ea770272bf6c81873922aa8a0c146f4e9921b0.tar.gz |
Fixed a bug: deadlock without any locking, simple select and update (Bug #7975).
Backported from 5.0.3.
innobase/row/row0ins.c:
If the SQL-query will update or replace duplicate records we take X-lock
for duplicate records.
sql/ha_innodb.cc:
INSERT ON DUPLICATE KEY UPDATE will also update duplicate records and we should
take X-lock in this case for duplicate records.
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r-- | sql/ha_innodb.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 6cb35fb392d..06d9bf24c13 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -5653,13 +5653,19 @@ innobase_get_at_most_n_mbchars( extern "C" { /********************************************************************** -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) /*===========================*/ { THD* thd; @@ -5671,9 +5677,14 @@ innobase_query_is_replace(void) ( thd->lex->sql_command == SQLCOM_LOAD && thd->lex->duplicates == DUP_REPLACE )) { return true; - } else { - return false; } + + if ( thd->lex->sql_command == SQLCOM_INSERT && + thd->lex->duplicates == DUP_UPDATE ) { + return true; + } + + return false; } } |