Re: pg_restore --no-policies should not restore policies' comment

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_restore --no-policies should not restore policies' comment
Date: 2025-09-03 11:50:09
Message-ID: CAHGQGwHeMNWECh7qdVoJBHJN_CnWTqJw99qGdriuDOY-V+6Leg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 27, 2025 at 3:18 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> > Since --no-publications and --no-subscriptions have been around for a long time,
> > while --no-policies was added in v18, I wonder if it makes sense to first fix
> > the publications and subscriptions cases (and add tests for them) and back-patch
> > to all supported versions. Then we can handle the policies case and
> > back-patch it
> > only to v18. Does that sound reasonable?
> >
> works for me.

So I've split your v2-0001 patch into two patches:

* v4-0001 handles comments on publications and subscriptions when
--no-publications / --no-subscriptions are specified. This will be
backpatched to all supported versions.

* v4-0002 handles comments on policies when --no-policies is specified.
This will be backpatched to v18, where --no-policies was added.

Both v4-0001 and v4-0002 are based on your patch, but I added
regression tests for them.

> > > 02: make pg_dump dump security label for shared database objects, like
> > > subscription, roles.

As I understand it, shared objects like roles are handled by pg_dumpall,
which already dumps their security labels via pg_shseclabel.
Subscriptions are an exception: pg_dump dumps them (and should dump
their security labels), but those labels are stored in pg_shseclabel,
which pg_dump doesn't query.

To fix this, making pg_dump query also pg_shseclabel when dumping
subscriptions would work. But your approach, having pg_dump query
pg_seclabels (covering both pg_seclabel and pg_shseclabel),
is simpler and sufficient. So I like your approach for now.

I also noticed pg_dump didn't dump security labels on event triggers,
so I extended your patch as v4-0003 to handle those as well.

> > > 03: make pg_restore not restore security labels if the associated
> > > object is excluded.

This patch looks good. I only applied minor cosmetic changes and
attached it as v4-0004.

Regards,

--
Fujii Masao

Attachment Content-Type Size
v4-0001-PG17-pg_restore-Fix-comment-handling-with-no-publicati.txt text/plain 4.4 KB
v4-0001-PG18-master-pg_restore-Fix-comment-handling-with-no-publicati.patch application/octet-stream 4.4 KB
v4-0001-PG16-pg_restore-Fix-comment-handling-with-no-publicati.txt text/plain 4.9 KB
v4-0001-PG15-pg_restore-Fix-comment-handling-with-no-publicati.txt text/plain 4.3 KB
v4-0001-PG13-PG14-pg_restore-Fix-comment-handling-with-no-publicati.txt text/plain 4.3 KB
v4-0004-pg_restore-Fix-security-label-handling-with-no-pu.patch application/octet-stream 1.9 KB
v4-0003-pg_dump-Fix-dumping-of-security-labels-on-subscri.patch application/octet-stream 3.1 KB
v4-0002-pg_restore-Fix-comment-handling-with-no-policies.patch application/octet-stream 4.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2025-09-03 11:51:55 Re: Refactoring: Use soft error reporting for *_opt_error functions
Previous Message Daniel Gustafsson 2025-09-03 11:42:56 Re: Solaris compiler status