PQputCopyEnd doesn't adhere to its API contract

Поиск
Список
Период
Сортировка
От Robert Haas
Тема PQputCopyEnd doesn't adhere to its API contract
Дата
Msg-id CA+Tgmobjj+0modbnmjy7ezeBFOBo9d2mAVcSPkzLx4LtZmc==g@mail.gmail.com
обсуждение исходный текст
Ответы Re: PQputCopyEnd doesn't adhere to its API contract
Список pgsql-hackers
According to the documentation for PQputCopyEnd:

> The result is 1 if the termination data was sent, zero if it was not sent because the attempt would block (this case
isonly possible if the connection is in
 
> nonblocking mode), or -1 if an error occurred. (Use PQerrorMessage to retrieve details if the return value is -1. If
thevalue is zero, wait for write-ready and try again.)
 

However, pqPutCopyEnd contains no return statement that can ever
possibly return 0.  I think the problem is approximately here:
   /* Try to flush data */   if (pqFlush(conn) < 0)       return -1;

pqFlush() returns 0 if no data is waiting to be sent, or otherwise the
return value of pqSendSome().  pqSendSome() returns -1 if an error
occurs, 0 if all data is sent, or 1 if some data was sent but the
socket is non-blocking and the caller must try again later.  It seems
to me that when pqSendSome() returns 1, pqPutCopyEnd ought to return 0
in order to meet its API contract - and then the client, presumably,
should repeatedly wait for the socket to become write-ready and then
try PQflush() until PQflush() returns non-zero.

Thoughts?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: postgresql.auto.conf read from wrong directory
Следующее
От: Tom Lane
Дата:
Сообщение: Re: popen and pclose redefinitions causing many warning in Windows build