Revert "Move portal pinning from PL/pgSQL to SPI"
This reverts commit b3617cdfbba1b5381e9d1c6bc0839500e8eb7273. This broke returning unnamed cursors from PL/pgSQL functions. Apparently, there are no test cases for this.
This commit is contained in:
parent
3afd75eaac
commit
b48b2f8793
@ -1175,12 +1175,6 @@ SPI_cursor_open_internal(const char *name, SPIPlanPtr plan,
|
|||||||
{
|
{
|
||||||
/* Use a random nonconflicting name */
|
/* Use a random nonconflicting name */
|
||||||
portal = CreateNewPortal();
|
portal = CreateNewPortal();
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the portal doesn't get closed by the user statements we
|
|
||||||
* execute.
|
|
||||||
*/
|
|
||||||
PinPortal(portal);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1419,9 +1413,6 @@ SPI_cursor_close(Portal portal)
|
|||||||
if (!PortalIsValid(portal))
|
if (!PortalIsValid(portal))
|
||||||
elog(ERROR, "invalid portal in SPI cursor operation");
|
elog(ERROR, "invalid portal in SPI cursor operation");
|
||||||
|
|
||||||
if (portal->portalPinned)
|
|
||||||
UnpinPortal(portal);
|
|
||||||
|
|
||||||
PortalDrop(portal, false);
|
PortalDrop(portal, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5257,6 +5257,12 @@ exec_for_query(PLpgSQL_execstate *estate, PLpgSQL_stmt_forq *stmt,
|
|||||||
/* Fetch loop variable's datum entry */
|
/* Fetch loop variable's datum entry */
|
||||||
var = (PLpgSQL_variable *) estate->datums[stmt->var->dno];
|
var = (PLpgSQL_variable *) estate->datums[stmt->var->dno];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the portal doesn't get closed by the user statements we
|
||||||
|
* execute.
|
||||||
|
*/
|
||||||
|
PinPortal(portal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch the initial tuple(s). If prefetching is allowed then we grab a
|
* Fetch the initial tuple(s). If prefetching is allowed then we grab a
|
||||||
* few more rows to avoid multiple trips through executor startup
|
* few more rows to avoid multiple trips through executor startup
|
||||||
@ -5318,6 +5324,8 @@ loop_exit:
|
|||||||
*/
|
*/
|
||||||
SPI_freetuptable(tuptab);
|
SPI_freetuptable(tuptab);
|
||||||
|
|
||||||
|
UnpinPortal(portal);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the FOUND variable to indicate the result of executing the loop
|
* Set the FOUND variable to indicate the result of executing the loop
|
||||||
* (namely, whether we looped one or more times). This must be set last so
|
* (namely, whether we looped one or more times). This must be set last so
|
||||||
|
Loading…
x
Reference in New Issue
Block a user