Re: Is there a way to detect that code is inside CREATE EXTENSION? - Mailing list pgsql-general

From Tom Lane
Subject Re: Is there a way to detect that code is inside CREATE EXTENSION?
Date
Msg-id 2448383.1670957347@sss.pgh.pa.us
Whole thread Raw
In response to Is there a way to detect that code is inside CREATE EXTENSION?  (Michel Pelletier <pelletier.michel@gmail.com>)
Responses Re: Is there a way to detect that code is inside CREATE EXTENSION?  (Julien Rouhaud <rjuju123@gmail.com>)
Re: Is there a way to detect that code is inside CREATE EXTENSION?  (Michel Pelletier <pelletier.michel@gmail.com>)
List pgsql-general
Michel Pelletier <pelletier.michel@gmail.com> writes:
> I'm working with an event trigger that fires on ALTER TABLE and regenerates
> certain objects, but unfortunately those objects end up being owned by any
> extensions that run ALTER TABLE and any subsequent alterations fail to
> regenerate because they are owned by that extension.

> Ideally, I'd like to be able to detect inside my trigger if I'm being
> called from CREATE EXTENSION or not, but I can't find any obvious way to
> detect that.

At the C-code level you can check the creating_extension global variable,
or maybe better look at the in_extension fields of CollectedCommands.

I don't think we expose that state at the SQL level, but it's pretty
hard to make a useful event trigger without writing any C ...

            regards, tom lane



pgsql-general by date:

Previous
From: Michel Pelletier
Date:
Subject: Is there a way to detect that code is inside CREATE EXTENSION?
Next
From: Julien Rouhaud
Date:
Subject: Re: Is there a way to detect that code is inside CREATE EXTENSION?