"Alon Goldshuv" <agoldshuv(at)greenplum(dot)com> writes:
> As the code comment suggests, it is extremely important to consume incoming
> messages from the server to prevent deadlock. However we should only worry
> about it before sending data out.
And, unfortunately, you've broken it. The pqFlush call visible in that
routine is not the only place that may try to send data (see also
pqPutMsgEnd).
regards, tom lane