Seeking Guidance on Fixing the Cyclic RLS Policy / Infinite Recursion Bug in PostgreSQL

Started by Aditya Dave6 months ago2 messageshackers

Thread notes

1 note#bug
hackorum-bot#bug
hackorum-bot
2 days ago

@global #bug

#bug
Jump to latest
#1Aditya Dave
daveaditya2004@gmail.com

Respected Sir,

I am Aditya, a student currently working on a research project with my
professor, where we are addressing the cyclic RLS policy problem in
PostgreSQL.

The issue is that when a SECURITY DEFINER UDF is not used and the rewriter
encounters a cyclic policy, PostgreSQL throws an "infinite recursion" error
in the terminal. This behavior is also acknowledged in the official
PostgreSQL test cases. Our goal is to find a solution to this problem and
potentially contribute the fix to the PostgreSQL community.

It would be incredibly valuable to have your guidance on this. Being able
to solve this problem in PostgreSQL would be a significant achievement, and
I believe your expertise could greatly help us move in the right direction.

Thank you for your time and consideration.

Regards,
Aditya.

#2Ashutosh Bapat
ashutosh.bapat.oss@gmail.com
In reply to: Aditya Dave (#1)
Re: Seeking Guidance on Fixing the Cyclic RLS Policy / Infinite Recursion Bug in PostgreSQL

Hi Aditya,

On Thu, May 28, 2026 at 6:55 PM Aditya Dave <daveaditya2004@gmail.com> wrote:

Respected Sir,

I am Aditya, a student currently working on a research project with my professor, where we are addressing the cyclic RLS policy problem in PostgreSQL.

The issue is that when a SECURITY DEFINER UDF is not used and the rewriter encounters a cyclic policy, PostgreSQL throws an "infinite recursion" error in the terminal. This behavior is also acknowledged in the official PostgreSQL test cases. Our goal is to find a solution to this problem and potentially contribute the fix to the PostgreSQL community.

It would be incredibly valuable to have your guidance on this. Being able to solve this problem in PostgreSQL would be a significant achievement, and I believe your expertise could greatly help us move in the right direction.

I am not sure whether that's a problem that the community wants to
solve or not. But you should start from there. Motivation: explain why
this is a problem worth solving? Are there real world use cases which
could benefit? Do you have examples? Do other widely used DBMSes solve
it? Then we would mostly expect you to have understood the problem -
why does that restriction exist? What would be required to lift that
restriction? Are there any hazards doing so? How would we take care of
these hazards? People will be willing to help if they are convinced
that you have worked on it yourself and helping you wouldn't waste
their limited time.

--
Best Wishes,
Ashutosh Bapat