Re: Docs and tests for RLS policies applied by command type

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Viktor Holmberg <v(at)viktorh(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Subject: Re: Docs and tests for RLS policies applied by command type
Date: 2025-10-23 08:22:27
Message-ID: CACJufxF2HdverWh9mo9HZ=skQeHVuApzuHwJmdaLGMHAJ+JWDw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 21, 2025 at 12:01 AM Viktor Holmberg <v(at)viktorh(dot)net> wrote:
>
> So patch 0001, attached, adds a new set of regression tests, near the
> start of rowsecurity.sql, which specifically tests which policies are
> applied for each command variant.
>
hi.
I only applied the 0001.

it would be better to add some comments to the regress tests, IMHO.
for example, for below:
+SELECT * FROM rls_test_src FOR UPDATE;
+SELECT * FROM rls_test_src FOR NO KEY UPDATE;
+SELECT * FROM rls_test_src FOR SHARE;
+SELECT * FROM rls_test_src FOR KEY SHARE;

we could add a comment such as:
"Expect both UPDATE and the SELECT command policies to be invoked for
these four below query".

seems missing tests for INSERT ... ON CONFLICT DO NOTHING
which only INSERT policy to be invoked.

The 0001 regess tests define several functions: sel_using_fn,
ins_check_fn, upd_using_fn,
upd_check_fn, and del_using_fn.
IMHO, these could be simplified (we probably only need two functions).

see the attached version for my attempt to reduce them.

Attachment Content-Type Size
v2-0001-refactor-New-RLS-tests-to-test-policies-applied-by-command-typ.no-cfbot application/octet-stream 8.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-10-23 08:22:33 Re: Making pg_rewind faster
Previous Message Потапов Александр 2025-10-23 08:20:05 PG version is not shown in pg_upgrade test log