pg_dump's checkSeek() seems inadequate - Mailing list pgsql-hackers

From Tom Lane
Subject pg_dump's checkSeek() seems inadequate
Date
Msg-id 28254.1277660531@sss.pgh.pa.us
Whole thread Raw
Responses Re: pg_dump's checkSeek() seems inadequate
Re: pg_dump's checkSeek() seems inadequate
List pgsql-hackers
While testing a fix for the pg_restore issues mentioned a few days ago,
I noticed that checkSeek() returns true on my old HPUX box even when the
input is in fact not seekable, for instance a pipe.  This leads to
pg_restore failing completely in cases where it ought to work, like this:

$ cat vector.dump | pg_restore -d vector
pg_restore: [custom archiver] WARNING: ftell mismatch with expected position -- ftell used
pg_restore: [custom archiver] error during file seek: Illegal seek
$ 

The test that checkSeek() is using is to see whether this works:
fseeko(fp, 0, SEEK_CUR)

and apparently on this platform that's a no-op even on an otherwise
unseekable file.  I don't know how common this behavior is; I don't
recall having seen complaints about pg_restore failing for other people.

If I change the test to be
fseeko(fp, 0, SEEK_SET)

then it does the right thing.  Since checkSeek() is applied immediately
after opening the input file this should be OK, but it does limit the
scope of usefulness of that function.

Any thoughts about whether or not to apply such a patch?  If it should
be changed, should we back-patch it?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Mike Fowler
Date:
Subject: [PATCH] Re: Adding xpath_exists function
Next
From: Tom Lane
Date:
Subject: Re: pg_dump's checkSeek() seems inadequate