Re: Use of !~* to keep a varchar column UNIQUE - Mailing list pgsql-novice

From Daniel T. Staal
Subject Re: Use of !~* to keep a varchar column UNIQUE
Date
Msg-id 56522.63.172.115.138.1155927569.squirrel@MageHandbook.com
Whole thread Raw
In response to Re: Use of !~* to keep a varchar column UNIQUE case-insensitive  ("Don Morrison" <donmorrison@gmail.com>)
Responses Re: Use of !~* to keep a varchar column UNIQUE  ("Don Morrison" <donmorrison@gmail.com>)
List pgsql-novice
On Fri, August 18, 2006 1:52 pm, Don Morrison said:

> The above works well enough, and I can live with it, but it is not
> comprehensive...it would be nice to use a regular expression....and do
> something like:

The other way of doing this, depending on your data integrety needs, would
be to use a before trigger on insert, which could trim the space and
convert to some normalized case.  PL/Perl would be a good language for
this.  ;)

Of course that has the problem of changing the data before it is inserted.
 It is up to you to decide if this change reperesnts a problem in your
particular case.  (I would think it probably would cause the database to
run a little faster: The processing only would happen once, at insert
time, instead of whenever the index is re-created.  Probably not
significant in most cases though.)

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------


pgsql-novice by date:

Previous
From: "Don Morrison"
Date:
Subject: Re: Use of !~* to keep a varchar column UNIQUE case-insensitive
Next
From: Tom Lane
Date:
Subject: Re: Use of !~* to keep a varchar column UNIQUE case-insensitive