Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d66e366

Browse files
author
Amit Kapila
committed
In bootstrap mode, don't allow the creation of files if they don't already
exist. In commit's b9d01fe and 3908473, 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
1 parent 0803b0a commit d66e366

File tree

1 file changed

+8
-25
lines changed
  • src/backend/storage/smgr

1 file changed

+8
-25
lines changed

src/backend/storage/smgr/md.c

+8-25
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,7 @@ mdcreate(SMgrRelation reln, ForkNumber forkNum, bool isRedo)
310310
{
311311
int save_errno = errno;
312312

313-
/*
314-
* During bootstrap, there are cases where a system relation will be
315-
* accessed (by internal backend processes) before the bootstrap
316-
* script nominally creates it. Therefore, allow the file to exist
317-
* already, even if isRedo is not set. (See also mdopen)
318-
*/
319-
if (isRedo || IsBootstrapProcessingMode())
313+
if (isRedo)
320314
fd = PathNameOpenFile(path, O_RDWR | PG_BINARY);
321315
if (fd < 0)
322316
{
@@ -572,26 +566,15 @@ mdopen(SMgrRelation reln, ForkNumber forknum, int behavior)
572566

573567
if (fd < 0)
574568
{
575-
/*
576-
* During bootstrap, there are cases where a system relation will be
577-
* accessed (by internal backend processes) before the bootstrap
578-
* script nominally creates it. Therefore, accept mdopen() as a
579-
* substitute for mdcreate() in bootstrap mode only. (See mdcreate)
580-
*/
581-
if (IsBootstrapProcessingMode())
582-
fd = PathNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | PG_BINARY);
583-
if (fd < 0)
569+
if ((behavior & EXTENSION_RETURN_NULL) &&
570+
FILE_POSSIBLY_DELETED(errno))
584571
{
585-
if ((behavior & EXTENSION_RETURN_NULL) &&
586-
FILE_POSSIBLY_DELETED(errno))
587-
{
588-
pfree(path);
589-
return NULL;
590-
}
591-
ereport(ERROR,
592-
(errcode_for_file_access(),
593-
errmsg("could not open file \"%s\": %m", path)));
572+
pfree(path);
573+
return NULL;
594574
}
575+
ereport(ERROR,
576+
(errcode_for_file_access(),
577+
errmsg("could not open file \"%s\": %m", path)));
595578
}
596579

597580
pfree(path);

0 commit comments

Comments
 (0)