From 48b0f260299f433449bb479f9f3e919e9f9bb9a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2007 22:38:26 +0400 Subject: Fix for bug #28415 "Some ALTER TABLE statements no longer work under LOCK TABLES" and failures of alter_table.test on Windows which occured after pushing fix for bugs #20662, #20903, #24508, #24738 (various problems with CREATE TABLE SELECT). ALTER TABLE statements which were handled using "fast" alter table optimization were not properly working under LOCK TABLES if table was transactional (for all table types under Windows). Code implementing "fast" version of ALTER TABLE tried to open and lock table using open_ltable() after renaming .FRM files (which corresponds to renaming tables in normal case) in some cases (for transactional tables or on Windows). This caused problems under LOCK TABLES and conflicted with name-lock taken by ALTER TABLE RENAME on target tables. This patch solves this issue by using reopen_name_locked_table() instead of open_ltable(). mysql-test/include/mix1.inc: Added test for bug #28415 "Some ALTER TABLE statements no longer work under LOCK TABLES" and minimal coverage for fast ALTER TABLE behaviour for transactional tables. mysql-test/r/innodb_mysql.result: Added test for bug #28415 "Some ALTER TABLE statements no longer work under LOCK TABLES" and minimal coverage for fast ALTER TABLE behaviour for transactional tables. sql/sql_table.cc: mysql_alter_table(): Fixed handling of transactional tables (and all tables on Windows) by "fast" ALTER TABLE. Code implementing "fast" version of ALTER TABLE tried to open and lock table using open_ltable() after renaming .FRM files (which corresponds to renaming tables in normal case) for such tables. This caused problems under LOCK TABLES and conflicted with name-lock taken by ALTER TABLE RENAME on target tables. We solve this issue by using reopen_name_locked_table() instead of open_ltable(). --- mysql-test/include/mix1.inc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mysql-test/include') diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index 352d5a987a2..fce37eef187 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -688,4 +688,24 @@ select * from t2; drop table t2; + +# +# Tests for bug #28415 "Some ALTER TABLE statements no longer work +# under LOCK TABLES" and some aspects of fast ALTER TABLE behaviour +# for transactional tables. +# +--disable_warnings +drop table if exists t1, t2; +--enable_warnings +create table t1 (i int); +alter table t1 modify i int default 1; +alter table t1 modify i int default 2, rename t2; +lock table t2 write; +alter table t2 modify i int default 3; +unlock tables; +lock table t2 write; +alter table t2 modify i int default 4, rename t1; +unlock tables; +drop table t1; + --echo End of 5.1 tests -- cgit v1.2.1