| From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
|---|---|
| To: | Tender Wang <tndrwang(at)gmail(dot)com> |
| Cc: | Joao Rito <joaovictor(dot)rito(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: MERGE fails to reject source references in NOT MATCHED BY SOURCE actions |
| Date: | 2026-11-23 09:29:39 |
| Message-ID: | CAEZATCXcYV3CkR-CYvPs9iGHMCZUNjTxobF3RF4ePAHj=muRmA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
BTW, while looking at this, I noticed that the docs for the
"condition" expression that can appear after MERGE ... WHEN ... AND
currently say:
A condition on a WHEN MATCHED clause can refer to columns in both the
source and the target relations. A condition on a WHEN NOT MATCHED BY
SOURCE clause can only refer to columns from the target relation, since
by definition there is no matching source row. A condition on a WHEN
NOT MATCHED [BY TARGET] clause can only refer to columns from the source
relation, since by definition there is no matching target row. Only the
system attributes from the target table are accessible.
That last sentence has existed since MERGE was added and it seems wrong to me.
In fact, I find that sentence hard to interpret -- there are multiple
possible interpretations, none of which seem to be true.
It could mean that, when accessing the target relation, the condition
can only refer to system attributes, not user-defined attributes,
which certainly isn't true.
Or it could mean that system attributes from the target table are
accessible, but system attributes from the source are not. That may
have been true at some point during the development of the MERGE
feature, but it's not true now -- if the source is a base table, its
system attributes are accessible.
Or it could be trying to document an exception to the previous
sentence -- a condition on a WHEN NOT MATCHED clause can't refer to
attributes of the target row, since there is no target row, but an
exception is made for system attributes. But that isn't true either --
there is no such exception.
So I propose simply deleting that sentence.
Regards,
Dean
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-doc-Remove-incorrect-sentence-from-MERGE-docs-for.patch.no-cfbot | application/octet-stream | 1.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andreas Karlsson | 2026-11-23 09:44:05 | Re: Proposal: ABSENT ON TRAILING NULL for JSON_ARRAY |
| Previous Message | shveta malik | 2026-11-23 09:25:55 | Re: Per-table resync for logical replication subscriptions |