pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Bath, David <dave.bath@unix.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Tidying values on variable instantiation
Date: Fri, 26 Aug 2005 10:20:27 -0500
Message-ID: <20050826152027.GB16546@wolff.to> (raw)
In-Reply-To: <200508261304.10542.dave.bath@unix.net>
References: <200508261304.10542.dave.bath@unix.net>

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.



view thread (7+ messages)  latest in thread

Message-ID: <20050826152027.GB16546@wolff.to>
Permalink:  ../20050826152027.GB16546@wolff.to/
Also on:    postgresql.org/message-id/20050826152027.GB16546@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, dave.bath@unix.net
  Subject: Re: Tidying values on variable instantiation
  In-Reply-To: <20050826152027.GB16546@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox