Re: A question relative to creating an audit table

From: Andrei Zhidenkov <andrei(dot)zhidenkov(at)n26(dot)com>
To: stan <stanb(at)panix(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: A question relative to creating an audit table
Date: 2020-02-28 14:02:47
Message-ID: EBEFC43C-338F-4DE8-A24E-E08D1DE76E1D@n26.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Please, read chapter 43.10.1 of the PostgreSQL documentation (https://www.postgresql.org/docs/11/plpgsql-trigger.html <https://www.postgresql.org/docs/11/plpgsql-trigger.html>). Just to be sure we are on the same page.

> On 28. Feb 2020, at 14:59, stan <stanb(at)panix(dot)com> wrote:
>
> On Thu, Feb 27, 2020 at 10:30:15PM +0100, Andrei Zhidenkov wrote:
>> Why not to pass TG_TABLE_SCHEMA and TG_TABLE_NAME in its arguments?
>>
>>> On 27. Feb 2020, at 22:28, stan <stanb(at)panix(dot)com> wrote:
>>>
>>> I ma considering setting up a function, and triggers to put a record in an
>>> audit table when certain tables are altered. I pretty much think I know how
>>> to do this, with one exception.
>>>
>>> Can a function, called by a trigger, determine what table it was called
>>> for?
>>>
>
> I suppose I could do that. I have in mind a single function to accomplish the
> audit log, but I will have to have unique triggers for each table. I was
> just hoping not to have to do that. Are these values that I could read
> automatically? Or do I have to hard code them?
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2020-02-28 17:45:29 Re: Recursive CTEs and randomness - is there something I'm missing?
Previous Message stan 2020-02-28 13:59:47 Re: A question relative to creating an audit table