Re: Some encoding trouble via libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "William Gray" <billy(dot)zophar(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Some encoding trouble via libpq
Date: 2007-03-29 23:53:38
Message-ID: 5795.1175212418@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"William Gray" <billy(dot)zophar(at)gmail(dot)com> writes:
> ... And in the case
> that fread() pulls in less data than requested, that means the next call to
> fread() should return zero, right?

Wouldn't count on that, particularly not when reading from an
interactive device. You are more likely to get a line per call.

What's bothering me about your code is that it assumes there are
exactly STDIN_BLOCK bytes available in the buffer when you call
fread, and the code does nothing that guarantees that. Personally
I'd have used "size - offset" as the fread length parameter and not
had to worry.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Hedstrom 2007-03-30 00:05:12 Re: Deleted Flag/Unique Constraint
Previous Message Tom Lane 2007-03-29 23:35:45 Re: COPY command details