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

Commitd05b4bd

Browse files
committed
Permission checking wasn't quite right for insert/update/delete rules,
either :-(.
1 parentc434ae3 commitd05b4bd

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

‎src/backend/rewrite/rewriteDefine.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.61 2001/03/23 04:49:54 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.62 2001/05/03 21:16:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -377,7 +377,7 @@ DefineQueryRewrite(RuleStmt *stmt)
377377
* We want the rule's table references to be checked as though by the
378378
* rule owner, not the user referencing the rule. Therefore, scan
379379
* through the rule's rtables and set the checkAsUser field on all
380-
* rtable entries (except *OLD* and *NEW*).
380+
* rtable entries.
381381
*/
382382
foreach(l,action)
383383
{
@@ -426,29 +426,28 @@ DefineQueryRewrite(RuleStmt *stmt)
426426
/*
427427
* setRuleCheckAsUser
428428
*Recursively scan a query and set the checkAsUser field to the
429-
*given userid in all rtable entries except *OLD* and *NEW*.
429+
*given userid in all rtable entries.
430+
*
431+
* Note: for a view (ON SELECT rule), the checkAsUser field of the *OLD*
432+
* RTE entry will be overridden when the view rule is expanded, and the
433+
* checkAsUser field of the *NEW* entry is irrelevant because that entry's
434+
* checkFor bits will never be set. However, for other types of rules it's
435+
* important to set these fields to match the rule owner. So we just set
436+
* them always.
430437
*/
431438
staticvoid
432439
setRuleCheckAsUser(Query*qry,Oiduserid)
433440
{
434441
List*l;
435442

436-
/* Set all the RTEs in this query node, except OLD and NEW */
443+
/* Set all the RTEs in this query node */
437444
foreach(l,qry->rtable)
438445
{
439446
RangeTblEntry*rte= (RangeTblEntry*)lfirst(l);
440447

441-
if (strcmp(rte->eref->relname,"*NEW*")==0)
442-
continue;
443-
if (strcmp(rte->eref->relname,"*OLD*")==0)
444-
continue;
445-
446448
if (rte->subquery)
447449
{
448-
449-
/*
450-
* Recurse into subquery in FROM
451-
*/
450+
/* Recurse into subquery in FROM */
452451
setRuleCheckAsUser(rte->subquery,userid);
453452
}
454453
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp