Reduce strength of assert in mdcreate() to work correctly during bootstrap.
authorAndres Freund <andres@anarazel.de>
Sun, 22 Feb 2015 21:30:56 +0000 (22:30 +0100)
committerAndres Freund <andres@anarazel.de>
Mon, 23 Feb 2015 00:12:37 +0000 (01:12 +0100)
src/backend/storage/smgr/md.c

index b754d3bd1981aff9d362028df1a7256ea14e9a2c..dbfa0ce6709ee1457f5283cb69315d4796f48ddd 100644 (file)
@@ -290,7 +290,13 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
    char       *path;
    File        fd;
 
-   if (isRedo && reln->md_fd[forkNum] != NULL)
+   /*
+    * During bootstrap, there are cases where a system relation will be
+    * accessed (by internal backend processes) before the bootstrap
+    * script nominally creates it.  Therefore, allow the file to exist
+    * already, even if isRedo is not set.  (See also mdopen)
+    */
+   if ((IsBootstrapProcessingMode() || isRedo) && reln->md_fd[forkNum] != NULL)
        return;                 /* created and opened already... */
 
    Assert(reln->md_fd[forkNum] == NULL);
@@ -303,12 +309,7 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
    {
        int         save_errno = errno;
 
-       /*
-        * During bootstrap, there are cases where a system relation will be
-        * accessed (by internal backend processes) before the bootstrap
-        * script nominally creates it.  Therefore, allow the file to exist
-        * already, even if isRedo is not set.  (See also mdopen)
-        */
+       /* see comment above */
        if (isRedo || IsBootstrapProcessingMode())
            fd = PathNameOpenFile(path, O_RDWR | PG_BINARY, 0600);
        if (fd < 0)