← Back to team overview

maria-developers team mailing list archive

Rev 2775: Fix for maria BUG#491097. in file:///home/bell/maria/bzr/work-maria-5.1-test/

 

At file:///home/bell/maria/bzr/work-maria-5.1-test/

------------------------------------------------------------
revno: 2775
revision-id: sanja@xxxxxxxxxxxx-20091203210748-x0t8m9pim0x20s7g
parent: monty@xxxxxxxxxxxx-20091201160902-a3iq6lw82xbto9yp
committer: sanja@xxxxxxxxxxxx
branch nick: work-maria-5.1-test
timestamp: Thu 2009-12-03 23:07:48 +0200
message:
  Fix for maria BUG#491097.
  
  Unlock tables before sending OK to client.
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2009-11-16 20:49:51 +0000
+++ b/sql/mysql_priv.h	2009-12-03 21:07:48 +0000
@@ -796,6 +796,7 @@
 void cleanup_items(Item *item);
 class THD;
 void close_thread_tables(THD *thd);
+void unlock_thread_tables(THD *thd);
 
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
 bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2009-11-30 21:37:27 +0000
+++ b/sql/sql_base.cc	2009-12-03 21:07:48 +0000
@@ -1213,6 +1213,33 @@
 }
 
 
+/**
+  Unlocks tables in thd->lock()
+
+
+  @param thd             Thread handler
+*/
+
+void unlock_thread_tables(THD *thd)
+{
+  if (thd->lock)
+  {
+    /*
+      For RBR we flush the pending event just before we unlock all the
+      tables.  This means that we are at the end of a topmost
+      statement, so we ensure that the STMT_END_F flag is set on the
+      pending event.  For statements that are *inside* stored
+      functions, the pending event will not be flushed: that will be
+      handled either before writing a query log event (inside
+      binlog_query()) or when preparing a pending event.
+     */
+    thd->binlog_flush_pending_rows_event(TRUE);
+    mysql_unlock_tables(thd, thd->lock);
+    thd->lock=0;
+  }
+}
+
+
 /*
   Close all tables used by the current substatement, or all tables
   used by this thread if we are on the upper level.
@@ -1325,21 +1352,8 @@
     /* Fallthrough */
   }
 
-  if (thd->lock)
-  {
-    /*
-      For RBR we flush the pending event just before we unlock all the
-      tables.  This means that we are at the end of a topmost
-      statement, so we ensure that the STMT_END_F flag is set on the
-      pending event.  For statements that are *inside* stored
-      functions, the pending event will not be flushed: that will be
-      handled either before writing a query log event (inside
-      binlog_query()) or when preparing a pending event.
-     */
-    thd->binlog_flush_pending_rows_event(TRUE);
-    mysql_unlock_tables(thd, thd->lock);
-    thd->lock=0;
-  }
+  unlock_thread_tables(thd);
+
   /*
     Note that we need to hold LOCK_open while changing the
     open_tables list. Another thread may work on it.

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2009-11-30 21:37:27 +0000
+++ b/sql/sql_parse.cc	2009-12-03 21:07:48 +0000
@@ -1252,6 +1252,12 @@
       ha_maria::implicit_commit(thd, FALSE);
 #endif
 
+      /*
+        We should unlock tables before sending OK to client, because
+        unlocking makes results of insert (for example) visible for other
+        threads (for some engines like MyISAM).
+      */
+      unlock_thread_tables(thd);
       net_end_statement(thd);
       query_cache_end_of_result(thd);
       /*
@@ -1645,6 +1651,12 @@
   ha_maria::implicit_commit(thd, FALSE);
 #endif
 
+  /*
+    We should unlock tables before sending OK to client, because unlocking
+    makes results of insert (for example) visible for other threads (for
+    some engines like MyISAM).
+  */
+  unlock_thread_tables(thd);
   net_end_statement(thd);
   query_cache_end_of_result(thd);