Re: Get current query in a trigger function

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: Get current query in a trigger function
Дата
Msg-id CA+TgmoaUUbWxH6jAgp_cTzdy99dTuuFCp7kTOfJe08W25nq+Uw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Get current query in a trigger function  (Vlad Arkhipov <arhipov@dc.baikal.ru>)
Список pgsql-hackers
On Mon, Jan 14, 2013 at 9:38 PM, Vlad Arkhipov <arhipov@dc.baikal.ru> wrote:
>>> Is there any simple way of getting a query for which a trigger was
>>> executed?
>>> debug_query_string and ActivePortal->sourceText return the top query when
>>> there are nested triggers.
>>
>> I believe - only if the trigger is written in C.
>>
> Yes, the trigger is written in C. But I didn't find any way to get access to
> the current EState or QueryDesc from a trigger function. The only common
> place of a trigger and the corresponding EState/QueryDesc structs seems to
> be CurrentMemoryContext in a trigger function, which ancestor has to be (?)
> EState->es_query_cxt. It's an ugly solution of course.

Ah, I see.  Yeah, I don't know of a good way to do that, although
there may be one.

> P.S. Is it a mistype EState->es_query_cxt? Should it be es_query_ctx?

I don't see why either of those is particularly better than the other."context" has a t both before and after the x.

...Robert

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: [PATCH] COPY .. COMPRESSED
Следующее
От: Kohei KaiGai
Дата:
Сообщение: [sepgsql 1/3] add name qualified creation label