Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Merlin Moncure
On Mon, Aug 29, 2011 at 9:00 AM, Kevin Grittner wrote: > Merlin Moncure wrote: > >> yeah, that's the correct way, but why does this work? >> select val from random() as val; > > If you look at the PostgreSQL reference docs for the SELECT > statement, a from_item can be a SELECT statement in paren

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Tom Lane
Alexey Klyukin writes: > On Aug 29, 2011, at 5:47 PM, Tom Lane wrote: >> There is a dump/reload bug though :-( ... if you were to do >> >> create view vv as select val from CAST(random() as integer) as val; >> >> you will find that the system prints it out with the :: syntax, >> which won't wor

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Alexey Klyukin
On Aug 29, 2011, at 5:47 PM, Tom Lane wrote: > "Kevin Grittner" writes: >> Merlin Moncure wrote: >>> yeah, that's the correct way, but why does this work? >>> select val from random() as val; > >> If you look at the PostgreSQL reference docs for the SELECT >> statement, a from_item can be a SE

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Tom Lane
"Kevin Grittner" writes: > Merlin Moncure wrote: >> yeah, that's the correct way, but why does this work? >> select val from random() as val; > If you look at the PostgreSQL reference docs for the SELECT > statement, a from_item can be a SELECT statement in parentheses or a > function call (amo

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Kevin Grittner
"Kevin Grittner" wrote: > test=# select val from (select 'a' = 'a') as val; > val > - > (t) > (1 row) Also note the difference between a record and a scalar here. I forgot to write it to return val as a scalar, which seems to be what you're after. It should have been: test=# select v

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Kevin Grittner
Alexey Klyukin wrote: > On Aug 29, 2011, at 5:02 PM, Kevin Grittner wrote: > >> Alexey Klyukin wrote: >> >>> Function calls can appear in the FROM clause. (This is >>> especially useful for functions that return result sets, but any >>> function can be used.) This acts as though its output were

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Alexey Klyukin
On Aug 29, 2011, at 5:02 PM, Kevin Grittner wrote: > Alexey Klyukin wrote: > >> Function calls can appear in the FROM clause. (This is especially >> useful for functions that return result sets, but any function can >> be used.) This acts as though its output were created as a >> temporary tabl

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Kevin Grittner
Alexey Klyukin wrote: > Function calls can appear in the FROM clause. (This is especially > useful for functions that return result sets, but any function can > be used.) This acts as though its output were created as a > temporary table for the duration of this single SELECT command. It doesn

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Kevin Grittner
Merlin Moncure wrote: > yeah, that's the correct way, but why does this work? > select val from random() as val; If you look at the PostgreSQL reference docs for the SELECT statement, a from_item can be a SELECT statement in parentheses or a function call (among other things). It cannot be an

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Merlin Moncure
On Mon, Aug 29, 2011 at 7:49 AM, Kevin Grittner wrote: > 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: >>

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Alexey Klyukin
On Aug 29, 2011, at 3:49 PM, Kevin Grittner wrote: > 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: >>

Re: [BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Kevin Grittner
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;

[BUGS] the '::' cast doesn't work in the FROM clause

2011-08-29 Thread Alexey Klyukin
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: