Re: pg_dump and large files - is this a problem?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
Cc: Zeugswetter Andreas SB SD <ZeugswetterA(at)spardat(dot)at>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Giles Lean <giles(at)nemeton(dot)com(dot)au>
Subject: Re: pg_dump and large files - is this a problem?
Date: 2002-10-25 04:07:37
Message-ID: 200210250407.g9P47bJ13801@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Philip Warner wrote:
> Rather than having a different patch file for each platform and refusing to
> code fseek/tell because we can't do SEEK_CUR, why not check for FSEEKO64
> and revert to a simple solution:
>
> #ifdef HAVE_FSEEKO64
> #define FSEEK fseeko64
> #define FTELL ftello64
> #define FILE_OFFSET off64_t

We can do this, but there is the problem of making the code pretty ugly.
Also, it is not immediately clear when off_t is something to be used by
fseek and when it is being used in file offsets that will never be
seeked. I am concerned about perhaps making things worse than they are
now.

> #else
> #ifdef HAVE_FSEEKO
> #define FSEEK fseeko
> #define FTELL ftello
> #define FILE_OFFSET off_t
> #else
> #if HAVE_FSEEK_BETTER_THAN_32_BIT
> #define FSEEK FSEEK_BETTER_THAN_32_BIT
> #define FTELL FTELL_BETTER_THAN_32_BIT
> #define FILE_OFFSET FILE_OFFSET_BETTER_THAN_32_BIT
> #else
> #if sizeof(off_t) > sizeof(long)

Can't do sizeof() tests in cpp, which is where the #if is processed.

> #define IGNORE_FSEEK
> #else
> #define FSEEK fseek
> #define FTELL ftell
> #define FILE_OFFSET long
> #end if...
>
> Then use a correct checkSeek which also checks IGNORE_FSEEK.
>
> AFAICT, this *will* do the job on all systems discussed. And we can
> certainly skip the HAVE_FSEEK_BETTER_THAN_32_BIT bit, but coding a trivial
> seek/tell pair for fsetpos/fgetpos is easy, even in a macro.

I don't think we can assume that off_t can be passed to fset/getpos
unless we know the platform supports it, unless people think fpos_t
being integral and the same size as fpos_t is enough.

Also, I don't think these can be done a macro, perhaps
fseeko(...,SEEK_SET), but not the others, and not ftello. See
port/fseeko.c for the reason.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2002-10-25 05:39:11 Re: pg_dump and large files - is this a problem?
Previous Message Bruce Momjian 2002-10-25 03:51:26 Re: pg_dump and large files - is this a problem?