| From: | Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru> | 
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> | 
| Subject: | Index expression syntax | 
| Date: | 2017-09-29 07:31:29 | 
| Message-ID: | aa9c018a-8273-3ba9-d457-6825be20f477@postgrespro.ru | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
I wonder why syntax error is produced in this case:
postgres=# create index metaindex on foo using 
gin(to_tsvector('english', x)||to_tsvector('english',y));
ERROR:  syntax error at or near "||"
LINE 1: ...taindex on foo using gin(to_tsvector('english', x)||to_tsvec...
                                                              ^
The error can be eliminated if extra surrounding parentheses are added:
postgres=# create index metaindex on foo using 
gin((to_tsvector('english', x)||to_tsvector('english',y)));
CREATE INDEX
Postgresql documentations says:
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ]/|name|/  ] ON/|table_name|/  [ USING/|method|/  ]
     ( {/|column_name|/  | (/|expression|/  ) } [ COLLATE/|collation|/  ] [/|opclass|/  ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] )
     [ WITH (/|storage_parameter|/  =/|value|/  [, ... ] ) ]
     [ TABLESPACE/|tablespace_name|/  ]
     [ WHERE/|predicate|/  ]
/|expression:|/
    An expression based on one or more columns of the table. The
    expression usually must be written with surrounding parentheses, as
    shown in the syntax. However, the parentheses can be omitted if the
    expression has the form of a function call.
----------
So documentations states that sometimes it is possible to avoid 
parentheses, but it is unclear why I have to use double parentheses...
I think that either grammar should be fixed, either documentation should 
be updated.
/||/
-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Konstantin Knizhnik | 2017-09-29 07:57:28 | Re: pg_prepared_xact_status | 
| Previous Message | amul sul | 2017-09-29 07:09:21 | Re: UPDATE of partition key |