From: | Ioana Danes <ioanadanes(at)gmail(dot)com> |
---|---|
To: | Leif Jensen <leif(at)crysberg(dot)dk> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Delete trigger |
Date: | 2015-09-18 12:14:55 |
Message-ID: | CAPg0s+6CrFQtpKFDjotzf+g0iBBfQzu+1h4bmXdq5Y=OSxUfyA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
It depends on the size of the table and the frequency of updates, deletes
but cold consider an audit table with triggers for update, delete and
truncate. At least you have a way to recover deleted records.
Ioana
On Fri, Sep 18, 2015 at 5:52 AM, Leif Jensen <leif(at)crysberg(dot)dk> wrote:
> Hello Laurenz,
>
> Thank you for you suggestion. I really want to aviod that someone
> 'accidentally' deletes too much by typing (programming) a not full
> qualified DELETE ... statement. In your case one would have to always use
> the delete function, but no restrictions on using the DELETE statement.
>
> Leif
>
>
> ----- Original Message -----
> > Leif Jensen wrote:
> > > If I do "DELETE FROM devicegroup WHERE group=1" I do not want to
> delete
> > > anything. I only want to
> > > delete if I do "DELETE FROM devicegroup WHERE groupid=x AND ctrlid=y
> AND
> > > userid=z". I don't wanna let
> > > anyone delete more than 1 row at a time.
> >
> > I can't think of a way to do that with a trigger.
> >
> > I'd write a
> > FUNCTION delete_devicegroup(groupid integer, ctrlid integer, userid
> > integer)
> > RETURNS void CALLED ON NULL INPUT VOLATILE SECURITY DEFINER
> > that enables the user to delete a row and checks that all arguments
> > are NOT NULL. The user doesn't get privileges to DELETE from the table
> > directly.
> >
> > Yours,
> > Laurenz Albe
> >
> >
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-09-18 12:47:15 | Re: Delete trigger |
Previous Message | Sathiyan Subramanian | 2015-09-18 11:49:05 | Re: Online backup of PostgreSQL data. |