Re: pgsql: Minor pg_dump improvements - Mailing list pgsql-committers

From Bernd Helmle
Subject Re: pgsql: Minor pg_dump improvements
Date
Msg-id 338692DFAEDFA2A5B1D541DE@apophis.credativ.lan
Whole thread Raw
In response to Re: pgsql: Minor pg_dump improvements  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgsql: Minor pg_dump improvements  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers

--On 9. Februar 2014 13:55:03 -0500 Tom Lane <tgl@sss.pgh.pa.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


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: pgsql: Update "huge pages" description in the 9.4 release notes
Next
From: Tom Lane
Date:
Subject: Re: pgsql: Minor pg_dump improvements