postgresql/src/backend/rewrite
Dean Rasheed f3d03fbd5d Fix UPDATE/DELETE ... WHERE CURRENT OF on a table with virtual columns.
Formerly, attempting to use WHERE CURRENT OF to update or delete from
a table with virtual generated columns would fail with the error
"WHERE CURRENT OF on a view is not implemented".

The reason was that the check preventing WHERE CURRENT OF from being
used on a view was in replace_rte_variables_mutator(), which presumed
that the only way it could get there was as part of rewriting a query
on a view. That is no longer the case, since replace_rte_variables()
is now also used to expand the virtual generated columns of a table.

Fix by doing the check for WHERE CURRENT OF on a view at parse time.
This is safe, since it is no longer possible for the relkind to change
after the query is parsed (as of b23cd185f).

Reported-by: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Author: Dean Rasheed <dean.a.rasheed@gmail.com>
Discussion: https://postgr.es/m/CAHg+QDc_TwzSgb=B_QgNLt3mvZdmRK23rLb+RkanSQkDF40GjA@mail.gmail.com
Backpatch-through: 18
2026-04-22 11:50:18 +01:00
..
Makefile SEARCH and CYCLE clauses 2021-02-01 14:32:51 +01:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
rewriteDefine.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
rewriteHandler.c Fix incorrect NEW references to generated columns in rule rewriting 2026-04-21 14:29:33 +09:00
rewriteManip.c Fix UPDATE/DELETE ... WHERE CURRENT OF on a table with virtual columns. 2026-04-22 11:50:18 +01:00
rewriteRemove.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
rewriteSearchCycle.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
rewriteSupport.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
rowsecurity.c Update copyright for 2025 2025-01-01 11:21:55 -05:00