minor error message enhance: print RLS policy name when only one permissive policy exists

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: minor error message enhance: print RLS policy name when only one permissive policy exists
Date: 2025-10-28 02:01:10
Message-ID: CACJufxEHB0GQEcKuGRE5usnQ-Q2CyAWoyFLHVp9qpzH7pbxWuQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

The attached patch did what the $subject says.
demo:

begin;
create role alice login;
grant all on schema public to alice;
drop table if exists tts;
create table tts(a int);
grant insert on tts to alice;
ALTER TABLE tts ENABLE ROW LEVEL SECURITY;
CREATE POLICY p1 ON tts FOR ALL USING (a = 1 or a = 2 or a = 3);
commit;

SET ROLE alice;
insert into tts values (4); --error

old ERROR message:
ERROR: new row violates row-level security policy for table "tts"

new ERROR message:
ERROR: new row violates row-level security policy "p1" for table "tts"

There are fewer than 10 lines of C code changes, but turns out that in the
regression tests, there are many cases where only one permissive policy exists
for INSERT or UPDATE.
So the patch is not smaller.

Attachment Content-Type Size
v1-0001-minor-RLS-violation-error-report-enhance.patch text/x-patch 16.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-10-28 02:40:16 Re: C11: should we use char32_t for unicode code points?
Previous Message Chao Li 2025-10-28 01:47:03 Re: Logical Replication of sequences