List:Commits« Previous MessageNext Message »
From:ingo Date:May 21 2006 10:45am
Subject:bk commit into 4.0 tree (ingo:1.2179) BUG#17436
View as plain text  
Below is the list of changes that have just been committed into a local
4.0 repository of mydev. When mydev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2179 06/05/21 10:45:52 ingo@stripped +1 -0
  Bug#17436 - ALTER TABLE causes pending INSERT DELAYED updates to fail.
  
  Cosmetic changes in preparation for real work on the
  INSERT DELAYED feature.

  sql/sql_insert.cc
    1.119 06/05/21 10:45:50 ingo@stripped +82 -82
    Bug#17436 - ALTER TABLE causes pending INSERT DELAYED updates to fail.
    Cosmetic changes.
    Variable name 'tmp' changed to 'di'.
    Changes in white space according to coding style.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-4.0-bug17436

--- 1.118/sql/sql_insert.cc	2005-05-31 11:08:12 +02:00
+++ 1.119/sql/sql_insert.cc	2006-05-21 10:45:50 +02:00
@@ -628,25 +628,25 @@
   thd->proc_info="waiting for delay_list";
   pthread_mutex_lock(&LOCK_delayed_insert);	// Protect master list
   I_List_iterator<delayed_insert> it(delayed_threads);
-  delayed_insert *tmp;
-  while ((tmp=it++))
+  delayed_insert *di;
+  while ((di= it++))
   {
-    if (!strcmp(tmp->thd.db,table_list->db) &&
-	!strcmp(table_list->real_name,tmp->table->real_name))
+    if (!strcmp(di->thd.db, table_list->db) &&
+        !strcmp(table_list->real_name, di->table->real_name))
     {
-      tmp->lock();
+      di->lock();
       break;
     }
   }
   pthread_mutex_unlock(&LOCK_delayed_insert); // For unlink from list
