the '::' cast doesn't work in the FROM clause

From: Alexey Klyukin <alexk(at)commandprompt(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: the '::' cast doesn't work in the FROM clause
Date: 2011-08-29 11:20:56
Message-ID: 44B95360-DA92-48F5-AB6D-4B17FE31FC65@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello,

The following statement produces an error message in PostgreSQL 8.4 - 9.2 (head):

postgres=# select val from random()::integer as val;
ERROR: syntax error at or near "::"
LINE 1: select val from random()::integer as val;

The same statement rewritten with CAST AS works as expected:
^
postgres=# select val from CAST(random() as integer) as val;
val
-----
1
(1 row)

The '::' cast works normally when used in a target list:

postgres=# select random()::integer as val;
val
--------
1
(1 row)

The documentation says these casts are equivalent, so either that's wrong, or this is a bug.
The target OS is Mac OS X 10.7.1 with llvm-gcc-4.2 used as a compiler.

--
Alexey Klyukin http://www.commandprompt.com
The PostgreSQL Company – Command Prompt, Inc.

Browse pgsql-bugs by date

  From Date Subject
Next Message Itagaki Takahiro 2011-08-29 11:42:45 BUG #6181: concat_ws() incompatibility with MySQL
Previous Message Itagaki Takahiro 2011-08-29 03:34:54 Re: pgbench -T isn't a hard cutoff.