Skip to content

Commit 18feafc

Browse files
committed
Ensure that a plpgsql LOOP with an empty body still executes at least
one CHECK_FOR_INTERRUPTS() call, so that you can control-C out of the loop. Reported by Merlin Moncure.
1 parent 7d3ab8a commit 18feafc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/pl/plpgsql/src/pl_exec.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.153 2005/10/15 02:49:49 momjian Exp $
6+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.154 2005/10/24 15:10:22 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -974,6 +974,17 @@ exec_stmts(PLpgSQL_execstate * estate, List *stmts)
974974
{
975975
ListCell *s;
976976

977+
if (stmts == NIL)
978+
{
979+
/*
980+
* Ensure we do a CHECK_FOR_INTERRUPTS() even though there is no
981+
* statement. This prevents hangup in a tight loop if, for instance,
982+
* there is a LOOP construct with an empty body.
983+
*/
984+
CHECK_FOR_INTERRUPTS();
985+
return PLPGSQL_RC_OK;
986+
}
987+
977988
foreach(s, stmts)
978989
{
979990
PLpgSQL_stmt *stmt = (PLpgSQL_stmt *) lfirst(s);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy