Re: ALTER DEFAULT PRIVILEGES IN SCHEMA pg_conflict silently has no effect

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, shveta malik <shvetamalik(at)gmail(dot)com>
Subject: Re: ALTER DEFAULT PRIVILEGES IN SCHEMA pg_conflict silently has no effect
Date: 2026-12-01 10:56:09
Message-ID: CAA4eK1L7-19VusD8+eR+0r0p6dg7L-PC0Vx=JkPzOPmBY5g6mA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 1, 2026 at 2:49 PM shveta malik <shveta(dot)malik(at)gmail(dot)com> wrote:
>
> While reviewing another patch related to CLT, I noticed a concerning
> behaviour on HEAD:
>
> 'ALTER DEFAULT PRIVILEGES IN SCHEMA pg_conflict' is accepted, but the
> privileges are not applied to newly created CLTs. This is because
> create_conflict_log_table() passes use_user_acl = false to
> heap_create_with_catalog(). So the command silently has no effect. See
> testcase [1]
>
> I think this needs handling because CLTs are meant to be queried by
> users, and a new CLT gets created for each subscription. So a user
> wanting a role (e.g. for monitoring) to read all CLTs would tend to
> use ALTER DEFAULT PRIVILEGES, and would get no error or warning that
> it did nothing.
>
> Note that ALTER DEFAULT PRIVILEGES IN SCHEMA pg_toast is also accepted
> and not applied to new toast tables, but that does not matter there,
> as non-superusers have no USAGE on pg_toast and access toast data only
> through the parent table. CLTs, on the other hand, are meant to be
> queried by users, so here the user would expect it to work. Thoughts?
>
> If others also think that this at least needs some handling, here are
> the options:
>
> 1) Emit an error for this command (modify
> ExecAlterDefaultPrivilegesStmt?), something like:
> ERROR: cannot set default privileges in schema "pg_conflict"
>
> 2) Document that default privileges are not applied to conflict log
> tables, and that privileges must be granted on each CLT after it is
> created.
>
> 3) Let the default privileges be applied to the CLTs (use_user_acl =
> true), as the user may need it for monitoring purposes, and thus may
> not need to grant privileges on each individual CLT. Note that with
> this, global default privileges of the subscription owner (ALTER
> DEFAULT PRIVILEGES FOR ROLE ... without IN SCHEMA) will also get
> applied to the CLTs.
>

In option-3, I am worried that we are giving unintended access to the
system managed table to a specified role via ALTER DEFAULT PRIVILEGES
FOR ROLE ... We can go with option-2 or 1, I would prefer option-2 to
keep the behavior similar to toast and let users explicitly assign
privilege to access CLT.

--
With Regards,
Amit Kapila.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2026-12-01 11:00:30 Re: Preserve conflict log table during upgrade
Previous Message John Naylor 2026-12-01 10:29:41 Re: [PATCH] Avoid copying tuples that a bounded sort will discard