Re: Detecting which columns a query will modify in a function called by a trigger

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: stan <stanb(at)panix(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Detecting which columns a query will modify in a function called by a trigger
Date: 2020-03-02 19:04:02
Message-ID: CAFj8pRDqM6p1Tae5zkh==kTfNEHqcwsWVAH=nMjQ6_Aa-4Xs+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-general

po 2. 3. 2020 v 19:59 odesílatel stan <stanb(at)panix(dot)com> napsal:

> I need to implement a fairly fine grained security model. Probably a bit
> finer that I can do with the standard ownership functionality.
>
> My thinking on this is to create a table that contains the users, and a
> "permission bit" for each function that they may want to do, vis a vi
> altering an existing row,or rows, or inserting new rows.
>
> Looks relatively straight forward, if fairly time consuming to do. But I
> would need to know which column(s) a given query would add..alter from the
> function to implement this via a trigger. looks like I see most of what I
> need t do this in the docs, but I can't quite figure out if I can get this
> down to what column(s) a given trigger will modify. Is this possible?
>

You can compare NEW and OLD record. It is pretty hard in PLpgSQL, but easy
with hstore or jsonb, or with PLPerl or PLPythonu

Regards

Pavel

>
>
> --
> "They that would give up essential liberty for temporary safety deserve
> neither liberty nor safety."
> -- Benjamin Franklin
>
>
>

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message stan 2020-03-02 20:28:29 Re: Detecting which columns a query will modify in a function called by a trigger
Previous Message Adrian Klaver 2020-03-02 19:02:54 Re: Detecting which columns a query will modify in a function called by a trigger

Browse pgsql-general by date

  From Date Subject
Next Message stan 2020-03-02 20:28:29 Re: Detecting which columns a query will modify in a function called by a trigger
Previous Message Adrian Klaver 2020-03-02 19:02:54 Re: Detecting which columns a query will modify in a function called by a trigger