X-Spam-Status: Yes, hits=5.0 required=5.0 tests=RCVD_IN_OSIRUSOFT_COM,X_OSIRU_SPAM_SRC version=2.20\r
X-Spam-Flag: YES\r
X-Spam-Level: *****\r
-X-Spam-Checker-Version: SpamAssassin 2.20 (devel $Id: win32,v 1.3 2002/09/16 02:50:20 momjian Exp $)\r
+X-Spam-Checker-Version: SpamAssassin 2.20 (devel $Id: win32,v 1.4 2002/09/23 01:59:40 momjian Exp $)\r
X-Spam-Report: Detailed Report\r
SPAM: -------------------- Start SpamAssassin results ----------------------\r
SPAM: This mail is probably spam. The original message has been altered\r
http://www.postgresql.org/users-lounge/docs/faq.html
+From pgsql-hackers-owner+M29089@postgresql.org Thu Sep 19 01:07:35 2002
+Return-path: <pgsql-hackers-owner+M29089@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8J57XE17033
+ for <pgman@candle.pha.pa.us>; Thu, 19 Sep 2002 01:07:34 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id C4A62476A3C; Thu, 19 Sep 2002 01:07:34 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id A818A4760B0; Thu, 19 Sep 2002 01:07:32 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 4E7414769C9
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:07:26 -0400 (EDT)
+Received: from ece.rice.edu (ece.rice.edu [128.42.4.34])
+ by postgresql.org (Postfix) with ESMTP id B6B5447590C
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:07:24 -0400 (EDT)
+Received: from localhost (localhost [127.0.0.1])
+ by ece.rice.edu (Postfix) with ESMTP
+ id 337C368A68; Thu, 19 Sep 2002 00:07:24 -0500 (CDT)
+Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154])
+ by ece.rice.edu (Postfix) with ESMTP
+ id 1EF0D68A65; Thu, 19 Sep 2002 00:07:23 -0500 (CDT)
+Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.34 #1 (Debian))
+ id 17rtX8-00042E-00; Thu, 19 Sep 2002 00:07:22 -0500
+Date: Thu, 19 Sep 2002 00:07:22 -0500
+From: "Ross J. Reedstrom" <reedstrm@rice.edu>
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+Message-ID: <20020919050722.GC15352@rice.edu>
+Mail-Followup-To: "Ross J. Reedstrom" <reedstrm@ece.rice.edu>,
+ Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+References: <200209190001.g8J01gG13849@candle.pha.pa.us>
+MIME-Version: 1.0
+Content-Type: text/plain; charset=us-ascii
+Content-Disposition: inline
+In-Reply-To: <200209190001.g8J01gG13849@candle.pha.pa.us>
+User-Agent: Mutt/1.3.27i
+X-Virus-Scanned: by AMaViS snapshot-20020300
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+On Wed, Sep 18, 2002 at 08:01:42PM -0400, 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?
+
+I'm pretty sure it errors with 'file in use'. Pretty ugly, huh?
+
+Ross
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From mascarm@mascari.com Thu Sep 19 01:24:42 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8J5ObE18446
+ for <pgman@candle.pha.pa.us>; Thu, 19 Sep 2002 01:24:40 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id BAA15293;
+ Thu, 19 Sep 2002 01:23:54 -0400
+Message-ID: <3D895F60.4010902@mascari.com>
+Date: Thu, 19 Sep 2002 01:23:45 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209190001.g8J01gG13849@candle.pha.pa.us>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: OR
+
+Bruce Momjian wrote:
+> I am working with several groups getting the Win32 port ready for 7.4
+> and I have a few questions:
+>
+> What is the standard workaround for the fact that rename() isn't atomic
+> on Win32? Do we need to create our own locking around the
+> reading/writing of files that are normally updated in place using
+> rename()?
+
+Visual C++ comes with the source to Microsoft's C library:
+
+rename() calls MoveFile() which will error if:
+
+1. The target file exists
+2. The source file is in use
+
+MoveFileEx() (not available on 95/98) can overwrite the target
+file if it exists. The Apache APR portability library uses
+MoveFileEx() to rename files if under NT/XP/2K vs. a sequence of :
+
+1. CreateFile() to test for target file existence
+2. DeleteFile() to remove the target file
+3. MoveFile() to rename the old file to new
+
+under Windows 95/98. Of course, some other process could create
+the target file between 2 and 3, so their rename() would just
+error out in that situation. I haven't tested it, but I recall
+reading somewhere that MoveFileEx() has the ability to rename an
+opened file. I'm 99% sure MoveFile() will fail if the source
+file is open.
+
+>
+> 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.
+
+Hope that helps,
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+
+
+
+
+
+From pgsql-hackers-owner+M29091@postgresql.org Thu Sep 19 01:24:54 2002
+Return-path: <pgsql-hackers-owner+M29091@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8J5OqE18478
+ for <pgman@candle.pha.pa.us>; Thu, 19 Sep 2002 01:24:53 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id A5031476A31; Thu, 19 Sep 2002 01:24:52 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id F2ED047698F; Thu, 19 Sep 2002 01:24:50 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id BA69E476086
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:24:47 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id 56A2D475FE3
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:24:46 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id BAA15293;
+ Thu, 19 Sep 2002 01:23:54 -0400
+Message-ID: <3D895F60.4010902@mascari.com>
+Date: Thu, 19 Sep 2002 01:23:45 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209190001.g8J01gG13849@candle.pha.pa.us>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: ORr
+
+Bruce Momjian wrote:
+> I am working with several groups getting the Win32 port ready for 7.4
+> and I have a few questions:
+>
+> What is the standard workaround for the fact that rename() isn't atomic
+> on Win32? Do we need to create our own locking around the
+> reading/writing of files that are normally updated in place using
+> rename()?
+
+Visual C++ comes with the source to Microsoft's C library:
+
+rename() calls MoveFile() which will error if:
+
+1. The target file exists
+2. The source file is in use
+
+MoveFileEx() (not available on 95/98) can overwrite the target
+file if it exists. The Apache APR portability library uses
+MoveFileEx() to rename files if under NT/XP/2K vs. a sequence of :
+
+1. CreateFile() to test for target file existence
+2. DeleteFile() to remove the target file
+3. MoveFile() to rename the old file to new
+
+under Windows 95/98. Of course, some other process could create
+the target file between 2 and 3, so their rename() would just
+error out in that situation. I haven't tested it, but I recall
+reading somewhere that MoveFileEx() has the ability to rename an
+opened file. I'm 99% sure MoveFile() will fail if the source
+file is open.
+
+>
+> 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.
+
+Hope that helps,
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+
+
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 6: Have you searched our list archives?
+
+http://archives.postgresql.org
+
+From pgsql-hackers-owner+M29090@postgresql.org Thu Sep 19 01:23:40 2002
+Return-path: <pgsql-hackers-owner+M29090@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8J5NcE18313
+ for <pgman@candle.pha.pa.us>; Thu, 19 Sep 2002 01:23:38 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 8B685476A38; Thu, 19 Sep 2002 01:23:39 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 54C6E4769AA; Thu, 19 Sep 2002 01:23:37 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 47A9B4762E6
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:23:33 -0400 (EDT)
+Received: from houston.familyhealth.com.au (unknown [203.59.48.253])
+ by postgresql.org (Postfix) with ESMTP id 9D4C6476171
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:23:31 -0400 (EDT)
+Received: (from root@localhost)
+ by houston.familyhealth.com.au (8.11.6/8.11.6) id g8J5NUJ42439
+ for pgsql-hackers@postgresql.org; Thu, 19 Sep 2002 13:23:30 +0800 (WST)
+ (envelope-from chriskl@familyhealth.com.au)
+Received: from mariner (mariner.internal [192.168.0.101])
+ by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id g8J5NSk42348;
+ Thu, 19 Sep 2002 13:23:28 +0800 (WST)
+From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
+To: "Ross J. Reedstrom" <reedstrm@rice.edu>
+cc: "PostgreSQL-development" <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+Date: Thu, 19 Sep 2002 13:24:01 +0800
+Message-ID: <GNELIHDDFBOCMGBFGEFOGEFCCEAA.chriskl@familyhealth.com.au>
+MIME-Version: 1.0
+Content-Type: text/plain;
+ charset="US-ASCII"
+Content-Transfer-Encoding: 7bit
+X-Priority: 3 (Normal)
+X-MSMail-Priority: Normal
+X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
+In-Reply-To: <20020919050722.GC15352@rice.edu>
+X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
+Importance: Normal
+X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/)
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+> On Wed, Sep 18, 2002 at 08:01:42PM -0400, 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?
+>
+> I'm pretty sure it errors with 'file in use'. Pretty ugly, huh?
+
+Yeah - the windows filesystem is pretty poor when it comes to multiuser
+access. That's why even as administrator I cannot delete borked files and
+people's profiles and stuff off our NT server - the files are always 'in
+use'. Even if you kick all users off, reboot the machine, do whatever.
+It's terrible.
+
+Chris
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From pgsql-hackers-owner+M29092@postgresql.org Thu Sep 19 01:32:51 2002
+Return-path: <pgsql-hackers-owner+M29092@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8J5WnE19160
+ for <pgman@candle.pha.pa.us>; Thu, 19 Sep 2002 01:32:50 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id A34DA476A7D; Thu, 19 Sep 2002 01:32:50 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 80422476A62; Thu, 19 Sep 2002 01:32:48 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 496D1476A44
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:32:44 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id 228C74769F6
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 01:32:43 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id BAA15313;
+ Thu, 19 Sep 2002 01:31:28 -0400
+Message-ID: <3D896127.2070103@mascari.com>
+Date: Thu, 19 Sep 2002 01:31:19 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
+cc: "Ross J. Reedstrom" <reedstrm@rice.edu>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <GNELIHDDFBOCMGBFGEFOGEFCCEAA.chriskl@familyhealth.com.au>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Christopher Kings-Lynne wrote:
+>>On Wed, Sep 18, 2002 at 08:01:42PM -0400, 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?
+>>
+>>I'm pretty sure it errors with 'file in use'. Pretty ugly, huh?
+>
+>
+> Yeah - the windows filesystem is pretty poor when it comes to multiuser
+> access. That's why even as administrator I cannot delete borked files and
+> people's profiles and stuff off our NT server - the files are always 'in
+> use'. Even if you kick all users off, reboot the machine, do whatever.
+> It's terrible.
+ >
+ > Chris
+ >
+
+Yep. That's why often it requires rebooting to uninstall
+software. How can the installer remove itself? Under Windows
+95/98/ME, you have to manually add entries to WININIT.INI. With
+Windows NT/XP/2K, MoveFileEx() with a NULL target and the
+MOVEFILE_DELAY_UNTIL_REBOOT flag will add the appropriate
+entries into the system registry so that the next time the
+machine reboots it will remove the files specified. Its a real
+pain and a real hack of an OS.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From pgsql-hackers-owner+M29135@postgresql.org Thu Sep 19 16:26:02 2002
+Return-path: <pgsql-hackers-owner+M29135@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8JKPvE10469
+ for <pgman@candle.pha.pa.us>; Thu, 19 Sep 2002 16:25:57 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 55024476101; Thu, 19 Sep 2002 16:25:40 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id B87A6476A3F; Thu, 19 Sep 2002 16:25:34 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id CC7F5476101
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 16:24:38 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id E04B8475AFF
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 16:24:35 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8JKO1g10337;
+ Thu, 19 Sep 2002 16:24:01 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209192024.g8JKO1g10337@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D895F60.4010902@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Thu, 19 Sep 2002 16:24:01 -0400 (EDT)
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: ORr
+
+Mike Mascari wrote:
+> Bruce Momjian wrote:
+> > I am working with several groups getting the Win32 port ready for 7.4
+> > and I have a few questions:
+> >
+> > What is the standard workaround for the fact that rename() isn't atomic
+> > on Win32? Do we need to create our own locking around the
+> > reading/writing of files that are normally updated in place using
+> > rename()?
+>
+> Visual C++ comes with the source to Microsoft's C library:
+>
+> rename() calls MoveFile() which will error if:
+>
+> 1. The target file exists
+> 2. The source file is in use
+>
+> MoveFileEx() (not available on 95/98) can overwrite the target
+> file if it exists. The Apache APR portability library uses
+> MoveFileEx() to rename files if under NT/XP/2K vs. a sequence of :
+>
+> 1. CreateFile() to test for target file existence
+> 2. DeleteFile() to remove the target file
+> 3. MoveFile() to rename the old file to new
+>
+> under Windows 95/98. Of course, some other process could create
+> the target file between 2 and 3, so their rename() would just
+> error out in that situation. I haven't tested it, but I recall
+> reading somewhere that MoveFileEx() has the ability to rename an
+> opened file. I'm 99% sure MoveFile() will fail if the source
+> file is open.
+
+OK, I downloaded APR and see in apr_file_rename():
+
+ if (MoveFileEx(frompath, topath, MOVEFILE_REPLACE_EXISTING |
+ MOVEFILE_COPY_ALLOWED))
+
+
+Looking at the entire APR function, they have lots of tests so it works
+on Win9X and wide characters. I think we will just use the APR as a
+guide in implementing the things we need. I think MoveFileEx() is the
+proper way to go; any other solution requires loop tests for rename.
+
+I see the MoveFileEx manual page at:
+
+ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/movefile.asp
+
+> > 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.
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 3: if posting/reading through Usenet, please send an appropriate
+subscribe-nomail command to majordomo@postgresql.org so that your
+message can get through to the mailing list cleanly
+
+From pgman Thu Sep 19 22:50:41 2002
+Return-path: <pgman>
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8K2ofr29042;
+ Thu, 19 Sep 2002 22:50:41 -0400 (EDT)
+From: Bruce Momjian <pgman>
+Message-ID: <200209200250.g8K2ofr29042@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <200209192024.g8JKO1g10337@candle.pha.pa.us>
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+Date: Thu, 19 Sep 2002 22:50:41 -0400 (EDT)
+cc: Mike Mascari <mascarm@mascari.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+Status: OR
+
+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@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+From pgsql-hackers-owner+M29166@postgresql.org Thu Sep 19 22:52:08 2002
+Return-path: <pgsql-hackers-owner+M29166@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K2q7E29312
+ for <pgman@candle.pha.pa.us>; Thu, 19 Sep 2002 22:52:07 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 5B1CE47620D; Thu, 19 Sep 2002 22:51:36 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 6CC8F47651C; Thu, 19 Sep 2002 22:51:13 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 77E1F476476
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 22:50:57 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id 8CF61476459
+ for <pgsql-hackers@postgresql.org>; Thu, 19 Sep 2002 22:50:55 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8K2ofr29042;
+ Thu, 19 Sep 2002 22:50:41 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209200250.g8K2ofr29042@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <200209192024.g8JKO1g10337@candle.pha.pa.us>
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+Date: Thu, 19 Sep 2002 22:50:41 -0400 (EDT)
+cc: Mike Mascari <mascarm@mascari.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+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@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From mascarm@mascari.com Fri Sep 20 00:02:33 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K42SE12294
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 00:02:31 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id AAA18322;
+ Fri, 20 Sep 2002 00:01:34 -0400
+Message-ID: <3D8A9DAD.5040500@mascari.com>
+Date: Fri, 20 Sep 2002 00:01:49 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209200250.g8K2ofr29042@candle.pha.pa.us>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: ORr
+
+Bruce Momjian wrote:
+> Bruce Momjian wrote:
+>>>
+>>>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&
+
+I read the article and did not come away with that conclusion.
+The article describes using the MOVEFILE_DELAY_UNTIL_REBOOT
+flag, which was created for the express purpose of allowing a
+SETUP.EXE to remove itself, or rather tell Windows to remove it
+on the next reboot. Also, if you want the Win32 port to run in
+95/98/ME, you can't rely on MoveFileEx(), you have to use
+MoveFile().
+
+I will do some testing with concurrency and let you know. But
+don't get your hopes up. This is one of the many advantages that
+TABLESPACEs have when more than one relation is stored in a
+single DATAFILE. There was Oracle for MS-DOS, after all..
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+From pgsql-hackers-owner+M29177@postgresql.org Fri Sep 20 00:06:31 2002
+Return-path: <pgsql-hackers-owner+M29177@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K46TE12770
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 00:06:29 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 44057476CF8; Fri, 20 Sep 2002 00:06:24 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id A0C78476C00; Fri, 20 Sep 2002 00:06:22 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 5AB4E476D1C
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 00:05:57 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id 990B9476D38
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 00:05:55 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8K45RV12655;
+ Fri, 20 Sep 2002 00:05:27 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209200405.g8K45RV12655@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8A9DAD.5040500@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Fri, 20 Sep 2002 00:05:27 -0400 (EDT)
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Mike Mascari wrote:
+> I read the article and did not come away with that conclusion.
+> The article describes using the MOVEFILE_DELAY_UNTIL_REBOOT
+> flag, which was created for the express purpose of allowing a
+> SETUP.EXE to remove itself, or rather tell Windows to remove it
+> on the next reboot. Also, if you want the Win32 port to run in
+> 95/98/ME, you can't rely on MoveFileEx(), you have to use
+> MoveFile().
+>
+> I will do some testing with concurrency and let you know. But
+> don't get your hopes up. This is one of the many advantages that
+> TABLESPACEs have when more than one relation is stored in a
+> single DATAFILE. There was Oracle for MS-DOS, after all..
+
+I was focusing on handling of pg_pwd and other config file that are
+written by various backend while other backends are reading them. The
+actual data files should be OK because we have an exclusive lock when we
+are adding/removing them.
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 5: Have you checked our extensive FAQ?
+
+http://www.postgresql.org/users-lounge/docs/faq.html
+
+From pgsql-hackers-owner+M29179@postgresql.org Fri Sep 20 00:33:22 2002
+Return-path: <pgsql-hackers-owner+M29179@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K4XKE14843
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 00:33:20 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id EB433476D5B; Fri, 20 Sep 2002 00:32:25 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 2ED3A476D4E; Fri, 20 Sep 2002 00:32:24 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 43723476994
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 00:32:20 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id A66C6476883
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 00:32:18 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id AAA18391;
+ Fri, 20 Sep 2002 00:31:31 -0400
+Message-ID: <3D8AA4B2.8090507@mascari.com>
+Date: Fri, 20 Sep 2002 00:31:46 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209200405.g8K45RV12655@candle.pha.pa.us>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Bruce Momjian wrote:
+> Mike Mascari wrote:
+>
+>>I will do some testing with concurrency and let you know. But
+>>don't get your hopes up. This is one of the many advantages that
+>>TABLESPACEs have when more than one relation is stored in a
+>>single DATAFILE. There was Oracle for MS-DOS, after all..
+>
+>
+> I was focusing on handling of pg_pwd and other config file that are
+> written by various backend while other backends are reading them. The
+> actual data files should be OK because we have an exclusive lock when we
+> are adding/removing them.
+>
+
+OK. So you want to test:
+
+1. Process 1 opens "foo"
+2. Process 2 opens "foo"
+3. Process 1 renames "foo" to "bar"
+4. Process 2 can safely read from its open file handle
+
+Is that what you want tested? I have a small Win32 app ready to
+test. Just let me know the scenarios...
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From mascarm@mascari.com Fri Sep 20 01:01:37 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K51WE17352
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 01:01:35 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id BAA18603;
+ Fri, 20 Sep 2002 01:00:49 -0400
+Message-ID: <3D8AAB8F.8010001@mascari.com>
+Date: Fri, 20 Sep 2002 01:01:03 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development
+ <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209200405.g8K45RV12655@candle.pha.pa.us> <3D8AA4B2.8090507@mascari.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: ORr
+
+Mike Mascari wrote:
+> Bruce Momjian wrote:
+>
+>> Mike Mascari wrote:
+>>
+>>> I will do some testing with concurrency and let you know. But don't
+>>> get your hopes up. This is one of the many advantages that
+>>> TABLESPACEs have when more than one relation is stored in a single
+>>> DATAFILE. There was Oracle for MS-DOS, after all..
+>>
+>>
+>>
+>> I was focusing on handling of pg_pwd and other config file that are
+>> written by various backend while other backends are reading them. The
+>> actual data files should be OK because we have an exclusive lock when we
+>> are adding/removing them.
+>>
+>
+> OK. So you want to test:
+>
+> 1. Process 1 opens "foo"
+> 2. Process 2 opens "foo"
+> 3. Process 1 renames "foo" to "bar"
+> 4. Process 2 can safely read from its open file handle
+
+Actually, looking at the pg_pwd code, you want to determine a
+way for:
+
+1. Process 1 opens "foo"
+2. Process 2 opens "foo"
+3. Process 1 creates "bar"
+4. Process 1 renames "bar" to "foo"
+5. Process 2 can continue to read data from the open file handle
+and get the original "foo" data.
+
+Is that correct?
+
+Mike Mascari
+mascarm@mascari.com
+
+
+From pgsql-hackers-owner+M29180@postgresql.org Fri Sep 20 01:02:47 2002
+Return-path: <pgsql-hackers-owner+M29180@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K52kE17470
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 01:02:46 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id A4AB5476D73; Fri, 20 Sep 2002 01:02:29 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 35B61476D76; Fri, 20 Sep 2002 01:02:21 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 4D3D14760AB
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:01:55 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id D259E475EAA
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:01:53 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id BAA18603;
+ Fri, 20 Sep 2002 01:00:49 -0400
+Message-ID: <3D8AAB8F.8010001@mascari.com>
+Date: Fri, 20 Sep 2002 01:01:03 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209200405.g8K45RV12655@candle.pha.pa.us> <3D8AA4B2.8090507@mascari.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Mike Mascari wrote:
+> Bruce Momjian wrote:
+>
+>> Mike Mascari wrote:
+>>
+>>> I will do some testing with concurrency and let you know. But don't
+>>> get your hopes up. This is one of the many advantages that
+>>> TABLESPACEs have when more than one relation is stored in a single
+>>> DATAFILE. There was Oracle for MS-DOS, after all..
+>>
+>>
+>>
+>> I was focusing on handling of pg_pwd and other config file that are
+>> written by various backend while other backends are reading them. The
+>> actual data files should be OK because we have an exclusive lock when we
+>> are adding/removing them.
+>>
+>
+> OK. So you want to test:
+>
+> 1. Process 1 opens "foo"
+> 2. Process 2 opens "foo"
+> 3. Process 1 renames "foo" to "bar"
+> 4. Process 2 can safely read from its open file handle
+
+Actually, looking at the pg_pwd code, you want to determine a
+way for:
+
+1. Process 1 opens "foo"
+2. Process 2 opens "foo"
+3. Process 1 creates "bar"
+4. Process 1 renames "bar" to "foo"
+5. Process 2 can continue to read data from the open file handle
+and get the original "foo" data.
+
+Is that correct?
+
+Mike Mascari
+mascarm@mascari.com
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 5: Have you checked our extensive FAQ?
+
+http://www.postgresql.org/users-lounge/docs/faq.html
+
+From pgsql-hackers-owner+M29181@postgresql.org Fri Sep 20 01:30:05 2002
+Return-path: <pgsql-hackers-owner+M29181@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K5U2E20514
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 01:30:03 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id CDCF2476D1D; Fri, 20 Sep 2002 01:29:59 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id CB1CB476C00; Fri, 20 Sep 2002 01:29:57 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id D9372475FC6
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:29:52 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id 21835475BF9
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:29:51 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8K5TYr20440;
+ Fri, 20 Sep 2002 01:29:34 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209200529.g8K5TYr20440@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8AAB8F.8010001@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Fri, 20 Sep 2002 01:29:33 -0400 (EDT)
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Mike Mascari wrote:
+> Actually, looking at the pg_pwd code, you want to determine a
+> way for:
+>
+> 1. Process 1 opens "foo"
+> 2. Process 2 opens "foo"
+> 3. Process 1 creates "bar"
+> 4. Process 1 renames "bar" to "foo"
+> 5. Process 2 can continue to read data from the open file handle
+> and get the original "foo" data.
+
+Yep, that's it.
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 2: you can get off all lists at once with the unregister command
+ (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
+
+From pgsql-hackers-owner+M29182@postgresql.org Fri Sep 20 01:36:21 2002
+Return-path: <pgsql-hackers-owner+M29182@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K5aJE21658
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 01:36:20 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 926CA4764F2; Fri, 20 Sep 2002 01:36:20 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 8F0E4475EEE; Fri, 20 Sep 2002 01:36:18 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 3A84C4769DA
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:36:14 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id E8DAA476413
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:36:12 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id BAA18679;
+ Fri, 20 Sep 2002 01:35:09 -0400
+Message-ID: <3D8AB39B.80708@mascari.com>
+Date: Fri, 20 Sep 2002 01:35:23 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209200529.g8K5TYr20440@candle.pha.pa.us>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Bruce Momjian wrote:
+> Mike Mascari wrote:
+>
+>>Actually, looking at the pg_pwd code, you want to determine a
+>>way for:
+>>
+>>1. Process 1 opens "foo"
+>>2. Process 2 opens "foo"
+>>3. Process 1 creates "bar"
+>>4. Process 1 renames "bar" to "foo"
+>>5. Process 2 can continue to read data from the open file handle
+>>and get the original "foo" data.
+>
+>
+> Yep, that's it.
+>
+
+So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+returns "Access Denied" when Process 1 attempts the rename. But
+I'm continuing to investigate the possibilities...
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Don't 'kill -9' the postmaster
+
+From sszabo@megazone23.bigpanda.com Fri Sep 20 01:50:39 2002
+Return-path: <sszabo@megazone23.bigpanda.com>
+Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K5oaE22843
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 01:50:38 -0400 (EDT)
+Received: by megazone.bigpanda.com (Postfix, from userid 1001)
+ id 709D1D61E; Thu, 19 Sep 2002 22:50:36 -0700 (PDT)
+Received: from localhost (localhost [127.0.0.1])
+ by megazone.bigpanda.com (Postfix) with ESMTP
+ id 624665C02; Thu, 19 Sep 2002 22:50:36 -0700 (PDT)
+Date: Thu, 19 Sep 2002 22:50:36 -0700 (PDT)
+From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8AB39B.80708@mascari.com>
+Message-ID: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+Status: OR
+
+
+On Fri, 20 Sep 2002, Mike Mascari wrote:
+
+> Bruce Momjian wrote:
+> > Mike Mascari wrote:
+> >
+> >>Actually, looking at the pg_pwd code, you want to determine a
+> >>way for:
+> >>
+> >>1. Process 1 opens "foo"
+> >>2. Process 2 opens "foo"
+> >>3. Process 1 creates "bar"
+> >>4. Process 1 renames "bar" to "foo"
+> >>5. Process 2 can continue to read data from the open file handle
+> >>and get the original "foo" data.
+> >
+> >
+> > Yep, that's it.
+> >
+>
+> So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+> returns "Access Denied" when Process 1 attempts the rename. But
+> I'm continuing to investigate the possibilities...
+
+Does a sequence like
+Process 1 opens "foo"
+Process 2 opens "foo"
+Process 1 creates "bar"
+Process 1 renames "foo" to <something>
+ - where something is generated to not overlap an existing file
+Process 1 renames "bar" to "foo"
+Process 2 continues reading
+let you do the replace and keep reading (at the penalty that
+you've now got to have a way to know when to remove the
+various <something>s)
+
+
+
+From pgsql-hackers-owner+M29183@postgresql.org Fri Sep 20 01:50:47 2002
+Return-path: <pgsql-hackers-owner+M29183@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K5ojE22893
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 01:50:46 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id A8A20476D3B; Fri, 20 Sep 2002 01:50:46 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 70EBC476B1F; Fri, 20 Sep 2002 01:50:44 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 8B227475EEE
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:50:40 -0400 (EDT)
+Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178])
+ by postgresql.org (Postfix) with ESMTP id AE58D476D2C
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 01:50:36 -0400 (EDT)
+Received: by megazone.bigpanda.com (Postfix, from userid 1001)
+ id 709D1D61E; Thu, 19 Sep 2002 22:50:36 -0700 (PDT)
+Received: from localhost (localhost [127.0.0.1])
+ by megazone.bigpanda.com (Postfix) with ESMTP
+ id 624665C02; Thu, 19 Sep 2002 22:50:36 -0700 (PDT)
+Date: Thu, 19 Sep 2002 22:50:36 -0700 (PDT)
+From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8AB39B.80708@mascari.com>
+Message-ID: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+
+On Fri, 20 Sep 2002, Mike Mascari wrote:
+
+> Bruce Momjian wrote:
+> > Mike Mascari wrote:
+> >
+> >>Actually, looking at the pg_pwd code, you want to determine a
+> >>way for:
+> >>
+> >>1. Process 1 opens "foo"
+> >>2. Process 2 opens "foo"
+> >>3. Process 1 creates "bar"
+> >>4. Process 1 renames "bar" to "foo"
+> >>5. Process 2 can continue to read data from the open file handle
+> >>and get the original "foo" data.
+> >
+> >
+> > Yep, that's it.
+> >
+>
+> So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+> returns "Access Denied" when Process 1 attempts the rename. But
+> I'm continuing to investigate the possibilities...
+
+Does a sequence like
+Process 1 opens "foo"
+Process 2 opens "foo"
+Process 1 creates "bar"
+Process 1 renames "foo" to <something>
+ - where something is generated to not overlap an existing file
+Process 1 renames "bar" to "foo"
+Process 2 continues reading
+let you do the replace and keep reading (at the penalty that
+you've now got to have a way to know when to remove the
+various <something>s)
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 2: you can get off all lists at once with the unregister command
+ (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
+
+From pgsql-hackers-owner+M29184@postgresql.org Fri Sep 20 02:06:47 2002
+Return-path: <pgsql-hackers-owner+M29184@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K66jE24908
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 02:06:45 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id E6AB6476994; Fri, 20 Sep 2002 02:06:43 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 5626C4760AB; Fri, 20 Sep 2002 02:06:41 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 0BFDC475EEE
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 02:05:04 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id BFD01475E83
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 02:05:02 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id CAA18737;
+ Fri, 20 Sep 2002 02:03:29 -0400
+Message-ID: <3D8ABA3F.6030002@mascari.com>
+Date: Fri, 20 Sep 2002 02:03:43 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: ORr
+
+Stephan Szabo wrote:
+> On Fri, 20 Sep 2002, Mike Mascari wrote:
+>>Bruce Momjian wrote:
+>>>Mike Mascari wrote:
+>>>>Actually, looking at the pg_pwd code, you want to determine a
+>>>>way for:
+>>>>
+>>>>1. Process 1 opens "foo"
+>>>>2. Process 2 opens "foo"
+>>>>3. Process 1 creates "bar"
+>>>>4. Process 1 renames "bar" to "foo"
+>>>>5. Process 2 can continue to read data from the open file handle
+>>>>and get the original "foo" data.
+>>>
+>>>
+>>>Yep, that's it.
+>>>
+>>
+>>So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+>>returns "Access Denied" when Process 1 attempts the rename. But
+>>I'm continuing to investigate the possibilities...
+>
+>
+> Does a sequence like
+> Process 1 opens "foo"
+> Process 2 opens "foo"
+> Process 1 creates "bar"
+> Process 1 renames "foo" to <something>
+> - where something is generated to not overlap an existing file
+> Process 1 renames "bar" to "foo"
+> Process 2 continues reading
+> let you do the replace and keep reading (at the penalty that
+> you've now got to have a way to know when to remove the
+> various <something>s)
+
+Yes! Indeed that does work.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From mascarm@mascari.com Fri Sep 20 02:04:41 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K64WE24578
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 02:04:38 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id CAA18737;
+ Fri, 20 Sep 2002 02:03:29 -0400
+Message-ID: <3D8ABA3F.6030002@mascari.com>
+Date: Fri, 20 Sep 2002 02:03:43 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development
+ <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: OR
+
+Stephan Szabo wrote:
+> On Fri, 20 Sep 2002, Mike Mascari wrote:
+>>Bruce Momjian wrote:
+>>>Mike Mascari wrote:
+>>>>Actually, looking at the pg_pwd code, you want to determine a
+>>>>way for:
+>>>>
+>>>>1. Process 1 opens "foo"
+>>>>2. Process 2 opens "foo"
+>>>>3. Process 1 creates "bar"
+>>>>4. Process 1 renames "bar" to "foo"
+>>>>5. Process 2 can continue to read data from the open file handle
+>>>>and get the original "foo" data.
+>>>
+>>>
+>>>Yep, that's it.
+>>>
+>>
+>>So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+>>returns "Access Denied" when Process 1 attempts the rename. But
+>>I'm continuing to investigate the possibilities...
+>
+>
+> Does a sequence like
+> Process 1 opens "foo"
+> Process 2 opens "foo"
+> Process 1 creates "bar"
+> Process 1 renames "foo" to <something>
+> - where something is generated to not overlap an existing file
+> Process 1 renames "bar" to "foo"
+> Process 2 continues reading
+> let you do the replace and keep reading (at the penalty that
+> you've now got to have a way to know when to remove the
+> various <something>s)
+
+Yes! Indeed that does work.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+From sszabo@megazone23.bigpanda.com Fri Sep 20 02:14:23 2002
+Return-path: <sszabo@megazone23.bigpanda.com>
+Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K6EDE25582
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 02:14:21 -0400 (EDT)
+Received: by megazone.bigpanda.com (Postfix, from userid 1001)
+ id B10E9D61E; Thu, 19 Sep 2002 23:14:14 -0700 (PDT)
+Received: from localhost (localhost [127.0.0.1])
+ by megazone.bigpanda.com (Postfix) with ESMTP
+ id A6B475C03; Thu, 19 Sep 2002 23:14:14 -0700 (PDT)
+Date: Thu, 19 Sep 2002 23:14:14 -0700 (PDT)
+From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8ABA3F.6030002@mascari.com>
+Message-ID: <20020919230827.A36505-100000@megazone23.bigpanda.com>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+Status: OR
+
+On Fri, 20 Sep 2002, Mike Mascari wrote:
+
+> Stephan Szabo wrote:
+> > On Fri, 20 Sep 2002, Mike Mascari wrote:
+> >>So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+> >>returns "Access Denied" when Process 1 attempts the rename. But
+> >>I'm continuing to investigate the possibilities...
+> >
+> >
+> > Does a sequence like
+> > Process 1 opens "foo"
+> > Process 2 opens "foo"
+> > Process 1 creates "bar"
+> > Process 1 renames "foo" to <something>
+> > - where something is generated to not overlap an existing file
+> > Process 1 renames "bar" to "foo"
+> > Process 2 continues reading
+> > let you do the replace and keep reading (at the penalty that
+> > you've now got to have a way to know when to remove the
+> > various <something>s)
+>
+> Yes! Indeed that does work.
+
+Thinking back, I think that may still fail on Win95 (using MoveFile).
+Once in the past I had to work on (un)installers for Win* and I
+vaguely remember Win95 being more strict than Win98 but that may just
+have been with moving the executable you're currently running.
+
+
+From pgsql-hackers-owner+M29185@postgresql.org Fri Sep 20 02:14:29 2002
+Return-path: <pgsql-hackers-owner+M29185@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K6ERE25614
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 02:14:27 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id B0200476D0C; Fri, 20 Sep 2002 02:14:26 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id D323F47655C; Fri, 20 Sep 2002 02:14:24 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 9EEBF476D02
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 02:14:20 -0400 (EDT)
+Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178])
+ by postgresql.org (Postfix) with ESMTP id 695B1475EAA
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 02:14:16 -0400 (EDT)
+Received: by megazone.bigpanda.com (Postfix, from userid 1001)
+ id B10E9D61E; Thu, 19 Sep 2002 23:14:14 -0700 (PDT)
+Received: from localhost (localhost [127.0.0.1])
+ by megazone.bigpanda.com (Postfix) with ESMTP
+ id A6B475C03; Thu, 19 Sep 2002 23:14:14 -0700 (PDT)
+Date: Thu, 19 Sep 2002 23:14:14 -0700 (PDT)
+From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8ABA3F.6030002@mascari.com>
+Message-ID: <20020919230827.A36505-100000@megazone23.bigpanda.com>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+On Fri, 20 Sep 2002, Mike Mascari wrote:
+
+> Stephan Szabo wrote:
+> > On Fri, 20 Sep 2002, Mike Mascari wrote:
+> >>So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+> >>returns "Access Denied" when Process 1 attempts the rename. But
+> >>I'm continuing to investigate the possibilities...
+> >
+> >
+> > Does a sequence like
+> > Process 1 opens "foo"
+> > Process 2 opens "foo"
+> > Process 1 creates "bar"
+> > Process 1 renames "foo" to <something>
+> > - where something is generated to not overlap an existing file
+> > Process 1 renames "bar" to "foo"
+> > Process 2 continues reading
+> > let you do the replace and keep reading (at the penalty that
+> > you've now got to have a way to know when to remove the
+> > various <something>s)
+>
+> Yes! Indeed that does work.
+
+Thinking back, I think that may still fail on Win95 (using MoveFile).
+Once in the past I had to work on (un)installers for Win* and I
+vaguely remember Win95 being more strict than Win98 but that may just
+have been with moving the executable you're currently running.
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From pgsql-hackers-owner+M29189@postgresql.org Fri Sep 20 03:22:41 2002
+Return-path: <pgsql-hackers-owner+M29189@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K7MdE01450
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 03:22:39 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 211C1476DAC; Fri, 20 Sep 2002 03:20:05 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id D76C4475F73; Fri, 20 Sep 2002 03:18:20 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 8C2E0476D57
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 03:15:32 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id 5098F476839
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 03:15:26 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id DAA18894;
+ Fri, 20 Sep 2002 03:13:06 -0400
+Message-ID: <3D8ACA96.80504@mascari.com>
+Date: Fri, 20 Sep 2002 03:13:26 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020919230827.A36505-100000@megazone23.bigpanda.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: ORr
+
+Stephan Szabo wrote:
+> On Fri, 20 Sep 2002, Mike Mascari wrote:
+>>
+>>Yes! Indeed that does work.
+>
+>
+> Thinking back, I think that may still fail on Win95 (using MoveFile).
+> Once in the past I had to work on (un)installers for Win* and I
+> vaguely remember Win95 being more strict than Win98 but that may just
+> have been with moving the executable you're currently running.
+
+Well, here's the test:
+
+foo.txt contains "This is FOO!"
+bar.txt contains "This is BAR!"
+
+Process 1 opens foo.txt
+Process 2 opens foo.txt
+Process 1 sleeps 7.5 seconds
+Process 2 sleeps 15 seconds
+Process 1 uses MoveFile() to rename "foo.txt" to "foo2.txt"
+Process 1 uses MoveFile() to rename "bar.txt" to "foo.txt"
+Process 1 uses DeleteFile() to remove "foo2.txt"
+Process 2 awakens and displays "This is FOO!"
+
+On the filesystem, we then have:
+
+foo.txt containing "This is BAR!"
+
+The good news is that this works fine under NT 4 using just
+MoveFile(). The bad news is that it requires the files be opened
+using CreateFile() with the FILE_SHARE_DELETE flag set. The C
+library which ships with Visual C++ 6 ultimately calls
+CreateFile() via fopen() but with no opportunity through the
+standard C library routines to use the FILE_SHARE_DELETE flag.
+And the FILE_SHARE_DELETE flag cannot be used under Windows
+95/98 (Bad Parameter). Which means, on those platforms, there
+still doesn't appear to be a solution. Under NT/XP/2K,
+AllocateFile() will have to modified to call CreateFile()
+instead of fopen(). I'm not sure about ME, but I suspect it
+behaves similarly to 95/98.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From mascarm@mascari.com Fri Sep 20 03:14:03 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8K7DwE00605
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 03:14:01 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id DAA18894;
+ Fri, 20 Sep 2002 03:13:06 -0400
+Message-ID: <3D8ACA96.80504@mascari.com>
+Date: Fri, 20 Sep 2002 03:13:26 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development
+ <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020919230827.A36505-100000@megazone23.bigpanda.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: OR
+
+Stephan Szabo wrote:
+> On Fri, 20 Sep 2002, Mike Mascari wrote:
+>>
+>>Yes! Indeed that does work.
+>
+>
+> Thinking back, I think that may still fail on Win95 (using MoveFile).
+> Once in the past I had to work on (un)installers for Win* and I
+> vaguely remember Win95 being more strict than Win98 but that may just
+> have been with moving the executable you're currently running.
+
+Well, here's the test:
+
+foo.txt contains "This is FOO!"
+bar.txt contains "This is BAR!"
+
+Process 1 opens foo.txt
+Process 2 opens foo.txt
+Process 1 sleeps 7.5 seconds
+Process 2 sleeps 15 seconds
+Process 1 uses MoveFile() to rename "foo.txt" to "foo2.txt"
+Process 1 uses MoveFile() to rename "bar.txt" to "foo.txt"
+Process 1 uses DeleteFile() to remove "foo2.txt"
+Process 2 awakens and displays "This is FOO!"
+
+On the filesystem, we then have:
+
+foo.txt containing "This is BAR!"
+
+The good news is that this works fine under NT 4 using just
+MoveFile(). The bad news is that it requires the files be opened
+using CreateFile() with the FILE_SHARE_DELETE flag set. The C
+library which ships with Visual C++ 6 ultimately calls
+CreateFile() via fopen() but with no opportunity through the
+standard C library routines to use the FILE_SHARE_DELETE flag.
+And the FILE_SHARE_DELETE flag cannot be used under Windows
+95/98 (Bad Parameter). Which means, on those platforms, there
+still doesn't appear to be a solution. Under NT/XP/2K,
+AllocateFile() will have to modified to call CreateFile()
+instead of fopen(). I'm not sure about ME, but I suspect it
+behaves similarly to 95/98.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+From tgl@sss.pgh.pa.us Fri Sep 20 10:28:40 2002
+Return-path: <tgl@sss.pgh.pa.us>
+Received: from sss.pgh.pa.us (root@[192.204.191.242])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KESbE13042
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 10:28:39 -0400 (EDT)
+Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])
+ by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g8KERq5D016068;
+ Fri, 20 Sep 2002 10:27:52 -0400 (EDT)
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Mike Mascari <mascarm@mascari.com>, Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+References: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+Comments: In-reply-to Stephan Szabo <sszabo@megazone23.bigpanda.com>
+ message dated "Thu, 19 Sep 2002 22:50:36 -0700"
+Date: Fri, 20 Sep 2002 10:27:52 -0400
+Message-ID: <16067.1032532072@sss.pgh.pa.us>
+From: Tom Lane <tgl@sss.pgh.pa.us>
+Status: OR
+
+Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
+> ... let you do the replace and keep reading (at the penalty that
+> you've now got to have a way to know when to remove the
+> various <something>s)
+
+That is the hard part. Mike's description omitted one crucial step:
+
+6. The old "foo" goes away when the last open file handle for it is
+closed.
+
+I doubt there is any practical way for Postgres to cause that to happen
+if the OS itself does not have any support for it.
+
+ regards, tom lane
+
+From pgsql-hackers-owner+M29205@postgresql.org Fri Sep 20 10:36:48 2002
+Return-path: <pgsql-hackers-owner+M29205@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KEalE13770
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 10:36:47 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id BBC23476E72; Fri, 20 Sep 2002 10:35:40 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 00890476D13; Fri, 20 Sep 2002 10:35:31 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 5D2BC476D6D
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 10:30:17 -0400 (EDT)
+Received: from sss.pgh.pa.us (unknown [192.204.191.242])
+ by postgresql.org (Postfix) with ESMTP id B17FE476CD8
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 10:30:15 -0400 (EDT)
+Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])
+ by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g8KERq5D016068;
+ Fri, 20 Sep 2002 10:27:52 -0400 (EDT)
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Mike Mascari <mascarm@mascari.com>, Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+References: <20020919224718.H36366-100000@megazone23.bigpanda.com>
+Comments: In-reply-to Stephan Szabo <sszabo@megazone23.bigpanda.com>
+ message dated "Thu, 19 Sep 2002 22:50:36 -0700"
+Date: Fri, 20 Sep 2002 10:27:52 -0400
+Message-ID: <16067.1032532072@sss.pgh.pa.us>
+From: Tom Lane <tgl@sss.pgh.pa.us>
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
+> ... let you do the replace and keep reading (at the penalty that
+> you've now got to have a way to know when to remove the
+> various <something>s)
+
+That is the hard part. Mike's description omitted one crucial step:
+
+6. The old "foo" goes away when the last open file handle for it is
+closed.
+
+I doubt there is any practical way for Postgres to cause that to happen
+if the OS itself does not have any support for it.
+
+ regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From pgsql-hackers-owner+M29206@postgresql.org Fri Sep 20 10:37:53 2002
+Return-path: <pgsql-hackers-owner+M29206@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KEbpE13898
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 10:37:51 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 891F9476DC6; Fri, 20 Sep 2002 10:36:31 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 2207D476F07; Fri, 20 Sep 2002 10:36:22 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 90195476DD2
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 10:33:48 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id 5ECE6476DB5
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 10:33:46 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8KEVMg13344;
+ Fri, 20 Sep 2002 10:31:22 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209201431.g8KEVMg13344@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8ACA96.80504@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Fri, 20 Sep 2002 10:31:22 -0400 (EDT)
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+
+I don't think we are not going to be supporting Win9X so there isn't an
+issue there. We will be supporting Win2000/NT/XP.
+
+I don't understand FILE_SHARE_DELETE. I read the description at:
+
+ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp
+
+but I don't understand it:
+
+ FILE_SHARE_DELETE - Windows NT/2000/XP: Subsequent open operations on
+ the object will succeed only if delete access is requested.
+
+---------------------------------------------------------------------------
+
+Mike Mascari wrote:
+> Stephan Szabo wrote:
+> > On Fri, 20 Sep 2002, Mike Mascari wrote:
+> >>
+> >>Yes! Indeed that does work.
+> >
+> >
+> > Thinking back, I think that may still fail on Win95 (using MoveFile).
+> > Once in the past I had to work on (un)installers for Win* and I
+> > vaguely remember Win95 being more strict than Win98 but that may just
+> > have been with moving the executable you're currently running.
+>
+> Well, here's the test:
+>
+> foo.txt contains "This is FOO!"
+> bar.txt contains "This is BAR!"
+>
+> Process 1 opens foo.txt
+> Process 2 opens foo.txt
+> Process 1 sleeps 7.5 seconds
+> Process 2 sleeps 15 seconds
+> Process 1 uses MoveFile() to rename "foo.txt" to "foo2.txt"
+> Process 1 uses MoveFile() to rename "bar.txt" to "foo.txt"
+> Process 1 uses DeleteFile() to remove "foo2.txt"
+> Process 2 awakens and displays "This is FOO!"
+>
+> On the filesystem, we then have:
+>
+> foo.txt containing "This is BAR!"
+>
+> The good news is that this works fine under NT 4 using just
+> MoveFile(). The bad news is that it requires the files be opened
+> using CreateFile() with the FILE_SHARE_DELETE flag set. The C
+> library which ships with Visual C++ 6 ultimately calls
+> CreateFile() via fopen() but with no opportunity through the
+> standard C library routines to use the FILE_SHARE_DELETE flag.
+> And the FILE_SHARE_DELETE flag cannot be used under Windows
+> 95/98 (Bad Parameter). Which means, on those platforms, there
+> still doesn't appear to be a solution. Under NT/XP/2K,
+> AllocateFile() will have to modified to call CreateFile()
+> instead of fopen(). I'm not sure about ME, but I suspect it
+> behaves similarly to 95/98.
+>
+> Mike Mascari
+> mascarm@mascari.com
+>
+>
+>
+>
+>
+> ---------------------------(end of broadcast)---------------------------
+> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+>
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 6: Have you searched our list archives?
+
+http://archives.postgresql.org
+
+From mascarm@mascari.com Fri Sep 20 10:57:31 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KEvRE16100
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 10:57:29 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id KAA20019;
+ Fri, 20 Sep 2002 10:56:39 -0400
+Message-ID: <3D8B373C.7060102@mascari.com>
+Date: Fri, 20 Sep 2002 10:57:00 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ PostgreSQL-development
+ <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209201431.g8KEVMg13344@candle.pha.pa.us>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: ORr
+
+Bruce Momjian wrote:
+> I don't think we are not going to be supporting Win9X so there isn't an
+> issue there. We will be supporting Win2000/NT/XP.
+>
+> I don't understand FILE_SHARE_DELETE. I read the description at:
+>
+> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp
+>
+> but I don't understand it:
+>
+> FILE_SHARE_DELETE - Windows NT/2000/XP: Subsequent open operations on
+> the object will succeed only if delete access is requested.
+
+I think that's a rather poor description. I think it just means
+that if the file is opened once via CreateFile() with
+FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
+fail unless they too have FILE_SHARE_DELETE. In other words, if
+one of us can delete this file while its open, any of us can.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+From pgsql-hackers-owner+M29208@postgresql.org Fri Sep 20 11:30:26 2002
+Return-path: <pgsql-hackers-owner+M29208@postgresql.org>
+Received: from west.navpoint.com (west.navpoint.com [207.106.42.13])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFUOE24840
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:30:25 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by west.navpoint.com (8.11.6/8.10.1) with ESMTP id g8KFBP217840
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:11:25 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id BD0D2476E5B; Fri, 20 Sep 2002 11:09:49 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 4691C476D5D; Fri, 20 Sep 2002 11:09:47 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 8341F475CB4
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 10:58:12 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id B1E1A474E5C
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 10:58:10 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id KAA20019;
+ Fri, 20 Sep 2002 10:56:39 -0400
+Message-ID: <3D8B373C.7060102@mascari.com>
+Date: Fri, 20 Sep 2002 10:57:00 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <200209201431.g8KEVMg13344@candle.pha.pa.us>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Bruce Momjian wrote:
+> I don't think we are not going to be supporting Win9X so there isn't an
+> issue there. We will be supporting Win2000/NT/XP.
+>
+> I don't understand FILE_SHARE_DELETE. I read the description at:
+>
+> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp
+>
+> but I don't understand it:
+>
+> FILE_SHARE_DELETE - Windows NT/2000/XP: Subsequent open operations on
+> the object will succeed only if delete access is requested.
+
+I think that's a rather poor description. I think it just means
+that if the file is opened once via CreateFile() with
+FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
+fail unless they too have FILE_SHARE_DELETE. In other words, if
+one of us can delete this file while its open, any of us can.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Don't 'kill -9' the postmaster
+
+From pgsql-hackers-owner+M29213@postgresql.org Fri Sep 20 11:30:47 2002
+Return-path: <pgsql-hackers-owner+M29213@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFUkE24923
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:30:46 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id DFE91476EA6; Fri, 20 Sep 2002 11:28:47 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 124F8476E95; Fri, 20 Sep 2002 11:28:46 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id C8ADF476F70
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:26:25 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id DC5BD476F53
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:26:19 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8KF5ch17250;
+ Fri, 20 Sep 2002 11:05:38 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209201505.g8KF5ch17250@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8B373C.7060102@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Fri, 20 Sep 2002 11:05:38 -0400 (EDT)
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Mike Mascari wrote:
+> Bruce Momjian wrote:
+> > I don't think we are not going to be supporting Win9X so there isn't an
+> > issue there. We will be supporting Win2000/NT/XP.
+> >
+> > I don't understand FILE_SHARE_DELETE. I read the description at:
+> >
+> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp
+> >
+> > but I don't understand it:
+> >
+> > FILE_SHARE_DELETE - Windows NT/2000/XP: Subsequent open operations on
+> > the object will succeed only if delete access is requested.
+>
+> I think that's a rather poor description. I think it just means
+> that if the file is opened once via CreateFile() with
+> FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
+> fail unless they too have FILE_SHARE_DELETE. In other words, if
+> one of us can delete this file while its open, any of us can.
+
+I don't understand what that gets us.
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Don't 'kill -9' the postmaster
+
+From pgsql-hackers-owner+M29210@postgresql.org Fri Sep 20 11:26:52 2002
+Return-path: <pgsql-hackers-owner+M29210@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFQoE24268
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:26:51 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 7ED2C476E31; Fri, 20 Sep 2002 11:25:32 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 89A6C476E66; Fri, 20 Sep 2002 11:25:18 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 4033C476DD3
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:11:44 -0400 (EDT)
+Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178])
+ by postgresql.org (Postfix) with ESMTP id A46C9476D7C
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:11:43 -0400 (EDT)
+Received: by megazone.bigpanda.com (Postfix, from userid 1001)
+ id 5F343D61C; Fri, 20 Sep 2002 08:10:19 -0700 (PDT)
+Received: from localhost (localhost [127.0.0.1])
+ by megazone.bigpanda.com (Postfix) with ESMTP
+ id 54E705C02; Fri, 20 Sep 2002 08:10:19 -0700 (PDT)
+Date: Fri, 20 Sep 2002 08:10:19 -0700 (PDT)
+From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8B373C.7060102@mascari.com>
+Message-ID: <20020920080949.H40440-100000@megazone23.bigpanda.com>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+On Fri, 20 Sep 2002, Mike Mascari wrote:
+
+> Bruce Momjian wrote:
+> > I don't think we are not going to be supporting Win9X so there isn't an
+> > issue there. We will be supporting Win2000/NT/XP.
+> >
+> > I don't understand FILE_SHARE_DELETE. I read the description at:
+> >
+> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp
+> >
+> > but I don't understand it:
+> >
+> > FILE_SHARE_DELETE - Windows NT/2000/XP: Subsequent open operations on
+> > the object will succeed only if delete access is requested.
+>
+> I think that's a rather poor description. I think it just means
+> that if the file is opened once via CreateFile() with
+> FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
+> fail unless they too have FILE_SHARE_DELETE. In other words, if
+> one of us can delete this file while its open, any of us can.
+
+The question is, what happens if two people have the file open
+and one goes and tries to delete it? Can the other still read
+from it?
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Don't 'kill -9' the postmaster
+
+From sszabo@megazone23.bigpanda.com Fri Sep 20 11:29:09 2002
+Return-path: <sszabo@megazone23.bigpanda.com>
+Received: from west.navpoint.com (west.navpoint.com [207.106.42.13])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFT6E24617
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:29:08 -0400 (EDT)
+Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178])
+ by west.navpoint.com (8.11.6/8.10.1) with ESMTP id g8KFBZ217956
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:11:35 -0400 (EDT)
+Received: by megazone.bigpanda.com (Postfix, from userid 1001)
+ id 5F343D61C; Fri, 20 Sep 2002 08:10:19 -0700 (PDT)
+Received: from localhost (localhost [127.0.0.1])
+ by megazone.bigpanda.com (Postfix) with ESMTP
+ id 54E705C02; Fri, 20 Sep 2002 08:10:19 -0700 (PDT)
+Date: Fri, 20 Sep 2002 08:10:19 -0700 (PDT)
+From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+To: Mike Mascari <mascarm@mascari.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8B373C.7060102@mascari.com>
+Message-ID: <20020920080949.H40440-100000@megazone23.bigpanda.com>
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+Status: OR
+
+On Fri, 20 Sep 2002, Mike Mascari wrote:
+
+> Bruce Momjian wrote:
+> > I don't think we are not going to be supporting Win9X so there isn't an
+> > issue there. We will be supporting Win2000/NT/XP.
+> >
+> > I don't understand FILE_SHARE_DELETE. I read the description at:
+> >
+> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp
+> >
+> > but I don't understand it:
+> >
+> > FILE_SHARE_DELETE - Windows NT/2000/XP: Subsequent open operations on
+> > the object will succeed only if delete access is requested.
+>
+> I think that's a rather poor description. I think it just means
+> that if the file is opened once via CreateFile() with
+> FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
+> fail unless they too have FILE_SHARE_DELETE. In other words, if
+> one of us can delete this file while its open, any of us can.
+
+The question is, what happens if two people have the file open
+and one goes and tries to delete it? Can the other still read
+from it?
+
+
+From JanWieck@Yahoo.com Fri Sep 20 11:36:53 2002
+Return-path: <JanWieck@Yahoo.com>
+Received: from smtp017.mail.yahoo.com (smtp017.mail.yahoo.com [216.136.174.114])
+ by candle.pha.pa.us (8.11.6/8.10.1) with SMTP id g8KFalE25760
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:36:52 -0400 (EDT)
+Received: from psc.progress.com (HELO Yahoo.com) (janwieck@192.233.92.200 with plain)
+ by smtp.mail.vip.sc5.yahoo.com with SMTP; 20 Sep 2002 15:36:41 -0000
+Message-ID: <3D8B4087.AF0CD803@Yahoo.com>
+Date: Fri, 20 Sep 2002 11:36:39 -0400
+From: Jan Wieck <JanWieck@Yahoo.com>
+Organization: Home
+X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
+X-Accept-Language: en,ru
+MIME-Version: 1.0
+To: Mike Mascari <mascarm@mascari.com>
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020919230827.A36505-100000@megazone23.bigpanda.com> <3D8ACA96.80504@mascari.com>
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+Status: OR
+
+Mike Mascari wrote:
+
+> instead of fopen(). I'm not sure about ME, but I suspect it
+> behaves similarly to 95/98.
+
+I just checked with Katie and the good news (tm) is that the Win32 port
+we did here at PeerDirect doesn't support 95/98 and ME anyway. It does
+support NT4, 2000 and XP. So don't bother.
+
+
+Jan
+
+--
+
+#======================================================================#
+# It's easier to get forgiveness for being wrong than for being right. #
+# Let's break this rule - forgive me. #
+#================================================== JanWieck@Yahoo.com #
+
+From pgsql-hackers-owner+M29216@postgresql.org Fri Sep 20 11:45:47 2002
+Return-path: <pgsql-hackers-owner+M29216@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFjkE26656
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:45:46 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 75E01476DE2; Fri, 20 Sep 2002 11:44:30 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id E1897476E29; Fri, 20 Sep 2002 11:44:16 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 96D5C47625F
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:38:15 -0400 (EDT)
+Received: from smtp017.mail.yahoo.com (smtp017.mail.yahoo.com [216.136.174.114])
+ by postgresql.org (Postfix) with SMTP id B00BA476225
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:38:14 -0400 (EDT)
+Received: from psc.progress.com (HELO Yahoo.com) (janwieck@192.233.92.200 with plain)
+ by smtp.mail.vip.sc5.yahoo.com with SMTP; 20 Sep 2002 15:36:41 -0000
+Message-ID: <3D8B4087.AF0CD803@Yahoo.com>
+Date: Fri, 20 Sep 2002 11:36:39 -0400
+From: Jan Wieck <JanWieck@Yahoo.com>
+Organization: Home
+X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
+X-Accept-Language: en,ru
+MIME-Version: 1.0
+To: Mike Mascari <mascarm@mascari.com>
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020919230827.A36505-100000@megazone23.bigpanda.com> <3D8ACA96.80504@mascari.com>
+Content-Type: text/plain; charset=us-ascii
+Content-Transfer-Encoding: 7bit
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Mike Mascari wrote:
+
+> instead of fopen(). I'm not sure about ME, but I suspect it
+> behaves similarly to 95/98.
+
+I just checked with Katie and the good news (tm) is that the Win32 port
+we did here at PeerDirect doesn't support 95/98 and ME anyway. It does
+support NT4, 2000 and XP. So don't bother.
+
+
+Jan
+
+--
+
+#======================================================================#
+# It's easier to get forgiveness for being wrong than for being right. #
+# Let's break this rule - forgive me. #
+#================================================== JanWieck@Yahoo.com #
+
+---------------------------(end of broadcast)---------------------------
+TIP 5: Have you checked our extensive FAQ?
+
+http://www.postgresql.org/users-lounge/docs/faq.html
+
+From pgsql-hackers-owner+M29222@postgresql.org Fri Sep 20 11:59:16 2002
+Return-path: <pgsql-hackers-owner+M29222@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFxEE28389
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:59:15 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 156F6476EFA; Fri, 20 Sep 2002 11:58:59 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 00F87476EE5; Fri, 20 Sep 2002 11:58:56 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 48990475E5E
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:57:18 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id F3EF1475D6E
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:57:16 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id LAA20244;
+ Fri, 20 Sep 2002 11:54:31 -0400
+Message-ID: <3D8B44CC.6070802@mascari.com>
+Date: Fri, 20 Sep 2002 11:54:52 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020920080949.H40440-100000@megazone23.bigpanda.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Stephan Szabo wrote:
+> On Fri, 20 Sep 2002, Mike Mascari wrote:
+>
+>
+>>I think that's a rather poor description. I think it just means
+>>that if the file is opened once via CreateFile() with
+>>FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
+>>fail unless they too have FILE_SHARE_DELETE. In other words, if
+>>one of us can delete this file while its open, any of us can.
+>
+>
+> The question is, what happens if two people have the file open
+> and one goes and tries to delete it? Can the other still read
+> from it?
+
+Yes. I just tested it and it worked. I'll test Bruce's scenario
+as well:
+
+foo contains: "FOO"
+bar contains: "BAR"
+
+1. Process 1 opens "foo"
+2. Process 2 opens "foo"
+3. Process 1 calls MoveFile("foo", "foo2");
+4. Process 3 opens "foo" <- Successful?
+5. Process 1 calls MoveFile("bar", "foo");
+6. Process 4 opens "foo" <- Successful?
+7. Process 1 calls DeleteFile("foo2");
+8. Process 1, 2, 3, 4 all read from their respective handles.
+
+I think the thing to worry about is a race condition between the
+two MoveFile() attempts. A very ugly hack would be to loop in a
+CreateFile() in an attempt to open "foo", giving up if the error
+is not a NOT EXISTS error code.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+
+From mascarm@mascari.com Fri Sep 20 11:55:47 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFthE27924
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:55:45 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id LAA20244;
+ Fri, 20 Sep 2002 11:54:31 -0400
+Message-ID: <3D8B44CC.6070802@mascari.com>
+Date: Fri, 20 Sep 2002 11:54:52 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
+cc: Bruce Momjian <pgman@candle.pha.pa.us>,
+ PostgreSQL-development
+ <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020920080949.H40440-100000@megazone23.bigpanda.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: OR
+
+Stephan Szabo wrote:
+> On Fri, 20 Sep 2002, Mike Mascari wrote:
+>
+>
+>>I think that's a rather poor description. I think it just means
+>>that if the file is opened once via CreateFile() with
+>>FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
+>>fail unless they too have FILE_SHARE_DELETE. In other words, if
+>>one of us can delete this file while its open, any of us can.
+>
+>
+> The question is, what happens if two people have the file open
+> and one goes and tries to delete it? Can the other still read
+> from it?
+
+Yes. I just tested it and it worked. I'll test Bruce's scenario
+as well:
+
+foo contains: "FOO"
+bar contains: "BAR"
+
+1. Process 1 opens "foo"
+2. Process 2 opens "foo"
+3. Process 1 calls MoveFile("foo", "foo2");
+4. Process 3 opens "foo" <- Successful?
+5. Process 1 calls MoveFile("bar", "foo");
+6. Process 4 opens "foo" <- Successful?
+7. Process 1 calls DeleteFile("foo2");
+8. Process 1, 2, 3, 4 all read from their respective handles.
+
+I think the thing to worry about is a race condition between the
+two MoveFile() attempts. A very ugly hack would be to loop in a
+CreateFile() in an attempt to open "foo", giving up if the error
+is not a NOT EXISTS error code.
+
+Mike Mascari
+mascarm@mascari.com
+
+
+From mascarm@mascari.com Fri Sep 20 12:29:18 2002
+Return-path: <mascarm@mascari.com>
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KGTEE01796
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 12:29:17 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id MAA20365;
+ Fri, 20 Sep 2002 12:27:10 -0400
+Message-ID: <3D8B4C74.2050708@mascari.com>
+Date: Fri, 20 Sep 2002 12:27:32 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: PostgreSQL-development <pgsql-hackers@postgresql.org>
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ Bruce Momjian
+ <pgman@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020920080949.H40440-100000@megazone23.bigpanda.com> <3D8B44CC.6070802@mascari.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+Status: ORr
+
+I wrote:
+> Stephan Szabo wrote:
+ >>
+>> The question is, what happens if two people have the file open
+>> and one goes and tries to delete it? Can the other still read
+>> from it?
+>
+> Yes. I just tested it and it worked. I'll test Bruce's scenario as well:
+>
+> foo contains: "FOO"
+> bar contains: "BAR"
+>
+> 1. Process 1 opens "foo"
+> 2. Process 2 opens "foo"
+> 3. Process 1 calls MoveFile("foo", "foo2");
+> 4. Process 3 opens "foo" <- Successful?
+> 5. Process 1 calls MoveFile("bar", "foo");
+> 6. Process 4 opens "foo" <- Successful?
+> 7. Process 1 calls DeleteFile("foo2");
+> 8. Process 1, 2, 3, 4 all read from their respective handles.
+
+Process 1: "FOO"
+Process 2: "FOO"
+Process 3: Error - File does not exist
+Process 4: "BAR"
+
+Its interesting in that it allows for Unix-style rename() and
+unlink() behavior, but with a race condition. Without Stephan's
+two MoveFile() trick and the FILE_SHARE_DELETE flag, however,
+the result would be Access Denied. Are the places in the backend
+that use rename() and unlink() renaming and unlinking files that
+are only opened for a brief moment by other backends?
+
+Mike Mascari
+mascarm@mascari.com
+
+
+From pgsql-hackers-owner+M29230@postgresql.org Fri Sep 20 13:12:45 2002
+Return-path: <pgsql-hackers-owner+M29230@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KHChE07387
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 13:12:44 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 54F85476F77; Fri, 20 Sep 2002 13:01:57 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 1CC51476F67; Fri, 20 Sep 2002 13:01:39 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id B253B476148
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 12:29:02 -0400 (EDT)
+Received: from corvette.mascari.com (dhcp065-024-158-068.columbus.rr.com [65.24.158.68])
+ by postgresql.org (Postfix) with ESMTP id 7F8FC476135
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 12:29:01 -0400 (EDT)
+Received: from mascari.com (ferrari.mascari.com [192.168.2.1])
+ by corvette.mascari.com (8.9.3/8.9.3) with ESMTP id MAA20365;
+ Fri, 20 Sep 2002 12:27:10 -0400
+Message-ID: <3D8B4C74.2050708@mascari.com>
+Date: Fri, 20 Sep 2002 12:27:32 -0400
+From: Mike Mascari <mascarm@mascari.com>
+User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
+X-Accept-Language: en-us, en
+MIME-Version: 1.0
+To: PostgreSQL-development <pgsql-hackers@postgresql.org>
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ Bruce Momjian <pgman@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+References: <20020920080949.H40440-100000@megazone23.bigpanda.com> <3D8B44CC.6070802@mascari.com>
+Content-Type: text/plain; charset=us-ascii; format=flowed
+Content-Transfer-Encoding: 7bit
+X-MailScanner: Found to be clean
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: ORr
+
+I wrote:
+> Stephan Szabo wrote:
+ >>
+>> The question is, what happens if two people have the file open
+>> and one goes and tries to delete it? Can the other still read
+>> from it?
+>
+> Yes. I just tested it and it worked. I'll test Bruce's scenario as well:
+>
+> foo contains: "FOO"
+> bar contains: "BAR"
+>
+> 1. Process 1 opens "foo"
+> 2. Process 2 opens "foo"
+> 3. Process 1 calls MoveFile("foo", "foo2");
+> 4. Process 3 opens "foo" <- Successful?
+> 5. Process 1 calls MoveFile("bar", "foo");
+> 6. Process 4 opens "foo" <- Successful?
+> 7. Process 1 calls DeleteFile("foo2");
+> 8. Process 1, 2, 3, 4 all read from their respective handles.
+
+Process 1: "FOO"
+Process 2: "FOO"
+Process 3: Error - File does not exist
+Process 4: "BAR"
+
+Its interesting in that it allows for Unix-style rename() and
+unlink() behavior, but with a race condition. Without Stephan's
+two MoveFile() trick and the FILE_SHARE_DELETE flag, however,
+the result would be Access Denied. Are the places in the backend
+that use rename() and unlink() renaming and unlinking files that
+are only opened for a brief moment by other backends?
+
+Mike Mascari
+mascarm@mascari.com
+
+
+---------------------------(end of broadcast)---------------------------
+TIP 6: Have you searched our list archives?
+
+http://archives.postgresql.org
+
+From pgsql-hackers-owner+M29235@postgresql.org Fri Sep 20 13:38:05 2002
+Return-path: <pgsql-hackers-owner+M29235@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KHc3E18565
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 13:38:04 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id D4B2C4764A8; Fri, 20 Sep 2002 13:38:01 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id D071B476173; Fri, 20 Sep 2002 13:37:59 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 6DD60476791
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 13:33:56 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id C679F476272
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 13:33:54 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8KHVRu17060;
+ Fri, 20 Sep 2002 13:31:27 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209201731.g8KHVRu17060@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8B4C74.2050708@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Fri, 20 Sep 2002 13:31:27 -0400 (EDT)
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>,
+ Stephan Szabo <sszabo@megazone23.bigpanda.com>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Mike Mascari wrote:
+> Its interesting in that it allows for Unix-style rename() and
+> unlink() behavior, but with a race condition. Without Stephan's
+> two MoveFile() trick and the FILE_SHARE_DELETE flag, however,
+> the result would be Access Denied. Are the places in the backend
+> that use rename() and unlink() renaming and unlinking files that
+> are only opened for a brief moment by other backends?
+
+Yes, those files are only opened for a brief moment. They are not held
+open.
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 2: you can get off all lists at once with the unregister command
+ (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
+
+From pgsql-hackers-owner+M29237@postgresql.org Fri Sep 20 13:57:39 2002
+Return-path: <pgsql-hackers-owner+M29237@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KHvcE21846
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 13:57:38 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 1EC6A4762C8; Fri, 20 Sep 2002 13:57:36 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 321B14760E8; Fri, 20 Sep 2002 13:57:34 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id CD7E8476D24
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 13:54:48 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id 0C6034762C8
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 13:54:47 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8KHrnp21564;
+ Fri, 20 Sep 2002 13:53:49 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209201753.g8KHrnp21564@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questions
+In-Reply-To: <3D8B4C74.2050708@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Fri, 20 Sep 2002 13:53:49 -0400 (EDT)
+cc: PostgreSQL-development <pgsql-hackers@postgresql.org>,
+ Stephan Szabo <sszabo@megazone23.bigpanda.com>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Mike Mascari wrote:
+> > foo contains: "FOO"
+> > bar contains: "BAR"
+> >
+> > 1. Process 1 opens "foo"
+> > 2. Process 2 opens "foo"
+> > 3. Process 1 calls MoveFile("foo", "foo2");
+> > 4. Process 3 opens "foo" <- Successful?
+> > 5. Process 1 calls MoveFile("bar", "foo");
+> > 6. Process 4 opens "foo" <- Successful?
+> > 7. Process 1 calls DeleteFile("foo2");
+> > 8. Process 1, 2, 3, 4 all read from their respective handles.
+>
+> Process 1: "FOO"
+> Process 2: "FOO"
+> Process 3: Error - File does not exist
+> Process 4: "BAR"
+>
+> Its interesting in that it allows for Unix-style rename() and
+> unlink() behavior, but with a race condition. Without Stephan's
+> two MoveFile() trick and the FILE_SHARE_DELETE flag, however,
+> the result would be Access Denied. Are the places in the backend
+> that use rename() and unlink() renaming and unlinking files that
+> are only opened for a brief moment by other backends?
+
+I think we are better off looping over
+MoveFileEx(MOVEFILE_REPLACE_EXISTING) until the file isn't opened by
+anyone. That localizes the changes to rename only and not out to all
+the opens.
+
+The open failure loops when the file isn't there seem much worse.
+
+I am a little concerned about starving the rename when there is a lot of
+activity but I don't see a better solution.
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 3: if posting/reading through Usenet, please send an appropriate
+subscribe-nomail command to majordomo@postgresql.org so that your
+message can get through to the mailing list cleanly
+
+From pgsql-hackers-owner+M29214@postgresql.org Fri Sep 20 11:31:33 2002
+Return-path: <pgsql-hackers-owner+M29214@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFVWE25017
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:31:32 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id D2062476F4F; Fri, 20 Sep 2002 11:29:20 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 1A194476EED; Fri, 20 Sep 2002 11:29:18 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id 6C448476F71
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:26:26 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id 2AA7E476F65
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:26:24 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8KF4rj17150;
+ Fri, 20 Sep 2002 11:04:53 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209201504.g8KF4rj17150@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questionst
+In-Reply-To: <3D8ABA3F.6030002@mascari.com>
+To: Mike Mascari <mascarm@mascari.com>
+Date: Fri, 20 Sep 2002 11:04:53 -0400 (EDT)
+cc: Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+
+It is good that moving the file out of the way works, but it doesn't
+completely solve the problem.
+
+What we have now with Unix rename is ideal:
+
+ 1) old opens continue seeing the old contents
+ 2) new opens see the new contents
+ 3) the file always exists under the fixed name
+
+We have that with MoveFileEx(), but we have to loop over the routine
+until is succeeds. If we move the old file out of the way, we loose the
+ability to know the file always exists and then we have to loop over
+open() until is succeeds.
+
+I think we may be best just looping on MoveFileEx() until is succeeds.
+We do the pg_pwd writes while holding an exclusive lock on pg_shadow so
+that will guarantee that no one else will slip an old version of the
+file in after we have written it. However, it also prevents pg_shadow
+access while we are doing the looping. Yuck.
+
+---------------------------------------------------------------------------
+
+Mike Mascari wrote:
+> Stephan Szabo wrote:
+> > On Fri, 20 Sep 2002, Mike Mascari wrote:
+> >>Bruce Momjian wrote:
+> >>>Mike Mascari wrote:
+> >>>>Actually, looking at the pg_pwd code, you want to determine a
+> >>>>way for:
+> >>>>
+> >>>>1. Process 1 opens "foo"
+> >>>>2. Process 2 opens "foo"
+> >>>>3. Process 1 creates "bar"
+> >>>>4. Process 1 renames "bar" to "foo"
+> >>>>5. Process 2 can continue to read data from the open file handle
+> >>>>and get the original "foo" data.
+> >>>
+> >>>
+> >>>Yep, that's it.
+> >>>
+> >>
+> >>So far, MoveFileEx("foo", "bar", MOVEFILE_REPLACE_EXISTING)
+> >>returns "Access Denied" when Process 1 attempts the rename. But
+> >>I'm continuing to investigate the possibilities...
+> >
+> >
+> > Does a sequence like
+> > Process 1 opens "foo"
+> > Process 2 opens "foo"
+> > Process 1 creates "bar"
+> > Process 1 renames "foo" to <something>
+> > - where something is generated to not overlap an existing file
+> > Process 1 renames "bar" to "foo"
+> > Process 2 continues reading
+> > let you do the replace and keep reading (at the penalty that
+> > you've now got to have a way to know when to remove the
+> > various <something>s)
+>
+> Yes! Indeed that does work.
+>
+> Mike Mascari
+> mascarm@mascari.com
+>
+>
+> ---------------------------(end of broadcast)---------------------------
+> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
+>
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 5: Have you checked our extensive FAQ?
+
+http://www.postgresql.org/users-lounge/docs/faq.html
+
+From tgl@sss.pgh.pa.us Fri Sep 20 11:50:26 2002
+Return-path: <tgl@sss.pgh.pa.us>
+Received: from sss.pgh.pa.us (root@[192.204.191.242])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KFoOE27327
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 11:50:25 -0400 (EDT)
+Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])
+ by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g8KFoH5D016740;
+ Fri, 20 Sep 2002 11:50:17 -0400 (EDT)
+To: Bruce Momjian <pgman@candle.pha.pa.us>
+cc: Mike Mascari <mascarm@mascari.com>,
+ Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questionst
+In-Reply-To: <200209201504.g8KF4rj17150@candle.pha.pa.us>
+References: <200209201504.g8KF4rj17150@candle.pha.pa.us>
+Comments: In-reply-to Bruce Momjian <pgman@candle.pha.pa.us>
+ message dated "Fri, 20 Sep 2002 11:04:53 -0400"
+Date: Fri, 20 Sep 2002 11:50:17 -0400
+Message-ID: <16739.1032537017@sss.pgh.pa.us>
+From: Tom Lane <tgl@sss.pgh.pa.us>
+Status: ORr
+
+Bruce Momjian <pgman@candle.pha.pa.us> writes:
+> I think we may be best just looping on MoveFileEx() until is succeeds.
+> We do the pg_pwd writes while holding an exclusive lock on pg_shadow so
+> that will guarantee that no one else will slip an old version of the
+> file in after we have written it. However, it also prevents pg_shadow
+> access while we are doing the looping. Yuck.
+
+Surely you're not evaluating this on the assumption that the pg_shadow
+triggers are the only places that use rename() ?
+
+I see other places in pgstat and relcache that expect rename() to work
+per Unix spec.
+
+ regards, tom lane
+
+From pgsql-hackers-owner+M29223@postgresql.org Fri Sep 20 12:04:21 2002
+Return-path: <pgsql-hackers-owner+M29223@postgresql.org>
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by candle.pha.pa.us (8.11.6/8.10.1) with ESMTP id g8KG06E28547
+ for <pgman@candle.pha.pa.us>; Fri, 20 Sep 2002 12:04:20 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP
+ id 0545E476F46; Fri, 20 Sep 2002 11:59:27 -0400 (EDT)
+Received: from postgresql.org (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with SMTP
+ id 17069476EA0; Fri, 20 Sep 2002 11:59:24 -0400 (EDT)
+Received: from localhost (postgresql.org [64.49.215.8])
+ by postgresql.org (Postfix) with ESMTP id DDE66476791
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:57:45 -0400 (EDT)
+Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251])
+ by postgresql.org (Postfix) with ESMTP id C7B5F4762DE
+ for <pgsql-hackers@postgresql.org>; Fri, 20 Sep 2002 11:57:43 -0400 (EDT)
+Received: (from pgman@localhost)
+ by candle.pha.pa.us (8.11.6/8.10.1) id g8KFu2k28023;
+ Fri, 20 Sep 2002 11:56:02 -0400 (EDT)
+From: Bruce Momjian <pgman@candle.pha.pa.us>
+Message-ID: <200209201556.g8KFu2k28023@candle.pha.pa.us>
+Subject: Re: [HACKERS] Win32 rename()/unlink() questionst
+In-Reply-To: <16739.1032537017@sss.pgh.pa.us>
+To: Tom Lane <tgl@sss.pgh.pa.us>
+Date: Fri, 20 Sep 2002 11:56:02 -0400 (EDT)
+cc: Mike Mascari <mascarm@mascari.com>,
+ Stephan Szabo <sszabo@megazone23.bigpanda.com>,
+ PostgreSQL-development <pgsql-hackers@postgresql.org>
+X-Mailer: ELM [version 2.4ME+ PL99 (25)]
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset=US-ASCII
+X-Virus-Scanned: by AMaViS new-20020517
+Precedence: bulk
+Sender: pgsql-hackers-owner@postgresql.org
+X-Virus-Scanned: by AMaViS new-20020517
+Status: OR
+
+Tom Lane wrote:
+> Bruce Momjian <pgman@candle.pha.pa.us> writes:
+> > I think we may be best just looping on MoveFileEx() until is succeeds.
+> > We do the pg_pwd writes while holding an exclusive lock on pg_shadow so
+> > that will guarantee that no one else will slip an old version of the
+> > file in after we have written it. However, it also prevents pg_shadow
+> > access while we are doing the looping. Yuck.
+>
+> Surely you're not evaluating this on the assumption that the pg_shadow
+> triggers are the only places that use rename() ?
+>
+> I see other places in pgstat and relcache that expect rename() to work
+> per Unix spec.
+
+Yes, I know there are others but I think we will need _a_ rename that
+works 100% and then replace that in all Win32 rename cases.
+
+Given what I have seen, I think a single rename with a loop that uses
+MoveFileEx() may be our best bet. It is localized, doesn't affect the
+open() code, and should work well. The only downside is that under
+heavy read activity the loop will loop around a few times but I just
+don't see another solution.
+
+I was initially concerned that the loop in rename could let old renames
+update the file overwriting newer contents but I realize now that
+rename() itself has the same issue (an old rename could hit in the code
+after a newer rename) so in all cases we must already have the proper
+locking in place.
+
+--
+ Bruce Momjian | http://candle.pha.pa.us
+ pgman@candle.pha.pa.us | (610) 359-1001
+ + If your life is a hard drive, | 13 Roberts Road
+ + Christ can be your backup. | Newtown Square, Pennsylvania 19073
+
+---------------------------(end of broadcast)---------------------------
+TIP 3: if posting/reading through Usenet, please send an appropriate
+subscribe-nomail command to majordomo@postgresql.org so that your
+message can get through to the mailing list cleanly
+