From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Mitar <mmitar(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: In which session context is a trigger run? |
Date: | 2018-12-28 23:25:30 |
Message-ID: | c1654f3a-410d-ae7a-8e8d-b3e7a6eee810@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 12/28/18 12:59 PM, Mitar wrote:
> Hi!
>
> On Fri, Dec 28, 2018 at 12:57 PM Adrian Klaver
> <adrian(dot)klaver(at)aklaver(dot)com> 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 seems it cannot access "posts_temp"
>>> table. It seems that "my_function" is called in the session of the
>>
>> Temp tables can not be seen by other sessions.
>
> Sure, but why is a temporary function used as a temporary trigger made
There is no such thing as a temporary trigger.
> from my session not run inside my session? Then it could see a
> temporary table made in my session.
Except that is not what your OP stated:
"And I add it to a regular table as a trigger:
CREATE TRIGGER posts_insert AFTER INSERT ON posts REFERENCING NEW
TABLE AS new_table FOR EACH STATEMENT EXECUTE FUNCTION
pg_temp.my_function();
When a row is added to "posts" table outside of my session, function
"my_function" is called, but it seems it cannot access "posts_temp"
table."
So are you talking about another case now?
>
>
> Mitar
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | patrick keshishian | 2018-12-28 23:40:27 | Re: libpq bug? |
Previous Message | Igor Korot | 2018-12-28 23:09:38 | Re: libpq bug? |