Re: Re: [GENERAL] pg_dump return status.. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Re: [GENERAL] pg_dump return status..
Date
Msg-id 10089.978711643@sss.pgh.pa.us
Whole thread Raw
In response to Re: Re: [GENERAL] pg_dump return status..  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: pg_dump return status..  (ncm@zembu.com (Nathan Myers))
List pgsql-hackers
Philip Warner <pjw@rhyme.com.au> writes:
> There are a few places to check, but a lot less than before. Assuming I
> should just die on any failed write (which seems reasonable),

Yes, I see no point in continuing after a write failure.  Just print
the strerror() message and exit.

> how do I
> check for a failed write in a way that works on all Unixes? Is the
> following OK:

> - fwrite: ok if return value equals item count
> - fprintf: ok if return value > 0.
> - fputc: ok if != EOF

Probably fprintf() >= 0 --- according to my specs, it returns the number
of chars emitted, or a negative value on error.  The other two are
correct.

Don't forget to check for a successful fclose() too, since otherwise
you won't notice a failure in dumping the last bufferload of data.

I do not recall the success/failure return codes for the zlib calls,
but I assume they check for write failure and reflect it back ...

            regards, tom lane

pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: Re: [GENERAL] pg_dump return status..
Next
From: Alex Pilosov
Date:
Subject: Re: Well, we seem to be proof against cache-inval problems now