Re: How to get column, table or parameter name reporting when violating DOMAIN type constraint - Mailing list pgsql-novice

From Tom Lane
Subject Re: How to get column, table or parameter name reporting when violating DOMAIN type constraint
Date
Msg-id 2914598.1679846405@sss.pgh.pa.us
Whole thread Raw
In response to Re: How to get column, table or parameter name reporting when violating DOMAIN type constraint  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: How to get column, table or parameter name reporting when violating DOMAIN type constraint
List pgsql-novice
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sunday, March 26, 2023, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> More to the point, you have the wrong mental model: a domain constraint
>> violation might not be associated with a table column at all.

> I disagree that the mental model is wrong.

The OP is asking for action-at-a-distance.  There are probably cases
where the distance is short enough that we could associate the runtime
error with a particular insertion target column, but I don't think it
could possibly be made to work for every sort of insert/select query.
In any case, the possibility of a hypothetical future feature (which
nobody is actively working on AFAIK) doesn't seem like a very useful
answer here.

> There are existing threads that I may hunt later.  IIRC, you (Tom) even
> suggested a possible way forward on this last time it came up.

I recall proposing that we try to produce syntax-error-like error
cursors for runtime errors, but it's not apparent to me that that'd
be tremendously applicable to the OP's problem.  The output would
look something like

ERROR: value for domain my_domain violates check constraint "value_min"
LINE 1: SELECT my_function(100, -100);
                                ^

which might be helpful for a human, but probably not very much so
for a program.  (BTW, this illustrates another issue: I'm pretty
sure that in the given case, the error is thrown while evaluating
my_function's arguments, long before we get within hailing distance
of any INSERT at all.)

            regards, tom lane



pgsql-novice by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: How to get column, table or parameter name reporting when violating DOMAIN type constraint
Next
From: Valerio Battaglia
Date:
Subject: Re: How to get column, table or parameter name reporting when violating DOMAIN type constraint