Re: abnormal behaviour of a CHECK CONSTRAINT with a regular

From: Daniel Struck <struck(dot)d(at)retrovirology(dot)lu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: abnormal behaviour of a CHECK CONSTRAINT with a regular
Date: 2004-02-11 10:40:05
Message-ID: 20040211114005.78fe1a06.struck.d@retrovirology.lu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> Correct. It is annoying in some cases, but if the input to the trigger
> isn't of the column datatype, then what type is it? It's hard to see
> how that could work in general.
>
> If you want, say, a varchar length constraint to be checked only after
> the trigger runs, I'd counsel declaring the column as plain text and
> writing the length test as a CHECK constraint.

I had just an example, where it would have been convenient, if one could change the type.

Let's say you want to give the users the possibility to enter incomplete dates (year, year&month or the complete date). Indeed you could not insert this information as it is. But later on for stats you would like to be able to treat the column as a date.

I have implemented it by storing the user information in a varchar column and inserting the whole date in another column.
(if the user only provides the year, the date is inserted as 16.05.year,...).

Kind regards,

Daniel Struck

--
Retrovirology Laboratory Luxembourg
Centre Hospitalier de Luxembourg
4, rue E. Barblé
L-1210 Luxembourg

phone: +352-44116105
fax: +352-44116113
web: http://www.retrovirology.lu
e-mail: struck(dot)d(at)retrovirology(dot)lu

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PostgreSQL Bugs List 2004-02-11 13:56:15 BUG #1078: Ref #1045 hostname lookup does not work
Previous Message PostgreSQL Bugs List 2004-02-10 22:54:33 BUG #1077: install-strip does not work for MacOS X 10.2.8