On Mon, 2002-08-12 at 21:07, Peter Eisentraut wrote:

> This is not the only issue.  You really need to check all uses of off_t
> (for example printf("%ld", off_t) will crash) and all places where off_t
> should have been used in the first place.  Furthermore you might need to
> replace ftell() and fseek() by ftello() and fseeko(), especially if you
> want pg_dump to support large archives.

Searching for fseek, ftell and off_t yields only 12 files in the whole
source tree, so fortunately the impact is not enormous.  As expected,
pg_dump is the main program involved.

There seem to be several places in the pg_dump code where int is used
instead of long int to receive the output of ftell().  I presume these
ought to be cleaned up as well.

Looking at how to deal with this, is the following going to be
portable?:
    
    in pg_dump/Makefile:
    CFLAGS += -D_LARGEFILE_SOURCE -D_OFFSET_BITS=64
    
    in pg_dump.h:
    #ifdef _LARGEFILE_SOURCE
      #define FSEEK fseeko
      #define FTELL ftello
      #define OFF_T_FORMAT %Ld
      typedef off_t OFF_T;
    #else
      #define FSEEK fseek
      #define FTELL ftell
      #define OFF_T_FORMAT %ld
      typedef long int OFF_T;
    #endif
    
    In pg_dump/*.c:
        change relevant occurrences of fseek and ftell to FSEEK and
        FTELL
    
        change all file offset parameters used or returned by fseek and
        ftell to OFF_T (usually from int)
    
        construct printf formats with OFF_T_FORMAT in appropriate places

> Still, most of the configuration work is already done in Autoconf (see
> AC_FUNC_FSEEKO and AC_SYS_LARGEFILE), so the work might be significantly
> less than the time spent debating the merits of large files on these
> lists. ;-)

Since running autoconf isn't part of a normal build, I'm not familiar
with that.  Can autoconf make any of the above unnecessary?

-- 
Oliver Elphick                                [EMAIL PROTECTED]
Isle of Wight, UK                            
http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Watch ye therefore, and pray always, that ye may be 
      accounted worthy to escape all these things that shall
      come to pass, and to stand before the Son of man."    
                               Luke 21:36 


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to