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

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(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 11:48:13
Message-ID: CAJpy0uAPqS5me4+5gqA9V+L3YDNU1V8wwZFqJtM_dYsqZUzF2A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 1, 2026 at 4:26 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> 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.

Okay, works for me. I can prepare a doc patch tomorrow unless someone
has a different opinion on it. We can revisit this later (e.g. option
1 or 3) based on user feedback.

thanks
Shveta

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2026-12-01 11:51:27 Re: pg_upgrade: fix use-after-close in cleanup_output_dirs()
Previous Message Heikki Linnakangas 2026-12-01 11:48:11 Re: pg_upgrade: fix use-after-close in cleanup_output_dirs()