Re: pgsql: Minor pg_dump improvements

From: Bernd Helmle <mailings(at)oopsware(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Minor pg_dump improvements
Date: 2014-05-05 14:32:15
Message-ID: 338692DFAEDFA2A5B1D541DE@apophis.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

--On 9. Februar 2014 13:55:03 -0500 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Agreed; we should be using the same coding pattern wherever we call
> ftello.
>
> I suspect that this code may be left over from coping with some ancient
> non-spec-compliant version of ftello? Probably not worth digging in
> the archives to find out. The Single Unix Spec v2 says that the result
> is (off_t) -1 on error, and we generally assume that platforms are at
> least compliant with that.
>
> grep shows me a couple of other places where the result of ftello doesn't
> seem to be getting checked for error. Odd that Coverity didn't notice
> those.

It stroke me today that there's still something broken. pg_dump fails when
used in custom archive mode and piping to e.g. pg_restore:

pg_dump -Fc -p 5447 regression | pg_restore
pg_dump: [custom archiver] could not determine seek position in archive
file: Illegal seek
pg_restore: [custom archiver] unexpected end of file

pg_dump fails in _CloseArchive() with this hunk:

+ if (tpos < 0 || errno)
+ exit_horribly(modulename, "could not determine seek position in archive
file: %s\n",
+ strerror(errno));

errno is set to 29, which is ESPIPE and tpos was set to -1. If I read the
manpage on OSX here correctly, ftell[o] will always fail if used with a
pipe in this case:

[ESPIPE] The file descriptor underlying stream is associated
with a pipe or FIFO or file-position indicator
value is unspecified (see ungetc(3)).

A quick check shows that Debian has the same issue.

--
Thanks

Bernd

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-05-05 14:54:57 Re: pgsql: Minor pg_dump improvements
Previous Message Bruce Momjian 2014-05-05 14:30:51 pgsql: Update "huge pages" description in the 9.4 release notes