| From: | Hunaid Sohail <hunaidpgml(at)gmail(dot)com> |
|---|---|
| To: | Marcos Pegoraro <marcos(at)f10(dot)com(dot)br> |
| Cc: | Robert Treat <rob(at)xzilla(dot)net>, Kacper Kuras <kacperkuras(at)hotmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Christoph Berg <myon(at)debian(dot)org> |
| Subject: | Re: Proposal: SELECT * EXCLUDE (...) command |
| Date: | 2026-10-12 12:37:03 |
| Message-ID: | CAMWA6ya6S1jbOQAMZgNcK15EMFOpSJEm3ioVxPRKrmp_=T_8-w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello,
I didn't find any test with nested EXCLUDE, would be good to see if works
> with fields that were already EXCLUDED and NOT MATERIALIZED to test not
> inlined CTEs
>
> SELECT * (EXCLUDE (id, created_at)) FROM (SELECT * (EXCLUDE (id)) FROM
> users);
> WITH CTE AS NOT MATERIALIZED (SELECT * (EXCLUDE (id, created_at)) FROM
> users) SELECT * (EXCLUDE (id)) FROM CTE;
>
I will add such cases in regression tests.
As of v3, the output of such queries looks like:
-- id already excluded in inner query, email and created_at excluded in
outer query
SELECT * (EXCLUDE (email, created_at)) FROM (SELECT * (EXCLUDE (id)) FROM
users); -- returns name only
name
-------
Alice
Bob
Carol
(3 rows)
-- Trying to exclude id again in outer query (error case)
SELECT * (EXCLUDE (id, created_at)) FROM (SELECT * (EXCLUDE (id)) FROM
users);
ERROR: column "id" does not exist
LINE 1: SELECT * (EXCLUDE (id, created_at)) FROM (SELECT * (EXCLUDE ...
^
-- Trying to exclude id again in outer query (error case)
WITH CTE AS NOT MATERIALIZED (SELECT * (EXCLUDE (id, created_at)) FROM
users)
SELECT * (EXCLUDE (id)) FROM CTE;
ERROR: column "id" does not exist
LINE 2: SELECT * (EXCLUDE (id)) FROM CTE;
^
Regards,
Hunaid Sohail
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hunaid Sohail | 2026-10-12 13:04:17 | Re: Proposal: SELECT * EXCLUDE (...) command |
| Previous Message | Heikki Linnakangas | 2026-10-12 12:34:46 | Re: [PATCH] Fix recovery connection detail in EXEC_BACKEND builds |