Thread: Indexes on Expressions -- Parentheses

Indexes on Expressions -- Parentheses

From
Thomas F.O'Connell
Date:
From 11.5 in the docs:


<bigger><bigger>"The syntax of the
</bigger></bigger><fontfamily><param>Courier</param><x-tad-bigger>CREATE
INDEX</x-tad-bigger></fontfamily><bigger><bigger> command normally
requires writing parentheses around index expressions, as shown in the
second example. The parentheses may be omitted when the expression is
just a function call, as in the first example."


</bigger></bigger>But when I try this:


db=# CREATE INDEX expression_idx on some_table( extract( year from
some_column ) );


I get a syntax error corresponding to the open parenthesis after
extract (and whitespace is not the issue).


If I add an enclosing set of parentheses, E.g.:


db=# CREATE INDEX expression_idx on some_table( ( extract( year from
some_column ) ) );


it works!


Is this a known issue?


-tfo
 From 11.5 in the docs:

"The syntax of the CREATE INDEX command normally requires writing
parentheses around index expressions, as shown in the second example.
The parentheses may be omitted when the expression is just a function
call, as in the first example."

But when I try this:

db=# CREATE INDEX expression_idx on some_table( extract( year from
some_column ) );

I get a syntax error corresponding to the open parenthesis after
extract (and whitespace is not the issue).

If I add an enclosing set of parentheses, E.g.:

db=# CREATE INDEX expression_idx on some_table( ( extract( year from
some_column ) ) );

it works!

Is this a known issue?

-tfo

Re: Indexes on Expressions -- Parentheses

From
Stephan Szabo
Date:
sszabo@bigpanda.com

On Tue, 28 Sep 2004, Thomas F.O'Connell wrote:

>  From 11.5 in the docs:
>
> "The syntax of the CREATE INDEX command normally requires writing
> parentheses around index expressions, as shown in the second example.
> The parentheses may be omitted when the expression is just a function
> call, as in the first example."
>
> But when I try this:
>
> db=# CREATE INDEX expression_idx on some_table( extract( year from
> some_column ) );

Extract(year from some_column) is not really just a function call it's
an expression that looks similar to a function call because that's how SQL
defined it.