From 56ea770272bf6c81873922aa8a0c146f4e9921b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Apr 2005 12:17:32 +0300 Subject: 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. --- sql/ha_innodb.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'sql/ha_innodb.cc') 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; } } -- cgit v1.2.1