pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #8211: Syntax error when creating index on expression
4+ messages / 4 participants
[nested] [flat]
* BUG #8211: Syntax error when creating index on expression
@ 2013-06-05 15:24 acizov@gmail.com
2013-06-05 16:33 ` Re: BUG #8211: Syntax error when creating index on expression bricklen <bricklen@gmail.com>
2013-06-05 16:35 ` Re: BUG #8211: Syntax error when creating index on expression Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 4+ messages in thread
From: acizov@gmail.com @ 2013-06-05 15:24 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 8211
Logged by: Andrey Cizov
Email address: acizov@gmail.com
PostgreSQL version: 9.2.3
Operating system: Windows
Description:
CREATE INDEX heuristic ON foos (1 / (a + b))
causes:
ERROR: syntax error at or near "1"
LINE 1: CREATE INDEX heuristic ON foos (1 / (a + b))
^
********** Error **********
ERROR: syntax error at or near "1"
SQL state: 42601
Character: 33
While:
CREATE INDEX heuristic ON foos ((1 / (a + b)))
Execution successful
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #8211: Syntax error when creating index on expression
2013-06-05 15:24 BUG #8211: Syntax error when creating index on expression acizov@gmail.com
@ 2013-06-05 16:33 ` bricklen <bricklen@gmail.com>
2013-06-05 17:26 ` Re: BUG #8211: Syntax error when creating index on expression David Johnston <polobo@yahoo.com>
1 sibling, 1 reply; 4+ messages in thread
From: bricklen @ 2013-06-05 16:33 UTC (permalink / raw)
To: acizov@gmail.com; +Cc: pgsql-bugs
On Wed, Jun 5, 2013 at 8:24 AM, <acizov@gmail.com> wrote:
>
> Bug reference: 8211
> Logged by: Andrey Cizov
> Email address: acizov@gmail.com
> PostgreSQL version: 9.2.3
> Operating system: Windows
> Description:
>
> CREATE INDEX heuristic ON foos (1 / (a + b))
>
> causes:
>
> ERROR: syntax error at or near "1"
> LINE 1: CREATE INDEX heuristic ON foos (1 / (a + b))
> ^
>
> ********** Error **********
>
> ERROR: syntax error at or near "1"
> SQL state: 42601
> Character: 33
>
> While:
>
> CREATE INDEX heuristic ON foos ((1 / (a + b)))
>
> Execution successful
Did you look at the docs?
http://www.postgresql.org/docs/current/static/sql-createindex.html
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.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #8211: Syntax error when creating index on expression
2013-06-05 15:24 BUG #8211: Syntax error when creating index on expression acizov@gmail.com
2013-06-05 16:33 ` Re: BUG #8211: Syntax error when creating index on expression bricklen <bricklen@gmail.com>
@ 2013-06-05 17:26 ` David Johnston <polobo@yahoo.com>
0 siblings, 0 replies; 4+ messages in thread
From: David Johnston @ 2013-06-05 17:26 UTC (permalink / raw)
To: pgsql-bugs
bricklen wrote
> 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 in fact the example provided:
CREATE INDEX ON films ((lower(title)));
could be written as:
CREATE INDEX ON films (lower(title));
The example expression has yet one additional pair of "()" that are not
required per the syntax since lower(...) is a function call. Extra "()"
never hurt I suppose...
I don't see this come up too often on the list but I will agree that it is
unexpected to require the extra set of "()". An example using an actual
expression with the extra "()" and then the function call example without -
to explicitly show when/why they can be omitted in the examples as well as
in the text - is an idea worth considering.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-8211-Syntax-error-when-creating-index-on-expression-tp57...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #8211: Syntax error when creating index on expression
2013-06-05 15:24 BUG #8211: Syntax error when creating index on expression acizov@gmail.com
@ 2013-06-05 16:35 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 4+ messages in thread
From: Tom Lane @ 2013-06-05 16:35 UTC (permalink / raw)
To: acizov@gmail.com; +Cc: pgsql-bugs
acizov@gmail.com writes:
> CREATE INDEX heuristic ON foos (1 / (a + b))
> causes:
> ERROR: syntax error at or near "1"
This is not a bug. You need an extra pair of parentheses around
the expression, ie
CREATE INDEX heuristic ON foos ((1 / (a + b)))
http://www.postgresql.org/docs/9.2/static/sql-createindex.html
points this out both in the syntax diagram and the text.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2013-06-05 17:26 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05 15:24 BUG #8211: Syntax error when creating index on expression acizov@gmail.com
2013-06-05 16:33 ` bricklen <bricklen@gmail.com>
2013-06-05 17:26 ` David Johnston <polobo@yahoo.com>
2013-06-05 16:35 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox