List:Commits« Previous MessageNext Message »
From:Konstantin Osipov Date:January 21 2010 4:10pm
Subject:bzr commit into mysql-5.6-next-mr branch (kostja:3063) Bug#46272
View as plain text  
#At file:///opt/local/work/next-4284-stage/ based on revid:kostja@stripped

 3063 Konstantin Osipov	2010-01-21
      Bug#46272 review fixes: remove an unnecessary friend.

    modified:
      sql/mdl.cc
      sql/mdl.h
      sql/sql_base.cc
=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc	2010-01-21 08:35:13 +0000
+++ b/sql/mdl.cc	2010-01-21 16:10:41 +0000
@@ -1690,11 +1690,12 @@ err:
 */
 
 bool
-MDL_ticket::upgrade_shared_lock_to_exclusive()
+MDL_context::upgrade_shared_lock_to_exclusive(MDL_ticket *mdl_ticket)
 {
   const char *old_msg;
   st_my_thread_var *mysys_var= my_thread_var;
-  THD *thd= m_ctx->get_thd();
+  THD *thd= get_thd();
+  MDL_lock *mdl_lock= mdl_ticket->m_lock;
   MDL_ticket *pending_ticket;
 
   DBUG_ENTER("MDL_ticket::upgrade_shared_lock_to_exclusive");
@@ -1703,18 +1704,18 @@ MDL_ticket::upgrade_shared_lock_to_exclu
   safe_mutex_assert_not_owner(&LOCK_open);
 
   /* Allow this function to be called twice for the same lock request. */
-  if (m_type == MDL_EXCLUSIVE)
+  if (mdl_ticket->m_type == MDL_EXCLUSIVE)
     DBUG_RETURN(FALSE);
 
   /* Only allow upgrades from MDL_UPGRADABLE_NO_WRITE/NO_READ_WRITE */
-  DBUG_ASSERT(m_type == MDL_UPGRADABLE_NO_WRITE ||
-              m_type == MDL_UPGRADABLE_NO_READ_WRITE);
+  DBUG_ASSERT(mdl_ticket->m_type == MDL_UPGRADABLE_NO_WRITE ||
+              mdl_ticket->m_type == MDL_UPGRADABLE_NO_READ_WRITE);
 
   /*
     Since we should have already acquired an intention exclusive
     global lock this call is only enforcing asserts.
   */
-  DBUG_ASSERT(m_ctx->is_global_lock_owner(MDL_INTENTION_EXCLUSIVE));
+  DBUG_ASSERT(is_global_lock_owner(MDL_INTENTION_EXCLUSIVE));
 
   /*
     Create an auxiliary ticket to represent a pending exclusive
@@ -1724,22 +1725,22 @@ MDL_ticket::upgrade_shared_lock_to_exclu
     to signal such connections that upon waking up they
     must back off, rather than fall into sleep again.
   */
-  if (! (pending_ticket= MDL_ticket::create(m_ctx, MDL_EXCLUSIVE)))
+  if (! (pending_ticket= MDL_ticket::create(this, MDL_EXCLUSIVE)))
     DBUG_RETURN(TRUE);
 
-  pthread_mutex_lock(&m_lock->m_mutex);
+  pthread_mutex_lock(&mdl_lock->m_mutex);
 
-  m_lock->add_pending(pending_ticket);
+  mdl_lock->add_pending(pending_ticket);
 
-  old_msg= MDL_ENTER_COND(thd, mysys_var, &m_ctx->m_ctx_wakeup_cond,
-                          &m_lock->m_mutex);
+  old_msg= MDL_ENTER_COND(thd, mysys_var, &m_ctx_wakeup_cond,
+                          &mdl_lock->m_mutex);
 
   while (1)
   {
-    if (m_lock->can_grant_lock(m_ctx, MDL_EXCLUSIVE, TRUE))
+    if (mdl_lock->can_grant_lock(this, MDL_EXCLUSIVE, TRUE))
       break;
 
-    m_lock->notify_shared_locks(m_ctx);
+    mdl_lock->notify_shared_locks(this);
 
     /* There is a shared or exclusive lock on the object. */
     DEBUG_SYNC(thd, "mdl_upgrade_shared_lock_to_exclusive_wait");
@@ -1757,34 +1758,34 @@ MDL_ticket::upgrade_shared_lock_to_exclu
     */
     struct timespec abstime;
     set_timespec(abstime, 1);
-    pthread_cond_timedwait(&m_ctx->m_ctx_wakeup_cond, &m_lock->m_mutex,
+    pthread_cond_timedwait(&m_ctx_wakeup_cond, &mdl_lock->m_mutex,
                            &abstime);
 
     if (mysys_var->abort)
     {
-      m_lock->remove_pending(pending_ticket);
+      mdl_lock->remove_pending(pending_ticket);
       /*
         If there are no other pending requests for exclusive locks
         we need to wake up threads waiting for a chance to acquire
         shared lock.
       */
-      m_lock->wake_up_waiters();
-      MDL_EXIT_COND(thd, mysys_var, &m_lock->m_mutex, old_msg);
+      mdl_lock->wake_up_waiters();
+      MDL_EXIT_COND(thd, mysys_var, &mdl_lock->m_mutex, old_msg);
       MDL_ticket::destroy(pending_ticket);
       DBUG_RETURN(TRUE);
     }
   }
 
   /* Set the new type of lock in the ticket. */
-  m_type= MDL_EXCLUSIVE;
+  mdl_ticket->m_type= MDL_EXCLUSIVE;
 
-  m_lock->remove_pending(pending_ticket);
+  mdl_lock->remove_pending(pending_ticket);
 
-  if (m_lock->cached_object)
-    (*m_lock->cached_object_release_hook)(m_lock->cached_object);
-  m_lock->cached_object= 0;
+  if (mdl_lock->cached_object)
+    (*mdl_lock->cached_object_release_hook)(mdl_lock->cached_object);
+  mdl_lock->cached_object= 0;
 
-  MDL_EXIT_COND(thd, mysys_var, &m_lock->m_mutex, old_msg);
+  MDL_EXIT_COND(thd, mysys_var, &mdl_lock->m_mutex, old_msg);
 
   MDL_ticket::destroy(pending_ticket);
 

=== modified file 'sql/mdl.h'
--- a/sql/mdl.h	2010-01-21 08:35:13 +0000
+++ b/sql/mdl.h	2010-01-21 16:10:41 +0000
@@ -402,7 +402,6 @@ public:
            m_type == MDL_UPGRADABLE_NO_READ_WRITE ||
            m_type == MDL_EXCLUSIVE;
   }
-  bool upgrade_shared_lock_to_exclusive();
   void downgrade_exclusive_lock();
   void set_needs_thr_lock_abort()
   {
@@ -556,6 +555,7 @@ public:
   bool acquire_global_shared_lock();
   void release_global_shared_lock();
 
+  bool upgrade_shared_lock_to_exclusive(MDL_ticket *mdl_ticket);
   /**
     Check if this context owns global lock of particular type.
   */
@@ -601,9 +601,7 @@ private:
   bool acquire_lock_impl(MDL_request *mdl_request);
   bool acquire_exclusive_lock_impl(MDL_request *mdl_request);
 
-  friend bool MDL_ticket::upgrade_shared_lock_to_exclusive();
   friend void notify_shared_lock(THD *thd, MDL_ticket *conflicting_ticket);
-
 private:
   MDL_context(const MDL_context &rhs);          /* not implemented */
   MDL_context &operator=(MDL_context &rhs);     /* not implemented */

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2010-01-21 08:35:13 +0000
+++ b/sql/sql_base.cc	2010-01-21 16:10:41 +0000
@@ -2145,7 +2145,7 @@ bool wait_while_table_is_used(THD *thd, 
                        table->s->table_name.str, (ulong) table->s,
                        table->db_stat, table->s->version));
 
-  if (table->mdl_ticket->upgrade_shared_lock_to_exclusive())
+  if (thd->mdl_context.upgrade_shared_lock_to_exclusive(table->mdl_ticket))
     DBUG_RETURN(TRUE);
 
   pthread_mutex_lock(&LOCK_open);


Attachment: [text/bzr-bundle] bzr/kostja@sun.com-20100121161041-dbg12yvg2rn550m9.bundle
Thread
bzr commit into mysql-5.6-next-mr branch (kostja:3063) Bug#46272Konstantin Osipov21 Jan