pgsql: Enforce WITH CHECK OPTION on DELETE FOR PORTION OF leftovers

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Enforce WITH CHECK OPTION on DELETE FOR PORTION OF leftovers
Date: 2026-08-14 11:54:49
Message-ID: E1wuqUq-00000000Xyp-0IMz@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Enforce WITH CHECK OPTION on DELETE FOR PORTION OF leftovers

DELETE FOR PORTION OF inserts temporal leftovers through ExecInsert(),
but the rewriter only attached view WCOs for INSERT/UPDATE. Leftover
rows could therefore silently escape a WITH CHECK OPTION view, while
the equivalent UPDATE correctly raised an error.

This commit fixes it by attaching the WCOs for FOR PORTION OF deletes
too.

Author: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Co-authored-by: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
Reviewed-by: solai v <solai(dot)cdac(at)gmail(dot)com>
Reviewed-by: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/CAN4CZFOuTyhGspG0Nyits8PiK2keoNXkLj-u3APzc66aRcWY9A%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9924e2d900bf833c1d732d4bf877f51269b03157

Modified Files
--------------
doc/src/sgml/ref/create_view.sgml | 20 ++++++----
src/backend/rewrite/rewriteHandler.c | 8 +++-
src/test/regress/expected/updatable_views.out | 56 +++++++++++++++++++++++++++
src/test/regress/sql/updatable_views.sql | 29 ++++++++++++++
4 files changed, 104 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2026-08-14 13:23:17 pgsql: Make generate_queries_for_path_pattern_recurse() interruptible
Previous Message Etsuro Fujita 2026-08-14 08:50:23 pgsql: postgres_fdw: Rename option "restore_stats" to "import_stats".