Re: Add schema-qualified relnames in constraint error messages. - Mailing list pgsql-hackers

From Alex Shulgin
Subject Re: Add schema-qualified relnames in constraint error messages.
Date
Msg-id CAM-UEKRpRykDz1sA3OimhjY=dOpWyuBMEf8rDxtWzBP7WB14Lg@mail.gmail.com
Whole thread Raw
In response to Re: Add schema-qualified relnames in constraint error messages.  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Add schema-qualified relnames in constraint error messages.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sat, Apr 2, 2016 at 11:41 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de> writes:
> On Mon, Mar 14, 2016 at 7:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Yeah, I don't much like that either.  But I don't think we can avoid
>> some refactoring there; as designed, conversion of an error message into
>> user-visible form is too tightly tied to receipt of the message.

> True.  Attached is a v2 which addresses all of the points raised earlier I
> believe.

I took a closer look at what's going on here and realized that actually
it's not that hard to decouple the message-building routine from the
PGconn state, because mostly it works with fields it's extracting out
of the PGresult anyway.  The only piece of information that's lacking
is conn->last_query.  I propose therefore that instead of doing it like
this, we copy last_query into error PGresults.  This is strictly less
added storage requirement than storing the whole verbose message would be,
and it saves time compared to the v2 patch in the typical case where
the application never does ask for an alternately-formatted error message.
Plus we can actually support requests for any variant format, not only
VERBOSE.

Attached is a libpq-portion-only version of a patch doing it this way.
I've not yet looked at the psql part of your patch.

Comments?

Ah, neat, that's even better. :-)

What about regression tests?  My assumption was that we won't be able to add them with the usual expected file approach, but that we also don't need it that hard.  Everyone's in favor?

--
Alex

pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: Move PinBuffer and UnpinBuffer to atomics
Next
From: Alex Shulgin
Date:
Subject: Re: More stable query plans via more predictable column statistics