]> granicus.if.org Git - postgresql/commitdiff
In bootstrap mode, don't allow the creation of files if they don't already
authorAmit Kapila <akapila@postgresql.org>
Mon, 28 Jan 2019 02:21:02 +0000 (07:51 +0530)
committerAmit Kapila <akapila@postgresql.org>
Mon, 28 Jan 2019 02:22:51 +0000 (07:52 +0530)
exist.

In commit's b9d01fe288 and 3908473c80, we have added some code where we
allowed the creation of files during mdopen even if they didn't exist
during the bootstrap mode.  The later commit obviates the need for same.

This was harmless code till now but with an upcoming feature where we don't
allow to create FSM for small tables, this will needlessly create FSM
files.

Author: John Naylor
Reviewed-by: Amit Kapila
Discussion: https://www.postgresql.org/message-id/CAJVSVGWvB13PzpbLEecFuGFc5V2fsO736BsdTakPiPAcdMM5tQ@mail.gmail.com
    https://www.postgresql.org/message-id/CAA4eK1KsET6sotf+rzOTQfb83pzVEzVhbQi1nxGFYVstVWXUGw@mail.gmail.com

src/backend/storage/smgr/md.c

index c37dd1290b84ee51f684aebf1b4fcd60c81e588a..2aba2dfe91763858a56b1f45e4cb76c3a4966199 100644 (file)
@@ -310,13 +310,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)
-                */
-               if (isRedo || IsBootstrapProcessingMode())
+               if (isRedo)
                        fd = PathNameOpenFile(path, O_RDWR | PG_BINARY);
                if (fd < 0)
                {
@@ -572,26 +566,15 @@ mdopen(SMgrRelation reln, ForkNumber forknum, int behavior)
 
        if (fd < 0)
        {
-               /*
-                * During bootstrap, there are cases where a system relation will be
-                * accessed (by internal backend processes) before the bootstrap
-                * script nominally creates it.  Therefore, accept mdopen() as a
-                * substitute for mdcreate() in bootstrap mode only. (See mdcreate)
-                */
-               if (IsBootstrapProcessingMode())
-                       fd = PathNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY);
-               if (fd < 0)
+               if ((behavior & EXTENSION_RETURN_NULL) &&
+                       FILE_POSSIBLY_DELETED(errno))
                {
-                       if ((behavior & EXTENSION_RETURN_NULL) &&
-                               FILE_POSSIBLY_DELETED(errno))
-                       {
-                               pfree(path);
-                               return NULL;
-                       }
-                       ereport(ERROR,
-                                       (errcode_for_file_access(),
-                                        errmsg("could not open file \"%s\": %m", path)));
+                       pfree(path);
+                       return NULL;
                }
+               ereport(ERROR,
+                               (errcode_for_file_access(),
+                                errmsg("could not open file \"%s\": %m", path)));
        }
 
        pfree(path);