Re: [DEPARSE] An alias named 'set' on an UPDATE, DELETE or MERGE target does not read back

From: Henson Choi <assam258(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [DEPARSE] An alias named 'set' on an UPDATE, DELETE or MERGE target does not read back
Date: 2026-10-19 13:32:52
Message-ID: CAAAe_zBO3PdEJn2JeO0T5Gf3_EbCYoWE73Bi9cCRHK4iLSKugA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom,

> Another good catch, but here again I find your solution
> overcomplicated and perhaps not very future-proof. Let's just
> emit AS all the time in these statements.

Agreed. The attached v2 writes AS before the alias of an UPDATE,
DELETE or MERGE target every time, as INSERT already does.

The tests are trimmed to UPDATE and DELETE in rules and MERGE in
a BEGIN ATOMIC function body, each with a target aliased "set"
and recreated from its deparsed text. Existing output in rules and
returning changes too, as in UPDATE rules_log AS trgt SET ... . The
full regression suite passes on master.

This changes the deparsed text of every aliased target. AS has been
accepted there in all supported branches, and the code change applies
cleanly to REL_15 through REL_19. I built each branch and ran the
regression tests.

Best regards,
Henson

Attachment Content-Type Size
v2-0001-Add-tests-for-a-relation-alias-named-SET-in-DML-t.patch application/octet-stream 4.8 KB
v2-0002-Always-write-AS-before-the-alias-of-a-DML-target.patch application/octet-stream 8.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2026-10-19 13:36:55 Re: Allow table AMs to define their own reloptions
Previous Message Ilia Evdokimov 2026-10-19 13:31:44 Re: Improve Hash/Merge Join estimate accuracy when all predicates are Hash/Merge clauses