Re: Fix RLS checks for UPDATE/DELETE FOR PORTION OF leftover rows - Mailing list pgsql-hackers

From Chao Li
Subject Re: Fix RLS checks for UPDATE/DELETE FOR PORTION OF leftover rows
Date
Msg-id 07EF5F4D-4AA3-4C21-8868-9ACC0D8B6655@gmail.com
Whole thread
Responses Re: Fix RLS checks for UPDATE/DELETE FOR PORTION OF leftover rows
List pgsql-hackers

> On Jun 30, 2026, at 15:51, Ayush Tiwari <ayushtiwari.slg01@gmail.com> wrote:
>
> Hi,
>
> On Tue, 30 Jun 2026 at 13:16, Chao Li <li.evan.chao@gmail.com> wrote:
> Hi,
>
> While revisiting “[8e72d914c] Add UPDATE/DELETE FOR PORTION OF”, I found a new issue where inserting leftover rows
mayskip row-level security checks. 
>
> Please see if it is the same as this:  PostgreSQL: Enforce INSERT RLS checks for FOR PORTION OF leftovers?
>
> If yes, it is already present in the PG 19 open list.
>
> Regards,
> Ayush

Thanks for pointing that out. I didn’t notice that thread.

Yes, that’s the same issue. I saw Paul wrote this there:
```
Skipping the RLS checks to insert the leftovers seems like the correct
behavior to me, since we are skipping the ACL checks (per the
standard). Shouldn't it be consistent?
I think the reason we skip the checks is that semantically, the
leftovers aren't changing anything: they are preserving the history
that is already there.
```

That explains why the ACL checks are skipped as stated in the doc, but I don’t think the same reasoning should apply to
RLSchecks. As I explained in my patch email, for example, directly inserting [70,100) is blocked by policy t_ins, but a
usercan work around that by inserting [1,100) and then updating [30,70), which seems like a security hole. 

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Ashutosh Sharma
Date:
Subject: Re: Support EXCEPT for ALL SEQUENCES publications
Next
From: Michael Paquier
Date:
Subject: Re: Add pg_stat_kind_info system view