pg_dump & RLS

From: Eduard Català <eduard(dot)catala(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: pg_dump & RLS
Date: 2020-08-21 19:02:47
Message-ID: CAL54xNZO-9hv+mYJ-0vPzmf_yuj99LfHLiffwOec+KnXj33kfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,
Sorry if this is not the appropriate list, I think so.

- ¿is posible to export using pg_dump only the rows that satisfy a rls
check?
- Of course, yes, use the --enable-row-security option in pg_dump
- Yes, but my RLS expression relies on a GUC:
CREATE POLICY my_policy ON my_table USING (company_id =
*current_setting('company_id')::int*);
Prior to starting dumping I need to set the company_id GUC into the
session, if not, there's no way to only export some rows.

Any ideas?
- Execute a command before starting the export
- Some kind of login trigger for a special user
- ...

Thank you!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2020-08-21 19:08:19 Re: pg_dump & RLS
Previous Message Achilleas Mantzios 2020-08-21 17:49:17 Re: pgbouncer bug?