~ubuntu-branches/ubuntu/vivid/drizzle/vivid

« back to all changes in this revision

Viewing changes to plugin/innobase/lock/lock0lock.cc

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (20.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20131029154340-j36v7gxq9tm1gi5f
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

Show diffs side-by-side

added added

removed removed

Lines of Context:
3616
3616
}
3617
3617
 
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. */
 
3622
UNIV_INLINE
 
3623
void
 
3624
lock_table_pop_autoinc_locks(
 
3625
/*=========================*/
 
3626
        trx_t*  trx)    /*!< in/out: transaction that owns the AUTOINC locks */
 
3627
{
 
3628
        ut_ad(mutex_own(&kernel_mutex));
 
3629
        ut_ad(!ib_vector_is_empty(trx->autoinc_locks));
 
3630
 
 
3631
        /* Skip any gaps, gaps are NULL lock entries in the
 
3632
        trx->autoinc_locks vector. */
 
3633
 
 
3634
        do {
 
3635
                ib_vector_pop(trx->autoinc_locks);
 
3636
 
 
3637
                if (ib_vector_is_empty(trx->autoinc_locks)) {
 
3638
                        return;
 
3639
                }
 
3640
 
 
3641
        } while (ib_vector_get_last(trx->autoinc_locks) == NULL);
 
3642
}
 
3643
 
 
3644
/*************************************************************//**
 
3645
Removes an autoinc lock request from the transaction's autoinc_locks. */
 
3646
UNIV_INLINE
 
3647
void
 
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 */
 
3652
{
 
3653
        lock_t* autoinc_lock;
 
3654
        lint    i = ib_vector_size(trx->autoinc_locks) - 1;
 
3655
 
 
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));
 
3660
 
 
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. */
 
3665
 
 
3666
        autoinc_lock = static_cast<ib_lock_t *>(ib_vector_get(trx->autoinc_locks, i));
 
3667
 
 
3668
        /* This is the default fast case. */
 
3669
 
 
3670
        if (autoinc_lock == lock) {
 
3671
                lock_table_pop_autoinc_locks(trx);
 
3672
        } else {
 
3673
                /* The last element should never be NULL */
 
3674
                ut_a(autoinc_lock != NULL);
 
3675
 
 
3676
                /* Handle freeing the locks from within the stack. */
 
3677
 
 
3678
                while (--i >= 0) {
 
3679
                  autoinc_lock = static_cast<ib_lock_t *>(ib_vector_get(trx->autoinc_locks, i));
 
3680
 
 
3681
                        if (UNIV_LIKELY(autoinc_lock == lock)) {
 
3682
                                ib_vector_set(trx->autoinc_locks, i, NULL);
 
3683
                                return;
 
3684
                        }
 
3685
                }
 
3686
 
 
3687
                /* Must find the autoinc lock. */
 
3688
                ut_error;
 
3689
        }
 
3690
}
 
3691
 
 
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. */
3654
3728
 
3655
3729
                if (!lock_get_wait(lock)
3656
3730
                    && !ib_vector_is_empty(trx->autoinc_locks)) {
3657
 
                        lock_t* autoinc_lock;
3658
 
 
3659
 
                        autoinc_lock = static_cast<lock_t *>(ib_vector_pop(trx->autoinc_locks));
3660
 
                        ut_a(autoinc_lock == lock);
 
3731
                        lock_table_remove_autoinc_lock(lock, trx);
3661
3732
                }
3662
3733
 
3663
3734
                ut_a(table->n_waiting_or_granted_auto_inc_locks > 0);