]> granicus.if.org Git - postgresql/commitdiff
Revert ill-starred change of 13-Feb-02: it appeared to fix a problem of
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Jan 2004 03:39:36 +0000 (03:39 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 14 Jan 2004 03:39:36 +0000 (03:39 +0000)
incorrect permissions checking, but in fact disabled most all permissions
checks for view updates.  This corrects problems reported by Sergey
Yatskevich among others, at the cost of re-introducing the problem
previously reported by Tim Burgess.  However, since we'd lived with that
problem for quite awhile without knowing it, we can live with it awhile
longer until a proper fix can be made in 7.5.

src/backend/rewrite/rewriteHandler.c

index f88938656e2f70dbfdf147293600bbd659a1cfe8..eed72700776c1cf99f79ac18211598492bf14e9c 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.113.2.1 2003/02/13 21:40:00 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.113.2.2 2004/01/14 03:39:36 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -62,11 +62,9 @@ rewriteRuleAction(Query *parsetree,
 {
        int                     current_varno,
                                new_varno;
-       List       *main_rtable;
        int                     rt_length;
        Query      *sub_action;
        Query     **sub_action_ptr;
-       List       *rt;
 
        /*
         * Make modifiable copies of rule action and qual (what we're passed
@@ -108,24 +106,9 @@ rewriteRuleAction(Query *parsetree,
         * NOTE: because planner will destructively alter rtable, we must ensure
         * that rule action's rtable is separate and shares no substructure
         * with the main rtable.  Hence do a deep copy here.
-        *
-        * Also, we must disable write-access checking in all the RT entries
-        * copied from the main query.  This is safe since in fact the rule action
-        * won't write on them, and it's necessary because the rule action may
-        * have a different commandType than the main query, causing
-        * ExecCheckRTEPerms() to make an inappropriate check.  The read-access
-        * checks can be left enabled, although they're probably redundant.
         */
-       main_rtable = (List *) copyObject(parsetree->rtable);
-
-       foreach(rt, main_rtable)
-       {
-               RangeTblEntry *rte = (RangeTblEntry *) lfirst(rt);
-
-               rte->checkForWrite = false;
-       }
-
-       sub_action->rtable = nconc(main_rtable, sub_action->rtable);
+       sub_action->rtable = nconc((List *) copyObject(parsetree->rtable),
+                                                          sub_action->rtable);
 
        /*
         * Each rule action's jointree should be the main parsetree's jointree