]> granicus.if.org Git - postgresql/commitdiff
Keep exec_simple_check_plan() from thinking "SELECT foo INTO bar" is simple.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Aug 2010 18:11:07 +0000 (18:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Aug 2010 18:11:07 +0000 (18:11 +0000)
It's not clear if this situation can occur in plpgsql other than via the
EXECUTE USING case Heikki illustrated, which I will shortly close off.
However, ignoring the intoClause if it's there is surely wrong, so let's
patch it for safety.

Backpatch to 8.3, which is as far back as this code has a PlannedStmt
to deal with.  There might be another way to make an equivalent test
before that, but since this is just preventing hypothetical bugs,
I'm not going to obsess about it.

src/pl/plpgsql/src/pl_exec.c

index 72083fda9a6970a64c518a7f71a060386ed6f2ec..7b9e2f447573308f6537a8be32f8a5fe0283e99e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.202.2.9 2010/08/09 18:50:37 tgl Exp $
+ *       $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.202.2.10 2010/08/19 18:11:07 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -4931,6 +4931,8 @@ exec_simple_check_plan(PLpgSQL_expr *expr)
         */
        if (!IsA(stmt, PlannedStmt))
                return;
+       if (stmt->commandType != CMD_SELECT || stmt->intoClause)
+               return;
        plan = stmt->planTree;
        if (!IsA(plan, Result))
                return;