Re: Proposal: SELECT * EXCLUDE (...) command

From: Kacper Kuras <kacperkuras(at)hotmail(dot)com>
To: Hunaid Sohail <hunaidpgml(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Christoph Berg <myon(at)debian(dot)org>, Robert Treat <rob(at)xzilla(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: SELECT * EXCLUDE (...) command
Date: 2026-12-05 16:47:43
Message-ID: VI0P193MB3111CA802702E1565A613B41BF492@VI0P193MB3111.EURP193.PROD.OUTLOOK.COM
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hunaid,

Looking at v4 again (rebased onto current master), I found three more
issues.

1. Qualified names in star options are looked up only at the current
query level, which breaks them when the star refers to a table of
an outer query:

SELECT * FROM users u
CROSS JOIN LATERAL (SELECT u.* (EXCLUDE (o.id))
FROM orders o LIMIT 1) s;

silently excludes u.id (o and u both have range table index 1),
while

SELECT EXISTS (SELECT u.* (EXCLUDE (u.id)) FROM orders o)
FROM users u;

fails with "invalid reference to FROM-clause entry for table "u"".
Passing &sublevels_up to refnameNamespaceItem() in
starOptionMatchesColumn() and comparing it with varlevelsup fixed
both for me, and the regression tests still pass.

2. REPLACE in RETURNING bypasses the RETURNING checks, because
applyStarOptions() always transforms the expression with
EXPR_KIND_SELECT_TARGET:

UPDATE orders SET amount = 1 WHERE id = 1
RETURNING * (REPLACE (amount WITH count(*)));

fails with the internal "Aggref found in non-Agg plan node" instead
of "aggregate functions are not allowed in RETURNING". Window and
set-returning functions slip through the same way.
transformTargetList() already has the expression kind, so it could
be passed down instead.

3. RENAME takes ColId, while AS in a select list takes ColLabel, so
SELECT id AS default works, but * (RENAME (id AS default)) is a
syntax error.

Regards,
Kacper Kuras

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Alexander Korotkov 2026-12-05 16:33:17 Re: test: avoid redundant standby catchup in 049_wait_for_lsn