Jeff Eckermann <jeff@akira.eckermann.com> writes:
> Based on past posts I have read, this error is usually associated with
> running out of memory for the query result. Problem is, I am only
> expecting about 30 lines of moderate length to be returned....
Have you verified that by doing
select count(*) from ... where ...
Watching psql's memory usage with top(1) is another way to check whether
a memory overrun might be happening.
The 'D message without prior T' followed by unexpected switch into COPY
mode certainly suggests that libpq has lost sync with the backend's
output. I am not aware of any failure modes that cause that in 7.0.3,
other than the aforementioned out-of-memory problem.
regards, tom lane