-  return tmp;
+  return di;
 }
 
 
 static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
 {
   int error;
-  delayed_insert *tmp;
+  delayed_insert *di;
   TABLE *table;
   DBUG_ENTER("delayed_get_table");
 
@@ -654,7 +654,7 @@
     table_list->db=thd->db;
 
   /* Find the thread which handles this table. */
-  if (!(tmp=find_handler(thd,table_list)))
+  if (! (di= find_handler(thd,table_list)))
   {
     /*
       No match. Create a new thread to handle the table, but
@@ -668,7 +668,7 @@
       The first search above was done without LOCK_delayed_create.
       Another thread might have created the handler in between. Search again.
     */
-    if (! (tmp= find_handler(thd, table_list)))
+    if (! (di= find_handler(thd, table_list)))
     {
       /*
         Avoid that a global read lock steps in while we are creating the
@@ -682,7 +682,7 @@
       */
       if (wait_if_global_read_lock(thd, 0, 1))
         goto err;
-      if (!(tmp=new delayed_insert()))
+      if (!(di= new delayed_insert()))
       {
 	my_error(ER_OUTOFMEMORY,MYF(0),sizeof(delayed_insert));
         goto err1;
@@ -690,74 +690,74 @@
       pthread_mutex_lock(&LOCK_thread_count);
       thread_count++;
       pthread_mutex_unlock(&LOCK_thread_count);
-      if (!(tmp->thd.db=my_strdup(table_list->db,MYF(MY_WME))) ||
-	  !(tmp->thd.query=my_strdup(table_list->real_name,MYF(MY_WME))))
+      if (! (di->thd.db=    my_strdup(table_list->db, MYF(MY_WME))) ||
+          ! (di->thd.query= my_strdup(table_list->real_name, MYF(MY_WME))))
       {
-	delete tmp;
+	delete di;
 	my_error(ER_OUT_OF_RESOURCES,MYF(0));
         goto err1;
       }
-      tmp->table_list= *table_list;			// Needed to open table
-      tmp->table_list.db= tmp->thd.db;
-      tmp->table_list.alias= tmp->table_list.real_name=tmp->thd.query;
-      tmp->lock();
-      pthread_mutex_lock(&tmp->mutex);
-      if ((error=pthread_create(&tmp->thd.real_id,&connection_attrib,
-				handle_delayed_insert,(void*) tmp)))
+      di->table_list= *table_list;                      // Needed to open table
+      di->table_list.db= di->thd.db;
+      di->table_list.alias= di->table_list.real_name= di->thd.query;
+      di->lock();
+      pthread_mutex_lock(&di->mutex);
+      if ((error= pthread_create(&di->thd.real_id, &connection_attrib,
+                                 handle_delayed_insert, (void*) di)))
       {
 	DBUG_PRINT("error",
 		   ("Can't create thread to handle delayed insert (error %d)",
 		    error));
-	pthread_mutex_unlock(&tmp->mutex);
-	tmp->unlock();
-	delete tmp;
-	net_printf(&thd->net,ER_CANT_CREATE_THREAD,error);
+        pthread_mutex_unlock(&di->mutex);
+        di->unlock();
+        delete di;
+        net_printf(&thd->net,ER_CANT_CREATE_THREAD,error);
         goto err1;
       }
 
       /* Wait until table is open */
       thd->proc_info="waiting for handler open";
-      while (!tmp->thd.killed && !tmp->table && !thd->killed)
+      while (!di->thd.killed && !di->table && !thd->killed)
       {
-	pthread_cond_wait(&tmp->cond_client,&tmp->mutex);
+        pthread_cond_wait(&di->cond_client, &di->mutex);
       }
-      pthread_mutex_unlock(&tmp->mutex);
+      pthread_mutex_unlock(&di->mutex);
       /*
         Release the protection against the global read lock and wake
         everyone, who might want to set a global read lock.
       */
       start_waiting_global_read_lock(thd);
       thd->proc_info="got old table";
-      if (tmp->thd.killed)
+      if (di->thd.killed)
       {
-	if (tmp->thd.fatal_error)
-	{
-	  /* Copy error message and abort */
-	  thd->fatal_error=1;
-	  strmov(thd->net.last_error,tmp->thd.net.last_error);
-	  thd->net.last_errno=tmp->thd.net.last_errno;
-	}
-	tmp->unlock();
-	goto err;
+        if (di->thd.fatal_error)
+        {
+          /* Copy error message and abort */
+          thd->fatal_error=1;
+          strmov(thd->net.last_error, di->thd.net.last_error);
+          thd->net.last_errno= di->thd.net.last_errno;
+        }
+        di->unlock();
+        goto err;
       }
       if (thd->killed)
       {
-	tmp->unlock();
-	goto err;
+        di->unlock();
+        goto err;
       }
     }
     pthread_mutex_unlock(&LOCK_delayed_create);
   }
 
-  pthread_mutex_lock(&tmp->mutex);
-  table= tmp->get_local_table(thd);
-  pthread_mutex_unlock(&tmp->mutex);
+  pthread_mutex_lock(&di->mutex);
+  table= di->get_local_table(thd);
+  pthread_mutex_unlock(&di->mutex);
   if (table)
-    thd->di=tmp;
-  else if (tmp->thd.fatal_error)
+    thd->di= di;
+  else if (di->thd.fatal_error)
     thd->fatal_error=1;
   /* Unlock the delayed insert object after its last access. */
-  tmp->unlock();
+  di->unlock();
   DBUG_RETURN((table_list->table=table));
 
  err1:
@@ -865,13 +865,13 @@
 			 char *query, uint query_length, int log_on)
 {
   delayed_row *row=0;
-  delayed_insert *di=thd->di;
+  delayed_insert *di= thd->di;
   DBUG_ENTER("write_delayed");
 
   thd->proc_info="waiting for handler insert";
   pthread_mutex_lock(&di->mutex);
   while (di->stacked_inserts >= delayed_queue_size && !thd->killed)
-    pthread_cond_wait(&di->cond_client,&di->mutex);
+    pthread_cond_wait(&di->cond_client, &di->mutex);
   thd->proc_info="storing row into queue";
 
   if (thd->killed || !(row= new delayed_row(duplic, log_on)))
@@ -898,7 +898,7 @@
 
   di->rows.push_back(row);
   di->stacked_inserts++;
-  di->status=1;
+  di->status= 1;
   if (table->blob_fields)
     unlink_blobs(table);
   pthread_cond_signal(&di->cond);
@@ -917,12 +917,12 @@
 static void end_delayed_insert(THD *thd)
 {
   DBUG_ENTER("end_delayed_insert");
-  delayed_insert *di=thd->di;
+  delayed_insert *di= thd->di;
   pthread_mutex_lock(&di->mutex);
-  DBUG_PRINT("info",("tables in use: %d",di->tables_in_use));
-  if (!--di->tables_in_use || di->thd.killed)
+  DBUG_PRINT("info",("tables in use: %d", di->tables_in_use));
+  if (! --di->tables_in_use || di->thd.killed)
   {						// Unlock table
-    di->status=1;
+    di->status= 1;
     pthread_cond_signal(&di->cond);
   }
   pthread_mutex_unlock(&di->mutex);
@@ -937,30 +937,30 @@
   VOID(pthread_mutex_lock(&LOCK_delayed_insert)); // For unlink from list
 
   I_List_iterator<delayed_insert> it(delayed_threads);
-  delayed_insert *tmp;
-  while ((tmp=it++))
+  delayed_insert *di;
+  while ((di= it++))
   {
     /* Ensure that the thread doesn't kill itself while we are looking at it */
-    pthread_mutex_lock(&tmp->mutex);
-    tmp->thd.killed=1;
-    if (tmp->thd.mysys_var)
+    pthread_mutex_lock(&di->mutex);
+    di->thd.killed= 1;
+    if (di->thd.mysys_var)
     {
-      pthread_mutex_lock(&tmp->thd.mysys_var->mutex);
-      if (tmp->thd.mysys_var->current_cond)
+      pthread_mutex_lock(&di->thd.mysys_var->mutex);
+      if (di->thd.mysys_var->current_cond)
       {
 	/*
 	  We need the following test because the main mutex may be locked
 	  in handle_delayed_insert()
 	*/
-	if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
-	  pthread_mutex_lock(tmp->thd.mysys_var->current_mutex);
-	pthread_cond_broadcast(tmp->thd.mysys_var->current_cond);
-	if (&tmp->mutex != tmp->thd.mysys_var->current_mutex)
-	  pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex);
+	if (&di->mutex != di->thd.mysys_var->current_mutex)
+	  pthread_mutex_lock(di->thd.mysys_var->current_mutex);
+	pthread_cond_broadcast(di->thd.mysys_var->current_cond);
+	if (&di->mutex != di->thd.mysys_var->current_mutex)
+	  pthread_mutex_unlock(di->thd.mysys_var->current_mutex);
       }
-      pthread_mutex_unlock(&tmp->thd.mysys_var->mutex);
+      pthread_mutex_unlock(&di->thd.mysys_var->mutex);
     }
-    pthread_mutex_unlock(&tmp->mutex);
+    pthread_mutex_unlock(&di->mutex);
   }
   VOID(pthread_mutex_unlock(&LOCK_delayed_insert)); // For unlink from list
 }
@@ -972,7 +972,7 @@
 
 extern "C" pthread_handler_decl(handle_delayed_insert,arg)
 {
-  delayed_insert *di=(delayed_insert*) arg;
+  delayed_insert *di= (delayed_insert*) arg;
   THD *thd= &di->thd;
 
   pthread_detach_this_thread();
@@ -1016,7 +1016,7 @@
 
   /* open table */
 
-  if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED)))
+  if (! (di->table= open_ltable(thd, &di->table_list, TL_WRITE_DELAYED)))
   {
     thd->fatal_error=1;				// Abort waiting inserts
     goto end;
@@ -1027,7 +1027,7 @@
     my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name);
     goto end;
   }
