UPDATE/DELETE FOR PORTION OF may insert leftover rows to preserve the parts of the old row that are outside the target range. Those inserts go through ExecInsert(), which checks RLS policies using WCO_RLS_INSERT_CHECK. However, the rewriter only added RLS WITH CHECK options for the original statement command. For UPDATE, that meant only WCO_RLS_UPDATE_CHECK options were available, so ExecInsert() skipped them. For DELETE, no RLS WITH CHECK options were added at all. As a result, leftover rows could be inserted even when they violated INSERT RLS policies. Fix this by adding INSERT RLS WITH CHECK options for UPDATE/DELETE FOR PORTION OF target relations. Also add regression coverage for both UPDATE and DELETE, including cases where allowed leftovers still succeed and disallowed leftovers are rejected. Author: Chao Li <lic@highgo.com> Co-authored-by: Paul A Jungwirth <pj@illuminatedcomputing.com> Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com> Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6C34A987-AC50-4477-BD71-2D4AFEE1A589%40gmail.com Discussion: https://www.postgresql.org/message-id/flat/CAJTYsWWdeBkoH5g8D-k9LDw9ciqsMxb21EJSiFXAzP4J%3DXyxOQ%40mail.gmail.com
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/19/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/19/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.