diff options
Diffstat (limited to 'src/backend/executor/spi.c')
-rw-r--r-- | src/backend/executor/spi.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index e4c2dac40db..428a4cb7d3f 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.60 2001/10/25 05:49:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.61 2001/11/05 19:41:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -360,6 +360,40 @@ SPI_copytupledesc(TupleDesc tupdesc) return ctupdesc; } +TupleTableSlot * +SPI_copytupleintoslot(HeapTuple tuple, TupleDesc tupdesc) +{ + MemoryContext oldcxt = NULL; + TupleTableSlot *cslot; + HeapTuple ctuple; + TupleDesc ctupdesc; + + if (tuple == NULL || 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); + } + + ctuple = heap_copytuple(tuple); + ctupdesc = CreateTupleDescCopy(tupdesc); + + cslot = MakeTupleTableSlot(); + ExecSetSlotDescriptor(cslot, ctupdesc, true); + cslot = ExecStoreTuple(ctuple, cslot, InvalidBuffer, true); + + if (oldcxt) + MemoryContextSwitchTo(oldcxt); + + return cslot; +} + HeapTuple SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, Datum *Values, char *Nulls) |