Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."? - Mailing list pgsql-hackers

From Eric Ridge
Subject Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?
Date
Msg-id CANcm6wZjrU6nGdw6FJKQQ4UvZVEMNEdgT+v4OJcCipy8BbB5eg@mail.gmail.com
Whole thread Raw
In response to Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?  (Darren Duncan <darren@darrenduncan.net>)
Responses Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?
Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?
List pgsql-hackers
On Sun, Oct 30, 2011 at 4:43 PM, Darren Duncan <darren@darrenduncan.net> wrote:

>  SELECT foo.* EXCLUDING foo.x, bar.* EXCLUDING bar.y, baz.z, (a+b) AS c FROM
> ...
> Is that where you're going with this?

Yes.  It's basically a modifier to the star that immediately precedes
it.  In order to support excluding multiple columns, it needs parens:    SELECT foo.* EXCLUDING (foo.x, foo.y), bar.*
EXCLUDING(bar.y), 
baz.z, (a+b) AS c

but yes, that's what I'm thinking.  I think doing this will require
more changes to the grammar than I had first thought because there'd
be no point in supporting:    SELECT foo.* EXCLUDING (foo.* EXCLUDING foo.y) FROM ...
It looks like the above would be implicitly allowed without a bit of extra work.

But, if you've got a complex query consisting of a few joins, it'd be
nice to say:    SELECT * EXCLUDING (table1.*, table2.x) FROM table1 INNER JOIN table2 ...

> If so, I think that would make the feature even more valuable and more
> syntactically clean than I had previously thought.

I don't actually like the term "EXCLUDING", but it conveys what's
happening and is already defined as a keyword.  I thought about
"EXCEPT", but that doesn't work for obvious reasons, and "NOT" might
just be confusing.

eric


pgsql-hackers by date:

Previous
From: Darren Duncan
Date:
Subject: Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?
Next
From: Darren Duncan
Date:
Subject: Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?