Re: Functional index adding one

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Functional index adding one
Дата
Msg-id 2693.1215097886@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Functional index adding one  (Sam Mason <sam@samason.me.uk>)
Ответы Re: Functional index adding one  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
Sam Mason <sam@samason.me.uk> writes:
> 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.

Right.  The problem is the Berkeley-era decision to put index opclasses
into the syntax without any keyword or punctuation, viz

    create index ... on table (column_name [ opclass_name ]);

So something like

    CREATE INDEX token_position_func ON token (a + b);

is ambiguous: is the + an infix operator, or is it a postfix operator
and the "b" is to be taken as an opclass name?

We hacked around that by requiring parens around expressions.  For
backwards compatibility with other Berkeley-era syntax, there's
a special exception that you can omit the parens when the expression is
just a function call.

            regards, tom lane

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

Предыдущее
От: Csaba Nagy
Дата:
Сообщение: Re: Switching between terminals
Следующее
От: "Valter Douglas Lisbôa Jr."
Дата:
Сообщение: High inserting by syslog