Skip to content

Commit b7987f8

Browse files
committed
Fix incorrect patch that removed permission checks on inheritance child
tables --- the parent table no longer got checked, either. Per bug #5458 from Takahiro Itagaki.
1 parent 5d6d037 commit b7987f8

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/backend/optimizer/prep/prepunion.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.181 2010/02/26 02:00:46 momjian Exp $
25+
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.182 2010/05/11 15:31:37 tgl Exp $
2626
*
2727
*-------------------------------------------------------------------------
2828
*/
@@ -1239,13 +1239,13 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
12391239
/*
12401240
* Build an RTE for the child, and attach to query's rangetable list.
12411241
* We copy most fields of the parent's RTE, but replace relation OID,
1242-
* and set inh = false.
1242+
* and set inh = false. Also, set requiredPerms to zero since all
1243+
* required permissions checks are done on the original RTE.
12431244
*/
12441245
childrte = copyObject(rte);
12451246
childrte->relid = childOID;
12461247
childrte->inh = false;
1247-
childrte->requiredPerms = 0; /* do not require permissions on child
1248-
* tables */
1248+
childrte->requiredPerms = 0;
12491249
parse->rtable = lappend(parse->rtable, childrte);
12501250
childRTindex = list_length(parse->rtable);
12511251

@@ -1266,6 +1266,10 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
12661266
* Translate the column permissions bitmaps to the child's attnums (we
12671267
* have to build the translated_vars list before we can do this). But
12681268
* if this is the parent table, leave copyObject's result alone.
1269+
*
1270+
* Note: we need to do this even though the executor won't run any
1271+
* permissions checks on the child RTE. The modifiedCols bitmap
1272+
* may be examined for trigger-firing purposes.
12691273
*/
12701274
if (childOID != parentOID)
12711275
{
@@ -1316,13 +1320,6 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
13161320

13171321
/* Otherwise, OK to add to root->append_rel_list */
13181322
root->append_rel_list = list_concat(root->append_rel_list, appinfos);
1319-
1320-
/*
1321-
* The executor will check the parent table's access permissions when it
1322-
* examines the parent's added RTE entry. There's no need to check twice,
1323-
* so turn off access check bits in the original RTE.
1324-
*/
1325-
rte->requiredPerms = 0;
13261323
}
13271324

13281325
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy