Skip to content

Commit f4b4a46

Browse files
committed
Keep exec_simple_check_plan() from thinking "SELECT foo INTO bar" is simple.
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.
1 parent 3869e9a commit f4b4a46

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pl/plpgsql/src/pl_exec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.265 2010/08/19 17:31:43 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.266 2010/08/19 18:10:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -5280,6 +5280,8 @@ exec_simple_check_plan(PLpgSQL_expr *expr)
52805280
*/
52815281
if (!IsA(stmt, PlannedStmt))
52825282
return;
5283+
if (stmt->commandType != CMD_SELECT || stmt->intoClause)
5284+
return;
52835285
plan = stmt->planTree;
52845286
if (!IsA(plan, Result))
52855287
return;

0 commit comments

Comments
 (0)