Re: libpq async duplicate error results - Mailing list pgsql-hackers

From Tom Lane
Subject Re: libpq async duplicate error results
Date
Msg-id 979911.1644253651@sss.pgh.pa.us
Whole thread Raw
In response to Re: libpq async duplicate error results  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: libpq async duplicate error results  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Re: libpq async duplicate error results  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
[ cc'ing Alvaro for pipeline questions ]

Fabien COELHO <coelho@cri.ensmp.fr> writes:
>> It is annoying that some of the text is duplicated in the second
>> report, but in the end that's cosmetic, and I'm not sure we can
>> improve it without breaking other things.  In particular, we
>> can't just think about what comes back in the PGgetResult calls,
>> we also have to consider what PQerrorMessage(conn) will report
>> afterwards.  So I don't think that resetting conn->errorMessage
>> during a PQgetResult series would be a good fix.
>> 
>> An idea that I don't have time to pursue right now is to track
>> how much of conn->errorMessage has been read out by PQgetResult,
>> and only report newly-added text in later PQgetResult calls of
>> a series, while PQerrorMessage would continue to report the
>> whole thing.  Buffer resets would occur where they do now.

> I agree that the message reset is not convincing, but it was the only way 
> to get the expected behavior without changing the existing functions.

I spent a bit more time poking at this issue.  I no longer like the
idea of reporting only the tail part of conn->errorMessage; I'm
afraid that would convert "edge cases sometimes return redundant text"
into "edge cases sometimes miss returning text at all", which is not
an improvement.

In any case, the particular example we're looking at here is connection
loss, which is not something that should greatly concern us as far as
pipeline semantics are concerned, because you're not getting any more
pipelined results anyway if that happens.  In the non-I/O-error case,
I see that PQgetResult does a hacky "resetPQExpBuffer(&conn->errorMessage)"
in between pipelined queries.  It seems like if there are real usability
issues in this area, they probably come from that not being well placed.
In particular, I wonder why that's done with the pqPipelineProcessQueue
call in the PGASYNC_IDLE stanza, yet not with the pqPipelineProcessQueue
call in the PGASYNC_READY stanza (where we're returning a PIPELINE_SYNC
result).  It kinda looks to me like maybe pqPipelineProcessQueue
ought to have the responsibility for doing that, rather than having
two out of the three call sites do it.  Also it would seem more natural
to associate it with the reinitialization that happens inside
pqPipelineProcessQueue.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Esteban Zimanyi
Date:
Subject: Re: Storage for multiple variable-length attributes in a single row
Next
From: Robert Haas
Date:
Subject: Re: [PATCH v2] use has_privs_for_role for predefined roles