Re: [HACKERS] Polymorphic arguments and composite types

2007-10-06 Thread Stephan Szabo
On Sat, 6 Oct 2007, Simon Riggs wrote: > On Sat, 2007-10-06 at 10:15 -0700, Stephan Szabo wrote: > > > > Yeh, it does, but you're forgetting that my original complaint was that > > > you couldn't use it in an ANY clause, which 4.2 does not exclude. > > > Bearing in mind you can use a scalar subqu

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-06 Thread Simon Riggs
On Sat, 2007-10-06 at 10:15 -0700, Stephan Szabo wrote: > > Yeh, it does, but you're forgetting that my original complaint was that > > you couldn't use it in an ANY clause, which 4.2 does not exclude. > > Bearing in mind you can use a scalar subquery in lots of places, I > > thought it worth repo

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-06 Thread Stephan Szabo
On Fri, 5 Oct 2007, Simon Riggs wrote: > On Fri, 2007-10-05 at 11:24 -0700, Stephan Szabo wrote: > > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > > > On Fri, 2007-10-05 at 10:59 -0700, Stephan Szabo wrote: > > > > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > > > > > > > On Fri, 2007-10-05 at 10:32

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Simon Riggs
On Fri, 2007-10-05 at 11:24 -0700, Stephan Szabo wrote: > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > On Fri, 2007-10-05 at 10:59 -0700, Stephan Szabo wrote: > > > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > > > > > On Fri, 2007-10-05 at 10:32 -0700, Stephan Szabo wrote: > > > > > On Fri, 5 Oct

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Stephan Szabo
On Fri, 5 Oct 2007, Simon Riggs wrote: > On Fri, 2007-10-05 at 10:59 -0700, Stephan Szabo wrote: > > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > > > On Fri, 2007-10-05 at 10:32 -0700, Stephan Szabo wrote: > > > > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > > > > > > > Because we already do exact

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Simon Riggs
On Fri, 2007-10-05 at 10:59 -0700, Stephan Szabo wrote: > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > On Fri, 2007-10-05 at 10:32 -0700, Stephan Szabo wrote: > > > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > > > > > Because we already do exactly that here: > > > > > > > > select 1, (sele

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Stephan Szabo
On Fri, 5 Oct 2007, Simon Riggs wrote: > On Fri, 2007-10-05 at 10:32 -0700, Stephan Szabo wrote: > > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > > > Because we already do exactly that here: > > > > > > select 1, (select col2 from c), 3; > > > > > > The inner select returns a ROW, yet we treat

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Simon Riggs
On Fri, 2007-10-05 at 10:32 -0700, Stephan Szabo wrote: > On Fri, 5 Oct 2007, Simon Riggs wrote: > > > Because we already do exactly that here: > > > > select 1, (select col2 from c), 3; > > > > The inner select returns a ROW, yet we treat it as a single column > > value. > > The inner select

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Simon Riggs
On Fri, 2007-10-05 at 13:18 -0400, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > I'll look at documenting that. > > I think the problem here is you've not bothered to read the manual, > because all of these behaviors *are* documented; two of them are > furthermore required by the S

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Stephan Szabo
On Fri, 5 Oct 2007, Simon Riggs wrote: > Because we already do exactly that here: > > select 1, (select col2 from c), 3; > > The inner select returns a ROW, yet we treat it as a single column > value. The inner select does not return a row. It's not a , it's a . ---

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > I'll look at documenting that. I think the problem here is you've not bothered to read the manual, because all of these behaviors *are* documented; two of them are furthermore required by the SQL standard. regards, tom lane --

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Simon Riggs
On Fri, 2007-10-05 at 11:42 -0400, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > 1. Why doesn't the subselect work? > > Because x = ANY (SELECT y FROM ...) is defined by the SQL standard to > involve performing x = y at each row of the SELECT output. There's > no wiggle room there

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Simon Riggs
On Fri, 2007-10-05 at 09:46 -0700, Jeff Davis wrote: > On Fri, 2007-10-05 at 12:29 -0400, Tom Lane wrote: > > The one-element-array trick seems a bit awkward though. I wonder > > why we don't have an "anyelement <@ anyarray" kind of operator... > > I thought we did -- until I decided to test my

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Jeff Davis
On Fri, 2007-10-05 at 12:29 -0400, Tom Lane wrote: > Jeff Davis <[EMAIL PROTECTED]> writes: > > You could do something like: > > SELECT * FROM c AS c1, c AS c2 WHERE ARRAY[c1.col1] <@ ANY(SELECT c2.col2); > > Good point --- actually he could convert it back to the original > subselect style, as lo

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Tom Lane
Jeff Davis <[EMAIL PROTECTED]> writes: > You could do something like: > SELECT * FROM c AS c1, c AS c2 WHERE ARRAY[c1.col1] <@ ANY(SELECT c2.col2); Good point --- actually he could convert it back to the original subselect style, as long as he's using the correct operator: SELECT * FROM c WHERE A

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Jeff Davis
On Fri, 2007-10-05 at 16:04 +0100, Simon Riggs wrote: > > select * from c, c as c2 where c.col1 = any (c2.col2) > > That works, thanks. > > As I said, I already solved the problem a different way. I was looking > to understand the 3 questions I raised along the way. > > Can you throw any light

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > 1. Why doesn't the subselect work? Because x = ANY (SELECT y FROM ...) is defined by the SQL standard to involve performing x = y at each row of the SELECT output. There's no wiggle room there. The standard does not specify any meaning for x = ANY (not-a

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Simon Riggs
On Fri, 2007-10-05 at 10:52 -0400, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > ...which is fine on just one table, but I want to join... > > > postgres=# select * from c where col1 = any (select col2 from c); > > ERROR: operator does not exist: integer = integer[] > > That isn'

Re: [HACKERS] Polymorphic arguments and composite types

2007-10-05 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > ...which is fine on just one table, but I want to join... > postgres=# select * from c where col1 = any (select col2 from c); > ERROR: operator does not exist: integer = integer[] That isn't a join. Are you looking for something like select * from c, c