#At file:///home/dlenev/src/bzr/mysql-6.1-falcon-bugs/ based on revid:dlenev@stripped
2723 Dmitry Lenev 2009-07-02
Bug#45701 - If a table has two foreign key relationships with one other table, an
alter table that drops one of the FKs will call external_lock twice for each table.
And if a table has a foreign key relationship with another table, an alter that
creates another foreign key relationship between the two tables will also call
external_lock twice for each table.
So it is necessary for Falcon to support multiple calls to external_lock by the
same connection to the same table. This was not needed before the Foreign Key
implementation.
So the current Connection pointer is sent into Table::SetAlter() and stored in
Table::alterConnection. And alterIsActive is now an int instead of a boolean.
If the same connection locks the table a second time, alterIsActive is incremented
and alterConnection remains set. It is not set to NULL until alterIsActive is
decremented to zero.
Manually applied patch from Falcon team tree to mysql-6.1-fk tree.
modified:
storage/falcon/StorageTable.cpp
storage/falcon/Table.cpp
storage/falcon/Table.h
=== modified file 'storage/falcon/StorageTable.cpp'
--- a/storage/falcon/StorageTable.cpp 2009-04-16 11:25:48 +0000
+++ b/storage/falcon/StorageTable.cpp 2009-07-01 20:07:55 +0000
@@ -634,7 +634,7 @@ void StorageTable::clearAlter(void)
bool StorageTable::setAlter(void)
{
- return share->table->setAlter();
+ return share->table->setAlter(storageConnection->connection);
}
int StorageTable::alterCheck(void)
=== modified file 'storage/falcon/Table.cpp'
--- a/storage/falcon/Table.cpp 2009-04-16 11:25:48 +0000
+++ b/storage/falcon/Table.cpp 2009-07-01 20:07:55 +0000
@@ -914,7 +914,8 @@ void Table::init(int id, const char *sch
debugThawedBytes = 0;
cardinality = 0;
priorCardinality = 0;
- alterIsActive = false;
+ alterIsActive = 0;
+ alterConnection = NULL;
syncObject.setName("Table::syncObject");
syncTriggers.setName("Table::syncTriggers");
syncAlter.setName("Table::syncAlter");
@@ -1765,7 +1766,8 @@ void Table::truncate(Transaction *transa
ageGroup = database->currentGeneration;
debugThawedRecords = 0;
debugThawedBytes = 0;
- alterIsActive = false;
+ alterIsActive = 0;
+ alterConnection = NULL;
deleting = false;
}
@@ -3638,19 +3640,21 @@ void Table::clearAlter(void)
{
Sync sync(&syncAlter, "Table::clearAlter");
sync.lock(Exclusive);
- alterIsActive = false;
+ if (--alterIsActive == 0)
+ alterConnection = NULL;
}
}
-bool Table::setAlter(void)
+bool Table::setAlter(Connection* connection)
{
Sync sync(&syncAlter, "Table::setAlter");
sync.lock(Exclusive);
- if (alterIsActive)
+ if (alterIsActive && (connection != alterConnection))
return false;
- alterIsActive = true;
+ alterIsActive++;
+ alterConnection = connection;
return true;
}
=== modified file 'storage/falcon/Table.h'
--- a/storage/falcon/Table.h 2009-04-09 15:40:11 +0000
+++ b/storage/falcon/Table.h 2009-07-01 20:07:55 +0000
@@ -127,7 +127,7 @@ public:
int nextColumnId (int previous);
void loadStuff();
void clearAlter(void);
- bool setAlter(void);
+ bool setAlter(Connection* connection);
void addTrigger (Trigger *trigger);
void dropTrigger (Trigger *trigger);
@@ -271,7 +271,8 @@ public:
bool changed;
bool eof;
bool markedForDelete;
- bool alterIsActive;
+ int alterIsActive;
+ Connection* alterConnection; // The connection currintly doing an alter.
bool deleting; // dropping or truncating.
int32 recordBitmapHighWater;
int32 ageGroup;
Attachment: [text/bzr-bundle] bzr/dlenev@mysql.com-20090701200755-asc833zxdam0pv7k.bundle
| Thread |
|---|
| • bzr commit into mysql-6.1-fk branch (dlenev:2723) Bug#45701 | Dmitry Lenev | 1 Jul |