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

Commit2f26cec

Browse files
committed
Reject non-ON-SELECT rules that are named "_RETURN".
DefineQueryRewrite() has long required that ON SELECT rules be named"_RETURN". But we overlooked the converse case: we should forbidnon-ON-SELECT rules that are named "_RETURN". In particular thisprevents using CREATE OR REPLACE RULE to overwrite a view's _RETURNrule with some other kind of rule, thereby breaking the view.Per bug #17646 from Kui Liu. Back-patch to all supported branches.Discussion:https://postgr.es/m/17646-70c93cfa40365776@postgresql.org
1 parent8c61160 commit2f26cec

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/backend/rewrite/rewriteDefine.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,18 @@ DefineQueryRewrite(const char *rulename,
531531
RelationGetDescr(event_relation),
532532
false, false);
533533
}
534+
535+
/*
536+
* And finally, if it's not an ON SELECT rule then it must *not* be
537+
* named _RETURN. This prevents accidentally or maliciously replacing
538+
* a view's ON SELECT rule with some other kind of rule.
539+
*/
540+
if (strcmp(rulename,ViewSelectRuleName)==0)
541+
ereport(ERROR,
542+
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
543+
errmsg("non-view rule for \"%s\" must not be named \"%s\"",
544+
RelationGetRelationName(event_relation),
545+
ViewSelectRuleName)));
534546
}
535547

536548
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp