@@ -397,7 +397,6 @@ GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
397
397
{
398
398
RelFileNodeBackend rnode ;
399
399
char * rpath ;
400
- int fd ;
401
400
bool collides ;
402
401
BackendId backend ;
403
402
@@ -445,26 +444,20 @@ GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
445
444
446
445
/* Check for existing file of same name */
447
446
rpath = relpath (rnode , MAIN_FORKNUM );
448
- fd = BasicOpenFile (rpath , O_RDONLY | PG_BINARY );
449
447
450
- if (fd > = 0 )
448
+ if (access ( rpath , F_OK ) = = 0 )
451
449
{
452
450
/* definite collision */
453
- close (fd );
454
451
collides = true;
455
452
}
456
453
else
457
454
{
458
455
/*
459
456
* Here we have a little bit of a dilemma: if errno is something
460
457
* other than ENOENT, should we declare a collision and loop? In
461
- * particular one might think this advisable for, say, EPERM.
462
- * However there really shouldn't be any unreadable files in a
463
- * tablespace directory, and if the EPERM is actually complaining
464
- * that we can't read the directory itself, we'd be in an infinite
465
- * loop. In practice it seems best to go ahead regardless of the
466
- * errno. If there is a colliding file we will get an smgr
467
- * failure when we attempt to create the new relation file.
458
+ * practice it seems best to go ahead regardless of the errno. If
459
+ * there is a colliding file we will get an smgr failure when we
460
+ * attempt to create the new relation file.
468
461
*/
469
462
collides = false;
470
463
}
0 commit comments