Martijn van Oosterhout <kleptog@svana.org> writes:
> To move the conversation along:
> https://github.com/postgres/postgres/blob/master/src/bin/psql/copy.c#L664
> Seems possibly even more robust than most people will code, but it's
> had a lot of real world testing.
Note that the looping behavior there is actually rather new, and is
probably unnecessary for 99% of applications; it would depend on what
your ambitions are for dealing gracefully with connection loss (and
even then, I think we were forced into this by pre-existing decisions
elsewhere in psql about where and how we handle connection loss).
The important thing for this question is the error reporting that
occurs at lines 692-694.
regards, tom lane