Re: RLS creates inaccurate limit and offset results

Поиск
Список
Период
Сортировка
От mike@mikebrancato.com
Тема Re: RLS creates inaccurate limit and offset results
Дата
Msg-id E13131DB-28E5-4F05-A9D8-D54F886230C2@mikebrancato.com
обсуждение исходный текст
Ответ на Re: RLS creates inaccurate limit and offset results  (Christophe Pettus <xof@thebuild.com>)
Ответы Re: RLS creates inaccurate limit and offset results
Re: RLS creates inaccurate limit and offset results
Список pgsql-bugs
On Nov 11, 2025, at 5:10 PM, Christophe Pettus <xof@thebuild.com> wrote:

LIMIT and OFFSET without ORDER BY are not guaranteed to return consistent results even without RLS.  RLS may cause it be more obvious, however.

If I understand the documentation (https://www.postgresql.org/docs/current/queries-limit.html), inconsistent results for different LIMIT / OFFSET values is only a known issue when selecting different subsets of data. Here, I’m seeing inconsistent results on the same subset of data. e.g. OFFSET 0 and OFFSET 1 return the same row without changing the overall query / WHERE clause or LIMIT. This claim seems to hold true without RLS, but with RLS, it adds at least this inconsistent edge case. If this is acceptable, I’d suggest documenting this as a known limitation of RLS that doesn’t require different LIMIT/OFFSET values and different subsets to result in inconsistently ordered data - I’d suspect its due to the POLICY checks that occur with accessing that table.

I ran across this with some failing integration tests for a personal project. Adding RLS started to make some API calls return incorrect information for edge cases that worked previously without RLS.


Mike Brancato

В списке pgsql-bugs по дате отправления: