Don't try to rewrite NEW references in a utility statement in a rule.
authorTom Lane
Sat, 7 Aug 2004 17:40:49 +0000 (17:40 +0000)
committerTom Lane
Sat, 7 Aug 2004 17:40:49 +0000 (17:40 +0000)
There won't be any, and in fact there won't even be an RTE for NEW,
which was leading to a core dump in CVS tip.  7.4 and earlier manage
not to crash when applying ResolveNew in this scenario, but I think
it was just good fortune that they didn't.  Per report from
Bernd Helmle.

src/backend/rewrite/rewriteHandler.c

index bccc369dc094fa4147543abdb9fbf41f89494110..fadc7416ad958d32d0580450db20e81b4a69a86e 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.140 2004/06/16 01:26:46 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.141 2004/08/07 17:40:49 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -208,7 +208,8 @@ rewriteRuleAction(Query *parsetree,
     * apply it to sub_action; we have to remember to update the sublink
     * inside rule_action, too.
     */
-   if (event == CMD_INSERT || event == CMD_UPDATE)
+   if ((event == CMD_INSERT || event == CMD_UPDATE) &&
+       sub_action->commandType != CMD_UTILITY)
    {
        sub_action = (Query *) ResolveNew((Node *) sub_action,
                                          new_varno,