Re: In which session context is a trigger run?

2018-12-31 Thread Mitar
Hi! On Mon, Dec 31, 2018 at 2:58 AM Peter J. Holzer wrote: > On 2018-12-30 08:56:13 -0800, Adrian Klaver wrote: > > On 12/30/18 3:08 AM, Peter J. Holzer wrote: > > > If I understood Mitar correctly he wants the trigger to execute in the > > > session where it was declared, not in the sessio

Re: In which session context is a trigger run?

2018-12-31 Thread Mitar
Hi! On Sun, Dec 30, 2018 at 9:58 PM David G. Johnston wrote: > Doesn’t seem likely. Maybe you can use NOTIFY/LISTEN in your temporary > triggers and have your active client perform the work after being notified. Yes, this is what I ended up doing. I signal the client and then the client

Re: In which session context is a trigger run?

2018-12-31 Thread Peter J. Holzer
On 2018-12-30 08:56:13 -0800, Adrian Klaver wrote: > On 12/30/18 3:08 AM, Peter J. Holzer wrote: > > If I understood Mitar correctly he wants the trigger to execute in the > > session where it was declared, not in the sessio where the statement was > > executed that triggered the trigger. > >

In which session context is a trigger run?

2018-12-30 Thread David G. Johnston
On Friday, December 28, 2018, Mitar wrote: > > On Fri, Dec 28, 2018 at 9:36 PM Adrian Klaver > wrote: > > When you create the temporary function it is 'pinned' to a particular > > session/pg_temp_nn. Running the trigger in another session 'pins' it to > > that session and it is not able to see

Re: In which session context is a trigger run?

2018-12-30 Thread Adrian Klaver
On 12/30/18 3:08 AM, Peter J. Holzer wrote: On 2018-12-29 13:01:47 -0800, Adrian Klaver wrote: On 12/28/18 11:44 PM, Mitar wrote: On Fri, Dec 28, 2018 at 9:36 PM Adrian Klaver wrote: When you create the temporary function it is 'pinned' to a particular session/pg_temp_nn. Running the trigger

Re: In which session context is a trigger run?

2018-12-30 Thread Peter J. Holzer
On 2018-12-29 13:01:47 -0800, Adrian Klaver wrote: > On 12/28/18 11:44 PM, Mitar wrote: > > On Fri, Dec 28, 2018 at 9:36 PM Adrian Klaver > > wrote: > > > When you create the temporary function it is 'pinned' to a particular > > > session/pg_temp_nn. Running the trigger in another session 'pins'

Re: In which session context is a trigger run?

2018-12-29 Thread Adrian Klaver
On 12/28/18 11:44 PM, Mitar wrote: Hi! On Fri, Dec 28, 2018 at 9:36 PM Adrian Klaver wrote: When you create the temporary function it is 'pinned' to a particular session/pg_temp_nn. Running the trigger in another session 'pins' it to that session and it is not able to see the posts_temp table

Re: In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! On Fri, Dec 28, 2018 at 9:36 PM Adrian Klaver wrote: > When you create the temporary function it is 'pinned' to a particular > session/pg_temp_nn. Running the trigger in another session 'pins' it to > that session and it is not able to see the posts_temp table in the > original session.

Re: In which session context is a trigger run?

2018-12-28 Thread Adrian Klaver
On 12/28/18 7:56 PM, Mitar wrote: Hi! On Fri, Dec 28, 2018 at 3:25 PM Adrian Klaver wrote: Sure, but why is a temporary function used as a temporary trigger made There is no such thing as a temporary trigger. A trigger defined using a temporary function gets deleted once a function gets

Re: In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! On Fri, Dec 28, 2018 at 3:25 PM Adrian Klaver wrote: > > Sure, but why is a temporary function used as a temporary trigger made > > There is no such thing as a temporary trigger. A trigger defined using a temporary function gets deleted once a function gets deleted, which is at the end of

Re: In which session context is a trigger run?

2018-12-28 Thread Adrian Klaver
On 12/28/18 12:59 PM, Mitar wrote: Hi! On Fri, Dec 28, 2018 at 12:57 PM Adrian Klaver wrote: CREATE OR REPLACE FUNCTION pg_temp.my_function() And it does what? Copies/transforms data from posts into posts_temp. When a row is added to "posts" table outside of my session, function

Re: In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! On Fri, Dec 28, 2018 at 12:57 PM Adrian Klaver wrote: > > CREATE OR REPLACE FUNCTION pg_temp.my_function() > > And it does what? Copies/transforms data from posts into posts_temp. > > When a row is added to "posts" table outside of my session, function > > "my_function" is called, but it

Re: In which session context is a trigger run?

2018-12-28 Thread Adrian Klaver
On 12/28/18 12:47 PM, Mitar wrote: Hi! It seems to me that triggers on a table are run in the session context of the user who made a change in the table, but not of the user who defined the trigger? So I create a temporary function: CREATE OR REPLACE FUNCTION pg_temp.my_function() And it

In which session context is a trigger run?

2018-12-28 Thread Mitar
Hi! It seems to me that triggers on a table are run in the session context of the user who made a change in the table, but not of the user who defined the trigger? So I create a temporary function: CREATE OR REPLACE FUNCTION pg_temp.my_function() And a temporary table: CREATE TEMPORARY TABLE