pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #8512: Can't use columns I can't read in the where clause of a select
Date: Tue, 8 Oct 2013 12:15:39 -0700 (PDT)
Message-ID: <1381259739660-5773757.post@n5.nabble.com> (raw)
In-Reply-To: <20131008190200.GE2706@tamriel.snowman.net>
References: <E1VTcOI-0004tt-Lf@wrigleys.postgresql.org>
	<20131008190200.GE2706@tamriel.snowman.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Stephen Frost wrote
> * 

> kurt@

>  (

> kurt@

> ) wrote:
>>     Allows SELECT from any column, or the specific columns listed, of the
>> specified table, view, or sequence. Also allows the use of COPY TO. This
>> privilege is also needed to reference existing column values in UPDATE or
>> DELETE.
>> 
>> 
>> I read that as "SELECT field1 from table where field2 = 1" should work if
>> I
>> have grant select(field1), but not on field2.  I'm getting a "permission
>> denied".  If I remove the where clause it of course works.
> 
> You have to have SELECT rights on a column to be able to use it in a
> conditional (eg: with WHERE).
> 
>> I'm not sure if the behaviour is expected or not.  Maybe I'm reading the
>> documentation wrong, or maybe the documentation is just wrong.  Could
>> someone please clarify?
> 
> It's expected.  The documentation could perhaps be improved, but the
> second sentence ("This privilege is also needed..") is intended to cover
> the case where the column is being referred to *anywhere* in the query,
> basically, and that applies to SELECT as much as UPDATE or DELETE.

"SELECT": read the current value
"UPDATE": cause the current value to be changed (does not require knowing
the existing value)
"DELETE": cause the current value (indirectly via row removal) to be removed
(does not require knowing the existing value)

A where clause requires that the user can know the current value in the
field

Within a SELECT statement there is no permissions distinction between the
different sub-clauses (e.g., ORDER BY, GROUP BY, WHERE, select-list) since
in any of these cases it is the current value of a column that is needed. 
So "SELECT" is read as being a top-level (as are UPDATE and DELETE) - and as
Stephen said because WHERE can be part of UPDATE and DELETE the additional
comment is made that WHERE in those contexts require "SELECT-like"
privileges if the column is used there.  But not if the column only exists
as a target-column.

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-8512-Can-t-use-columns-I-can-t-read-in-the-where-clause-...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (3+ messages)

Message-ID: <1381259739660-5773757.post@n5.nabble.com>
Permalink:  ../1381259739660-5773757.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1381259739660-5773757.post@n5.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: polobo@yahoo.com
  Subject: Re: BUG #8512: Can't use columns I can't read in the where clause of a select
  In-Reply-To: <1381259739660-5773757.post@n5.nabble.com>
  References: <E1VTcOI-0004tt-Lf@wrigleys.postgresql.org> <20131008190200.GE2706@tamriel.snowman.net> <1381259739660-5773757.post@n5.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox