3627
3627
/*************************************************************//**
3628
Pops autoinc lock requests from the transaction's autoinc_locks. We
3629
handle the case where there are gaps in the array and they need to
3630
be popped off the stack. */
3633
lock_table_pop_autoinc_locks(
3634
/*=========================*/
3635
trx_t* trx) /*!< in/out: transaction that owns the AUTOINC locks */
3637
ut_ad(mutex_own(&kernel_mutex));
3638
ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
3640
/* Skip any gaps, gaps are NULL lock entries in the
3641
trx->autoinc_locks vector. */
3644
ib_vector_pop(trx->autoinc_locks);
3646
if (ib_vector_is_empty(trx->autoinc_locks)) {
3650
} while (ib_vector_get_last(trx->autoinc_locks) == NULL);
3653
/*************************************************************//**
3654
Removes an autoinc lock request from the transaction's autoinc_locks. */
3657
lock_table_remove_autoinc_lock(
3658
/*===========================*/
3659
lock_t* lock, /*!< in: table lock */
3660
trx_t* trx) /*!< in/out: transaction that owns the lock */
3662
lock_t* autoinc_lock;
3663
lint i = ib_vector_size(trx->autoinc_locks) - 1;
3665
ut_ad(mutex_own(&kernel_mutex));
3666
ut_ad(lock_get_mode(lock) == LOCK_AUTO_INC);
3667
ut_ad(lock_get_type_low(lock) & LOCK_TABLE);
3668
ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
3670
/* With stored functions and procedures the user may drop
3671
a table within the same "statement". This special case has
3672
to be handled by deleting only those AUTOINC locks that were
3673
held by the table being dropped. */
3675
autoinc_lock = ib_vector_get(trx->autoinc_locks, i);
3677
/* This is the default fast case. */
3679
if (autoinc_lock == lock) {
3680
lock_table_pop_autoinc_locks(trx);
3682
/* The last element should never be NULL */
3683
ut_a(autoinc_lock != NULL);
3685
/* Handle freeing the locks from within the stack. */
3688
autoinc_lock = ib_vector_get(trx->autoinc_locks, i);
3690
if (UNIV_LIKELY(autoinc_lock == lock)) {
3691
ib_vector_set(trx->autoinc_locks, i, NULL);
3696
/* Must find the autoinc lock. */
3701
/*************************************************************//**
3628
3702
Removes a table lock request from the queue and the trx list of locks;
3629
3703
this is a low-level function which does NOT check if waiting requests
3630
3704
can now be granted. */