Re: pg_basebackup for streaming base backups - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: pg_basebackup for streaming base backups
Date
Msg-id AANLkTi=Rg6dSV14WbFp7QXOarhhzKECoq9eRurcdsvFQ@mail.gmail.com
Whole thread Raw
In response to Re: pg_basebackup for streaming base backups  (Fujii Masao <masao.fujii@gmail.com>)
List pgsql-hackers
On Wed, Jan 19, 2011 at 1:12 PM, Fujii Masao <masao.fujii@gmail.com> wrote:
>>> +               r = PQgetCopyData(conn, ©buf, 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


pgsql-hackers by date:

Previous
From: Dan Ports
Date:
Subject: Re: SSI and Hot Standby
Next
From: Joseph Adams
Date:
Subject: Re: JSON data type status?