* spi.c
* Server Programming Interface
*
- * $Id: spi.c,v 1.52 2001/02/19 19:49:52 tgl Exp $
+ * $Id: spi.c,v 1.53 2001/03/22 03:59:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "executor/spi_priv.h"
#include "access/printtup.h"
-uint32 SPI_processed = 0;
-Oid SPI_lastoid = InvalidOid;
+uint32 SPI_processed = 0;
+Oid SPI_lastoid = InvalidOid;
SPITupleTable *SPI_tuptable = NULL;
-int SPI_result;
+int SPI_result;
static _SPI_connection *_SPI_stack = NULL;
static _SPI_connection *_SPI_current = NULL;
int
SPI_connect()
{
+
/*
* When procedure called by Executor _SPI_curid expected to be equal
* to _SPI_connected
/* Create memory contexts for this procedure */
_SPI_current->procCxt = AllocSetContextCreate(TopTransactionContext,
"SPI Proc",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
_SPI_current->execCxt = AllocSetContextCreate(TopTransactionContext,
"SPI Exec",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
/* ... and switch to procedure's context */
_SPI_current->savedcxt = MemoryContextSwitchTo(_SPI_current->procCxt);
void
AtEOXact_SPI(void)
{
+
/*
* Note that memory contexts belonging to SPI stack entries will be
* freed automatically, so we can ignore them here. We just need to
}
/*
- * If we have a toasted datum, forcibly detoast it here to avoid memory
- * leakage inside the type's output routine.
+ * If we have a toasted datum, forcibly detoast it here to avoid
+ * memory leakage inside the type's output routine.
*/
if (typisvarlena)
val = PointerGetDatum(PG_DETOAST_DATUM(origval));
result = OidFunctionCall3(foutoid,
val,
ObjectIdGetDatum(typelem),
- Int32GetDatum(tupdesc->attrs[fnumber - 1]->atttypmod));
+ Int32GetDatum(tupdesc->attrs[fnumber - 1]->atttypmod));
/* Clean up detoasted copy, if any */
if (val != origval)
#endif
tupdesc = ExecutorStart(queryDesc, state);
- /* Don't work currently --- need to rearrange callers so that
- * we prepare the portal before doing CreateExecutorState() etc.
- * See pquery.c for the correct order of operations.
+ /*
+ * Don't work currently --- need to rearrange callers so that we
+ * prepare the portal before doing CreateExecutorState() etc. See
+ * pquery.c for the correct order of operations.
*/
if (isRetrieveIntoPortal)
- {
elog(FATAL, "SPI_select: retrieve into portal not implemented");
- }
ExecutorRun(queryDesc, state, EXEC_FOR, (long) tcount);
elog(FATAL, "SPI: stack corrupted");
if (execmem) /* switch to the Executor memory context */
- {
_SPI_execmem();
- }
return 0;
}