Skip to content
Snippets Groups Projects
Commit 88047e59 authored by Peter Eisentraut's avatar Peter Eisentraut
Browse files

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
parent 8995440e
No related branches found
No related tags found
No related merge requests found
......@@ -1164,6 +1164,14 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure *proc)
Py_XDECREF(plargs);
Py_XDECREF(plrv);
/*
* If there was an error the iterator might have not been exhausted
* yet. Set it to NULL so the next invocation of the function will
* start the iteration again.
*/
Py_XDECREF(proc->setof);
proc->setof = NULL;
PG_RE_THROW();
}
PG_END_TRY();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment