On Wed, Jan 19, 2011 at 1:12 PM, Fujii Masao <masao.fu...@gmail.com> wrote:
>>> +               r = PQgetCopyData(conn, &copybuf, 0);
>>> +               if (r == -1)
>>>
>>> Since -1 of PQgetCopyData might indicate an error, in this case,
>>> we would need to call PQgetResult?.
>>
>> Uh, -1 means end of data, no? -2 means error?
>
> The comment in pqGetCopyData3 says
>
>        /*
>         * On end-of-copy, exit COPY_OUT or COPY_BOTH mode and let caller
>         * read status with PQgetResult().      The normal case is that it's
>         * Copy Done, but we let parseInput read that.  If error, we expect
>         * the state was already changed.
>         */
>
> Also the comment in getCopyDataMessage says
>
>        /*
>         * If it's a legitimate async message type, process it.  (NOTIFY
>         * messages are not currently possible here, but we handle them for
>         * completeness.)  Otherwise, if it's anything except Copy Data,
>         * report end-of-copy.
>         */
>
> So I thought that. BTW, walreceiver has already done that.

When PQgetCopyData returns -1, PQgetResult should be called. This is true.
But when I read the patch again, I found that Magnus has already done that.
So my comment missed the point :( Sorry for noise.

+       res = PQgetResult(conn);
+       if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+               fprintf(stderr, _("%s: final receive failed: %s\n"),
+                               progname, PQerrorMessage(conn));
+               exit(1);
+       }

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to