Re: dealing with extension dependencies that aren't quite 'e' - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: dealing with extension dependencies that aren't quite 'e'
Date
Msg-id CAMsr+YHqNVb6sxWC5MDy+=F=dFaYiTkq35+Sp2pVxGN6rOYvBg@mail.gmail.com
Whole thread Raw
In response to dealing with extension dependencies that aren't quite 'e'  (Abhijit Menon-Sen <ams@2ndQuadrant.com>)
List pgsql-hackers
On 15 January 2016 at 14:26, Abhijit Menon-Sen <ams@2ndquadrant.com> wrote:
* «DROP EXTENSION ext» won't work without adding CASCADE, which is an
  (admittedly relatively minor) inconvenience to users.

* More importantly, pg_dump will dump all those trigger definitions,
  which is inappropriate in this case because the extension will try
  to create them.


I dealt with both of those in BDR (and pglogical), where we create TRUNCATE triggers to capture and replicate table truncation. The triggers are created either during node creation/join by a SQL function that calls into C code, or via an event trigger on CREATE TABLE for subsequent creations.

Creating them tgisinternal gets you both properties you need IIRC. Certainly it hides them from pg_dump, which was the requirement for me.

You can't easily create a tgisinternal trigger from SQL. You can hack it but it's ugly. It's simple enough to just create from C. See:


Other people are doing it the hacky way already, see e.g.:



Rather than overloading 'e', we could introduce a new dependency type
that references an extension, but means that the dependent object should
be dropped when the extension is, but it can also be dropped on its own,
and pg_dump should ignore it.

So ... kind of like tgisinternal and 'i' dependencies, but without the restriction on the object being dropped directly?

Is there any particular reason the user needs to be able to drop the created trigger directly?

Is it reasonable to endorse the use of 'i' dependencies by extensions instead?
 
--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-hackers by date:

Previous
From: Ioseph Kim
Date:
Subject: Re: PGCon 2016 call for papers
Next
From: Craig Ringer
Date:
Subject: Re: Do we need SQL-level access to amoptions functions?