diff options
author | unknown <kostja@bodhi.(none)> | 2007-07-27 16:37:29 +0400 |
---|---|---|
committer | unknown <kostja@bodhi.(none)> | 2007-07-27 16:37:29 +0400 |
commit | 0c371eddee315fac4b7368b97e6853f60f7255eb (patch) | |
tree | 222b968f3296750c8756393cb2779dcfb1da2784 /sql/opt_range.cc | |
parent | a086d6ec12c43aef951d7ae49a8af73d7478751a (diff) | |
download | mariadb-git-0c371eddee315fac4b7368b97e6853f60f7255eb.tar.gz |
A fix and a test case for Bug#24918 drop table and lock / inconsistent
between perm and temp tables. Review fixes.
The original bug report complains that if we locked a temporary table
with LOCK TABLES statement, we would not leave LOCK TABLES mode
when this temporary table is dropped.
Additionally, the bug was escalated when it was discovered than
when a temporary transactional table that was previously
locked with LOCK TABLES statement was dropped, futher actions with
this table, such as UNLOCK TABLES, would lead to a crash.
The problem originates from incomplete support of transactional temporary
tables. When we added calls to handler::store_lock()/handler::external_lock()
to operations that work with such tables, we only covered the normal
server code flow and did not cover LOCK TABLES mode.
In LOCK TABLES mode, ::external_lock(LOCK) would sometimes be called without
matching ::external_lock(UNLOCK), e.g. when a transactional temporary table
was dropped. Additionally, this table would be left in the list of LOCKed
TABLES.
The patch aims to address this inadequacy. Now, whenever an instance
of 'handler' is destroyed, we assert that it was priorly
external_lock(UNLOCK)-ed. All the places that violate this assert
were fixed.
This patch introduces no changes in behavior -- the discrepancy in
behavior will be fixed when we start calling ::store_lock()/::external_lock()
for all tables, regardless whether they are transactional or not,
temporary or not.
mysql-test/r/innodb_mysql.result:
Update test results (Bug#24918)
mysql-test/t/innodb_mysql.test:
Add a test case for Bug#24918
sql/handler.h:
Make handler::external_lock() a protected method. Backport from 5.1 its
public wrapper handler::ha_external_lock().
Assert that the handler is not closed if it is still locked.
sql/lock.cc:
In mysql_lock_tables only call lock_external() for the list of tables that
we called store_lock() for.
E.g. get_lock_data() does not add non-transactional temporary tables to the
lock list, so lock_external() should not be called for them.
Use handler::ha_external_lock() instead of handler::external_lock().
Add comments for mysql_lock_remove(), parameterize one strange
side effect that it has. At least in one place where mysql_lock_remove
is used, this side effect is not desired (DROP TABLE). The parameter
will be dropped in 5.1, along with the side effect.
sql/mysql_priv.h:
Update declaration of mysql_lock_remove().
sql/opt_range.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
sql/sql_base.cc:
When closing a temporary table, remove the table from the list of LOCKed
TABLES of this thread, in case it's there.
It's there if it is a transactional temporary table.
Use a new declaration of mysql_lock_remove().
sql/sql_class.h:
Extend the comment for THD::temporary_tables.
sql/sql_table.cc:
Deploy handler::ha_external_lock() instead of handler::external_lock()
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 247f0eada49..d978c8882ac 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -972,7 +972,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file, free_file)); file->reset(); - file->external_lock(current_thd, F_UNLCK); + file->ha_external_lock(current_thd, F_UNLCK); file->close(); } } @@ -1142,7 +1142,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) /* Caller will free the memory */ goto failure; /* purecov: inspected */ } - if (file->external_lock(thd, F_RDLCK)) + if (file->ha_external_lock(thd, F_RDLCK)) goto failure; if (!head->no_keyread) { @@ -1152,7 +1152,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) if (file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) || init() || reset()) { - file->external_lock(thd, F_UNLCK); + file->ha_external_lock(thd, F_UNLCK); file->close(); goto failure; } |