-  di->table->copy_blobs=1;
+  di->table->copy_blobs= 1;
 
   /* One can now use this */
   pthread_mutex_lock(&LOCK_delayed_insert);
@@ -1052,7 +1052,7 @@
       pthread_mutex_unlock(&di->mutex);
       pthread_mutex_lock(&LOCK_delayed_insert);
       di->unlink();
-      lock_count=di->lock_count();
+      lock_count= di->lock_count();
       pthread_mutex_unlock(&LOCK_delayed_insert);
       pthread_mutex_lock(&di->mutex);
       if (!lock_count && !di->tables_in_use &&
!di->stacked_inserts)
@@ -1067,16 +1067,16 @@
       /* Information for pthread_kill */
       di->thd.mysys_var->current_mutex= &di->mutex;
       di->thd.mysys_var->current_cond= &di->cond;
-      di->thd.proc_info="Waiting for INSERT";
+      di->thd.proc_info= "Waiting for INSERT";
 
       DBUG_PRINT("info",("Waiting for someone to insert rows"));
       while (!thd->killed)
       {
 	int error;
 #if defined(HAVE_BROKEN_COND_TIMEDWAIT)
-	error=pthread_cond_wait(&di->cond,&di->mutex);
+	error=pthread_cond_wait(&di->cond, &di->mutex);
 #else
-	error=pthread_cond_timedwait(&di->cond,&di->mutex,&abstime);
+	error=pthread_cond_timedwait(&di->cond, &di->mutex, &abstime);
 #ifdef EXTRA_DEBUG
 	if (error && error != EINTR && error != ETIMEDOUT)
 	{
@@ -1102,7 +1102,7 @@
       pthread_mutex_unlock(&di->thd.mysys_var->mutex);
       pthread_mutex_lock(&di->mutex);
     }
-    di->thd.proc_info=0;
+    di->thd.proc_info= 0;
 
     if (di->tables_in_use && ! thd->lock)
     {
@@ -1119,7 +1119,7 @@
       if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1,
                                           MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK)))
       {
-	di->dead=thd->killed=1;			// Fatal error
+        di->dead= thd->killed= 1;                       // Fatal error
       }
       pthread_cond_broadcast(&di->cond_client);
     }
@@ -1127,10 +1127,10 @@
     {
       if (di->handle_inserts())
       {
-	di->dead=thd->killed=1;			// Some fatal error
+        di->dead= thd->killed= 1;                       // Some fatal error
       }
     }
-    di->status=0;
+    di->status= 0;
     if (!di->stacked_inserts && !di->tables_in_use && thd->lock)
     {
       /* No one is doing a insert delayed;
@@ -1139,7 +1139,7 @@
       thd->lock=0;
       pthread_mutex_unlock(&di->mutex);
       mysql_unlock_tables(thd, lock);
-      di->group_count=0;
+      di->group_count= 0;
       pthread_mutex_lock(&di->mutex);
     }
     if (di->tables_in_use)
@@ -1153,16 +1153,16 @@
   */
 
   close_thread_tables(thd);			// Free the table
-  di->table=0;
-  di->dead=thd->killed=1;			// If error
+  di->table= 0;
+  di->dead= thd->killed= 1;                     // If error
   pthread_cond_broadcast(&di->cond_client);	// Safety
   pthread_mutex_unlock(&di->mutex);
 
   pthread_mutex_lock(&LOCK_delayed_create);	// Because of delayed_get_table
-  pthread_mutex_lock(&LOCK_delayed_insert);	
+  pthread_mutex_lock(&LOCK_delayed_insert);
   delete di;
   pthread_mutex_unlock(&LOCK_delayed_insert);
-  pthread_mutex_unlock(&LOCK_delayed_create);  
+  pthread_mutex_unlock(&LOCK_delayed_create);
 
   my_thread_end();
   pthread_exit(0);
Thread
bk commit into 4.0 tree (ingo:1.2179) BUG#17436ingo21 May