Skip site navigation (1) Skip section navigation (2)

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

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <alexk(at)commandprompt(dot)com>,<pgsql-bugs(at)postgresql(dot)org>
Subject: Re: the '::' cast doesn't work in the FROM clause
Date: 2011-08-29 12:49:42
Message-ID: 4E5B449602000025000407D9@gw.wicourts.gov (view raw or flat)
Thread:
Lists: pgsql-bugs
Alexey Klyukin  wrote:
 
> The following statement produces an error message in PostgreSQL 8.4
> - 9.2 (head):
> 
> postgres=# 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;
 
> The documentation says these casts are equivalent, so either that's
> wrong, or this is a bug.
 
Please point out where you think the documentation says that.  The
way I read it, this is the correct syntax:
 
test=# select val from (select random()::integer) as x(val);
 val 
-----
   1
(1 row)
 
Not only are you missing required parentheses and the SELECT keyword,
you're returning a record rather than a scalar value.
 
-Kevin

Responses

pgsql-bugs by date

Next:From: Alexey KlyukinDate: 2011-08-29 13:15:44
Subject: Re: the '::' cast doesn't work in the FROM clause
Previous:From: Itagaki TakahiroDate: 2011-08-29 11:42:45
Subject: BUG #6181: concat_ws() incompatibility with MySQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group