On 26.01.22 14:52, Fabien COELHO wrote:
command = SELECT pg_terminate_backend(pg_backend_pid());
result 1 status = PGRES_FATAL_ERROR
error message = "FATAL: terminating connection due to administrator
command
"
result 2 status = PGRES_FATAL_ERROR
error message = "FATAL: terminating connection due to administrator
command
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
"
Also, why are there multiple results being generated in the first place?
My interpretation is that the first message is a close message issued by
the server before actually severing the connection, and the second
message is generated by libpq when it notices that the connection has
been closed, so there is some sense in having to results to report these
two consecutive errors, and the question might be about when the buffer
should be reset.
I see. If we stipulate for a moment that getting two results is what we
want here, I see a conceptual problem. Users of PQexec() don't care
whether the error message they are ultimately getting is a concatenation
of two messages from two internal results (old behavior) or just an
appropriately accumulated message from the last internal result (new
behavior). But users of PQgetResult() don't have a principled way to
deal with this anymore. They can't just ignore one or the other result,
because they could after all be two separate errors from two separate
commands. So the only proper behavior is to show all errors from all
results. But that results in this misbehavior because the last error
message must include the messages from the previous messages in order to
accommodate PQexec() users.