Re: [GENERAL] Linux Largefile Support In Postgresql RPMS

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] Linux Largefile Support In Postgresql RPMS
Date: 2002-08-13 12:18:21
Message-ID: 1029241101.1135.560.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

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 Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jules Alberts 2002-08-13 12:26:31 opaque function not accepted (without error message)
Previous Message Jan Theofel 2002-08-13 11:56:46 age command

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-08-13 13:00:15 Re: [COMMITTERS] pgsql-server/src backend/tcop/postgres.cbacke
Previous Message Rod Taylor 2002-08-13 12:00:09 Re: db partial dumping with pg_dump