From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | a <372660931(at)qq(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How do I get the SQL statement in a trigger? |
Date: | 2018-05-10 10:44:33 |
Message-ID: | CAFj8pRChg8EMSPNeLRv8zEzd1e=sxMvBOtPey6-CcDMJgNanYg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2018-05-10 12:42 GMT+02:00 a <372660931(at)qq(dot)com>:
> Thanks a lot, would you please be so kind to tell me more about what is top
> level query??
>
for example - if you run some queries from PLpgSQL functions (triggers),
then these queries are not top queries.
Regards
Pavel
>
>
> ------------------ Original message ------------------
> *From:* "Pavel Stehule";
> *Sendtime:* Thursday, May 10, 2018 6:38 PM
> *To:* "a"<372660931(at)qq(dot)com>;
> *Cc:* "pgsql-general";
> *Subject:* Re: How do I get the SQL statement in a trigger?
>
> Hi
>
> 2018-05-10 12:23 GMT+02:00 a <372660931(at)qq(dot)com>:
>
>> Hi I would like to write a trigger that recorded every sql statement
>> under the effected entry. So if it is possible to retrieve the sql
>> statement within a trigger??
>>
>
> You can read a tom command from pg_stat_activity table
>
> postgres=# select query from pg_stat_activity where pid =
> pg_backend_pid();
> +------------------------------------------------------------------+
> | query |
> +------------------------------------------------------------------+
> | select query from pg_stat_activity where pid = pg_backend_pid(); |
> +------------------------------------------------------------------+
> (1 row)
>
> But this information is available only for top level query.
>
> Regards
>
> Pavel
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Fabio Ugo Venchiarutti | 2018-05-10 10:50:09 | Re: How do I get the SQL statement in a trigger? |
Previous Message | a | 2018-05-10 10:42:22 | Re: How do I get the SQL statement in a trigger? |