| From: | solai v <solai(dot)cdac(at)gmail(dot)com> |
|---|---|
| To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
| Cc: | Viktor Holmberg <v(at)viktorh(dot)net>, Vik Fearing <vik(at)postgresfriends(dot)org>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Allow ON CONFLICT DO UPDATE to return EXCLUDED values |
| Date: | 2026-07-02 06:11:47 |
| Message-ID: | CAF0whud3pcy=pxyRkvZtTMKSKWJufpUD+geb=BUTAN01gybctQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Dean,
I tested the latest v6 patch and it worked well for me.
I first reproduced the current behavior on an unpatched build. As
expected, using EXCLUDED in the RETURNING clause resulted in:
ERROR: invalid reference to FROM-clause entry for table "excluded"
DETAIL: There is an entry for table "excluded", but it cannot be
referenced from this part of the query.
After applying v6-0001-Allow-EXCLUDED-in-RETURNING-list-of-INSERT-ON-CON.patch,
rebuilding PostgreSQL, and rerunning the same test, the query
completed successfully and returned the expected EXCLUDED value.
I also tried a few additional scenarios:
RETURNING age, EXCLUDED.age
Returning multiple EXCLUDED columns
Using EXCLUDED in expressions (e.g. EXCLUDED.age + 10)
Using aliases in the RETURNING list
Testing with different data types (NUMERIC and BOOLEAN)
Verifying that existing RETURNING behavior is unchanged
Verifying that EXCLUDED is NULL when no conflict occurs
Confirming that ON CONFLICT DO NOTHING behavior is unchanged
All of these behaved as expected, and I didn't encounter any issues
during testing.
Overall, the patch looks good to me.
Thanks for working on this.
Best regards,
solai
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-07-02 06:15:06 | Re: Fix jsonpath .decimal() to honor silent mode |
| Previous Message | Kyotaro Horiguchi | 2026-07-02 06:03:49 | Re: Handle concurrent drop when doing whole database vacuum |