Skip to content

Commit b9d01fe

Browse files
committed
Per Tatsuo's recommendation, change mdopen so that it won't
automatically create the file, except during bootstrap mode where that seems to be necessary.
1 parent 0041202 commit b9d01fe

File tree

1 file changed

+14
-4
lines changed
  • src/backend/storage/smgr

1 file changed

+14
-4
lines changed

src/backend/storage/smgr/md.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.52 1999/09/02 02:57:49 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.53 1999/09/05 23:24:53 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -284,13 +284,23 @@ mdopen(Relation reln)
284284
fd = FileNameOpenFile(path, O_RDWR | O_BINARY, 0600);
285285
#endif
286286

287-
/* this should only happen during bootstrap processing */
288287
if (fd < 0)
288+
{
289+
/* in bootstrap mode, accept mdopen as substitute for mdcreate */
290+
if (IsBootstrapProcessingMode())
291+
{
289292
#ifndef __CYGWIN32__
290-
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600);
293+
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600);
291294
#else
292-
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
295+
fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
293296
#endif
297+
}
298+
if (fd < 0)
299+
{
300+
elog(ERROR, "mdopen: couldn't open %s: %m", path);
301+
return -1;
302+
}
303+
}
294304

295305
vfd = _fdvec_alloc();
296306
if (vfd < 0)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy