comment/security label for publication/subscription

Started by Peter Eisentrautover 9 years ago5 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliessuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t36319
psql -h localhost -U postgres

Built from patchset v5 (message #5), September 20, 2026 at 03:29 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t36319_5 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t36319_5 && git checkout t36319_5

Patchset v5 (message #5) is on t36319_5

Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

Here is a patch to add COMMENT support for publications and subscriptions.

On a similar issue, do we need SECURITY LABEL support for those? Does
that make sense?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

t36319_1
0001-Add-COMMENT-support-for-publications-and-subscriptio.patchinvalid/octet-stream; name=0001-Add-COMMENT-support-for-publications-and-subscriptio.patchDownload+39-1
#2Robert Haas
robertmhaas@gmail.com
In reply to: Peter Eisentraut (#1)
Re: comment/security label for publication/subscription

On Fri, Mar 24, 2017 at 12:18 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

Here is a patch to add COMMENT support for publications and subscriptions.

On a similar issue, do we need SECURITY LABEL support for those? Does
that make sense?

IMHO, it's good to have COMMENT and SECURITY LABEL support for pretty
much everything.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Stephen Frost
sfrost@snowman.net
In reply to: Robert Haas (#2)
Re: comment/security label for publication/subscription

* Robert Haas (robertmhaas@gmail.com) wrote:

On Fri, Mar 24, 2017 at 12:18 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:

Here is a patch to add COMMENT support for publications and subscriptions.

On a similar issue, do we need SECURITY LABEL support for those? Does
that make sense?

IMHO, it's good to have COMMENT and SECURITY LABEL support for pretty
much everything.

+1

Thanks!

Stephen

#4Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#1)
Re: [HACKERS] comment/security label for publication/subscription

Hi,

On 2017-03-24 00:18:26 -0400, Peter Eisentraut wrote:

Here is a patch to add COMMENT support for publications and subscriptions.

On a similar issue, do we need SECURITY LABEL support for those? Does
that make sense?

It looks like this was committed (87dee41f3ed).

Unfortunately I found, during an investigation of something completely
independent, that it leads to comments and (and presumably security labels) to
be orphaned on DROP.

In fact, our regression database actually contains such an orphaned comment:

regression[1536656][1]=# SELECT * FROM pg_description WHERE classoid = 'pg_subscription'::regclass;
┌────────┬──────────┬──────────┬───────────────────┐
│ objoid │ classoid │ objsubid │ description │
├────────┼──────────┼──────────┼───────────────────┤
│ 123718 │ 6100 │ 0 │ test subscription │
└────────┴──────────┴──────────┴───────────────────┘
(1 row)

Seems we need to beef up oidjoins.sql to find orphaned objects.

I can't entirely blame this commit, it seems pretty cruddy that the drop
routine of every global object needs to have a synchronized copy of various
Delete* routines. It's bad enough that drop functions for global objects need
to know about having to drop dependencies manually, but copying the set of
objects that need to be dropped in each seems like a bad idea.

Trivial repro:

DROP SUBSCRIPTION IF EXISTS s;

CREATE SUBSCRIPTION s CONNECTION '' PUBLICATION p
WITH (connect = false, slot_name = NONE);
COMMENT ON SUBSCRIPTION s IS 'leaked';
DROP SUBSCRIPTION s;

SELECT * FROM pg_description WHERE classoid = 'pg_subscription'::regclass;

Which will show something like:
┌────────┬──────────┬──────────┬─────────────┐
│ objoid │ classoid │ objsubid │ description │
├────────┼──────────┼──────────┼─────────────┤
│ 116868 │ 6100 │ 0 │ leaked │
└────────┴──────────┴──────────┴─────────────┘

Greetings,

Andres Freund

#5Chao Li
li.evan.chao@gmail.com
In reply to: Andres Freund (#4)
Re: [HACKERS] comment/security label for publication/subscription

On Aug 9, 2026, at 01:35, Andres Freund <andres@anarazel.de> wrote:

Hi,

On 2017-03-24 00:18:26 -0400, Peter Eisentraut wrote:

Here is a patch to add COMMENT support for publications and subscriptions.

On a similar issue, do we need SECURITY LABEL support for those? Does
that make sense?

It looks like this was committed (87dee41f3ed).

Unfortunately I found, during an investigation of something completely
independent, that it leads to comments and (and presumably security labels) to
be orphaned on DROP.

In fact, our regression database actually contains such an orphaned comment:

regression[1536656][1]=# SELECT * FROM pg_description WHERE classoid = 'pg_subscription'::regclass;
┌────────┬──────────┬──────────┬───────────────────┐
│ objoid │ classoid │ objsubid │ description │
├────────┼──────────┼──────────┼───────────────────┤
│ 123718 │ 6100 │ 0 │ test subscription │
└────────┴──────────┴──────────┴───────────────────┘
(1 row)

Seems we need to beef up oidjoins.sql to find orphaned objects.

I can't entirely blame this commit, it seems pretty cruddy that the drop
routine of every global object needs to have a synchronized copy of various
Delete* routines. It's bad enough that drop functions for global objects need
to know about having to drop dependencies manually, but copying the set of
objects that need to be dropped in each seems like a bad idea.

Trivial repro:

DROP SUBSCRIPTION IF EXISTS s;

CREATE SUBSCRIPTION s CONNECTION '' PUBLICATION p
WITH (connect = false, slot_name = NONE);
COMMENT ON SUBSCRIPTION s IS 'leaked';
DROP SUBSCRIPTION s;

SELECT * FROM pg_description WHERE classoid = 'pg_subscription'::regclass;

Which will show something like:
┌────────┬──────────┬──────────┬─────────────┐
│ objoid │ classoid │ objsubid │ description │
├────────┼──────────┼──────────┼─────────────┤
│ 116868 │ 6100 │ 0 │ leaked │
└────────┴──────────┴──────────┴─────────────┘

Greetings,

Andres Freund

I just debugged the code. Dropping a publication uses the generic deleteOneObject() path, so that comment, security label etc. dependencies are deleted automatically. While for some reason, doDeletion() explicitly reject subscription:
```
/*
* These global object types are not supported here.
*/
case AuthIdRelationId:
case DatabaseRelationId:
case TableSpaceRelationId:
case SubscriptionRelationId:
case ParameterAclRelationId:
elog(ERROR, "global objects cannot be deleted by doDeletion");
break;
```

Therefore, DropSubscription() has to perform the cleanup explicitly. I guess that is why commit 87dee41f3ed missed adding the deletion of comments and security labels to DropSubscription().

I have prepared a patch to fix the bug. The fix is straightforward, and I have added tests for both comments and security labels.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachments:

t36319_5
v1-0001-Remove-comments-and-security-labels-when-dropping.patchapplication/octet-stream; name=v1-0001-Remove-comments-and-security-labels-when-dropping.patch; x-unix-mode=0644Download+41-2