Some platforms reject fsync() on files opened O_RDONLY.
authorTom Lane
Tue, 23 Feb 2010 05:44:55 +0000 (05:44 +0000)
committerTom Lane
Tue, 23 Feb 2010 05:44:55 +0000 (05:44 +0000)
src/port/copydir.c

index 3cd7db7a4cd9e30d6a2485a3c219b87719b20a2a..14c6ffe769123c0aa62840d68fcdc8ab19ccd2e6 100644 (file)
@@ -11,7 +11,7 @@
  * as a service.
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/port/copydir.c,v 1.31 2010/02/22 15:29:46 tgl Exp $
+ *   $PostgreSQL: pgsql/src/port/copydir.c,v 1.32 2010/02/23 05:44:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -221,7 +221,7 @@ static void
 fsync_fname(char *fname)
 {
    int fd = BasicOpenFile(fname, 
-                          O_RDONLY | PG_BINARY,
+                          O_RDWR | PG_BINARY,
                           S_IRUSR | S_IWUSR);
 
    if (fd < 0)
@@ -229,8 +229,6 @@ fsync_fname(char *fname)
                (errcode_for_file_access(),
                 errmsg("could not open file \"%s\": %m", fname)));
 
-   errno = 0;
-
    if (pg_fsync(fd) != 0)
        ereport(ERROR,
                (errcode_for_file_access(),