Re: Some encoding trouble via libpq - Mailing list pgsql-general

From Tom Lane
Subject Re: Some encoding trouble via libpq
Date
Msg-id 5795.1175212418@sss.pgh.pa.us
Whole thread Raw
In response to Some encoding trouble via libpq  ("Billy Gray" <billy.zophar@gmail.com>)
Responses Re: Some encoding trouble via libpq  ("William Gray" <billy.zophar@gmail.com>)
List pgsql-general
"William Gray" <billy.zophar@gmail.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: COPY command details
Next
From: "John D. Burger"
Date:
Subject: Re: Deleted Flag/Unique Constraint