Re: Note on scalar subquery syntax - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Note on scalar subquery syntax
Date
Msg-id 20050803181145.GA7409@svana.org
Whole thread Raw
In response to Note on scalar subquery syntax  (Kevin Murphy <murphy@genome.chop.edu>)
Responses Re: Note on scalar subquery syntax
List pgsql-general
On Wed, Aug 03, 2005 at 09:40:26AM -0400, Kevin Murphy wrote:
> You have to wrap a scalar subquery in its own parentheses even where you
> might think it to be unnecessary, such as when the subquery is the sole
> argument to a function.

It first guess I imagine it is because the syntax becomes ambiguous,
expecially if you have multiple arguments to the function.

Say you a function "func" and your query was: SELECT * FROM x ORDER BY y

Then this isn't parsable obviously:

SELECT func( SELECT * FROM x ORDER BY y, 1, 1 ) )

Since you don't know where the ORDER BY ends and the function list
continues. Adding parenthesis at the appropriate point removes the
ambiguity.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Ragnar Hafstað
Date:
Subject: Re: postgresql.conf value need advice
Next
From: CSN
Date:
Subject: pg_dump - dump specific functions and other items?