Skip to content

Commit f5c496b

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 3d7feba commit f5c496b

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.261.2.3 2010/08/19 17:31:50 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.261.2.4 2010/08/19 18:10:56 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -5272,6 +5272,8 @@ exec_simple_check_plan(PLpgSQL_expr *expr)
52725272
*/
52735273
if (!IsA(stmt, PlannedStmt))
52745274
return;
5275+
if (stmt->commandType != CMD_SELECT || stmt->intoClause)
5276+
return;
52755277
plan = stmt->planTree;
52765278
if (!IsA(plan, Result))
52775279
return;

0 commit comments

Comments
 (0)