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

Поиск
Список
Период
Сортировка
От Don Morrison
Тема Re: Use of !~* to keep a varchar column UNIQUE case-insensitive
Дата
Msg-id aee6519f0608181052n5a6c8337wf164a434059929a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Use of !~* to keep a varchar column UNIQUE case-insensitive  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Use of !~* to keep a varchar column UNIQUE case-insensitive  ("Don Morrison" <donmorrison@gmail.com>)
Re: Use of !~* to keep a varchar column UNIQUE  ("Daniel T. Staal" <DStaal@usa.net>)
Re: Use of !~* to keep a varchar column UNIQUE case-insensitive  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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)...

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Don Morrison"
Дата:
Сообщение: Re: Use of !~* to keep a varchar column UNIQUE case-insensitive
Следующее
От: "Don Morrison"
Дата:
Сообщение: Re: Use of !~* to keep a varchar column UNIQUE case-insensitive