Use ftruncate() not truncate() in mdunlink. Seems Windows doesn't
support the latter.
This commit is contained in:
parent
d788c922d7
commit
591b9b091c
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.131 2007/11/15 21:14:38 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.132 2007/11/15 21:49:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -316,7 +316,23 @@ mdunlink(RelFileNode rnode, bool isRedo)
|
||||
if (isRedo)
|
||||
ret = unlink(path);
|
||||
else
|
||||
ret = truncate(path, 0);
|
||||
{
|
||||
/* truncate(2) would be easier here, but Windows hasn't got it */
|
||||
int fd;
|
||||
|
||||
fd = BasicOpenFile(path, O_RDWR | PG_BINARY, 0);
|
||||
if (fd >= 0)
|
||||
{
|
||||
int save_errno;
|
||||
|
||||
ret = ftruncate(fd, 0);
|
||||
save_errno = errno;
|
||||
close(fd);
|
||||
errno = save_errno;
|
||||
}
|
||||
else
|
||||
ret = -1;
|
||||
}
|
||||
if (ret < 0)
|
||||
{
|
||||
if (!isRedo || errno != ENOENT)
|
||||
|
Loading…
Reference in New Issue
Block a user