List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:July 1 2008 1:12pm
Subject:bzr commit into mysql-6.0-backup branch (svoj:2641) Bug#37012
View as plain text  
#At file:///home/svoj/devel/bzr-mysql/mysql-6.0-backup-37012/

 2641 Sergey Vojtovich	2008-07-01
      BUG#37012 - Online backup: Can't backup to a pipe.
      
      It was impossible to backup to a pipe. Backup code refuse
      to overwrite existing files no matter if they're regular files
      or named pipes.
      
      This fix allows to write backup image to existing named pipe.
      
      No test case for this fix, as currently there is no good way
      in our test suite to determine if OS supports named pipes.
modified:
  sql/backup/stream.cc

per-file messages:
  sql/backup/stream.cc
    Allow to write to existing named pipe.
    
    Also fixed "comparison is always false due to limited
    range of data type" compiler warning.
=== modified file 'sql/backup/stream.cc'
--- a/sql/backup/stream.cc	2008-06-26 10:38:48 +0000
+++ b/sql/backup/stream.cc	2008-07-01 13:12:03 +0000
@@ -1,4 +1,5 @@
 #include "../mysql_priv.h"
+#include "my_dir.h"
 
 #include "backup_stream.h"
 #include "stream.h"
@@ -129,8 +130,8 @@ extern "C" int stream_read(void *instanc
     {
       if (!zstream->avail_in)
       {
-        zstream->avail_in= my_read(fd, s->zbuf, ZBUF_SIZE, MYF(0));
-        if (zstream->avail_in == (size_t) -1)
+        zstream->avail_in= (uInt) my_read(fd, s->zbuf, ZBUF_SIZE, MYF(0));
+        if (zstream->avail_in == (uInt) -1)
           DBUG_RETURN(BSTREAM_ERROR);
         else if (!zstream->avail_in)
           break;
@@ -215,7 +216,7 @@ bool Stream::rewind()
 
 Output_stream::Output_stream(Logger &log, const ::String &name,
                              bool with_compression)
-  :Stream(log, name, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC)
+  :Stream(log, name, 0)
 {
   m_with_compression= with_compression;
   stream.write= stream_write;
@@ -284,8 +285,16 @@ bool Output_stream::init()
 */
 bool Output_stream::open()
 {
+  MY_STAT stat_info;
   close();
 
+  /* Allow to write to existing named pipe */
+  if (my_stat(m_path.c_ptr(), &stat_info, MYF(0)) &&
+      MY_S_ISFIFO(stat_info.st_mode))
+    m_flags= O_WRONLY;
+  else
+    m_flags= O_WRONLY|O_CREAT|O_EXCL|O_TRUNC;
+
   bool ret= Stream::open();
 
   if (!ret)

Thread
bzr commit into mysql-6.0-backup branch (svoj:2641) Bug#37012Sergey Vojtovich1 Jul