summaryrefslogtreecommitdiff
path: root/innobase/lock
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2004-11-27 00:45:01 +0200
committerunknown <marko@hundin.mysql.fi>2004-11-27 00:45:01 +0200
commit346dce93c2a63757540ed15e660dd07d41f7f20d (patch)
tree8ca2dd048763662b02f24eeeac0e7571a2ffe83d /innobase/lock
parentb0d586e5648e78981c63e68059c6c836a228a082 (diff)
downloadmariadb-git-346dce93c2a63757540ed15e660dd07d41f7f20d.tar.gz
InnoDB: Make intermediate COMMITs in ALTER TABLE more robust (Bug #6633)
innobase/include/lock0lock.h: Replaced lock_get_ix_table() with lock_get_table(). innobase/lock/lock0lock.c: Replaced lock_get_ix_table() with lock_get_table(). innobase/include/row0mysql.h: row_lock_table_for_mysql(): Added parameter mode. innobase/row/row0mysql.c: row_lock_table_for_mysql(): Added parameter mode. sql/ha_innodb.cc: ha_innobase::write_row(): Make ALTER TABLE commits more robust: account for conversions from non-InnoDB format, do not attempt to commit if there are other than a single IX or IS lock on the source table, and the source table is in InnoDB format. This prohibits intermediate commits for OPTIMIZE TABLE if the table contains an auto_increment field.
Diffstat (limited to 'innobase/lock')
-rw-r--r--innobase/lock/lock0lock.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c
index 78a78c9dd95..d9a10eb60c0 100644
--- a/innobase/lock/lock0lock.c
+++ b/innobase/lock/lock0lock.c
@@ -395,19 +395,6 @@ lock_rec_get_nth_bit(
return(ut_bit_get_nth(b, bit_index));
}
-/*************************************************************************
-Gets the table covered by an IX table lock. */
-
-dict_table_t*
-lock_get_ix_table(
-/*==============*/
- /* out: the table covered by the lock */
- lock_t* lock) /* in: table lock */
-{
- ut_a(lock->type_mode == (LOCK_TABLE | LOCK_IX));
- return(lock->un_member.tab_lock.table);
-}
-
/*************************************************************************/
#define lock_mutex_enter_kernel() mutex_enter(&kernel_mutex)
@@ -615,6 +602,45 @@ lock_get_wait(
}
/*************************************************************************
+Gets the table covered by an IX or IS table lock, if there are no
+other locks on the table. */
+
+dict_table_t*
+lock_get_table(
+/*===========*/
+ /* out: the table covered by the lock,
+ or NULL if it is not an IX or IS table lock,
+ or there are other locks on the table */
+ lock_t* lock, /* in: lock */
+ ulint* mode) /* out: lock mode of table */
+{
+ dict_table_t* table;
+ ulint lock_mode;
+
+ table = NULL;
+ *mode = LOCK_NONE;
+
+ if (lock_get_type(lock) != LOCK_TABLE) {
+ return(table);
+ }
+
+ lock_mode = lock_get_mode(lock);
+ switch (lock_mode) {
+ case LOCK_IS:
+ case LOCK_IX:
+ *mode = lock_mode;
+ table = lock->un_member.tab_lock.table;
+ if (UT_LIST_GET_LEN(table->locks) != 1 ||
+ UT_LIST_GET_FIRST(table->locks) != lock) {
+ /* We only support the case when
+ there is only one lock on this table. */
+ table = NULL;
+ }
+ }
+ return(table);
+}
+
+/*************************************************************************
Sets the wait flag of a lock and the back pointer in trx to lock. */
UNIV_INLINE
void