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

Commiteeaa497

Browse files
committed
Give error message, rather than coredump, for utility statements in
conditional rules (rules with WHERE clauses). We cannot support thesesince there's noplace to hang a condition on a utility statement.We caught the other case (attempt to attach a condition at rewrite time)awhile ago, but this one escaped notice until now.
1 parent12c1552 commiteeaa497

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

‎src/backend/parser/analyze.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.187 2001/05/22 16:37:15 petere Exp $
9+
*$Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.188 2001/06/04 16:17:30 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -1742,13 +1742,15 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
17421742
}
17431743
else
17441744
{
1745-
List*actions;
1745+
List*oldactions;
1746+
List*newactions=NIL;
17461747

17471748
/*
17481749
* transform each statement, like parse_analyze()
17491750
*/
1750-
foreach(actions,stmt->actions)
1751+
foreach(oldactions,stmt->actions)
17511752
{
1753+
Node*action= (Node*)lfirst(oldactions);
17521754
ParseState*sub_pstate=make_parsestate(pstate->parentParseState);
17531755
Query*sub_qry,
17541756
*top_subqry;
@@ -1775,7 +1777,16 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
17751777
addRTEtoQuery(sub_pstate,newrte, false, true);
17761778

17771779
/* Transform the rule action statement */
1778-
top_subqry=transformStmt(sub_pstate,lfirst(actions));
1780+
top_subqry=transformStmt(sub_pstate,action);
1781+
1782+
/*
1783+
* We cannot support utility-statement actions (eg NOTIFY)
1784+
* with nonempty rule WHERE conditions, because there's no
1785+
* way to make the utility action execute conditionally.
1786+
*/
1787+
if (top_subqry->commandType==CMD_UTILITY&&
1788+
stmt->whereClause!=NULL)
1789+
elog(ERROR,"Rules with WHERE conditions may only have SELECT, INSERT, UPDATE, or DELETE actions");
17791790

17801791
/*
17811792
* If the action is INSERT...SELECT, OLD/NEW have been pushed
@@ -1846,11 +1857,13 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
18461857
sub_qry->jointree->fromlist=sub_pstate->p_joinlist;
18471858
}
18481859

1849-
lfirst(actions)=top_subqry;
1860+
newactions=lappend(newactions,top_subqry);
18501861

18511862
release_pstate_resources(sub_pstate);
18521863
pfree(sub_pstate);
18531864
}
1865+
1866+
stmt->actions=newactions;
18541867
}
18551868

18561869
returnqry;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp