From: | "Don Morrison" <donmorrison(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Use of !~* to keep a varchar column UNIQUE case-insensitive |
Date: | 2006-08-18 17:52:28 |
Message-ID: | aee6519f0608181052n5a6c8337wf164a434059929a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
> create unique index fooi on foo (lower(name));
>
> Suppressing whitespace is left as an exercise for the reader...
create unique index fooi on foo (lower(trim both
'\040\f\t\r\n\a\b\e\v' from name));
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:
create unique index fooi on foo (lower(substring(name FROM '^\s*(\S*)\s*$')));
but (at least in postgres 7.4.13) the use of substring doesn't
work...I tried it and no index violation is generated even when
inserting duplicates with no spaces to begin with. (side-note: not
sure that regex would work anyways, as I'm not sure \S would exclude
all non-printables, just some maybe)...
From | Date | Subject | |
---|---|---|---|
Next Message | Don Morrison | 2006-08-18 18:04:08 | Re: Use of !~* to keep a varchar column UNIQUE case-insensitive |
Previous Message | Don Morrison | 2006-08-18 16:49:06 | Re: Use of !~* to keep a varchar column UNIQUE case-insensitive |