1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

When querying a table with child tables, do not check permissions on the

child tables.  This was found to be useless and confusing in virtually all
cases, and also contrary to the SQL standard.
This commit is contained in:
Peter Eisentraut
2009-10-23 05:24:52 +00:00
parent ab61df9e52
commit 76d8883c8e
4 changed files with 33 additions and 20 deletions

View File

@ -22,7 +22,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.176 2009/10/12 18:10:48 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.177 2009/10/23 05:24:52 petere Exp $
*
*-------------------------------------------------------------------------
*/
@ -1244,6 +1244,7 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
childrte = copyObject(rte);
childrte->relid = childOID;
childrte->inh = false;
childrte->requiredPerms = 0; /* do not require permissions on child tables */
parse->rtable = lappend(parse->rtable, childrte);
childRTindex = list_length(parse->rtable);

View File

@ -406,11 +406,22 @@ SELECT fx FROM atestp2; -- ok
----
(0 rows)
SELECT fy FROM atestp2; -- fail, no privilege on atestc.fy
ERROR: permission denied for relation atestc
SELECT atestp2 FROM atestp2; -- fail, no privilege on atestc.fy
ERROR: permission denied for relation atestc
SELECT oid FROM atestp2; -- fail, no privilege on atestc.oid
SELECT fy FROM atestp2; -- ok
fy
----
(0 rows)
SELECT atestp2 FROM atestp2; -- ok
atestp2
---------
(0 rows)
SELECT oid FROM atestp2; -- ok
oid
-----
(0 rows)
SELECT fy FROM atestc; -- fail
ERROR: permission denied for relation atestc
SET SESSION AUTHORIZATION regressuser1;
GRANT SELECT(fy,oid) ON atestc TO regressuser2;

View File

@ -277,9 +277,10 @@ GRANT SELECT(fx) ON atestc TO regressuser2;
SET SESSION AUTHORIZATION regressuser2;
SELECT fx FROM atestp2; -- ok
SELECT fy FROM atestp2; -- fail, no privilege on atestc.fy
SELECT atestp2 FROM atestp2; -- fail, no privilege on atestc.fy
SELECT oid FROM atestp2; -- fail, no privilege on atestc.oid
SELECT fy FROM atestp2; -- ok
SELECT atestp2 FROM atestp2; -- ok
SELECT oid FROM atestp2; -- ok
SELECT fy FROM atestc; -- fail
SET SESSION AUTHORIZATION regressuser1;
GRANT SELECT(fy,oid) ON atestc TO regressuser2;