From: | Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Get current query in a trigger function |
Date: | 2013-01-15 02:38:11 |
Message-ID: | 50F4C113.80600@dc.baikal.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 01/15/2013 01:45 AM, Robert Haas wrote:
> On Fri, Jan 11, 2013 at 4:47 AM, Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)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.
P.S. Is it a mistype EState->es_query_cxt? Should it be es_query_ctx?
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2013-01-15 02:39:38 | Re: Curious buildfarm failures |
Previous Message | Stephen Frost | 2013-01-15 02:33:39 | Re: [PATCH] COPY .. COMPRESSED |