Re: Atomic rename feature for Windows.

2022-11-30 Thread Ian Lawrence Barwick
2022年10月19日(水) 6:06 Thomas Munro : > > On Wed, Apr 6, 2022 at 10:40 AM Victor Spirin wrote: > > Updated patch: we use the posix semantic features in Windows build 17763 > > and up. > > We found an issue with this feature on Windows Server 2016 without > > updates (Windows 1607 Build 14393) > > Hi

Re: Atomic rename feature for Windows.

2022-10-18 Thread Thomas Munro
On Wed, Apr 6, 2022 at 10:40 AM Victor Spirin wrote: > Updated patch: we use the posix semantic features in Windows build 17763 > and up. > We found an issue with this feature on Windows Server 2016 without > updates (Windows 1607 Build 14393) Hi Victor, I rebased and simplified this, and added

Re: Atomic rename feature for Windows.

2022-04-13 Thread Andres Freund
Hi, On April 13, 2022 8:30:33 AM PDT, Robert Haas wrote: >On Wed, Apr 13, 2022 at 11:03 AM Andres Freund wrote: >> > Next decade's hot new processor design might do things >> > differently enough that it matters that we use SpinLockInit() >> > not memset-to-zero. This is not academic either,

Re: Atomic rename feature for Windows.

2022-04-13 Thread Robert Haas
On Wed, Apr 13, 2022 at 11:03 AM Andres Freund wrote: > > Next decade's hot new processor design might do things > > differently enough that it matters that we use SpinLockInit() > > not memset-to-zero. This is not academic either, as we've had > > exactly such bugs in the past. > > FWIW, I'l

Re: Atomic rename feature for Windows.

2022-04-13 Thread Tom Lane
Andres Freund writes: > On 2022-04-13 10:19:44 -0400, Tom Lane wrote: >> Next decade's hot new processor design might do things >> differently enough that it matters that we use SpinLockInit() >> not memset-to-zero. This is not academic either, as we've had >> exactly such bugs in the past. >

Re: Atomic rename feature for Windows.

2022-04-13 Thread Andres Freund
Hi, On 2022-04-13 10:19:44 -0400, Tom Lane wrote: > Meh. I agree that it seems unlikely that anyone will come out with a > new processor design that lacks the ability to do spinlocks or atomics. > It's substantially more likely though that someone would want those > configure switches

Re: Atomic rename feature for Windows.

2022-04-13 Thread Robert Haas
On Wed, Apr 13, 2022 at 10:19 AM Tom Lane wrote: > Meh. I agree that it seems unlikely that anyone will come out with a > new processor design that lacks the ability to do spinlocks or atomics. > It's substantially more likely though that someone would want those > configure switches temporarily

Re: Atomic rename feature for Windows.

2022-04-13 Thread Tom Lane
Robert Haas writes: > On Wed, Apr 13, 2022 at 3:04 AM Michael Paquier wrote: >> Agreed. I think that things can be usually helpful. Now, I am not >> really convinced that there is a strong need in running a VAX if you >> are worrying about timing issues so this is a matter of balance. You >>

Re: Atomic rename feature for Windows.

2022-04-13 Thread Robert Haas
On Wed, Apr 13, 2022 at 3:04 AM Michael Paquier wrote: > Agreed. I think that things can be usually helpful. Now, I am not > really convinced that there is a strong need in running a VAX if you > are worrying about timing issues so this is a matter of balance. You > could get down to the same

Re: Atomic rename feature for Windows.

2022-04-13 Thread Michael Paquier
On Fri, Apr 08, 2022 at 11:44:31AM -0400, Greg Stark wrote: > Generally I think supporting older systems that do funny things is > helpful in avoiding problems that either 1) Can happen on newer > systems but rarely 2) Can happen on other systems that people are > using but we don't know about and

Re: Atomic rename feature for Windows.

2022-04-08 Thread Robert Haas
On Fri, Apr 8, 2022 at 11:45 AM Greg Stark wrote: > But that's useful for some things and not for others. Like, it's > useful to be sure we don't have odd dependencies on timing quirks of > the specific machines that are currently common, or depend on gcc/llvm > compiler behaviour that isn't

Re: Atomic rename feature for Windows.

2022-04-08 Thread Greg Stark
On Fri, 8 Apr 2022 at 11:30, Robert Haas wrote: > > On Fri, Apr 8, 2022 at 10:12 AM Greg Stark wrote: > > On Thu, 9 Dec 2021 at 23:36, Tom Lane wrote: > > > I'm not for dropping support for some platform just because it's old. > > > > I guess I'll have to spin up the Vax again :) > > This is a

Re: Atomic rename feature for Windows.

2022-04-08 Thread Robert Haas
On Fri, Apr 8, 2022 at 10:12 AM Greg Stark wrote: > On Thu, 9 Dec 2021 at 23:36, Tom Lane wrote: > > I'm not for dropping support for some platform just because it's old. > > I guess I'll have to spin up the Vax again :) This is a pretty good summary of what's wrong with our current deprecation

Re: Atomic rename feature for Windows.

2022-04-08 Thread Greg Stark
On Thu, 9 Dec 2021 at 23:36, Tom Lane wrote: > > I'm not for dropping support for some platform just because it's old. I guess I'll have to spin up the Vax again :)

Re: Atomic rename feature for Windows.

2022-04-05 Thread Victor Spirin
Hi Updated patch: we use the posix semantic features in Windows build 17763 and up. We found an issue with this feature on Windows Server 2016 without updates (Windows 1607 Build 14393) Victor Spirin Postgres Professional:http://www.postgrespro.com The Russian Postgres Company 05.07.2021

Re: Atomic rename feature for Windows.

2021-12-12 Thread Michael Paquier
On Thu, Dec 09, 2021 at 11:33:17PM -0500, Tom Lane wrote: > My general approach to platform compatibility is that when we > break compatibility with old versions of something, we should do so > because it will bring concrete benefits. If we can plausibly > drop support for Windows versions that

Re: Atomic rename feature for Windows.

2021-12-09 Thread Tom Lane
Thomas Munro writes: > Playing the devil's advocate here: why shouldn't we routinely drop > support for anything that'll be EOL'd when a given PostgreSQL major > release ships? I don't like the word "routinely" here. Your next bit is a better argument: > Something EOL'd over a year ago that

Re: Atomic rename feature for Windows.

2021-12-09 Thread Thomas Munro
On Fri, Dec 10, 2021 at 5:23 PM Thomas Munro wrote: > Playing the devil's advocate here: why shouldn't we routinely drop > support for anything that'll be EOL'd when a given PostgreSQL major > release ships? The current policy seems somewhat extreme in the other > direction: our target OS

Re: Atomic rename feature for Windows.

2021-12-09 Thread Thomas Munro
On Tue, Jul 6, 2021 at 1:43 PM Michael Paquier wrote: > This is a large bump for Studio >= 2015 I am afraid. That does not > seem acceptable, as it means losing support for GetLocaleInfoEx() > across older versions. Playing the devil's advocate here: why shouldn't we routinely drop support for

Re: Atomic rename feature for Windows.

2021-11-30 Thread Victor Spirin
Hi The flags for calling the CreateFile function have been changed. Victor Spirin Postgres Professional:http://www.postgrespro.com The Russian Postgres Company 05.07.2021 16:53, Victor Spirin пишет: Hi I used the SetFileInformationByHandle function with the FILE_RENAME_FLAG_POSIX_SEMANTICS

Re: Atomic rename feature for Windows.

2021-11-14 Thread Victor Spirin
Hi Added the pgunlink_windows_posix_semantics function and modified the pgunlink function I used FILE_DISPOSITION_POSIX_SEMANTICS flag for unlink files on Windows 10 (1607) and above. Victor Spirin Postgres Professional:http://www.postgrespro.com The Russian Postgres Company 05.07.2021

Re: Atomic rename feature for Windows.

2021-11-03 Thread Victor Spirin
Hi Added a small fix for calling the GetFileAttributes function Victor Spirin Postgres Professional:http://www.postgrespro.com The Russian Postgres Company 05.07.2021 16:53, Victor Spirin пишет: Hi I used the SetFileInformationByHandle function with the FILE_RENAME_FLAG_POSIX_SEMANTICS flag

Re: Atomic rename feature for Windows.

2021-10-04 Thread Victor Spirin
Thank you Thank you In this version of patch: 1. Made function isWindows1607OrGreater() without manifest 2. To open a directory using CreateFile, have to specify the FILE_FLAG_BACKUP_SEMANTICS flag as part of dwFlagsAndAttributes. Checks that file is a directory by the GetFileAttributes

Re: Atomic rename feature for Windows.

2021-10-01 Thread Juan José Santamaría Flecha
On Thu, Sep 30, 2021 at 11:00 PM Victor Spirin wrote: > > IsWindowsVersionOrGreater(10,0,1607) always returns false > > Only IsWindowsVersionOrGreater(10,0,0) is a valid call. (There are no > service packs in Windows 10.) > > I haven't found a way to determine the Windows 10 release ID. > The

Re: Atomic rename feature for Windows.

2021-09-30 Thread Victor Spirin
Thanks. IsWindowsVersionOrGreater(10,0,1607) always returns false Only IsWindowsVersionOrGreater(10,0,0) is a valid call. (There are no service packs in Windows 10.) I haven't found a way to determine the Windows 10 release ID. The RtlGetVersion function returns dwBuildNumber = 19042 on my

