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 */
12441245childrte = copyObject (rte );
12451246childrte -> relid = childOID ;
12461247childrte -> inh = false;
1247- childrte -> requiredPerms = 0 ;/* do not require permissions on child
1248- * tables */
1248+ childrte -> requiredPerms = 0 ;
12491249parse -> rtable = lappend (parse -> rtable ,childrte );
12501250childRTindex = 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 */
12701274if (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 */
13181322root -> 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/*