| From: | Robert Treat <rob(at)xzilla(dot)net> |
|---|---|
| To: | Christoph Berg <myon(at)debian(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Hunaid Sohail <hunaidpgml(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Proposal: SELECT * EXCLUDE (...) command |
| Date: | 2026-02-16 14:24:49 |
| Message-ID: | CABV9wwPVNJJSOnFZhTfAVrotzNXTmKg8H9gyvY+_V9uqw5mhMw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Jan 15, 2026 at 8:15 AM Christoph Berg <myon(at)debian(dot)org> wrote:
>
> Re: Peter Eisentraut
> > => select * exclude (foo) from t1, t2;
> > ERROR: 02000: SELECT list is empty after excluding all columns
> >
> > My paper proposes that this should be an error because foo is ambiguous.
>
> Consider this example:
>
> create table t1(id int, data text, more_data text);
> create table t2(id int, other_data text, different_data text);
>
> Now if you wanted just the data without the surrogate keys, you would
> want to say:
>
> select * exclude (id) from t1 join t2 on t1.id = t2.id;
>
> Having to specify (t1.id, t2.id) would make it cumbersome to use,
> especially considering "exclude" would mostly be useful for
> interactive use.
>
A slightly different but perhaps more compelling version of this would be:
select * exclude (id) from t1 join t2 using (id);
Without the exclude, the returned row would only have a single id
column, so it seems pretty natural to similarly add an exclude for
that single id column.
Robert Treat
https://xzilla.net
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashutosh Bapat | 2026-02-16 14:52:51 | Re: Better shared data structure management and resizable shared data structures |
| Previous Message | Akshay Joshi | 2026-02-16 14:09:46 | [PATCH] pgindent truncates last line of files missing a trailing newline |