Re: Win32 rename()/unlink() questions

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Mike Mascari <mascarm(at)mascari(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Win32 rename()/unlink() questions
Date: 2002-09-20 02:50:41
Message-ID: 200209200250.g8K2ofr29042@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian wrote:
> > > Second, when you unlink() a file on Win32, do applications continue
> > > accessing the old file contents if they had the file open before the
> > > unlink?
> > >
> >
> > unlink() just calls DeleteFile() which will error if:
> >
> > 1. The target file is in use
> >
> > CreateFile() has the option:
> >
> > FILE_FLAG_DELETE_ON_CLOSE
> >
> > which might be able to be used to simulate traditional unlink()
> > behavior.
>
> No, that flag isn't going to help us. I wonder what MoveFileEx does if
> the target file exists _and_ is open by another user? I don't see any
> loop in that Win32 rename() routine, and I looked at the Unix version of
> apr_file_rename and its just a straight rename() call.

This says that if the target is in use, it is overwritten:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q140570&

While I think that is good news, does it open the problem of other
readers reading partial updates to the file and therefore seeing
garbage. Not sure how to handle that, nor am I even sure how I would
test it.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-09-20 02:52:15 Re: DROP COLUMN misbehaviour with multiple inheritance
Previous Message Tom Lane 2002-09-20 02:49:32 Re: DROP COLUMN misbehaviour with multiple inheritance