postgresql/src/backend/executor/tstoreReceiver.c
PostgreSQL Daemon 2ff501590b Tag appropriate files for rc3
Also performed an initial run through of upgrading our Copyright date to
extend to 2005 ... first run here was very simple ... change everything
where: grep 1996-2004 && the word 'Copyright' ... scanned through the
generated list with 'less' first, and after, to make sure that I only
picked up the right entries ...
2004-12-31 22:04:05 +00:00

90 lines
1.9 KiB
C

/*-------------------------------------------------------------------------
*
* tstoreReceiver.c
* an implementation of DestReceiver that stores the result tuples in
* a Tuplestore
*
*
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/tstoreReceiver.c,v 1.13 2004/12/31 21:59:45 pgsql Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "executor/tstoreReceiver.h"
typedef struct
{
DestReceiver pub;
Tuplestorestate *tstore;
MemoryContext cxt;
} TStoreState;
/*
* Prepare to receive tuples from executor.
*/
static void
tstoreStartupReceiver(DestReceiver *self, int operation, TupleDesc typeinfo)
{
/* do nothing */
}
/*
* Receive a tuple from the executor and store it in the tuplestore.
*/
static void
tstoreReceiveTuple(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
{
TStoreState *myState = (TStoreState *) self;
MemoryContext oldcxt = MemoryContextSwitchTo(myState->cxt);
tuplestore_puttuple(myState->tstore, tuple);
MemoryContextSwitchTo(oldcxt);
}
/*
* Clean up at end of an executor run
*/
static void
tstoreShutdownReceiver(DestReceiver *self)
{
/* do nothing */
}
/*
* Destroy receiver when done with it
*/
static void
tstoreDestroyReceiver(DestReceiver *self)
{
pfree(self);
}
/*
* Initially create a DestReceiver object.
*/
DestReceiver *
CreateTuplestoreDestReceiver(Tuplestorestate *tStore,
MemoryContext tContext)
{
TStoreState *self = (TStoreState *) palloc(sizeof(TStoreState));
self->pub.receiveTuple = tstoreReceiveTuple;
self->pub.rStartup = tstoreStartupReceiver;
self->pub.rShutdown = tstoreShutdownReceiver;
self->pub.rDestroy = tstoreDestroyReceiver;
self->pub.mydest = Tuplestore;
self->tstore = tStore;
self->cxt = tContext;
return (DestReceiver *) self;
}