提交 591b9b09 编写于 作者: T Tom Lane

Use ftruncate() not truncate() in mdunlink. Seems Windows doesn't

support the latter.
上级 d788c922
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册