1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

Enhancement of SPI to get access to portals

- New functions to create a portal using a prepared/saved
  SPI plan or lookup an existing portal by name.
- Functions to fetch/move from/in portals. Results are placed
  in the usual SPI_processed and SPI_tuptable, so the entire
  set of utility functions can be used to gain attribute access.
- Prepared/saved SPI plans now use their own memory context
  and SPI_freeplan(plan) can remove them.
- Tuple result sets (SPI_tuptable) now uses it's own memory
  context and can be free'd by SPI_freetuptable(tuptab).

Enhancement of PL/pgSQL

- Uses generic named portals internally in FOR ... SELECT
  loops to avoid running out of memory on huge result sets.
- Support for CURSOR and REFCURSOR syntax using the new SPI
  functionality. Cursors used internally only need no explicit
  transaction block. Refcursor variables can be used inside
  of explicit transaction block to pass cursors between main
  application and functions.


Jan
This commit is contained in:
Jan Wieck
2001-05-21 14:22:19 +00:00
parent be03eb25f3
commit d27f363e3f
13 changed files with 1521 additions and 121 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.127 2001/05/09 21:10:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.128 2001/05/21 14:22:11 wieck Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@ -108,6 +108,7 @@ PerformPortalFetch(char *name,
QueryDesc *queryDesc;
EState *estate;
MemoryContext oldcontext;
bool faked_desc = false;
/*
* sanity checks
@ -143,13 +144,14 @@ PerformPortalFetch(char *name,
queryDesc = PortalGetQueryDesc(portal);
estate = PortalGetState(portal);
if (dest == None) /* MOVE */
if (dest != queryDesc->dest) /* MOVE */
{
QueryDesc *qdesc = (QueryDesc *) palloc(sizeof(QueryDesc));
memcpy(qdesc, queryDesc, sizeof(QueryDesc));
qdesc->dest = dest;
queryDesc = qdesc;
faked_desc = true;
}
BeginCommand(name,
@ -197,7 +199,7 @@ PerformPortalFetch(char *name,
/*
* Clean up and switch back to old context.
*/
if (dest == None) /* MOVE */
if (faked_desc) /* MOVE */
pfree(queryDesc);
MemoryContextSwitchTo(oldcontext);