Unix Technical Forum

Re: [DOCS] pg_total_relation_size() and CHECKPOINT

This is a discussion on Re: [DOCS] pg_total_relation_size() and CHECKPOINT within the pgsql Hackers forums, part of the PostgreSQL category; --> We are not alone ;-) http://sourceforge.net/project/shown...ease_id=557649 Version 1.02 2007-01-25 * Fix the stat function (on Windows) to use GetFileAttributesEx ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 11:48 PM
Zubkovsky, Sergey
 
Posts: n/a
Default Re: [DOCS] pg_total_relation_size() and CHECKPOINT


We are not alone ;-)

http://sourceforge.net/project/shown...ease_id=557649

Version 1.02
2007-01-25
* Fix the stat function (on Windows) to use GetFileAttributesEx insead of FindFirstFile



-----Original Message-----
From: Zubkovsky, Sergey
Sent: Friday, March 28, 2008 6:43 PM
To: Andrew Dunstan
Cc: Tom Lane; Alvaro Herrera; Gregory Stark; pgsql-hackers@postgresql.org; Magnus Hagander
Subject: RE: [HACKERS] [DOCS] pg_total_relation_size() and CHECKPOINT


It seems I've found the cause and the workaround of the problem.
MSVC's stat() is implemented by using FindNextFile().
MSDN contains the following suspicious paragraph Ábout FindNextFile():

"In rare cases, file attribute information on NTFS file systems may not be current at the time you call this function. To obtain the current NTFS filesystem file attributes, call GetFileInformationByHandle."

Since we generally cannot open an examined file, we need another way.

In the prepared custom build of PG 8.3.1 the native MSVC's stat() was rewrote by adding GetFileAttributesEx() to correct stat's st_size value.
I had seen that a result of MSVC's stat() and a result of GetFileAttributesEx() may be differ by the file size values at least.

The most important thing is the test in the original post
( http://archives.postgresql.org/pgsql...3/msg00041.php )
doesn't reproduce any inconsistence now.
All work fine.

This was tested on my WinXP SP2 platform but I suppose it will work on any NT-based OS.


Thanks,
Sergey Zubkovsky

-----Original Message-----
From: Andrew Dunstan [mailto:andrew@dunslane.net]
Sent: Thursday, March 27, 2008 3:54 PM
To: Zubkovsky, Sergey
Cc: Tom Lane; Alvaro Herrera; Gregory Stark; pgsql-hackers@postgresql.org; Magnus Hagander
Subject: Re: [HACKERS] [DOCS] pg_total_relation_size() and CHECKPOINT



Zubkovsky, Sergey wrote:
> Maybe this helps:
>
> "It is not an error to set a file pointer to a position beyond the end
> of the file. The size of the file does not increase until you call the
> SetEndOfFile, WriteFile, or WriteFileEx function. A write operation
> increases the size of the file to the file pointer position plus the
> size of the buffer written, which results in the intervening bytes
> uninitialized."
>
> http://msdn2.microsoft.com/en-us/lib...41(VS.85).aspx
>
> According to Windows' lseek implementation (attached) SetEndOfFile()
> isn't called for this case.
>
>
>


Yes, but we immediately follow the lseek bye a write(). See
src/backend/storage/smgr/md.c:mdextend() .

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 11:48 PM
Andrew Dunstan
 
Posts: n/a
Default Re: [DOCS] pg_total_relation_size() and CHECKPOINT




Zubkovsky, Sergey wrote:
>
> In the prepared custom build of PG 8.3.1 the native MSVC's stat() was rewrote by adding GetFileAttributesEx() to correct stat's st_size value.
> I had seen that a result of MSVC's stat() and a result of GetFileAttributesEx() may be differ by the file size values at least.
>
> The most important thing is the test in the original post
> ( http://archives.postgresql.org/pgsql...3/msg00041.php )
> doesn't reproduce any inconsistence now.
> All work fine.
>
> This was tested on my WinXP SP2 platform but I suppose it will work on any NT-based OS.
>
>
>



If you have a patch, please send it to the -patches list.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:59 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com