Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?

From: Eric Ridge <eebbrr(at)gmail(dot)com>
To: Darren Duncan <darren(at)darrenduncan(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?
Date: 2011-10-30 21:12:39
Message-ID: CANcm6wZjrU6nGdw6FJKQQ4UvZVEMNEdgT+v4OJcCipy8BbB5eg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Oct 30, 2011 at 4:43 PM, Darren Duncan <darren(at)darrenduncan(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Darren Duncan 2011-10-30 22:11:33 Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?
Previous Message Darren Duncan 2011-10-30 20:43:39 Re: Thoughts on "SELECT * EXCLUDING (...) FROM ..."?