List:Commits« Previous MessageNext Message »
From:antony Date:July 21 2006 9:16pm
Subject:bk commit into 5.0 tree (acurtis:1.2224) BUG#15669
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of antony. When antony 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@stripped, 2006-07-21 14:16:46-07:00, acurtis@stripped +1 -0
  Bug#15669
    "CSV test giving incorrect results on OpenBSD"
    Force invalidation of cached mmap pages

  sql/examples/ha_tina.cc@stripped, 2006-07-21 14:16:37-07:00, acurtis@stripped +40 -8
    Bug#15669
      "CSV test giving incorrect results on OpenBSD"
      Force invalidation of cached mmap pages when file is altered via
      traditional I/O primatives

# 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:	acurtis
# Host:	ltantony.xiphis.org
# Root:	/opt2/tmp/openbsd/p2-bug15669.2

--- 1.22/sql/examples/ha_tina.cc	2006-07-21 14:16:55 -07:00
+++ 1.23/sql/examples/ha_tina.cc	2006-07-21 14:16:55 -07:00
@@ -101,13 +101,28 @@
   return (byte*) share->table_name;
 }
 
+
+int free_mmap(TINA_SHARE *share)
+{
+  DBUG_ENTER("ha_tina::free_mmap");
+  if (share->mapped_file)
+  {
+    msync(share->mapped_file, 0, MS_INVALIDATE);
+    if (munmap(share->mapped_file, share->file_stat.st_size))
+      DBUG_RETURN(1);
+  }
+  share->mapped_file= NULL;
+  DBUG_RETURN(0);
+}
+
 /*
   Reloads the mmap file.
 */
 int get_mmap(TINA_SHARE *share, int write)
 {
   DBUG_ENTER("ha_tina::get_mmap");
-  if (share->mapped_file && munmap(share->mapped_file, share->file_stat.st_size))
+  
+  if (free_mmap(share))
     DBUG_RETURN(1);
 
   if (my_fstat(share->data_file, &share->file_stat, MYF(MY_WME)) == -1)
@@ -230,8 +245,7 @@
   int result_code= 0;
   if (!--share->use_count){
     /* Drop the mapped file */
-    if (share->mapped_file) 
-      munmap(share->mapped_file, share->file_stat.st_size);
+    free_mmap(share);
     result_code= my_close(share->data_file,MYF(0));
     hash_delete(&tina_open_tables, (byte*) share);
     thr_lock_delete(&share->lock);
@@ -493,6 +507,9 @@
 
   size= encode_quote(buf);
 
+  if (free_mmap(share))
+    DBUG_RETURN(-1);
+
   if (my_write(share->data_file, buffer.ptr(), size, MYF(MY_WME | MY_NABP)))
     DBUG_RETURN(-1);
 
@@ -534,8 +551,22 @@
   if (chain_append())
     DBUG_RETURN(-1);
 
+  if (free_mmap(share))
+    DBUG_RETURN(-1);
+
   if (my_write(share->data_file, buffer.ptr(), size, MYF(MY_WME | MY_NABP)))
     DBUG_RETURN(-1);
+
+  /* 
+    Ok, this is means that we will be doing potentially bad things 
+    during a bulk insert on some OS'es. What we need is a cleanup
+    call for ::write_row that would let us fix up everything after the bulk
+    insert. The archive handler does this with an extra mutx call, which
+    might be a solution for this.
+  */
+  if (get_mmap(share, 0) > 0) 
+    DBUG_RETURN(-1);
+
   DBUG_RETURN(0);
 }
 
@@ -812,15 +843,13 @@
       length= length - (size_t)(ptr->end - ptr->begin);
     }
 
-    /* Truncate the file to the new size */
-    if (my_chsize(share->data_file, length, 0, MYF(MY_WME)))
+    if (free_mmap(share))
       DBUG_RETURN(-1);
 
-    if (munmap(share->mapped_file, length))
+    /* Truncate the file to the new size */
+    if (my_chsize(share->data_file, length, 0, MYF(MY_WME)))
       DBUG_RETURN(-1);
 
-    /* We set it to null so that get_mmap() won't try to unmap it */
-    share->mapped_file= NULL;
     if (get_mmap(share, 0) > 0) 
       DBUG_RETURN(-1);
   }
@@ -837,6 +866,9 @@
 
   if (!records_is_known)
     return (my_errno=HA_ERR_WRONG_COMMAND);
+
+  if (free_mmap(share)) 
+    DBUG_RETURN(-1);
 
   int rc= my_chsize(share->data_file, 0, 0, MYF(MY_WME));
 
Thread
bk commit into 5.0 tree (acurtis:1.2224) BUG#15669antony21 Jul