3618
3618
/*************************************************************//**
3619
Pops autoinc lock requests from the transaction's autoinc_locks. We
3620
handle the case where there are gaps in the array and they need to
3621
be popped off the stack. */
3624
lock_table_pop_autoinc_locks(
3625
/*=========================*/
3626
trx_t* trx) /*!< in/out: transaction that owns the AUTOINC locks */
3628
ut_ad(mutex_own(&kernel_mutex));
3629
ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
3631
/* Skip any gaps, gaps are NULL lock entries in the
3632
trx->autoinc_locks vector. */
3635
ib_vector_pop(trx->autoinc_locks);
3637
if (ib_vector_is_empty(trx->autoinc_locks)) {
3641
} while (ib_vector_get_last(trx->autoinc_locks) == NULL);
3644
/*************************************************************//**
3645
Removes an autoinc lock request from the transaction's autoinc_locks. */
3648
lock_table_remove_autoinc_lock(
3649
/*===========================*/
3650
lock_t* lock, /*!< in: table lock */
3651
trx_t* trx) /*!< in/out: transaction that owns the lock */
3653
lock_t* autoinc_lock;
3654
lint i = ib_vector_size(trx->autoinc_locks) - 1;
3656
ut_ad(mutex_own(&kernel_mutex));
3657
ut_ad(lock_get_mode(lock) == LOCK_AUTO_INC);
3658
ut_ad(lock_get_type_low(lock) & LOCK_TABLE);
3659
ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
3661
/* With stored functions and procedures the user may drop
3662
a table within the same "statement". This special case has
3663
to be handled by deleting only those AUTOINC locks that were
3664
held by the table being dropped. */
3666
autoinc_lock = static_cast<ib_lock_t *>(ib_vector_get(trx->autoinc_locks, i));
3668
/* This is the default fast case. */
3670
if (autoinc_lock == lock) {
3671
lock_table_pop_autoinc_locks(trx);
3673
/* The last element should never be NULL */
3674
ut_a(autoinc_lock != NULL);
3676
/* Handle freeing the locks from within the stack. */
3679
autoinc_lock = static_cast<ib_lock_t *>(ib_vector_get(trx->autoinc_locks, i));
3681
if (UNIV_LIKELY(autoinc_lock == lock)) {
3682
ib_vector_set(trx->autoinc_locks, i, NULL);
3687
/* Must find the autoinc lock. */
3692
/*************************************************************//**
3619
3693
Removes a table lock request from the queue and the trx list of locks;
3620
3694
this is a low-level function which does NOT check if waiting requests
3621
3695
can now be granted. */