Re: pg_restore --no-policies should not restore policies' comment
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-09-04T09:00:02Z
Lists: pgsql-hackers
On Wed, Sep 3, 2025 at 7:50 PM Fujii Masao <masao.fujii@gmail.com> wrote:
>
> > > > 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.
>
>
in _tocEntryRestorePass
if we do
if ((strcmp(te->desc, "COMMENT") == 0 ||
strcmp(te->desc, "SECURITY LABEL") == 0) &&
strncmp(te->tag, "EVENT TRIGGER ", 14) == 0)
return RESTORE_PASS_POST_ACL;
then RestorePass related comments also need to be adjusted for security label?
typedef enum
{
RESTORE_PASS_MAIN = 0, /* Main pass (most TOC item types) */
RESTORE_PASS_ACL, /* ACL item types */
RESTORE_PASS_POST_ACL, /* Event trigger and matview refresh items */
#define RESTORE_PASS_LAST RESTORE_PASS_POST_ACL
} RestorePass;
we do not support security label on extension, see SecLabelSupportsObjectType.
below the dumpExtension function code should be removed?
/* Dump Extension Comments and Security Labels */
if (extinfo->dobj.dump & DUMP_COMPONENT_SECLABEL)
dumpSecLabel(fout, "EXTENSION", qextname,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
Commits
-
pg_dump: Remove unnecessary code for security labels on extensions.
- 762faf702c6f 19 (unreleased) landed
-
pg_restore: Fix security label handling with --no-publications/subscriptions.
- a4dbb11bb9ac 13.23 landed
- bc476f8b8b64 14.20 landed
- 5f42008f9030 15.15 landed
- 0870397ccfbd 16.11 landed
- dc8aa2f586d0 17.7 landed
- 7aecc00b3d66 18.0 landed
- 45f50c995fb6 19 (unreleased) landed
-
pg_dump: Fix dumping of security labels on subscriptions and event triggers.
- dff7591a7041 13.23 landed
- 295c0a644af5 14.20 landed
- 165b07efe4e2 15.15 landed
- 20b23784fc31 16.11 landed
- 968141898777 17.7 landed
- 176002c5bfa6 18.0 landed
- 8e5b92928d28 19 (unreleased) landed
-
pg_restore: Fix comment handling with --no-policies.
- 2ddbfede0c61 18.0 landed
- 66dabc06b1b0 19 (unreleased) landed
-
pg_restore: Fix comment handling with --no-publications / --no-subscriptions.
- 8fbd1f8ea2e1 13.23 landed
- db900ec358bd 14.20 landed
- c8ed16050564 15.15 landed
- 97527a5e68d5 16.11 landed
- f7f9c5d65816 17.7 landed
- 77d2b155caf7 18.0 landed
- b54e8dbfe3b1 19 (unreleased) landed
-
Core support for "extensions", which are packages of SQL objects.
- d9572c4e3b47 9.1.0 cited