#107 PgConnection.flush fails to handle nonblocking writes

open
nobody
None
5
2009-11-13
2009-11-13
Edward Faulkner
No

PgConnection.flush appears to misunderstand how to use the underlying PQflush function. When PQflush returns 1, this is not an error. The 1 should be returned to the caller of PgConnection.flush, so the caller knows whether to call flush again.

1 means "call again when the socket is writable."
0 means "no more data to write".
-1 means error, and only in this case should PgConnection.flush throw an exception.

This is necessary for any application that wants to write big statements in a nonblocking way.

Discussion