Re: Functional index adding one

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: Functional index adding one
Дата
Msg-id 20080703131949.GV2572@frubble.xen.chris-lamb.co.uk
обсуждение исходный текст
Ответ на Functional index adding one  (lbarcala@freeresearch.org)
Ответы Re: Functional index adding one  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Thu, Jul 03, 2008 at 11:50:39AM +0200, lbarcala@freeresearch.org wrote:
> test=# CREATE INDEX token_position_func
> test-# ON token (position+1);
> ERROR:  syntax error at or near "+"
> LINE 2: ON token (position+1);
>
> I read that I can do "ON function(column)" but, is there a built-in
> function in PostgreSQL to do what I want (add one to the value) or have i
> to build one to make this simple calculation?

You just want an extra set of brackets; i.e.:

  CREATE INDEX token_position_func ON token ((position+1));

Should do the trick.  Not entirely sure why, but it'll probably have
something to do with avoiding ambiguity in the grammar.


  Sam

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

Предыдущее
От: Gwyneth Morrison
Дата:
Сообщение: Re: Delete from Join
Следующее
От: Lennin Caro
Дата:
Сообщение: Re: Delete from Join