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

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: 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 19:20:08
Message-ID: CAHyXU0wyZPjR1iC7yKzTn8t1ZD4vXMPQW8PwdbxFeDH+aCm9uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Aug 29, 2011 at 9:00 AM, Kevin Grittner
<Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
> Merlin Moncure <mmoncure(at)gmail(dot)com> 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 arbitrary
> expression containing operators (like ::).

right -- duh. I knew that...the canonical case for this is the
definition of pg_locks view. I've just never seen it used for a
regular scalar function. The whole thing is pretty peculiar IMO (but
useful occasionally).

merlin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Thorvald Natvig 2011-08-29 22:02:12 BUG #6183: FATAL: canceling authentication due to timeout
Previous Message Steven Williams 2011-08-29 17:19:48 BUG #6182: /etc/init.d/postgresql-8.4 is incomplete for chkconfig