diff options
author | unknown <marko@hundin.mysql.fi> | 2005-06-08 15:45:56 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2005-06-08 15:45:56 +0300 |
commit | 2e2a4e4f3e4086186b0e6cfba5bfaf0019aeb88a (patch) | |
tree | 88674f8a313f50ceff17e35e64cd03a377089114 /innobase | |
parent | 67d0502bcf05ee19edf0710ef153ca6b68244b26 (diff) | |
download | mariadb-git-2e2a4e4f3e4086186b0e6cfba5bfaf0019aeb88a.tar.gz |
InnoDB: Do not distinguish explicitly requested table locks.
Since UNLOCK TABLES will commit the transaction (and thus release
all InnoDB locks held by it), it is unnecessary to release the
user-requested table locks separately.
innobase/include/lock0lock.h:
Remove references to LOCK_TABLE_EXP and LOCK_TABLE_TRANSACTIONAL.
Remove lock_release_tables_off_kernel().
innobase/include/row0mysql.h:
Remove row_unlock_tables_for_mysql().
innobase/include/trx0trx.h:
Remove n_lock_table_exp and n_lock_table_transactional.
innobase/lock/lock0lock.c:
Remove references to LOCK_TABLE_EXP and LOCK_TABLE_TRANSACTIONAL.
Remove lock_release_tables_off_kernel().
Remove references to trx->n_lock_table_exp
and trx->n_lock_table_transactional.
innobase/row/row0mysql.c:
Remove row_unlock_tables_for_mysql().
Remove references to LOCK_TABLE_TRANSACTIONAL and LOCK_TABLE_EXP.
innobase/trx/trx0trx.c:
Remove n_lock_table_exp and n_lock_table_transactional.
sql/ha_innodb.cc:
Remove references to LOCK_TABLE_EXP and LOCK_TABLE_TRANSACTIONAL
and row_unlock_tables_for_mysql().
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/include/lock0lock.h | 16 | ||||
-rw-r--r-- | innobase/include/row0mysql.h | 13 | ||||
-rw-r--r-- | innobase/include/trx0trx.h | 7 | ||||
-rw-r--r-- | innobase/lock/lock0lock.c | 118 | ||||
-rw-r--r-- | innobase/row/row0mysql.c | 34 | ||||
-rw-r--r-- | innobase/trx/trx0trx.c | 10 |
6 files changed, 14 insertions, 184 deletions
diff --git a/innobase/include/lock0lock.h b/innobase/include/lock0lock.h index 9830c8abfc6..3f39a0b40c7 100644 --- a/innobase/include/lock0lock.h +++ b/innobase/include/lock0lock.h @@ -413,9 +413,7 @@ lock_table( /* out: DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, - does nothing; - if LOCK_TABLE_EXP bits are set, - creates an explicit table lock */ + does nothing */ dict_table_t* table, /* in: database table in dictionary cache */ ulint mode, /* in: lock mode */ que_thr_t* thr); /* in: query thread */ @@ -452,15 +450,6 @@ lock_release_off_kernel( /*====================*/ trx_t* trx); /* in: transaction */ /************************************************************************* -Releases table locks explicitly requested with LOCK TABLES (indicated by -lock type LOCK_TABLE_EXP), and releases possible other transactions waiting -because of these locks. */ - -void -lock_release_tables_off_kernel( -/*===========================*/ - trx_t* trx); /* in: transaction */ -/************************************************************************* Cancels a waiting lock request and releases possible other transactions waiting behind it. */ @@ -612,9 +601,6 @@ extern lock_sys_t* lock_sys; /* Lock types */ #define LOCK_TABLE 16 /* these type values should be so high that */ #define LOCK_REC 32 /* they can be ORed to the lock mode */ -#define LOCK_TABLE_EXP 80 /* explicit table lock (80 = 16 + 64) */ -#define LOCK_TABLE_TRANSACTIONAL 144 - /* transactional table lock (144 = 16 + 128)*/ #define LOCK_TYPE_MASK 0xF0UL /* mask used to extract lock type from the type_mode field in a lock */ /* Waiting lock flag */ diff --git a/innobase/include/row0mysql.h b/innobase/include/row0mysql.h index 28e94fad68f..4bb9fa63cd1 100644 --- a/innobase/include/row0mysql.h +++ b/innobase/include/row0mysql.h @@ -172,14 +172,6 @@ row_lock_table_autoinc_for_mysql( row_prebuilt_t* prebuilt); /* in: prebuilt struct in the MySQL table handle */ /************************************************************************* -Unlocks all table locks explicitly requested by trx (with LOCK TABLES, -lock type LOCK_TABLE_EXP). */ - -void -row_unlock_tables_for_mysql( -/*========================*/ - trx_t* trx); /* in: transaction */ -/************************************************************************* Sets a table lock on the table mentioned in prebuilt. */ int @@ -190,9 +182,10 @@ row_lock_table_for_mysql( table handle */ dict_table_t* table, /* in: table to lock, or NULL if prebuilt->table should be - locked as LOCK_TABLE_EXP | + locked as prebuilt->select_lock_type */ - ulint mode); /* in: lock mode of table */ + ulint mode); /* in: lock mode of table + (ignored if table==NULL) */ /************************************************************************* Does an insert for MySQL. */ diff --git a/innobase/include/trx0trx.h b/innobase/include/trx0trx.h index 6ca9c778aeb..8df50d6703d 100644 --- a/innobase/include/trx0trx.h +++ b/innobase/include/trx0trx.h @@ -497,13 +497,6 @@ struct trx_struct{ in the lock list trx_locks */ ibool trx_create_lock;/* this is TRUE if we have created a new lock for a record accessed */ - ulint n_lock_table_exp;/* number of explicit table locks - (LOCK TABLES) reserved by the - transaction, stored in trx_locks */ - ulint n_lock_table_transactional; - /* number of transactional table locks - (LOCK TABLES..WHERE ENGINE) reserved by - the transaction, stored in trx_locks */ UT_LIST_NODE_T(trx_t) trx_list; /* list of transactions */ UT_LIST_NODE_T(trx_t) diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index bde3eb0c16f..f2d5d035ab1 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -2208,11 +2208,7 @@ lock_grant( release it at the end of the SQL statement */ lock->trx->auto_inc_lock = lock; - } else if (lock_get_type(lock) == LOCK_TABLE_EXP || - lock_get_type(lock) == LOCK_TABLE_TRANSACTIONAL) { - ut_a(lock_get_mode(lock) == LOCK_S - || lock_get_mode(lock) == LOCK_X); - } + } if (lock_print_waits) { fprintf(stderr, "Lock wait for trx %lu ends\n", @@ -3415,14 +3411,6 @@ lock_table_create( lock->type_mode = type_mode | LOCK_TABLE; lock->trx = trx; - if (lock_get_type(lock) == LOCK_TABLE_EXP) { - lock->trx->n_lock_table_exp++; - } - - if (lock_get_type(lock) == LOCK_TABLE_TRANSACTIONAL) { - lock->trx->n_lock_table_transactional++; - } - lock->un_member.tab_lock.table = table; UT_LIST_ADD_LAST(un_member.tab_lock.locks, table->locks, lock); @@ -3459,14 +3447,6 @@ lock_table_remove_low( trx->auto_inc_lock = NULL; } - if (lock_get_type(lock) == LOCK_TABLE_EXP) { - trx->n_lock_table_exp--; - } - - if (lock_get_type(lock) == LOCK_TABLE_TRANSACTIONAL) { - trx->n_lock_table_transactional--; - } - UT_LIST_REMOVE(trx_locks, trx->trx_locks, lock); UT_LIST_REMOVE(un_member.tab_lock.locks, table->locks, lock); } @@ -3597,10 +3577,7 @@ lock_table( /* out: DB_SUCCESS, DB_LOCK_WAIT, DB_DEADLOCK, or DB_QUE_THR_SUSPENDED */ ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, - does nothing; - if LOCK_TABLE_EXP|LOCK_TABLE_TRANSACTIONAL - bits are set, - creates an explicit table lock */ + does nothing */ dict_table_t* table, /* in: database table in dictionary cache */ ulint mode, /* in: lock mode */ que_thr_t* thr) /* in: query thread */ @@ -3615,8 +3592,7 @@ lock_table( return(DB_SUCCESS); } - ut_a(flags == 0 || flags == LOCK_TABLE_EXP || - flags == LOCK_TABLE_TRANSACTIONAL); + ut_a(flags == 0); trx = thr_get_trx(thr); @@ -3729,9 +3705,7 @@ lock_table_dequeue( #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ - ut_a(lock_get_type(in_lock) == LOCK_TABLE || - lock_get_type(in_lock) == LOCK_TABLE_EXP || - lock_get_type(in_lock) == LOCK_TABLE_TRANSACTIONAL); + ut_a(lock_get_type(in_lock) == LOCK_TABLE); lock = UT_LIST_GET_NEXT(un_member.tab_lock.locks, in_lock); @@ -3835,12 +3809,6 @@ lock_release_off_kernel( } lock_table_dequeue(lock); - - if (lock_get_type(lock) == LOCK_TABLE_EXP || - lock_get_type(lock) == LOCK_TABLE_TRANSACTIONAL) { - ut_a(lock_get_mode(lock) == LOCK_S - || lock_get_mode(lock) == LOCK_X); - } } if (count == LOCK_RELEASE_KERNEL_INTERVAL) { @@ -3860,74 +3828,6 @@ lock_release_off_kernel( mem_heap_empty(trx->lock_heap); ut_a(trx->auto_inc_lock == NULL); - ut_a(trx->n_lock_table_exp == 0); - ut_a(trx->n_lock_table_transactional == 0); -} - -/************************************************************************* -Releases table locks explicitly requested with LOCK TABLES (indicated by -lock type LOCK_TABLE_EXP), and releases possible other transactions waiting -because of these locks. */ - -void -lock_release_tables_off_kernel( -/*===========================*/ - trx_t* trx) /* in: transaction */ -{ - dict_table_t* table; - ulint count; - lock_t* lock; - -#ifdef UNIV_SYNC_DEBUG - ut_ad(mutex_own(&kernel_mutex)); -#endif /* UNIV_SYNC_DEBUG */ - - lock = UT_LIST_GET_LAST(trx->trx_locks); - - count = 0; - - while (lock != NULL) { - - count++; - - if (lock_get_type(lock) == LOCK_TABLE_EXP) { - ut_a(lock_get_mode(lock) == LOCK_S - || lock_get_mode(lock) == LOCK_X); - if (trx->insert_undo || trx->update_undo) { - - /* The trx may have modified the table. - We block the use of the MySQL query - cache for all currently active - transactions. */ - - table = lock->un_member.tab_lock.table; - - table->query_cache_inv_trx_id = - trx_sys->max_trx_id; - } - - lock_table_dequeue(lock); - - lock = UT_LIST_GET_LAST(trx->trx_locks); - continue; - } - - if (count == LOCK_RELEASE_KERNEL_INTERVAL) { - /* Release the kernel mutex for a while, so that we - do not monopolize it */ - - lock_mutex_exit_kernel(); - - lock_mutex_enter_kernel(); - - count = 0; - } - - lock = UT_LIST_GET_PREV(trx_locks, lock); - } - - ut_a(trx->n_lock_table_exp == 0); - ut_a(trx->n_lock_table_transactional == 0); } /************************************************************************* @@ -4040,15 +3940,7 @@ lock_table_print( #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&kernel_mutex)); #endif /* UNIV_SYNC_DEBUG */ - ut_a(lock_get_type(lock) == LOCK_TABLE || - lock_get_type(lock) == LOCK_TABLE_EXP || - lock_get_type(lock) == LOCK_TABLE_TRANSACTIONAL); - - if (lock_get_type(lock) == LOCK_TABLE_EXP) { - fputs("EXPLICIT ", file); - } else if (lock_get_type(lock) == LOCK_TABLE_TRANSACTIONAL) { - fputs("TRANSACTIONAL ", file); - } + ut_a(lock_get_type(lock) == LOCK_TABLE); fputs("TABLE LOCK table ", file); ut_print_name(file, lock->trx, lock->un_member.tab_lock.table->name); diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index fcb3831b5fc..0b010096002 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -971,25 +971,6 @@ run_again: } /************************************************************************* -Unlocks all table locks explicitly requested by trx (with LOCK TABLES, -lock type LOCK_TABLE_EXP). */ - -void -row_unlock_tables_for_mysql( -/*========================*/ - trx_t* trx) /* in: transaction */ -{ - if (!trx->n_lock_table_exp) { - - return; - } - - mutex_enter(&kernel_mutex); - lock_release_tables_off_kernel(trx); - mutex_exit(&kernel_mutex); -} - -/************************************************************************* Sets a table lock on the table mentioned in prebuilt. */ int @@ -1000,9 +981,10 @@ row_lock_table_for_mysql( table handle */ dict_table_t* table, /* in: table to lock, or NULL if prebuilt->table should be - locked or a + locked as prebuilt->select_lock_type */ - ulint mode) /* in: lock mode of table */ + ulint mode) /* in: lock mode of table + (ignored if table==NULL) */ { trx_t* trx = prebuilt->trx; que_thr_t* thr; @@ -1038,14 +1020,8 @@ run_again: if (table) { err = lock_table(0, table, mode, thr); } else { - if (mode == LOCK_TABLE_TRANSACTIONAL) { - err = lock_table(LOCK_TABLE_TRANSACTIONAL, - prebuilt->table, - prebuilt->select_lock_type, thr); - } else { - err = lock_table(LOCK_TABLE_EXP, prebuilt->table, - prebuilt->select_lock_type, thr); - } + err = lock_table(0, prebuilt->table, + prebuilt->select_lock_type, thr); } trx->error_state = err; diff --git a/innobase/trx/trx0trx.c b/innobase/trx/trx0trx.c index cdda1dd4dee..c3b12468523 100644 --- a/innobase/trx/trx0trx.c +++ b/innobase/trx/trx0trx.c @@ -158,8 +158,6 @@ trx_create( trx->n_tickets_to_enter_innodb = 0; trx->auto_inc_lock = NULL; - trx->n_lock_table_exp = 0; - trx->n_lock_table_transactional = 0; trx->read_view_heap = mem_heap_create(256); trx->read_view = NULL; @@ -309,8 +307,6 @@ trx_free( ut_a(!trx->has_search_latch); ut_a(!trx->auto_inc_lock); - ut_a(!trx->n_lock_table_exp); - ut_a(!trx->n_lock_table_transactional); ut_a(trx->dict_operation_lock_mode == 0); @@ -1711,12 +1707,6 @@ trx_print( (ulong) trx->mysql_n_tables_locked); } - if (trx->n_lock_table_transactional > 0 || trx->n_lock_table_exp > 0) { -fprintf(f, "mysql explicit table locks %lu, transactional table locks %lu\n", - (ulong) trx->n_lock_table_exp, - (ulong) trx->n_lock_table_transactional); - } - newline = TRUE; switch (trx->que_state) { |