Re: pg_dump return status.. - Mailing list pgsql-hackers

From ncm@zembu.com (Nathan Myers)
Subject Re: pg_dump return status..
Date
Msg-id 20010105141709.E10336@store.zembu.com
Whole thread Raw
In response to Re: Re: [GENERAL] pg_dump return status..  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pg_dump return status..
List pgsql-hackers
On Fri, Jan 05, 2001 at 11:20:43AM -0500, Tom Lane wrote:
> Philip Warner <pjw@rhyme.com.au> writes:
> > 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.

An fprintf returning 0 is a suspicious event; it's easy to imagine 
cases where it makes sense, but I don't think I have ever coded one.
Probably >N (where N is the smallest reasonable output, defaulting 
to 1) may be a better test in real code.

As I recall, on SunOS 4 the printf()s don't return the number of 
characters written.  I don't recall what they do instead, and have
no access to such machines any more.

Other old BSD-derived systems are likely to have have wonky return 
values/types on the printf()s.  Looking at the list of supported 
platforms, none jump out as likely candidates, but in the "unsupported" 
list, Ultrix and NextStep do.  (Do we care?)

If SunOS 4 is to remain a supported platform, the printf checks may 
need to be special-cased for it.

Nathan Myers
ncm@zembu.com


pgsql-hackers by date:

Previous
From: Ian Lance Taylor
Date:
Subject: Re: Recursion and SPI
Next
From: Ian Lance Taylor
Date:
Subject: Re: pg_dump return status..