Re: Use of !~* to keep a varchar column UNIQUE

From: "Daniel T(dot) Staal" <DStaal(at)usa(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Use of !~* to keep a varchar column UNIQUE
Date: 2006-08-18 18:59:29
Message-ID: 56522.63.172.115.138.1155927569.squirrel@MageHandbook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.
---------------------------------------------------------------

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2006-08-18 19:54:51 Re: libpq Describe Extension [WAS: Bytea and perl]
Previous Message Don Morrison 2006-08-18 18:04:08 Re: Use of !~* to keep a varchar column UNIQUE case-insensitive