Re: [HACKERS] comment/security label for publication/subscription - Mailing list pgsql-hackers

From Andres Freund
Subject Re: [HACKERS] comment/security label for publication/subscription
Date
Msg-id vaiwitfb6wsxvglbcm323all5tchrdb5s2evmbthl3v3jyb2ke@p4hvqdq6nbr3
Whole thread
In response to [HACKERS] comment/security label for publication/subscription  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: DOCS - Add missing EXCEPT parameter description to ALTER PUBLICATION
Re: DOCS - Add missing EXCEPT parameter description to ALTER PUBLICATION
Re: Allow a condition string in an injection point
List pgsql-hackers
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



Attachment

pgsql-hackers by date:

Previous
From: "贾明伟"
Date:
Subject: [RFC PATCH v3 0/7] Umbra: a remap-aware smgr prototype
Next
From: Bryan Green
Date:
Subject: [PATCH] Make select_views regression test output deterministic