Re: [PATCHES] Fix for win32 stat() problems

2008-04-10 Thread Magnus Hagander
Magnus Hagander wrote: > Magnus Hagander wrote: > > Attached is a patch that attempts to fix the issues with stat() not > > properly updating st_size on win32, as reported in this thread: > > http://archives.postgresql.org/pgsql-hackers/2008-03/msg01181.php > > > > It has to have a chance to affec

Re: [PATCHES] Fix for win32 stat() problems

2008-04-10 Thread Magnus Hagander
Tom Lane wrote: > Magnus Hagander <[EMAIL PROTECTED]> writes: > > A whole lot simpler patch :-) > > Seems like you no longer need the !defined(_DIRMOD_C) bit here? Correct. That wasn't the actual error, that was me misdiagnosing the situation. > Also please include a comment about why has to be

Re: [PATCHES] Fix for win32 stat() problems

2008-04-10 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Andrew Dunstan wrote: >> How about #defining safe_stat to be pg_win32_safe_stat on Windows and >> simply stat elsewhere? Then use safe_stat at the places you consider >> critical. > I would couple this with a pgwin32_unsafe_stat on Windows, which ch

Re: [PATCHES] Fix for win32 stat() problems

2008-04-10 Thread Tom Lane
Magnus Hagander <[EMAIL PROTECTED]> writes: > A whole lot simpler patch :-) Seems like you no longer need the !defined(_DIRMOD_C) bit here? Also please include a comment about why has to be forcibly included. A more general question: can't we get rid of most of the #ifdef WIN32 cruft in include/

Re: [PATCHES] Fix for win32 stat() problems

2008-04-10 Thread Magnus Hagander
Magnus Hagander wrote: > Attached is a patch that attempts to fix the issues with stat() not > properly updating st_size on win32, as reported in this thread: > http://archives.postgresql.org/pgsql-hackers/2008-03/msg01181.php > > It has to have a chance to affect things beyond just the > pg_relat

Re: [PATCHES] Fix for win32 stat() problems

2008-04-10 Thread Alvaro Herrera
Andrew Dunstan wrote: > How about #defining safe_stat to be pg_win32_safe_stat on Windows and > simply stat elsewhere? Then use safe_stat at the places you consider > critical. I would couple this with a pgwin32_unsafe_stat on Windows, which changes the size value to 0, so that if anyone gets

Re: [PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Andrew Dunstan
Magnus Hagander wrote: Tom Lane wrote: Magnus Hagander <[EMAIL PROTECTED]> writes: Trying to prepare a patch that does it the normal way, but so far I'm failing rather miserably. The *struct* stat is already redefined on win32, so whenever I try #undef or so it conflicts with that :-(

Re: [PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Magnus Hagander
Tom Lane wrote: > Magnus Hagander <[EMAIL PROTECTED]> writes: > > Trying to prepare a patch that does it the normal way, but so far > > I'm failing rather miserably. The *struct* stat is already > > redefined on win32, so whenever I try #undef or so it conflicts > > with that :-( Since there is no

Re: [PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Tom Lane
Magnus Hagander <[EMAIL PROTECTED]> writes: > Trying to prepare a patch that does it the normal way, but so far I'm > failing rather miserably. The *struct* stat is already redefined on > win32, so whenever I try #undef or so it conflicts with that :-( Since > there is no way to #undef only the par

Re: [PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Magnus Hagander
Tom Lane wrote: > Magnus Hagander <[EMAIL PROTECTED]> writes: > > Tom Lane wrote: > >> Ick. > > > The reason not to do so was to avoid having to do the two filesystem > > calls for *every* stat, instead just calling them both when we > > actually need to use the st_size member. > > I don't think

Re: [PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Tom Lane
Magnus Hagander <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Ick. > The reason not to do so was to avoid having to do the two filesystem > calls for *every* stat, instead just calling them both when we actually > need to use the st_size member. I don't think that's worth (a) the code uglifica

Re: [PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Magnus Hagander
Tom Lane wrote: > Magnus Hagander <[EMAIL PROTECTED]> writes: > > + #ifndef WIN32 > > if (stat(xlogpath, &stat_buf) == 0) > > + #else > > + if (pgwin32_safestat(xlogpath, &stat_buf) == 0) > > + #endif > > Ick. Please do this the way we normally do things when we have to > ov

Re: [PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Tom Lane
Magnus Hagander <[EMAIL PROTECTED]> writes: > + #ifndef WIN32 > if (stat(xlogpath, &stat_buf) == 0) > + #else > + if (pgwin32_safestat(xlogpath, &stat_buf) == 0) > + #endif Ick. Please do this the way we normally do things when we have to override broken Windows syscalls

[PATCHES] Fix for win32 stat() problems

2008-04-09 Thread Magnus Hagander
Attached is a patch that attempts to fix the issues with stat() not properly updating st_size on win32, as reported in this thread: http://archives.postgresql.org/pgsql-hackers/2008-03/msg01181.php It has to have a chance to affect things beyond just the pg_relation_size() function, so this patch