Re: Atomic rename feature for Windows.

2021-09-30 Thread Victor Spirin
Thank you, Fixed FILE_RENAME_INFO structure I prepared 2 versions of the patch: 1) with manifest and IsWindows10OrGreater() function 2) without manifest and RtlGetVersion function from ntdll.dll What's better? Victor Spirin Postgres Professional:http://www.postgrespro.com The Russian

Re: Atomic rename feature for Windows.

2021-09-23 Thread Thomas Munro
On Wed, Sep 8, 2021 at 10:13 PM Juan José Santamaría Flecha wrote: > On Thu, Jul 8, 2021 at 12:32 AM Victor Spirin wrote: >> > #if defined(_MSC_VER) && _MSC_VER >= 1900 >> > -#define MIN_WINNT 0x0600 >> > +#define MIN_WINNT 0x0A00 >> > #else >> > #define MIN_WINNT 0x0501 >> > #endif >> >

Re: Atomic rename feature for Windows.

2021-09-23 Thread Thomas Munro
On Wed, Sep 8, 2021 at 9:40 AM Victor Spirin wrote: > Is this code better? Maybe there is another correct method? Hmm, if we want to use the system header's struct definition, add some space for a path at the end, and avoid heap allocation, perhaps we could do something like: struct {

Re: Atomic rename feature for Windows.

2021-09-23 Thread Juan José Santamaría Flecha
On Tue, Sep 7, 2021 at 11:40 PM Victor Spirin wrote: > > I checked the pgrename_windows_posix_semantics() function on Windows 7. > It returns error 87: Parameter is incorrect. Hence, it is necessary to > check the Windows version and call the old pgrename function for old > Windows. > > The

Re: Atomic rename feature for Windows.

2021-09-08 Thread Juan José Santamaría Flecha
On Thu, Jul 8, 2021 at 12:32 AM Victor Spirin wrote: > > > #if defined(_MSC_VER) && _MSC_VER >= 1900 > > -#define MIN_WINNT 0x0600 > > +#define MIN_WINNT 0x0A00 > > #else > > #define MIN_WINNT 0x0501 > > #endif > > This is a large bump for Studio >= 2015 I am afraid. That does not > >

Re: Atomic rename feature for Windows.

2021-09-07 Thread Victor Spirin
Thank you, In this variant: 1) renamed file win10.manifest to windows.manifest 2) renamed function pgrename_win10 to pgrename_windows_posix_semantics 3) Function pgrename returns result of pgrename_windows_posix_semantics function and not contiue run old version of function. 4) Added call

Re: Atomic rename feature for Windows.

2021-09-06 Thread Thomas Munro
On Tue, Sep 7, 2021 at 5:44 AM Victor Spirin wrote: > I have changed the way I add the manifest to projects. I used the > AdditionalManifestFiles option for a VS project. Hi Victor, Thanks for working on this! I wonder if POSIX-style rename is used automatically on recent Windows, based on the

Re: Atomic rename feature for Windows.

2021-09-06 Thread Victor Spirin
Hello. I have changed the way I add the manifest to projects. I used the AdditionalManifestFiles option for a VS project. Victor Spirin Postgres Professional:http://www.postgrespro.com The Russian Postgres Company 08.07.2021 1:32, Victor Spirin пишет: Thanks! In this version of the patch,

Re: Atomic rename feature for Windows.

2021-07-07 Thread Victor Spirin
Thanks! In this version of the patch, calls to malloc have been removed. Hopefully MAX_PATH is long enough for filenames. How does that cope with durable_rename_excl() where rename() is used on Windows?  The problems that 909b449 has somewhat "fixed" were annoying for the users as it

Re: Atomic rename feature for Windows.

2021-07-05 Thread Michael Paquier
On Mon, Jul 05, 2021 at 04:53:06PM +0300, Victor Spirin wrote: > This patch related to this post: > https://www.postgresql.org/message-id/CAEepm%3D0FV-k%2B%3Dd9z08cW%3DZXoR1%3Dkw9wdpkP6WAuOrKJdz-8ujg%40mail.gmail.com How does that cope with durable_rename_excl() where rename() is used on Windows?

Atomic rename feature for Windows.

2021-07-05 Thread Victor Spirin
Hi I used the SetFileInformationByHandle function with the FILE_RENAME_FLAG_POSIX_SEMANTICS flag for the file rename function.. 1) The _WIN32_WINNT variable needs to be increased to 0x0A00 (Windows 10).  Fixed conflict with #undef CHECKSUM_TYPE_NONE 2) The SetFileInformationByHandle