diff options
Diffstat (limited to 'src/backend/parser/analyze.c')
-rw-r--r-- | src/backend/parser/analyze.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 65f40f4cad8..2bdcef170f3 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.79 1998/07/20 20:48:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.80 1998/08/18 00:48:54 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -742,11 +742,33 @@ static Query * transformRuleStmt(ParseState *pstate, RuleStmt *stmt) { Query *qry; + Query *action; List *actions; qry = makeNode(Query); qry->commandType = CMD_UTILITY; + /* + * 'instead nothing' rules with a qualification need a + * query a rangetable so the rewrite handler can add the + * negated rule qualification to the original query. We + * create a query with the new command type CMD_NOTHING + * here that is treated special by the rewrite system. + */ + if (stmt->actions == NIL) { + Query *nothing_qry = makeNode(Query); + nothing_qry->commandType = CMD_NOTHING; + + addRangeTableEntry(pstate, stmt->object->relname, "*CURRENT*", + FALSE, FALSE); + addRangeTableEntry(pstate, stmt->object->relname, "*NEW*", + FALSE, FALSE); + + nothing_qry->rtable = pstate->p_rtable; + + stmt->actions = lappend(NIL, nothing_qry); + } + actions = stmt->actions; /* @@ -768,7 +790,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt) pstate->p_is_rule = true; /* for expand all */ pstate->p_hasAggs = false; - lfirst(actions) = transformStmt(pstate, lfirst(actions)); + action = (Query *)lfirst(actions); + if (action->commandType != CMD_NOTHING) + lfirst(actions) = transformStmt(pstate, lfirst(actions)); actions = lnext(actions); } |