WL#4973: Apply Google extra fixes to BUG#32149 to Server

Affects: Server-5.4   —   Status: Complete

Google extra fixes to BUG#32149.
In MySQL 5.4.0
MySQL 5.4.0:
To improve MySQL Server scalability, apply the Google patch for BUG#32149
the launchpad tree 5.1-patches maintained by Mark Callaghan:
http://bazaar.launchpad.net/~mdcallag/+junk/5.1-map/revision/2749
Community contribution; no further LLD needed.

=== modified file 'sql/sql_insert.cc'
--- sql/sql_insert.cc	2008-09-10 09:44:21 +0000
+++ sql/sql_insert.cc	2008-12-04 15:03:02 +0000
@@ -3065,6 +3065,9 @@ bool select_insert::send_data(List
       DBUG_RETURN(1);
     }
   }
+
+  // Release latches in case bulk insert takes a long time
+  ha_release_temporary_latches(thd);
   
   error= write_record(thd, table, &info);
   table->auto_increment_field_not_null= FALSE;

=== modified file 'sql/sql_select.cc'
--- sql/sql_select.cc	2008-08-28 09:54:50 +0000
+++ sql/sql_select.cc	2008-12-04 15:03:02 +0000
@@ -10526,6 +10526,9 @@ free_tmp_table(THD *thd, TABLE *entry)
   save_proc_info=thd->proc_info;
   thd_proc_info(thd, "removing tmp table");
 
+  // Release latches since this can take a long time
+  ha_release_temporary_latches(thd);
+
   if (entry->file)
   {
     if (entry->db_stat)
@@ -10571,6 +10574,10 @@ bool create_myisam_from_heap(THD *thd, T
     table->file->print_error(error,MYF(0));
     DBUG_RETURN(1);
   }
+
+  // Release latches since this can take a long time
+  ha_release_temporary_latches(thd);
+
   new_table= *table;
   share= *table->s;
   new_table.s= &share;

=== modified file 'storage/myisam/ha_myisam.cc'
--- storage/myisam/ha_myisam.cc	2008-03-28 10:14:27 +0000
+++ storage/myisam/ha_myisam.cc	2008-12-04 15:03:02 +0000
@@ -1081,6 +1081,9 @@ int ha_myisam::repair(THD *thd, MI_CHECK
   param.out_flag= 0;
   strmov(fixed_name,file->filename);
 
+  // Release latches since this can take a long time
+  ha_release_temporary_latches(thd);
+
   // Don't lock tables if we have used LOCK TABLE
   if (!thd->locked_tables && 
       mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))