~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/lock/lock0lock.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
3625
3625
}
3626
3626
 
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. */
 
3631
UNIV_INLINE
 
3632
void
 
3633
lock_table_pop_autoinc_locks(
 
3634
/*=========================*/
 
3635
        trx_t*  trx)    /*!< in/out: transaction that owns the AUTOINC locks */
 
3636
{
 
3637
        ut_ad(mutex_own(&kernel_mutex));
 
3638
        ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
 
3639
 
 
3640
        /* Skip any gaps, gaps are NULL lock entries in the
 
3641
        trx->autoinc_locks vector. */
 
3642
 
 
3643
        do {
 
3644
                ib_vector_pop(trx->autoinc_locks);
 
3645
 
 
3646
                if (ib_vector_is_empty(trx->autoinc_locks)) {
 
3647
                        return;
 
3648
                }
 
3649
 
 
3650
        } while (ib_vector_get_last(trx->autoinc_locks) == NULL);
 
3651
}
 
3652
 
 
3653
/*************************************************************//**
 
3654
Removes an autoinc lock request from the transaction's autoinc_locks. */
 
3655
UNIV_INLINE
 
3656
void
 
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 */
 
3661
{
 
3662
        lock_t* autoinc_lock;
 
3663
        lint    i = ib_vector_size(trx->autoinc_locks) - 1;
 
3664
 
 
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));
 
3669
 
 
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. */
 
3674
 
 
3675
        autoinc_lock = ib_vector_get(trx->autoinc_locks, i);
 
3676
 
 
3677
        /* This is the default fast case. */
 
3678
 
 
3679
        if (autoinc_lock == lock) {
 
3680
                lock_table_pop_autoinc_locks(trx);
 
3681
        } else {
 
3682
                /* The last element should never be NULL */
 
3683
                ut_a(autoinc_lock != NULL);
 
3684
 
 
3685
                /* Handle freeing the locks from within the stack. */
 
3686
 
 
3687
                while (--i >= 0) {
 
3688
                        autoinc_lock = ib_vector_get(trx->autoinc_locks, i);
 
3689
 
 
3690
                        if (UNIV_LIKELY(autoinc_lock == lock)) {
 
3691
                                ib_vector_set(trx->autoinc_locks, i, NULL);
 
3692
                                return;
 
3693
                        }
 
3694
                }
 
3695
 
 
3696
                /* Must find the autoinc lock. */
 
3697
                ut_error;
 
3698
        }
 
3699
}
 
3700
 
 
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. */
3663
3737
 
3664
3738
                if (!lock_get_wait(lock)
3665
3739
                    && !ib_vector_is_empty(trx->autoinc_locks)) {
3666
 
                        lock_t* autoinc_lock;
3667
3740
 
3668
 
                        autoinc_lock = ib_vector_pop(trx->autoinc_locks);
3669
 
                        ut_a(autoinc_lock == lock);
 
3741
                        lock_table_remove_autoinc_lock(lock, trx);
3670
3742
                }
3671
3743
 
3672
3744
                ut_a(table->n_waiting_or_granted_auto_inc_locks > 0);