From bb37525b77096f06240a3292a026ba8711f7c7f9 Mon Sep 17 00:00:00 2001
From: osku <Unknown>
Date: Fri, 2 Jun 2006 07:10:14 +0000
Subject: [PATCH] From MySQL:

Fix bug #17264. For alter table on win32 for succesful operation completion
it is used TL_WRITE(=10) lock instead of TL_WRITE_ALLOW_READ(=6), however in
InnoDB handler TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes race
condition when several clients do alter table simultaneously.
---
 handler/ha_innodb.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc
index fb750ddb803..9ec17a26610 100644
--- a/handler/ha_innodb.cc
+++ b/handler/ha_innodb.cc
@@ -6940,6 +6940,17 @@ ha_innobase::store_lock(
 		&& !thd->tablespace_op
 		&& thd->lex->sql_command != SQLCOM_TRUNCATE
 		&& thd->lex->sql_command != SQLCOM_OPTIMIZE
+
+#ifdef __WIN__
+                /* For alter table on win32 for succesful operation
+                completion it is used TL_WRITE(=10) lock instead of
+                TL_WRITE_ALLOW_READ(=6), however here in innodb handler
+                TL_WRITE is lifted to TL_WRITE_ALLOW_WRITE, which causes
+                race condition when several clients do alter table
+                simultaneously (bug #17264). This fix avoids the problem. */
+                && thd->lex->sql_command != SQLCOM_ALTER_TABLE
+#endif
+
 		&& thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
 
 			lock_type = TL_WRITE_ALLOW_WRITE;
-- 
2.30.9