+
+
+SPI_copytupledesc
+SPI - Tuple Descriptor Copy
+
+
+SPI_copytupledesc
+
+
+Makes copy of tuple descriptor in upper Executor context
+
+
SPIcopying tuple descriptors
+
+
+
+2001-08-02
+
+
+SPI_copytupledesc(tupdesc)
+
+
+
+
+2001-08-02
+
+
Inputs
+
+
+
+
+TupleDesc tupdesc
+
+
+Input tuple descriptor to be copied
+
+
+
+
+
+
+
+
+2001-08-02
+
+
Outputs
+
+
+
+
+TupleDesc
+
+
+Copied tuple descriptor
+
+
+ non-NULL
+ if tupdesc
+ is not NULL and the copy was successful
+
+
+ NULL
+ only if tupdesc
+ is NULL
+
+
+
+
+
+
+
+
+
+
+
+2001-08-02
+
+
Description
+
+SPI_copytupledesc
+ makes a copy of tupdesc in upper Executor context. See the section on Memory Management.
+
+
+
+
Usage
+
+TBD
+
+
+
+
+
+
+
+
+
+
SPI_modifytuple
- After SPI_connect is called current context is the procedure's one. All
-allocations made via palloc/repalloc or by SPI utility functions (except
-for SPI_copytuple, SPI_modifytuple,
- SPI_palloc and SPI_repalloc) are
+ After SPI_connect is called current context is the
+ procedure's one. All allocations made via
+palloc/repalloc or by SPI utility
+functions (except for SPI_copytuple,
+SPI_copytupledesc,
+SPI_modifytuple,
+SPI_palloc and SPI_repalloc) are
made in this context.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.56 2001/08/02 16:05:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.57 2001/08/02 18:08:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
return ctuple;
}
+TupleDesc
+SPI_copytupledesc(TupleDesc tupdesc)
+{
+ MemoryContext oldcxt = NULL;
+ TupleDesc ctupdesc;
+
+ if (tupdesc == NULL)
+ {
+ SPI_result = SPI_ERROR_ARGUMENT;
+ return NULL;
+ }
+
+ if (_SPI_curid + 1 == _SPI_connected) /* connected */
+ {
+ if (_SPI_current != &(_SPI_stack[_SPI_curid + 1]))
+ elog(FATAL, "SPI: stack corrupted");
+ oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt);
+ }
+
+ ctupdesc = CreateTupleDescCopy(tupdesc);
+
+ if (oldcxt)
+ MemoryContextSwitchTo(oldcxt);
+
+ return ctupdesc;
+}
+
HeapTuple
SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
Datum *Values, char *Nulls)
}
static bool
-_SPI_checktuples()
+_SPI_checktuples(void)
{
uint32 processed = _SPI_current->processed;
SPITupleTable *tuptable = _SPI_current->tuptable;
failed = true;
}
else
-/* some tuples were processed */
{
+ /* some tuples were processed */
if (tuptable == NULL) /* spi_printtup was not called */
failed = true;
else if (processed != (tuptable->alloced - tuptable->free))
*
* spi.h
*
+ * $Id: spi.h,v 1.28 2001/08/02 18:08:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
HeapTuple *vals; /* tuples */
} SPITupleTable;
-#define SPI_ERROR_CONNECT -1
-#define SPI_ERROR_COPY -2
-#define SPI_ERROR_OPUNKNOWN -3
-#define SPI_ERROR_UNCONNECTED -4
-#define SPI_ERROR_CURSOR -5
-#define SPI_ERROR_ARGUMENT -6
-#define SPI_ERROR_PARAM -7
-#define SPI_ERROR_TRANSACTION -8
-#define SPI_ERROR_NOATTRIBUTE -9
-#define SPI_ERROR_NOOUTFUNC -10
-#define SPI_ERROR_TYPUNKNOWN -11
+#define SPI_ERROR_CONNECT (-1)
+#define SPI_ERROR_COPY (-2)
+#define SPI_ERROR_OPUNKNOWN (-3)
+#define SPI_ERROR_UNCONNECTED (-4)
+#define SPI_ERROR_CURSOR (-5)
+#define SPI_ERROR_ARGUMENT (-6)
+#define SPI_ERROR_PARAM (-7)
+#define SPI_ERROR_TRANSACTION (-8)
+#define SPI_ERROR_NOATTRIBUTE (-9)
+#define SPI_ERROR_NOOUTFUNC (-10)
+#define SPI_ERROR_TYPUNKNOWN (-11)
#define SPI_OK_CONNECT 1
#define SPI_OK_FINISH 2
extern int SPI_freeplan(void *plan);
extern HeapTuple SPI_copytuple(HeapTuple tuple);
+extern TupleDesc SPI_copytupledesc(TupleDesc tupdesc);
extern HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts,
int *attnum, Datum *Values, char *Nulls);
extern int SPI_fnumber(TupleDesc tupdesc, char *fname);