There doesn't seem to be any case where PQputCopyEnd() returns 0

Поиск
Список
Период
Сортировка
От Kasahara Tatsuhito
Тема There doesn't seem to be any case where PQputCopyEnd() returns 0
Дата
Msg-id CAP0=ZVJjCh2p-97vydPESFAE4Mf2JSEvD5ugL2TpsKwAQ5mfrQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: There doesn't seem to be any case where PQputCopyEnd() returns 0
Список pgsql-hackers
Hi,

The following is written in the comments of PQputCopyEnd().

 (snip)
 * Returns 1 if successful, 0 if data could not be sent (only possible
 * in nonblock mode), or -1 if an error occurs.
 (snip)

The PQputCopyEnd() section of the manual (libpq.sgml) describes the following.

       The result is 1 if the termination message was sent; or in
       nonblocking mode, this may only indicate that the termination
       message was successfully queued.  (In nonblocking mode, to be
       certain that the data has been sent, you should next wait for
       write-ready and call <xref linkend="libpq-PQflush"/>, repeating until it
       returns zero.)  Zero indicates that the function could not queue
       the termination message because of full buffers; this will only
       happen in nonblocking mode.  (In this case, wait for
       write-ready and try the <xref linkend="libpq-PQputCopyEnd"/> call
       again.)  If a hard error occurs, -1 is returned; you can use
       <xref linkend="libpq-PQerrorMessage"/> to retrieve details.


These says that 0 may be returned if a non-blocking mode is used, but
there doesn't seem to be any case where 0 is returned in the code of
PQputCopyEnd().

I may have missed something, but is it a mistake in the comments or
documentation?

Or should it return 0 when sending a COPY exit message fails
in non-blocking mode, like this?

@@ -2370,7 +2370,7 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
                        /* Send COPY DONE */
                        if (pqPutMsgStart('c', false, conn) < 0 ||
                                pqPutMsgEnd(conn) < 0)
-                               return -1;
+                               return pqIsnonblocking(conn) ? 0 : -1;
                }

                /*
@@ -2399,7 +2399,7 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
                        if (pqPutMsgStart(0, false, conn) < 0 ||
                                pqPutnchar("\\.\n", 3, conn) < 0 ||
                                pqPutMsgEnd(conn) < 0)
-                               return -1;
+                               return pqIsnonblocking(conn) ? 0 : -1;
                }
        }


Best regards,

-- 
Tatsuhito Kasahara
kasahara.tatsuhito _at_ gmail.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Ronan Dunklau
Дата:
Сообщение: Re: Preserve attstattarget on REINDEX CONCURRENTLY
Следующее
От: Greg Nancarrow
Дата:
Сообщение: Re: Parallel INSERT (INTO ... SELECT ...)