Hello
I'm one of the Google SoC's students for PostgreSQL. While reading sql92
standard, I found something like this:
11.36 <grant statement>
General Rules
3) For every identified privilege descriptor whose action is
SELECT, INSERT, UPDATE, or REFERENCES without a column name,
privilege descriptors are also created for each column C in O
for which A holds the corresponding privilege with grant op-
tion. For each such column, a privilege descriptor is created
that specifies the identical <grantee>, the identical <action>,
object C, and grantor A.
According to this, column privilege descriptors are created automatically
while table privilege descriptor is created. Then, while checking privilege,
can I JUST check column level privilege?
Here is some examples.
(1)
CREATE TABLE t1 (c1 int, c2 int);
GRANT SELECT ON t1 TO grantee;
REVOKE SELECT ON t1 (c1) FROM grantee;
Now grantee has privilege on t1(c2) but NOT on t1(c1). Although grantee
has privilege on t1, he still has no privilege on t1(c1). So checking column
privilege is enough. We don't need to check table privilege.
(2)
CREATE TABLE t1 (c1 int, c2 int);
REVOKE SELECT ON t1 FROM grantee;
GRANT SELECT ON t1(c2) TO grantee;
Here, still, grantee has privilege on t1(c2) but NOT on t1(c1). (Is this
right?) Although grantee has no privilege on t1, he can has privilege on
t1(c1). Here, again, checking column privilege is enough.
Table privilege is useful when you add columns to a table. Whether grantee
has privilege on the new columns depends on whether he has privilege on the
table.
Any and all help and/or comment is appreciated. From sql standard, I found
no information on how privilege check should be done.
Thanks.
Dong
--
Guodong Liu
Database Lab, School of EECS, Peking University
Room 314, Building 42, Peking University, Beijing, 100871, China