Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRDfs-0000VG-Dn for pgsql-general@arkaria.postgresql.org; Fri, 08 Jun 2018 09:27:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fRDfq-0002Ue-EN for pgsql-general@arkaria.postgresql.org; Fri, 08 Jun 2018 09:27:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRDfq-0002UV-4Q for pgsql-general@lists.postgresql.org; Fri, 08 Jun 2018 09:27:10 +0000 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fRDfm-0004ol-MS for pgsql-general@lists.postgresql.org; Fri, 08 Jun 2018 09:27:09 +0000 Received: by mail-ot0-x242.google.com with SMTP id q17-v6so14931723otg.2 for ; Fri, 08 Jun 2018 02:27:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=XIih1iBtEvRWuruqykzeAEMGg+fItVIfLZbVisjiypo=; b=MDEyUY4DOLX+FjKyIOBVyVssLZmsSfbQs2NgHISgcLfyMq94Gva6TV//+U9yo+1Emw 6rRGg7iYMWhUwVlGiBy7YRNOTyHtGwYVh28HMvPbLPHKN5xF97drOSUlx/QM/mbELgd+ 6zZSw6mldXgSmkg+uFNTCz/o6tl06RNu23E0p9XD5nprKZjVq2RV5Yd4m5Lw7aSDMlT0 WUl33F14Augzx0mvrQWJ2Fhbx/c02IbWZ1Frg6PE2nJTBiu6XcrhbYjKSxaXjgCW6V/B v2EBRd7eMA93N7ZnNHMhdmFwSeTXBBh/4I9sRB3cmbrOWkU2D6d96a3v/z0Or66eurvJ AQeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=XIih1iBtEvRWuruqykzeAEMGg+fItVIfLZbVisjiypo=; b=sirjgxJxbvx7ETyOGxy/41loBsARj6/c37I3N4IlxayWKacBR/iz4l+atygKWrWVSf UpW/j4mXFzjMPnSO3Gwv0sPXgN4kaSXJcBrPOasf6ije9ijti9ScLXnhRJanhUOV1mg5 mkRLttFoxdB4vFLcyuwMAjqvDGBXWSSIITU0IFoQ2LPqinj3spIWo/4riFfYKt1l6mjB UvIKINC6e7FNmDWVziM3jdokq4tTT6Nd4VVyQ5BPpqVI/hl88NL+GRfMkloBTZh7xWdR Xgs76cxKYzo+sfxBo5V3KE7WbXmIqzk9rVPqVymD8akWu1JLsPHtCoEWqyDGYJNoM4oI koJA== X-Gm-Message-State: APt69E0jBEMc5L1QT4wryoElc5j3tEovKuKIYKnoQYB2e6fDA6Bw++oq gUqPEwgTiStp3za5JBWBlL9+/A== X-Google-Smtp-Source: ADUXVKK9N8abINadR4wKgtRWrDdKgN/r2muddjSMUi5ccy1in/ZHvubDkz5oP+aJc4YvpoqOzNiptQ== X-Received: by 2002:a9d:2f91:: with SMTP id r17-v6mr3418102otb.356.1528450024283; Fri, 08 Jun 2018 02:27:04 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id m191-v6sm19170955oig.0.2018.06.08.02.27.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 02:27:03 -0700 (PDT) Subject: Re: Can you make a simple view non-updatable? To: pgsql-general@lists.postgresql.org References: <20180608110410.17103b1onzx4qrqc@www.gelassene-pferde.biz> From: Ron Message-ID: <9f42a43a-cb8d-a82c-05c5-fb0e30ec1a91@gmail.com> Date: Fri, 8 Jun 2018 04:27:02 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------C501465190B88728E51C6FFA" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------C501465190B88728E51C6FFA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 06/08/2018 04:17 AM, Ryan Murphy wrote: > > maybe it is time to overhaul the security concept. > > > 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. > > 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. Something like CREATE READ ONLY VIEW test_view2 AS SELECT .... -- Angular momentum makes the world go 'round. --------------C501465190B88728E51C6FFA Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 06/08/2018 04:17 AM, Ryan Murphy wrote:

maybe it is time to overhaul the security concept.

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.

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.

Something like CREATE READ ONLY VIEW test_view2 AS SELECT ....

--
Angular momentum makes the world go 'round.
--------------C501465190B88728E51C6FFA--