Re: plpgsql trigger original query

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: plpgsql trigger original query
Дата
Msg-id 162867790709141332n75fade31ra4e7abdc4b6426c@mail.gmail.com
обсуждение исходный текст
Ответ на plpgsql trigger original query  (Dan99 <power919@gmail.com>)
Список pgsql-general
> Hi,
>
> I am looking for a way to get the original query that caused a trigger
> to fire.  I need to be able to get this query either inside the
> trigger itself (and then send it to the function the trigger calls) or
> get it in the end function.  Is this doable? The reason i am asking is
> that I would like to be able to send a variable (this variable would
> come from php where the original query is executed) to the end
> function called by the trigger.
>
> Any help with this would be greatly appreciated.
>
> Thanks,
> Dan
>

currently this feature isn't supported. You can look to
pg_stat_activity table for top outer statement:

create or replace function current_statement()
returns varchar as $$
select current_query from pg_stat_activity where procpid = pg_backend_pid();
$$ language sql;

postgres=# select now(), current_statement();
            now             |         current_statement
----------------------------+------------------------------------
 2007-09-14 22:29:58.285+02 | select now(), current_statement();
(1 row)

Regards
Pavel Stehule

В списке pgsql-general по дате отправления:

Предыдущее
От: rihad
Дата:
Сообщение: Inserting a timestamp in a "timestamp" column.
Следующее
От: Erik Jones
Дата:
Сообщение: Re: Inserting a timestamp in a "timestamp" column.