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

From Shulgin, Oleksandr
Subject Re: Add schema-qualified relnames in constraint error messages.
Date
Msg-id CACACo5Sbuen2SV=-MfnOBvX7BZNc=N1zQqtXSg=AppgEF7C_4Q@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.  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
Re: Add schema-qualified relnames in constraint error messages.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, Mar 14, 2016 at 7:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de> writes:
> What I dislike about this POC is all the disruption in libpq, to be
> honest.

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.

We still extract the message building part of code from pqGetErrorNotice3(), but the user-facing change is much more sane now: just added a new function PQresultVerboseErrorMessage().

> It would be much neater if we could form the verbose message every
> time and let the client decide where to cut it.  Maybe a bit "too clever"
> would be to put a \0 char between short message and it's verbose
> continuation.  The client could then reach the verbose part like this
> (assuming that libpq did put a verbose part there): msg + strlen(msg) + 1.

Blech :-(

:-)  That would not work either way, I've just noticed that SQLLEVEL is put at the start of the message in verbose mode, but not by default.

Thinking about it, though, it seems to me that we could get away with
always performing both styles of conversion and sticking both strings
into the PGresult.  That would eat a little more space but not much.
Then we just need to add API to let the application get at both forms.

This is what the v2 basically implements, now complete with help, tab-complete and documentation changes.  I don't think we can add a usual simple regression test here reliably, due to LOCATION field which might be subject to unexpected line number changes.  But do we really need one?

--
Regards,
Alex

Attachment

pgsql-hackers by date:

Previous
From: Mark Dilger
Date:
Subject: Re: [PATCH] Integer overflow in timestamp[tz]_part() and date/time boundaries check
Next
From: "Shulgin, Oleksandr"
Date:
Subject: Re: More stable query plans via more predictable column statistics