]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix UPDATE/DELETE ... WHERE CURRENT OF on a table with virtual columns.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Wed, 22 Apr 2026 10:50:18 +0000 (11:50 +0100)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Wed, 22 Apr 2026 10:50:18 +0000 (11:50 +0100)
commitf3d03fbd5d017c8e8e42a3b3bcca696cfd94a8c3
tree7a9422a24a438731f56e20006705bafac263ec46
parentcf38dedf693a17f9317d8ed85ab7468afebf8cbf
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
src/backend/parser/analyze.c
src/backend/rewrite/rewriteManip.c
src/test/regress/expected/generated_virtual.out
src/test/regress/expected/portals.out
src/test/regress/sql/generated_virtual.sql
src/test/regress/sql/portals.sql