On Mon, Dec 18, 2006 at 09:50:12AM -0500, Bruce Momjian wrote:

> > > Yes, Magnus-san suggested the problem. It is present TODO.  The entire 
> > > adjustment was still difficult though I had tried it. SetFilePointer 
> > > might 
> > > be able to be saved. However, I think it might be an attempt of 8.3...
> > 
> > I've been looking at a fix for this, and I think I have it. The solution
> > looks to be to redefine off_t to 64-bit (the standard headers *always*
> > define it as 32-bit, and there is no way to change that - at least not
> > that I can find).
> > 
> > I have the fix made for just bin/pg_dump for now (in pg_dump.h), and I'm
> > testing that. (So far only on MSVC builds)
> > 
> > A question though - is there any *gain* from using 64-bit offsets in the
> > actual backend? The change could of course be done in port.h, but that
> 
> No, not really.  All files are kept < 1gig for the backend.  We had code
> for that from Berkeley, so we have just kept it.

Ok, based on this, here's a patch that *appears* to fix the problem on
Win32. I tried the suggested repro to dump a pgbench database of
appropriate size, and it does restore properly and give me the proper
amount of rows in all the tables. But that's all I've tested so far.

Also, it compiles fine on MSVC. I still haven't managed to get the MingW
build environment working properly on Win64 even for building Win32
apps, so I haven't been able to build it on MingW yet. It *should* work
since it's all standard functions, but might require further hacks. I'll
try to get around to that later, and Dave has promised to give it a
compile-try as well, but if someone wants to test that, please do ;)

So, does it seem reasonable, and the right place to stick it? Oh, and
please do *not* apply until someone confirms it works on mingw!

//Magnus

Index: src/bin/pg_dump/pg_dump.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.h,v
retrieving revision 1.130
diff -c -r1.130 pg_dump.h
*** src/bin/pg_dump/pg_dump.h   9 Oct 2006 23:36:59 -0000       1.130
--- src/bin/pg_dump/pg_dump.h   18 Dec 2006 14:33:16 -0000
***************
*** 16,21 ****
--- 16,33 ----
  
  #include "postgres_fe.h"
  
+ #ifdef WIN32
+ /*
+  * WIN32 does not provide a 64-bit off_t, but it does provide functions 
operating
+  * with 64-bit offsets. Redefine off_t to what's always a 64-bit int, and 
redefine
+  * the functions that accept off_t to be the 64-bit only ones.
+  */
+ #define off_t __int64
+ #undef fseeko
+ #define fseeko(stream, offset, origin) _fseeki64(stream, offset, origin)
+ #undef ftello
+ #define ftello(stream) _ftelli64(stream)
+ #endif
  
  /*
   * pg_dump uses two different mechanisms for identifying database objects:
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to