Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit303a257

Browse files
committed
Revert ill-starred change of 13-Feb-02: it appeared to fix a problem of
incorrect permissions checking, but in fact disabled most all permissionschecks for view updates. This corrects problems reported by SergeyYatskevich among others, at the cost of re-introducing the problempreviously reported by Tim Burgess. However, since we'd lived with thatproblem for quite awhile without knowing it, we can live with it awhilelonger until a proper fix can be made in 7.5.
1 parentace92ce commit303a257

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

‎src/backend/rewrite/rewriteHandler.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.131 2003/11/29 19:51:55 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.132 2004/01/14 03:39:22 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -70,11 +70,9 @@ rewriteRuleAction(Query *parsetree,
7070
{
7171
intcurrent_varno,
7272
new_varno;
73-
List*main_rtable;
7473
intrt_length;
7574
Query*sub_action;
7675
Query**sub_action_ptr;
77-
List*rt;
7876

7977
/*
8078
* Make modifiable copies of rule action and qual (what we're passed
@@ -109,32 +107,32 @@ rewriteRuleAction(Query *parsetree,
109107
* Generate expanded rtable consisting of main parsetree's rtable plus
110108
* rule action's rtable; this becomes the complete rtable for the rule
111109
* action.Some of the entries may be unused after we finish
112-
* rewriting, but if we tried to remove them we'd have a much harder
113-
* job to adjust RT indexes in the query's Vars. It's OK to have
114-
* unused RT entries, since planner will ignore them.
110+
* rewriting, but we leave them all in place for two reasons:
111+
*
112+
** We'd have a much harder job to adjust the query's varnos
113+
* if we selectively removed RT entries.
114+
*
115+
** If the rule is INSTEAD, then the original query won't be
116+
* executed at all, and so its rtable must be preserved so that
117+
* the executor will do the correct permissions checks on it.
118+
*
119+
* RT entries that are not referenced in the completed jointree will be
120+
* ignored by the planner, so they do not affect query semantics. But
121+
* any permissions checks specified in them will be applied during
122+
* executor startup (see ExecCheckRTEPerms()). This allows us to check
123+
* that the caller has, say, insert-permission on a view, when the view
124+
* is not semantically referenced at all in the resulting query.
125+
*
126+
* When a rule is not INSTEAD, the permissions checks done on its copied
127+
* RT entries will be redundant with those done during execution of the
128+
* original query, but we don't bother to treat that case differently.
115129
*
116130
* NOTE: because planner will destructively alter rtable, we must ensure
117131
* that rule action's rtable is separate and shares no substructure
118132
* with the main rtable. Hence do a deep copy here.
119-
*
120-
* Also, we must disable write-access checking in all the RT entries
121-
* copied from the main query.This is safe since in fact the rule
122-
* action won't write on them, and it's necessary because the rule
123-
* action may have a different commandType than the main query,
124-
* causing ExecCheckRTEPerms() to make an inappropriate check.The
125-
* read-access checks can be left enabled, although they're probably
126-
* redundant.
127133
*/
128-
main_rtable= (List*)copyObject(parsetree->rtable);
129-
130-
foreach(rt,main_rtable)
131-
{
132-
RangeTblEntry*rte= (RangeTblEntry*)lfirst(rt);
133-
134-
rte->checkForWrite= false;
135-
}
136-
137-
sub_action->rtable=nconc(main_rtable,sub_action->rtable);
134+
sub_action->rtable=nconc((List*)copyObject(parsetree->rtable),
135+
sub_action->rtable);
138136

139137
/*
140138
* Each rule action's jointree should be the main parsetree's jointree

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp