Re: Tidying values on variable instantiation

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Bath, David" <dave(dot)bath(at)unix(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Tidying values on variable instantiation
Date: 2005-08-26 15:20:27
Message-ID: 20050826152027.GB16546@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Aug 26, 2005 at 13:04:10 +1000,
> Desired Outcome(s):
> * I would like to have the convenience of declaring a column that obeys
> a constraint (similar to using a domain), but allows a "tidy-up" as the
> value is created BEFORE asserting the constraint. This *might* be
> termed a "domain trigger". (Perhaps even a WORM is possible!).
> * I would like to able to declare columns as
> "trimmed_varchar(n)".
> * I'd like to be able to use the same approach for other "weak domains".
>
> Question(s):
> * Am I being realistic, or should I grit my teeth and clone code from
> trigger to trigger and column to column?
> * Is this something I should try and do using domains, types and
> cast functions from "text" or some horrible combination of them all?
> * Has anybody got a code sample that might do something similar.

I think it is normal to expect the application to pass you clean data.

I think you can do what you want by creating a new type. I seem to remember
there are issues with creating whatever(n) types (my memory is that varchar(n)
is hardwired into the parser), but certainly you could make an alternate
version of text whose input function trimmed leading and trailing whitespace.
You could also create casts between this new type and text if you needed
that ability as well.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Browne 2005-08-26 16:31:23 Re: Tidying values on variable instantiation
Previous Message Greg Patnude 2005-08-26 15:06:18 Re: Tidying values on variable instantiation