Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 88047e5

Browse files
committed
Fix an error when a set-returning function fails halfway through the execution
If the function using yield to return rows fails halfway, the iterator stays open and subsequent calls to the function will resume reading from it. The fix is to unref the iterator and set it to NULL if there has been an error. Jan Urbański
1 parent 8995440 commit 88047e5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/pl/plpython/plpython.c

+8
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,14 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure *proc)
11641164
Py_XDECREF(plargs);
11651165
Py_XDECREF(plrv);
11661166

1167+
/*
1168+
* If there was an error the iterator might have not been exhausted
1169+
* yet. Set it to NULL so the next invocation of the function will
1170+
* start the iteration again.
1171+
*/
1172+
Py_XDECREF(proc->setof);
1173+
proc->setof = NULL;
1174+
11671175
PG_RE_THROW();
11681176
}
11691177
PG_END_TRY();

0 commit comments

Comments
 (0)