summaryrefslogtreecommitdiff
path: root/innobase/lock
diff options
context:
space:
mode:
authormarko@hundin.mysql.fi <>2004-11-27 00:45:01 +0200
committermarko@hundin.mysql.fi <>2004-11-27 00:45:01 +0200
commit2e7cb4d011a50ed9c4b940eea4cb2c407def7fc7 (patch)
tree8ca2dd048763662b02f24eeeac0e7571a2ffe83d /innobase/lock
parent19dab11881e900c9e79db570b2f6456f67aa23fb (diff)
downloadmariadb-git-2e7cb4d011a50ed9c4b940eea4cb2c407def7fc7.tar.gz
InnoDB: Make intermediate COMMITs in ALTER TABLE more robust (Bug #6633)
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