Re: 'value too long' and before insert/update trigger

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Kevin Golding <KGolding(at)axessgroup(dot)com(dot)au>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: 'value too long' and before insert/update trigger
Date: 2017-08-24 05:55:51
Message-ID: CAKFQuwZAieGuQa2OTunzv7dtei9ztKiSeEJ1muPjZTEA58xJbw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, August 23, 2017, Kevin Golding <KGolding(at)axessgroup(dot)com(dot)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. I suspect changing this property of the system is
unlikely though I agree that I too have sometimes wished that a trigger
could be used to make invalid data, for a given type, valid.

Some hackish use of views, and triggers thereon, may provide an avenue to
gradual migration.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vincenzo Romano 2017-08-24 07:11:13 Re: DROP [TEMP] TABLE syntax, as reason why not?
Previous Message Pavel Stehule 2017-08-24 05:48:06 Re: 'value too long' and before insert/update trigger