Re: [GENERAL] 'value too long' and before insert/update trigger - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] 'value too long' and before insert/update trigger
Date
Msg-id 30073.1503575043@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] 'value too long' and before insert/update trigger  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wednesday, August 23, 2017, Kevin Golding <KGolding@axessgroup.com.au>
> wrote:
>> Presumably the length validation is being done before the trigger is run.
>> Is there some way this could be changed so the trigger happens first?

> The input tuple passed into the trigger is a valid record of the same type
> as the table to which it is attached.  This means that while table
> constraints are not enforced all column values must already be valid for
> the defined column type.

Right, that's why this isn't likely to change.  You could replace the
datatype-related limit with a CHECK constraint, and then it'd be possible
for a BEFORE trigger to modify the value to make it compliant before the
constraint is checked.

            regards, tom lane


pgsql-general by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: [GENERAL] DROP [TEMP] TABLE syntax, as reason why not?
Next
From: Tom Lane
Date:
Subject: Re: [GENERAL] DROP [TEMP] TABLE syntax, as reason why not?