Re: Can you make a simple view non-updatable?

From: "Thiemo Kellner, NHC Barhufpflege" <thiemo(dot)kellner(at)gelassene-pferde(dot)biz>
To: Ryan Murphy <ryanfmurphy(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Can you make a simple view non-updatable?
Date: 2018-06-08 10:31:11
Message-ID: 20180608123111.14253uifyz5zmbi8@www.gelassene-pferde.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Zitat von Ryan Murphy <ryanfmurphy(at)gmail(dot)com>:

> I could see how I could revoke permissions from, say, all users that aren't
> superusers to INSERT or UPDATE certain views. However, if possible it
> would be nice to get an error message about the VIEW not being updatable,
> rather than a user access error, which could be misleading.

I feel it would be the other way round. If you deny something that is
technically possible, I would be puzzled to get an error about a
technical impossibility. If you want to stop people updating a view,
in my opion, it is very well to tell them they are not allowed to and
not that it isn't technically possible. So there can start a
discussion whether they are rightfully denied to update data therein,
instead of first discussing why it is not technically possible to
update to find out it IS technically possible but it was actually
denied.

> When I try to insert into a non-updatable VIEWs, I get this message:
>
> ERROR: cannot insert into view "test_view"
> DETAIL: Views containing GROUP BY are not automatically updatable.
> HINT: To enable inserting into the view, provide an INSTEAD OF INSERT
> trigger or an unconditional ON INSERT DO INSTEAD rule.
>
> It would be great to see something like this when trying to insert into a
> simple VIEW that I had made non-updatable:
>
> ERROR: cannot insert into view "test_view2"
> DETAIL: This view has manually been made non-updatable.

You still could put a trigger on the views throwing according
exceptions for specific users. I think I partly used that already but
can't find the code at the moment.

--
+49 (0)1578-772 37 37
+41 (0)78 947 36 21
Öffentlicher PGP-Schlüssel:
http://pgp.mit.edu/pks/lookup?op=get&search=0xCA167FB0E717AFFC

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mariusz 2018-06-08 12:04:36 Re: Code of Conduct plan
Previous Message Jean Claude 2018-06-08 10:16:27 Re: Service pgpool